starting to rewire examples properly
git-svn-id: https://svn.apache.org/repos/asf/tomee/site/trunk@1796252 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/content/admin/cluster/index.html b/content/admin/cluster/index.html
index 3a8de09..6f6180d 100644
--- a/content/admin/cluster/index.html
+++ b/content/admin/cluster/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/admin/cluster/index.pdf b/content/admin/cluster/index.pdf
index bf203ad..101782a 100644
--- a/content/admin/cluster/index.pdf
+++ b/content/admin/cluster/index.pdf
Binary files differ
diff --git a/content/admin/configuration/application.html b/content/admin/configuration/application.html
index 26f2557..02009d6 100644
--- a/content/admin/configuration/application.html
+++ b/content/admin/configuration/application.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/admin/configuration/application.pdf b/content/admin/configuration/application.pdf
index c3809cf..40d7fc3 100644
--- a/content/admin/configuration/application.pdf
+++ b/content/admin/configuration/application.pdf
Binary files differ
diff --git a/content/admin/configuration/containers.html b/content/admin/configuration/containers.html
index 47d8e28..7314fd0 100644
--- a/content/admin/configuration/containers.html
+++ b/content/admin/configuration/containers.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/admin/configuration/containers.pdf b/content/admin/configuration/containers.pdf
index 0c9be58..046cae7 100644
--- a/content/admin/configuration/containers.pdf
+++ b/content/admin/configuration/containers.pdf
Binary files differ
diff --git a/content/admin/configuration/index.html b/content/admin/configuration/index.html
index e6e19bf..7920ab0 100644
--- a/content/admin/configuration/index.html
+++ b/content/admin/configuration/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/admin/configuration/index.pdf b/content/admin/configuration/index.pdf
index b8e438a..f6657d6 100644
--- a/content/admin/configuration/index.pdf
+++ b/content/admin/configuration/index.pdf
Binary files differ
diff --git a/content/admin/configuration/resources.html b/content/admin/configuration/resources.html
index bc86182..68c76e1 100644
--- a/content/admin/configuration/resources.html
+++ b/content/admin/configuration/resources.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/admin/configuration/resources.pdf b/content/admin/configuration/resources.pdf
index 98f3911..63fe2df 100644
--- a/content/admin/configuration/resources.pdf
+++ b/content/admin/configuration/resources.pdf
Binary files differ
diff --git a/content/admin/configuration/server.html b/content/admin/configuration/server.html
index aef13d3..fe1aa9b 100644
--- a/content/admin/configuration/server.html
+++ b/content/admin/configuration/server.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/admin/configuration/server.pdf b/content/admin/configuration/server.pdf
index 1f711a0..9e7c7a4 100644
--- a/content/admin/configuration/server.pdf
+++ b/content/admin/configuration/server.pdf
Binary files differ
diff --git a/content/admin/file-layout.html b/content/admin/file-layout.html
index b23b245..63af45b 100644
--- a/content/admin/file-layout.html
+++ b/content/admin/file-layout.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/admin/file-layout.pdf b/content/admin/file-layout.pdf
index 6f767c1..6b48e72 100644
--- a/content/admin/file-layout.pdf
+++ b/content/admin/file-layout.pdf
Binary files differ
diff --git a/content/admin/index.html b/content/admin/index.html
index 1ddd4e5..b69a9fa 100644
--- a/content/admin/index.html
+++ b/content/admin/index.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/admin/index.pdf b/content/admin/index.pdf
index 5dbf75b..fad40b7 100644
--- a/content/admin/index.pdf
+++ b/content/admin/index.pdf
Binary files differ
diff --git a/content/advanced/applicationcomposer/index.html b/content/advanced/applicationcomposer/index.html
index 04ca080..ed200f3 100644
--- a/content/advanced/applicationcomposer/index.html
+++ b/content/advanced/applicationcomposer/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/advanced/applicationcomposer/index.pdf b/content/advanced/applicationcomposer/index.pdf
index 0d4a497..49386c6 100644
--- a/content/advanced/applicationcomposer/index.pdf
+++ b/content/advanced/applicationcomposer/index.pdf
Binary files differ
diff --git a/content/advanced/client/index.html b/content/advanced/client/index.html
index af5ea9c..78dd773 100644
--- a/content/advanced/client/index.html
+++ b/content/advanced/client/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/advanced/client/index.pdf b/content/advanced/client/index.pdf
index 09c707f..72abb73 100644
--- a/content/advanced/client/index.pdf
+++ b/content/advanced/client/index.pdf
Binary files differ
diff --git a/content/advanced/client/jndi.html b/content/advanced/client/jndi.html
index c11c26d..301343c 100644
--- a/content/advanced/client/jndi.html
+++ b/content/advanced/client/jndi.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/advanced/client/jndi.pdf b/content/advanced/client/jndi.pdf
index 8732ffc..864be64 100644
--- a/content/advanced/client/jndi.pdf
+++ b/content/advanced/client/jndi.pdf
Binary files differ
diff --git a/content/advanced/index.html b/content/advanced/index.html
index bb8810e..8e0af56 100644
--- a/content/advanced/index.html
+++ b/content/advanced/index.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/advanced/index.pdf b/content/advanced/index.pdf
index 07d6e17..c82f0f4 100644
--- a/content/advanced/index.pdf
+++ b/content/advanced/index.pdf
Binary files differ
diff --git a/content/advanced/jms/jms-configuration.html b/content/advanced/jms/jms-configuration.html
index c2342ca..2594dcd 100644
--- a/content/advanced/jms/jms-configuration.html
+++ b/content/advanced/jms/jms-configuration.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/advanced/jms/jms-configuration.pdf b/content/advanced/jms/jms-configuration.pdf
index 63db103..9346055 100644
--- a/content/advanced/jms/jms-configuration.pdf
+++ b/content/advanced/jms/jms-configuration.pdf
Binary files differ
diff --git a/content/advanced/setup/index.html b/content/advanced/setup/index.html
index f1dc80e..9e147ef 100644
--- a/content/advanced/setup/index.html
+++ b/content/advanced/setup/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/advanced/shading/index.html b/content/advanced/shading/index.html
index 4c29aba..de91389 100644
--- a/content/advanced/shading/index.html
+++ b/content/advanced/shading/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/advanced/shading/index.pdf b/content/advanced/shading/index.pdf
index c571e7f..d3b3018 100644
--- a/content/advanced/shading/index.pdf
+++ b/content/advanced/shading/index.pdf
Binary files differ
diff --git a/content/advanced/tomee-embedded/index.html b/content/advanced/tomee-embedded/index.html
index 2a42e6d..94855d1 100644
--- a/content/advanced/tomee-embedded/index.html
+++ b/content/advanced/tomee-embedded/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/advanced/tomee-embedded/index.pdf b/content/advanced/tomee-embedded/index.pdf
index 39f7f9b..c1e3047 100644
--- a/content/advanced/tomee-embedded/index.pdf
+++ b/content/advanced/tomee-embedded/index.pdf
Binary files differ
diff --git a/content/blog/2016/03/new-website.html b/content/blog/2016/03/new-website.html
index 3c371cf..2e97dbc 100644
--- a/content/blog/2016/03/new-website.html
+++ b/content/blog/2016/03/new-website.html
@@ -72,7 +72,7 @@
<li><a href="../../../admin/index.html">Admin</a></li>
<li><a href="../../../advanced/index.html">Advanced</a></li>
<li><a href="../../../security/index.html">Security</a></li>
- <li><a href="../../../examples/index.html">Examples</a></li>
+ <li><a href="../../../examples/index-ng.html">Examples</a></li>
<li><a href="../../../blog/index.html">Blog</a></li>
<li><a href="../../../community/index.html">Community</a></li>
<li><a href="../../../download-ng.html">Downloads</a></li>
diff --git a/content/blog/2016/03/new-website.pdf b/content/blog/2016/03/new-website.pdf
index b9996f0..cf19111 100644
--- a/content/blog/2016/03/new-website.pdf
+++ b/content/blog/2016/03/new-website.pdf
Binary files differ
diff --git a/content/blog/2017/tomee-7.0.3-released.html b/content/blog/2017/tomee-7.0.3-released.html
index 9ff2b85..1f1c7de 100644
--- a/content/blog/2017/tomee-7.0.3-released.html
+++ b/content/blog/2017/tomee-7.0.3-released.html
@@ -72,7 +72,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/blog/2017/tomee-7.0.3-released.pdf b/content/blog/2017/tomee-7.0.3-released.pdf
index d3f0405..95efdbf 100644
--- a/content/blog/2017/tomee-7.0.3-released.pdf
+++ b/content/blog/2017/tomee-7.0.3-released.pdf
Binary files differ
diff --git a/content/blog/index.html b/content/blog/index.html
index 22fe9ac..b195d5f 100644
--- a/content/blog/index.html
+++ b/content/blog/index.html
@@ -72,7 +72,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/blog/index.pdf b/content/blog/index.pdf
index 5a384e5..c007aca 100644
--- a/content/blog/index.pdf
+++ b/content/blog/index.pdf
Binary files differ
diff --git a/content/community/commercial.html b/content/community/commercial.html
index e63e3ae..414548f 100644
--- a/content/community/commercial.html
+++ b/content/community/commercial.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/community/commercial.pdf b/content/community/commercial.pdf
index c0982d9..d36d764 100644
--- a/content/community/commercial.pdf
+++ b/content/community/commercial.pdf
Binary files differ
diff --git a/content/community/contributors.html b/content/community/contributors.html
index 8495ac1..a4711be 100644
--- a/content/community/contributors.html
+++ b/content/community/contributors.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
@@ -110,6 +110,32 @@
<div class="col-sm-4">
<div class="photo col-sm-5">
+ <img alt="Thiago Veronezi" src="http://www.gravatar.com/avatar/a02777ec107dbbdaa723f4115397dbb0?s=140">
+ <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;">Thiago Veronezi</h3>
+ <p></p>
+ <ul class="list-inline">
+
+ </div>
+ </div>
+
+ <div class="col-sm-4">
+ <div class="photo col-sm-5">
+ <img alt="Andy" src="http://www.gravatar.com/avatar/fea00dfa5f55664b225d9c072d9c6766?s=140">
+ <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="jlmonteiro" src="http://www.gravatar.com/avatar/7c00c0723f8604a75defa699507b43b9?s=140">
<i class="pull-right fa fa-star-o" style="color:#F38F24;"></i>
</div>
@@ -146,32 +172,6 @@
</div>
</div>
- <div class="col-sm-4">
- <div class="photo col-sm-5">
- <img alt="Andy" src="http://www.gravatar.com/avatar/fea00dfa5f55664b225d9c072d9c6766?s=140">
- <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="Thiago Veronezi" src="http://www.gravatar.com/avatar/a02777ec107dbbdaa723f4115397dbb0?s=140">
- <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;">Thiago Veronezi</h3>
- <p></p>
- <ul class="list-inline">
-
- </div>
- </div>
-
</ul>
</div>
</div>
diff --git a/content/community/index.html b/content/community/index.html
index 2d567c1..baf203d 100644
--- a/content/community/index.html
+++ b/content/community/index.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/community/social.html b/content/community/social.html
index 6f40a18..ea8b4a0 100644
--- a/content/community/social.html
+++ b/content/community/social.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/community/sources.html b/content/community/sources.html
index 3f87ead..f005eb8 100644
--- a/content/community/sources.html
+++ b/content/community/sources.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/developer/classloading/index.html b/content/developer/classloading/index.html
index 24bc8ad..b10fe8e 100644
--- a/content/developer/classloading/index.html
+++ b/content/developer/classloading/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/classloading/index.pdf b/content/developer/classloading/index.pdf
index 0305e9e..770ac17 100644
--- a/content/developer/classloading/index.pdf
+++ b/content/developer/classloading/index.pdf
Binary files differ
diff --git a/content/developer/configuration/cxf.html b/content/developer/configuration/cxf.html
index 0351e3b..9a15c20 100644
--- a/content/developer/configuration/cxf.html
+++ b/content/developer/configuration/cxf.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/configuration/cxf.pdf b/content/developer/configuration/cxf.pdf
index 09384b1..ded475a 100644
--- a/content/developer/configuration/cxf.pdf
+++ b/content/developer/configuration/cxf.pdf
Binary files differ
diff --git a/content/developer/ide/index.html b/content/developer/ide/index.html
index 363eb38..d442346 100644
--- a/content/developer/ide/index.html
+++ b/content/developer/ide/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/ide/index.pdf b/content/developer/ide/index.pdf
index 8479872..209816e 100644
--- a/content/developer/ide/index.pdf
+++ b/content/developer/ide/index.pdf
Binary files differ
diff --git a/content/developer/index.html b/content/developer/index.html
index 56d86e0..94b07f7 100644
--- a/content/developer/index.html
+++ b/content/developer/index.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/developer/index.pdf b/content/developer/index.pdf
index 3ae5451..7bc61d1 100644
--- a/content/developer/index.pdf
+++ b/content/developer/index.pdf
Binary files differ
diff --git a/content/developer/json/index.html b/content/developer/json/index.html
index b307ba3..82085cc 100644
--- a/content/developer/json/index.html
+++ b/content/developer/json/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/json/index.pdf b/content/developer/json/index.pdf
index 8917fa5..09bfe8e 100644
--- a/content/developer/json/index.pdf
+++ b/content/developer/json/index.pdf
Binary files differ
diff --git a/content/developer/testing/applicationcomposer/index.html b/content/developer/testing/applicationcomposer/index.html
index dd99eb4..eeed768 100644
--- a/content/developer/testing/applicationcomposer/index.html
+++ b/content/developer/testing/applicationcomposer/index.html
@@ -71,7 +71,7 @@
<li><a href="../../../admin/index.html">Admin</a></li>
<li><a href="../../../advanced/index.html">Advanced</a></li>
<li><a href="../../../security/index.html">Security</a></li>
- <li><a href="../../../examples/index.html">Examples</a></li>
+ <li><a href="../../../examples/index-ng.html">Examples</a></li>
<li><a href="../../../blog/index.html">Blog</a></li>
<li><a href="../../../community/index.html">Community</a></li>
<li><a href="../../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/testing/applicationcomposer/index.pdf b/content/developer/testing/applicationcomposer/index.pdf
index 3c350c5..3168145 100644
--- a/content/developer/testing/applicationcomposer/index.pdf
+++ b/content/developer/testing/applicationcomposer/index.pdf
Binary files differ
diff --git a/content/developer/testing/arquillian/index.html b/content/developer/testing/arquillian/index.html
index 5109162..7b231e5 100644
--- a/content/developer/testing/arquillian/index.html
+++ b/content/developer/testing/arquillian/index.html
@@ -71,7 +71,7 @@
<li><a href="../../../admin/index.html">Admin</a></li>
<li><a href="../../../advanced/index.html">Advanced</a></li>
<li><a href="../../../security/index.html">Security</a></li>
- <li><a href="../../../examples/index.html">Examples</a></li>
+ <li><a href="../../../examples/index-ng.html">Examples</a></li>
<li><a href="../../../blog/index.html">Blog</a></li>
<li><a href="../../../community/index.html">Community</a></li>
<li><a href="../../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/testing/arquillian/index.pdf b/content/developer/testing/arquillian/index.pdf
index e663130..a1c8da9 100644
--- a/content/developer/testing/arquillian/index.pdf
+++ b/content/developer/testing/arquillian/index.pdf
Binary files differ
diff --git a/content/developer/testing/index.html b/content/developer/testing/index.html
index 29d92c3..1aa39ba 100644
--- a/content/developer/testing/index.html
+++ b/content/developer/testing/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/testing/index.pdf b/content/developer/testing/index.pdf
index 9ce191d..12aa6c2 100644
--- a/content/developer/testing/index.pdf
+++ b/content/developer/testing/index.pdf
Binary files differ
diff --git a/content/developer/testing/other/index.html b/content/developer/testing/other/index.html
index 87edb3c..a606f5c 100644
--- a/content/developer/testing/other/index.html
+++ b/content/developer/testing/other/index.html
@@ -71,7 +71,7 @@
<li><a href="../../../admin/index.html">Admin</a></li>
<li><a href="../../../advanced/index.html">Advanced</a></li>
<li><a href="../../../security/index.html">Security</a></li>
- <li><a href="../../../examples/index.html">Examples</a></li>
+ <li><a href="../../../examples/index-ng.html">Examples</a></li>
<li><a href="../../../blog/index.html">Blog</a></li>
<li><a href="../../../community/index.html">Community</a></li>
<li><a href="../../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/testing/other/index.pdf b/content/developer/testing/other/index.pdf
index c756a53..43f07d5 100644
--- a/content/developer/testing/other/index.pdf
+++ b/content/developer/testing/other/index.pdf
Binary files differ
diff --git a/content/developer/tools/gradle-plugins.html b/content/developer/tools/gradle-plugins.html
index f4aacf1..a245202 100644
--- a/content/developer/tools/gradle-plugins.html
+++ b/content/developer/tools/gradle-plugins.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/tools/gradle-plugins.pdf b/content/developer/tools/gradle-plugins.pdf
index 3f21e60..4aad05a 100644
--- a/content/developer/tools/gradle-plugins.pdf
+++ b/content/developer/tools/gradle-plugins.pdf
Binary files differ
diff --git a/content/developer/tools/index.html b/content/developer/tools/index.html
index fe5b0cf..d6ce5d7 100644
--- a/content/developer/tools/index.html
+++ b/content/developer/tools/index.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/tools/index.pdf b/content/developer/tools/index.pdf
index f34c27f..c37264d 100644
--- a/content/developer/tools/index.pdf
+++ b/content/developer/tools/index.pdf
Binary files differ
diff --git a/content/developer/tools/maven-plugins.html b/content/developer/tools/maven-plugins.html
index 13e0116..5e908de 100644
--- a/content/developer/tools/maven-plugins.html
+++ b/content/developer/tools/maven-plugins.html
@@ -71,7 +71,7 @@
<li><a href="../../admin/index.html">Admin</a></li>
<li><a href="../../advanced/index.html">Advanced</a></li>
<li><a href="../../security/index.html">Security</a></li>
- <li><a href="../../examples/index.html">Examples</a></li>
+ <li><a href="../../examples/index-ng.html">Examples</a></li>
<li><a href="../../blog/index.html">Blog</a></li>
<li><a href="../../community/index.html">Community</a></li>
<li><a href="../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/tools/maven-plugins.pdf b/content/developer/tools/maven-plugins.pdf
index ac580d5..09aa9ba 100644
--- a/content/developer/tools/maven-plugins.pdf
+++ b/content/developer/tools/maven-plugins.pdf
Binary files differ
diff --git a/content/developer/tools/maven/applicationcomposer.html b/content/developer/tools/maven/applicationcomposer.html
index a062a4a..7fa300c 100644
--- a/content/developer/tools/maven/applicationcomposer.html
+++ b/content/developer/tools/maven/applicationcomposer.html
@@ -71,7 +71,7 @@
<li><a href="../../../admin/index.html">Admin</a></li>
<li><a href="../../../advanced/index.html">Advanced</a></li>
<li><a href="../../../security/index.html">Security</a></li>
- <li><a href="../../../examples/index.html">Examples</a></li>
+ <li><a href="../../../examples/index-ng.html">Examples</a></li>
<li><a href="../../../blog/index.html">Blog</a></li>
<li><a href="../../../community/index.html">Community</a></li>
<li><a href="../../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/tools/maven/applicationcomposer.pdf b/content/developer/tools/maven/applicationcomposer.pdf
index 8c3183f..d79d6ab 100644
--- a/content/developer/tools/maven/applicationcomposer.pdf
+++ b/content/developer/tools/maven/applicationcomposer.pdf
Binary files differ
diff --git a/content/developer/tools/maven/embedded.html b/content/developer/tools/maven/embedded.html
index dde2fc2..a3b34db 100644
--- a/content/developer/tools/maven/embedded.html
+++ b/content/developer/tools/maven/embedded.html
@@ -71,7 +71,7 @@
<li><a href="../../../admin/index.html">Admin</a></li>
<li><a href="../../../advanced/index.html">Advanced</a></li>
<li><a href="../../../security/index.html">Security</a></li>
- <li><a href="../../../examples/index.html">Examples</a></li>
+ <li><a href="../../../examples/index-ng.html">Examples</a></li>
<li><a href="../../../blog/index.html">Blog</a></li>
<li><a href="../../../community/index.html">Community</a></li>
<li><a href="../../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/tools/maven/embedded.pdf b/content/developer/tools/maven/embedded.pdf
index a9beb56..16f774f 100644
--- a/content/developer/tools/maven/embedded.pdf
+++ b/content/developer/tools/maven/embedded.pdf
Binary files differ
diff --git a/content/developer/tools/maven/tomee.html b/content/developer/tools/maven/tomee.html
index 9200fb6..f31f188 100644
--- a/content/developer/tools/maven/tomee.html
+++ b/content/developer/tools/maven/tomee.html
@@ -71,7 +71,7 @@
<li><a href="../../../admin/index.html">Admin</a></li>
<li><a href="../../../advanced/index.html">Advanced</a></li>
<li><a href="../../../security/index.html">Security</a></li>
- <li><a href="../../../examples/index.html">Examples</a></li>
+ <li><a href="../../../examples/index-ng.html">Examples</a></li>
<li><a href="../../../blog/index.html">Blog</a></li>
<li><a href="../../../community/index.html">Community</a></li>
<li><a href="../../../download-ng.html">Downloads</a></li>
diff --git a/content/developer/tools/maven/tomee.pdf b/content/developer/tools/maven/tomee.pdf
index 4c68d87..b720205 100644
--- a/content/developer/tools/maven/tomee.pdf
+++ b/content/developer/tools/maven/tomee.pdf
Binary files differ
diff --git a/content/download-ng.html b/content/download-ng.html
index 84948a9..69f09a0 100644
--- a/content/download-ng.html
+++ b/content/download-ng.html
@@ -71,7 +71,7 @@
<li><a href="admin/index.html">Admin</a></li>
<li><a href="advanced/index.html">Advanced</a></li>
<li><a href="security/index.html">Security</a></li>
- <li><a href="examples/index.html">Examples</a></li>
+ <li><a href="examples/index-ng.html">Examples</a></li>
<li><a href="blog/index.html">Blog</a></li>
<li><a href="community/index.html">Community</a></li>
<li><a href="download-ng.html">Downloads</a></li>
diff --git a/content/download-ng.pdf b/content/download-ng.pdf
index 2d96831..09e98fd 100644
--- a/content/download-ng.pdf
+++ b/content/download-ng.pdf
Binary files differ
diff --git a/content/examples/LICENSE b/content/examples/LICENSE
new file mode 100755
index 0000000..b71e72c
--- /dev/null
+++ b/content/examples/LICENSE
@@ -0,0 +1,1197 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+=========================================================================
+ - W3C Schemas
+ License: W3C Software Notice and License
+-------------------------------------------------------------------------
+
+W3C¨ SOFTWARE NOTICE AND LICENSE
+Copyright © 1994-2014 World Wide Web Consortium, (Massachusetts Institute of
+Technology, Institut National de Recherche en Informatique et en Automatique,
+Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/
+
+This W3C work (including software, documents, or other related items) is
+being provided by the copyright holders under the following license. By
+obtaining, using and/or copying this work, you (the licensee) agree that you
+have read, understood, and will comply with the following terms and
+conditions:
+
+Permission to use, copy, modify, and distribute this software and its
+documentation, with or without modification, for any purpose and without
+fee or royalty is hereby granted, provided that you include the following on
+ALL copies of the software and documentation or portions thereof, including
+modifications, that you make:
+
+ 1. The full text of this NOTICE in a location viewable to users of the
+ redistributed or derivative work.
+ 2. Any pre-existing intellectual property disclaimers, notices, or terms
+ and conditions. If none exist, a short notice of the following form
+ (hypertext is preferred, text is permitted) should be used within
+ the body of any redistributed or derivative code: "Copyright ©
+ [$date-of-software] World Wide Web Consortium, (Massachusetts Institute
+ of Technology, Institut National de Recherche en Informatique et en
+ Automatique, Keio University). All Rights Reserved.
+ http://www.w3.org/Consortium/Legal/"
+ 3. Notice of any changes or modifications to the W3C files, including the
+ date changes were made. (We recommend you provide URIs to the location
+ from which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
+NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
+THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS,
+COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in advertising or
+publicity pertaining to the software without specific, written prior permission.
+Title to copyright in this software and any associated documentation will at all
+times remain with copyright holders.
+
+
+=========================================================================
+ - HSQLDB (http://hsqldb.org/) org.hsqldb:hsqldb:jar:224
+ License: HSQLDB License (http://hsqldb.org/web/hsqlLicense.html)
+-------------------------------------------------------------------------
+
+For work developed by the HSQL Development Group:
+
+Copyright (c) 2001-2014, The HSQL Development Group
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+Neither the name of the HSQL Development Group nor the names of its
+contributors may be used to endorse or promote products derived from this
+software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+For work originally developed by the Hypersonic SQL Group:
+
+Copyright (c) 1995-2000 by the Hypersonic SQL Group.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+Neither the name of the Hypersonic SQL Group nor the names of its
+contributors may be used to endorse or promote products derived from this
+software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE HYPERSONIC SQL GROUP,
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+This software consists of voluntary contributions made by many individuals on behalf of the
+Hypersonic SQL Group.
+
+=========================================================================
+ - Serp (http://serp.sourceforge.net) net.sourceforge.serp:serp:jar:1.13.1
+ License: BSD (LICENSE.txt)
+-------------------------------------------------------------------------
+
+Copyright (c) 2002, A. Abram White
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of 'serp' nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+=========================================================================
+ - WSDL4J (http://sf.net/projects/wsdl4j) wsdl4j:wsdl4j:jar:1.6.2
+ License: CPL (http://www.opensource.org/licenses/cpl1.0.txt)
+-------------------------------------------------------------------------
+
+Common Public License Version 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC
+LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
+CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are
+distributed by that particular Contributor. A Contribution 'originates' from a
+Contributor if it was added to the Program by such Contributor itself or anyone
+acting on such Contributor's behalf. Contributions do not include additions to
+the Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii) are not
+derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents " mean patent claims licensable by a Contributor which are
+necessarily infringed by the use or sale of its Contribution alone or when
+combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement,
+including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free copyright license to
+reproduce, prepare derivative works of, publicly display, publicly perform,
+distribute and sublicense the Contribution of such Contributor, if any, and such
+derivative works, in source code and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed
+Patents to make, use, sell, offer to sell, import and otherwise transfer the
+Contribution of such Contributor, if any, in source code and object code form.
+This patent license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor, such
+addition of the Contribution causes such combination to be covered by the
+Licensed Patents. The patent license shall not apply to any other combinations
+which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses
+to its Contributions set forth herein, no assurances are provided by any
+Contributor that the Program does not infringe the patent or other intellectual
+property rights of any other entity. Each Contributor disclaims any liability to
+Recipient for claims brought by any other entity based on infringement of
+intellectual property rights or otherwise. As a condition to exercising the
+rights and licenses granted hereunder, each Recipient hereby assumes sole
+responsibility to secure any other intellectual property rights needed, if any.
+For example, if a third party patent license is required to allow Recipient to
+distribute the Program, it is Recipient's responsibility to acquire that license
+before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright license set
+forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its
+own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title and
+non-infringement, and implied warranties or conditions of merchantability and
+fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for
+damages, including direct, indirect, special, incidental and consequential
+damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered
+by that Contributor alone and not by any other party; and
+
+iv) states that source code for the Program is available from such
+Contributor, and informs licensees how to obtain it in a reasonable manner on or
+through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the
+Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if
+any, in a manner that reasonably allows subsequent Recipients to identify the
+originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with
+respect to end users, business partners and the like. While this license is
+intended to facilitate the commercial use of the Program, the Contributor who
+includes the Program in a commercial product offering should do so in a manner
+which does not create potential liability for other Contributors. Therefore, if
+a Contributor includes the Program in a commercial product offering, such
+Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any losses, damages
+and costs (collectively "Losses") arising from claims, lawsuits and other legal
+actions brought by a third party against the Indemnified Contributor to the
+extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor to
+control, and cooperate with the Commercial Contributor in, the defense and any
+related settlement negotiations. The Indemnified Contributor may participate in
+any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product
+offering, Product X. That Contributor is then a Commercial Contributor. If that
+Commercial Contributor then makes performance claims, or offers warranties
+related to Product X, those performance claims and warranties are such
+Commercial Contributor's responsibility alone. Under this section, the
+Commercial Contributor would have to defend claims against the other
+Contributors related to those performance claims and warranties, and if a court
+requires any other Contributor to pay any damages as a result, the Commercial
+Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
+IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
+Recipient is solely responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its exercise of
+rights under this Agreement, including but not limited to the risks and costs of
+program errors, compliance with applicable laws, damage to or loss of data,
+programs or equipment, and unavailability or interruption of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
+CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable
+law, it shall not affect the validity or enforceability of the remainder of the
+terms of this Agreement, and without further action by the parties hereto, such
+provision shall be reformed to the minimum extent necessary to make such
+provision valid and enforceable.
+
+If Recipient institutes patent litigation against a Contributor with respect to
+a patent applicable to software (including a cross-claim or counterclaim in a
+lawsuit), then any patent licenses granted by that Contributor to such Recipient
+under this Agreement shall terminate as of the date such litigation is filed. In
+addition, if Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the Program
+itself (excluding combinations of the Program with other software or hardware)
+infringes such Recipient's patent(s), then such Recipient's rights granted under
+Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to
+comply with any of the material terms or conditions of this Agreement and does
+not cure such failure in a reasonable period of time after becoming aware of
+such noncompliance. If all Recipient's rights under this Agreement terminate,
+Recipient agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under this Agreement
+and any licenses granted by Recipient relating to the Program shall continue and
+survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in
+order to avoid inconsistency the Agreement is copyrighted and may only be
+modified in the following manner. The Agreement Steward reserves the right to
+publish new versions (including revisions) of this Agreement from time to time.
+No one other than the Agreement Steward has the right to modify this Agreement.
+IBM is the initial Agreement Steward. IBM may assign the responsibility to serve
+as the Agreement Steward to a suitable separate entity. Each new version of the
+Agreement will be given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the Agreement
+under which it was received. In addition, after a new version of the Agreement
+is published, Contributor may elect to distribute the Program (including its
+Contributions) under the new version. Except as expressly stated in Sections
+2(a) and 2(b) above, Recipient receives no rights or licenses to the
+intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the
+intellectual property laws of the United States of America. No party to this
+Agreement will bring a legal action under this Agreement more than one year
+after the cause of action arose. Each party waives its rights to a jury trial in
+any resulting litigation.
+
+
+=========================================================================
+ - HOWL logger (http://forge.objectweb.org/projects/howl/) org.objectweb.howl:howl:jar:1.0.1-1
+ License: BSD
+-------------------------------------------------------------------------
+
+Copyright (c) 2004, Bull S.A.
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+=========================================================================
+ - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.6.1
+ - SLF4J LOG4J-12 Binding (http://www.slf4j.org) org.slf4j:slf4j-log4j12:jar:1.6.1
+ License: MIT License (http://www.opensource.org/licenses/mit-license.php)
+-------------------------------------------------------------------------
+
+Copyright (c) 2004-2014 QOS.ch
+ All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+=========================================================================
+ - Apache XBean :: ASM shaded (repackaged) org.apache.xbean:xbean-asm-shaded:bundle:3.8
+ License: BSD (http://asm.ow2.org/license.html)
+-------------------------------------------------------------------------
+
+Copyright (c) 2000-2014 INRIA, France Telecom
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+
+
+=========================================================================
+ - JSTL, JSP, Java EE Schemas
+ License: CDDL
+-------------------------------------------------------------------------
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+1. Definitions.
+
+1.1. "Contributor" means each individual or entity that
+creates or contributes to the creation of Modifications.
+
+1.2. "Contributor Version" means the combination of the
+Original Software, prior Modifications used by a
+Contributor (if any), and the Modifications made by that
+particular Contributor.
+
+1.3. "Covered Software" means (a) the Original Software, or
+(b) Modifications, or (c) the combination of files
+containing Original Software with files containing
+Modifications, in each case including portions thereof.
+
+1.4. "Executable" means the Covered Software in any form
+other than Source Code.
+
+1.5. "Initial Developer" means the individual or entity
+that first makes Original Software available under this
+License.
+
+1.6. "Larger Work" means a work which combines Covered
+Software or portions thereof with code not governed by the
+terms of this License.
+
+1.7. "License" means this document.
+
+1.8. "Licensable" means having the right to grant, to the
+maximum extent possible, whether at the time of the initial
+grant or subsequently acquired, any and all of the rights
+conveyed herein.
+
+1.9. "Modifications" means the Source Code and Executable
+form of any of the following:
+
+A. Any file that results from an addition to,
+deletion from or modification of the contents of a
+file containing Original Software or previous
+Modifications;
+
+B. Any new file that contains any part of the
+Original Software or previous Modification; or
+
+C. Any new file that is contributed or otherwise made
+available under the terms of this License.
+
+1.10. "Original Software" means the Source Code and
+Executable form of computer software code that is
+originally released under this License.
+
+1.11. "Patent Claims" means any patent claim(s), now owned
+or hereafter acquired, including without limitation,
+method, process, and apparatus claims, in any patent
+Licensable by grantor.
+
+1.12. "Source Code" means (a) the common form of computer
+software code in which modifications are made and (b)
+associated documentation included in or with such code.
+
+1.13. "You" (or "Your") means an individual or a legal
+entity exercising rights under, and complying with all of
+the terms of, this License. For legal entities, "You"
+includes any entity which controls, is controlled by, or is
+under common control with You. For purposes of this
+definition, "control" means (a) the power, direct or
+indirect, to cause the direction or management of such
+entity, whether by contract or otherwise, or (b) ownership
+of more than fifty percent (50%) of the outstanding shares
+or beneficial ownership of such entity.
+
+2. License Grants.
+
+2.1. The Initial Developer Grant.
+
+Conditioned upon Your compliance with Section 3.1 below and
+subject to third party intellectual property claims, the
+Initial Developer hereby grants You a world-wide,
+royalty-free, non-exclusive license:
+
+(a) under intellectual property rights (other than
+patent or trademark) Licensable by Initial Developer,
+to use, reproduce, modify, display, perform,
+sublicense and distribute the Original Software (or
+portions thereof), with or without Modifications,
+and/or as part of a Larger Work; and
+
+(b) under Patent Claims infringed by the making,
+using or selling of Original Software, to make, have
+made, use, practice, sell, and offer for sale, and/or
+otherwise dispose of the Original Software (or
+portions thereof).
+
+(c) The licenses granted in Sections 2.1(a) and (b)
+are effective on the date Initial Developer first
+distributes or otherwise makes the Original Software
+available to a third party under the terms of this
+License.
+
+(d) Notwithstanding Section 2.1(b) above, no patent
+license is granted: (1) for code that You delete from
+the Original Software, or (2) for infringements
+caused by: (i) the modification of the Original
+Software, or (ii) the combination of the Original
+Software with other software or devices.
+
+2.2. Contributor Grant.
+
+Conditioned upon Your compliance with Section 3.1 below and
+subject to third party intellectual property claims, each
+Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than
+patent or trademark) Licensable by Contributor to
+use, reproduce, modify, display, perform, sublicense
+and distribute the Modifications created by such
+Contributor (or portions thereof), either on an
+unmodified basis, with other Modifications, as
+Covered Software and/or as part of a Larger Work; and
+
+(b) under Patent Claims infringed by the making,
+using, or selling of Modifications made by that
+Contributor either alone and/or in combination with
+its Contributor Version (or portions of such
+combination), to make, use, sell, offer for sale,
+have made, and/or otherwise dispose of: (1)
+Modifications made by that Contributor (or portions
+thereof); and (2) the combination of Modifications
+made by that Contributor with its Contributor Version
+(or portions of such combination).
+
+(c) The licenses granted in Sections 2.2(a) and
+2.2(b) are effective on the date Contributor first
+distributes or otherwise makes the Modifications
+available to a third party.
+
+(d) Notwithstanding Section 2.2(b) above, no patent
+license is granted: (1) for any code that Contributor
+has deleted from the Contributor Version; (2) for
+infringements caused by: (i) third party
+modifications of Contributor Version, or (ii) the
+combination of Modifications made by that Contributor
+with other software (except as part of the
+Contributor Version) or other devices; or (3) under
+Patent Claims infringed by Covered Software in the
+absence of Modifications made by that Contributor.
+
+3. Distribution Obligations.
+
+3.1. Availability of Source Code.
+
+Any Covered Software that You distribute or otherwise make
+available in Executable form must also be made available in
+Source Code form and that Source Code form must be
+distributed only under the terms of this License. You must
+include a copy of this License with every copy of the
+Source Code form of the Covered Software You distribute or
+otherwise make available. You must inform recipients of any
+such Covered Software in Executable form as to how they can
+obtain such Covered Software in Source Code form in a
+reasonable manner on or through a medium customarily used
+for software exchange.
+
+3.2. Modifications.
+
+The Modifications that You create or to which You
+contribute are governed by the terms of this License. You
+represent that You believe Your Modifications are Your
+original creation(s) and/or You have sufficient rights to
+grant the rights conveyed by this License.
+
+3.3. Required Notices.
+
+You must include a notice in each of Your Modifications
+that identifies You as the Contributor of the Modification.
+You may not remove or alter any copyright, patent or
+trademark notices contained within the Covered Software, or
+any notices of licensing or any descriptive text giving
+attribution to any Contributor or the Initial Developer.
+
+3.4. Application of Additional Terms.
+
+You may not offer or impose any terms on any Covered
+Software in Source Code form that alters or restricts the
+applicable version of this License or the recipients'
+rights hereunder. You may choose to offer, and to charge a
+fee for, warranty, support, indemnity or liability
+obligations to one or more recipients of Covered Software.
+However, you may do so only on Your own behalf, and not on
+behalf of the Initial Developer or any Contributor. You
+must make it absolutely clear that any such warranty,
+support, indemnity or liability obligation is offered by
+You alone, and You hereby agree to indemnify the Initial
+Developer and every Contributor for any liability incurred
+by the Initial Developer or such Contributor as a result of
+warranty, support, indemnity or liability terms You offer.
+
+3.5. Distribution of Executable Versions.
+
+You may distribute the Executable form of the Covered
+Software under the terms of this License or under the terms
+of a license of Your choice, which may contain terms
+different from this License, provided that You are in
+compliance with the terms of this License and that the
+license for the Executable form does not attempt to limit
+or alter the recipient's rights in the Source Code form
+from the rights set forth in this License. If You
+distribute the Covered Software in Executable form under a
+different license, You must make it absolutely clear that
+any terms which differ from this License are offered by You
+alone, not by the Initial Developer or Contributor. You
+hereby agree to indemnify the Initial Developer and every
+Contributor for any liability incurred by the Initial
+Developer or such Contributor as a result of any such terms
+You offer.
+
+3.6. Larger Works.
+
+You may create a Larger Work by combining Covered Software
+with other code not governed by the terms of this License
+and distribute the Larger Work as a single product. In such
+a case, You must make sure the requirements of this License
+are fulfilled for the Covered Software.
+
+4. Versions of the License.
+
+4.1. New Versions.
+
+Sun Microsystems, Inc. is the initial license steward and
+may publish revised and/or new versions of this License
+from time to time. Each version will be given a
+distinguishing version number. Except as provided in
+Section 4.3, no one other than the license steward has the
+right to modify this License.
+
+4.2. Effect of New Versions.
+
+You may always continue to use, distribute or otherwise
+make the Covered Software available under the terms of the
+version of the License under which You originally received
+the Covered Software. If the Initial Developer includes a
+notice in the Original Software prohibiting it from being
+distributed or otherwise made available under any
+subsequent version of the License, You must distribute and
+make the Covered Software available under the terms of the
+version of the License under which You originally received
+the Covered Software. Otherwise, You may also choose to
+use, distribute or otherwise make the Covered Software
+available under the terms of any subsequent version of the
+License published by the license steward.
+
+4.3. Modified Versions.
+
+When You are an Initial Developer and You want to create a
+new license for Your Original Software, You may create and
+use a modified version of this License if You: (a) rename
+the license and remove any references to the name of the
+license steward (except to note that the license differs
+from this License); and (b) otherwise make it clear that
+the license contains terms which differ from this License.
+
+5. DISCLAIMER OF WARRANTY.
+
+COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
+BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
+SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
+PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
+COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
+INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF
+ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
+WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
+DISCLAIMER.
+
+6. TERMINATION.
+
+6.1. This License and the rights granted hereunder will
+terminate automatically if You fail to comply with terms
+herein and fail to cure such breach within 30 days of
+becoming aware of the breach. Provisions which, by their
+nature, must remain in effect beyond the termination of
+this License shall survive.
+
+6.2. If You assert a patent infringement claim (excluding
+declaratory judgment actions) against Initial Developer or
+a Contributor (the Initial Developer or Contributor against
+whom You assert such claim is referred to as "Participant")
+alleging that the Participant Software (meaning the
+Contributor Version where the Participant is a Contributor
+or the Original Software where the Participant is the
+Initial Developer) directly or indirectly infringes any
+patent, then any and all rights granted directly or
+indirectly to You by such Participant, the Initial
+Developer (if the Initial Developer is not the Participant)
+and all Contributors under Sections 2.1 and/or 2.2 of this
+License shall, upon 60 days notice from Participant
+terminate prospectively and automatically at the expiration
+of such 60 day notice period, unless if within such 60 day
+period You withdraw Your claim with respect to the
+Participant Software against such Participant either
+unilaterally or pursuant to a written agreement with
+Participant.
+
+6.3. In the event of termination under Sections 6.1 or 6.2
+above, all end user licenses that have been validly granted
+by You or any distributor hereunder prior to termination
+(excluding licenses granted to You by any distributor)
+shall survive termination.
+
+7. LIMITATION OF LIABILITY.
+
+UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
+INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
+COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
+LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
+CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
+LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
+STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
+INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
+APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
+NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
+CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
+APPLY TO YOU.
+
+8. U.S. GOVERNMENT END USERS.
+
+The Covered Software is a "commercial item," as that term is
+defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
+computer software" (as that term is defined at 48 C.F.R. ?
+252.227-7014(a)(1)) and "commercial computer software
+documentation" as such terms are used in 48 C.F.R. 12.212 (Sept.
+1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1
+through 227.7202-4 (June 1995), all U.S. Government End Users
+acquire Covered Software with only those rights set forth herein.
+This U.S. Government Rights clause is in lieu of, and supersedes,
+any other FAR, DFAR, or other clause or provision that addresses
+Government rights in computer software under this License.
+
+9. MISCELLANEOUS.
+
+This License represents the complete agreement concerning subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the
+extent necessary to make it enforceable. This License shall be
+governed by the law of the jurisdiction specified in a notice
+contained within the Original Software (except to the extent
+applicable law, if any, provides otherwise), excluding such
+jurisdiction's conflict-of-law provisions. Any litigation
+relating to this License shall be subject to the jurisdiction of
+the courts located in the jurisdiction and venue specified in a
+notice contained within the Original Software, with the losing
+party responsible for costs, including, without limitation, court
+costs and reasonable attorneys' fees and expenses. The
+application of the United Nations Convention on Contracts for the
+International Sale of Goods is expressly excluded. Any law or
+regulation which provides that the language of a contract shall
+be construed against the drafter shall not apply to this License.
+You agree that You alone are responsible for compliance with the
+United States export administration regulations (and the export
+control laws and regulation of any other countries) when You use,
+distribute or otherwise make available any Covered Software.
+
+10. RESPONSIBILITY FOR CLAIMS.
+
+As between Initial Developer and the Contributors, each party is
+responsible for claims and damages arising, directly or
+indirectly, out of its utilization of rights under this License
+and You agree to work with Initial Developer and Contributors to
+distribute such responsibility on an equitable basis. Nothing
+herein is intended or shall be deemed to constitute any admission
+of liability.
+
+============================================================
+el-api, istack
+
+The GNU General Public License (GPL) Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification follow.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+ One line to give the program's name and a brief idea of what it does.
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ signature of Ty Coon, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
+
+"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
+
+Certain source files distributed by Oracle are subject to the following clarification and special exception to the GPL Version 2, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the License file that accompanied this code."
+
+Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination.
+
+As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
+
+
diff --git a/content/examples/NOTICE b/content/examples/NOTICE
new file mode 100755
index 0000000..78edc7d
--- /dev/null
+++ b/content/examples/NOTICE
@@ -0,0 +1,45 @@
+Apache OpenEJB
+Copyright 1999-2014 The Apache OpenEJB development community
+
+This product includes/uses software, HSQLDB (http://hsqldb.org/)
+
+This product includes/uses software, WSDL4J (http://sf.net/projects/wsdl4j)
+
+This product includes/uses software, Serp (http://serp.sourceforge.net)
+
+This product includes/uses software, Swizzle :: Stream (http://swizzle.codehaus.org)
+
+This product includes/uses software, Backport of JSR 166 (http://www.mathcs.emory.edu/dcl/util/backport-util-concurrent/),
+developed by Dawid Kurzyniec (http://www.mathcs.emory.edu/~dawidk/)
+
+This product includes/uses software, Sun JAXB Reference Implementation Runtime,
+developed by Sun Microsystems (http://www.sun.com/)
+
+This product includes/uses software, Java Architecture for XML Binding (JAXB) API,
+developed by Sun Microsystems (http://www.sun.com/)
+
+This product includes/uses software, ASM Tree (http://asm.objectweb.org/asm-tree),
+developed by ObjectWeb (http://www.objectweb.org/)
+
+This product includes/uses software, ASM Core (http://asm.objectweb.org/asm),
+developed by ObjectWeb (http://www.objectweb.org/)
+
+This product includes/uses software, ASM Commons (http://asm.objectweb.org/asm-commons),
+developed by ObjectWeb (http://www.objectweb.org/)
+=========================================================================
+FastInfoset (https://fi.java.net/)
+License: Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt)
+=========================================================================
+Istack Commons Runtime (https://istack-commons.java.net/)
+License: CDDL v1.1 and GPL v2 (https://glassfish.java.net/public/CDDL+GPL_1_1.html)
+=========================================================================
+Jaxb Core (https://jaxb.java.net/)
+License: CDDL v1.1 and GPL v2 (https://glassfish.java.net/public/CDDL+GPL_1_1.html)
+=========================================================================
+Quartz (http://quartz-scheduler.org/)
+License: Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0.txt)
+=========================================================================
+el-api - Unified Expression Language is dual licensed under 2 OSI approved licenses (https://uel.java.net/license.html)
+ COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL - Version 1.1)
+ GNU General Public License (GPL - Version 2, June 1991) with the Classpath Exception
+=========================================================================
\ No newline at end of file
diff --git a/content/examples/access-timeout-meta.html b/content/examples/access-timeout-meta.html
new file mode 100644
index 0000000..8c23491
--- /dev/null
+++ b/content/examples/access-timeout-meta.html
@@ -0,0 +1,507 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/access-timeout-meta.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>@AccessTimeout the Meta-Annotation Way</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example access-timeout-meta can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/access-timeout-meta" class="bare">https://github.com/apache/tomee/tree/master/examples/access-timeout-meta</a></p>
+</div>
+<div class="paragraph">
+<p>Any annotation that takes parameters can benefit from meta-annotations. Here we see how <code>@AccessTimeout</code> can be far more understandable and manageable through meta-annotations.
+We’ll use the <a href="access-timeout.html">access-timeout</a> example as our use-case.</p>
+</div>
+<div class="paragraph">
+<p>The value of the parameters supplied to <code>@AccessTimeout</code> have a dramatic affect on how what that annotation actually does. Moreover, <code>@AccessTimeout</code> has one of those designs
+where <code>-1</code> and <code>0</code> have signifcantly different meanings. One means "wait forever", the other means "never wait". Only a lucky few can remember which is which on a daily basis.
+For the rest of us it is a constant source of bugs.</p>
+</div>
+<div class="paragraph">
+<p>Meta-Annotations to the rescue!</p>
+</div>
+</div>
+</div>
+<h1 id="_creating_the_meta_annotations" class="sect0">Creating the Meta-Annotations</h1>
+<div class="paragraph">
+<p>As a matter of best-practices, we will put our meta-annotations in a package called <code>api</code>, for this example that gives us <code>org.superbiz.accesstimeout.api</code>. The package <code>org.superbiz.api</code> would work just as well.</p>
+</div>
+<div class="paragraph">
+<p>The basic idea is to have a package where "approved' annotations are used and to prohibit usage of the non-meta versions of the annotations. All the real configuration will
+then be centralized in the <code>api</code> package and changes to timeout values will be localized to that package and automatically be reflected throuhout the application.</p>
+</div>
+<div class="paragraph">
+<p>An interesting side-effect of this approach is that if the <code>api</code> package where the meta-annotation definitions exist is kept in a separate jar as well, then one can effectively
+change the configuration of an entire application by simply replacing the <code>api</code> jar.</p>
+</div>
+<div class="sect1">
+<h2 id="__metatype_small_the_root_meta_annotation_small">@Metatype <small>The "root" Meta-Annotation</small></h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>As with all meta-annotation usage, you first need to create your own "root" meta-annotation. This is as easy as creating an annotation
+named <code>Metatype</code> that is annotated with itself and has <code>ElementType.ANNOTATION_TYPE</code> as its target.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.accesstimeout.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface Metatype {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="__awaitnever">@AwaitNever</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>When the <code>@AccessTimeout</code> annotation has the value of <code>0</code> that has the implication that one should never wait to access the bean. If the bean is busy, the caller will immediately
+receive an <code>ConcurrentAccessException</code>. This is hard to remember and definitely not self-documenting for those that never knew the details.</p>
+</div>
+<div class="paragraph">
+<p>To create a meta-annotation version of <code>@AccessTimeout(0)</code> we simply need to think of a good annotation name, create that annotation, and annotate it with both <code>@AccessTimeout</code>
+and <code>@Metatype</code></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.accesstimeout.api;
+
+import javax.ejb.AccessTimeout;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+@AccessTimeout(0)
+public @interface AwaitNever {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="__awaitforever">@AwaitForever</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Just as <code>0</code> carries the special meaning of "never wait", a value of <code>-1</code> means "wait forever."</p>
+</div>
+<div class="paragraph">
+<p>As long as we’re being picky, which we can be with meta-annotations,
+Technically "wait forever" is not the best description. The actual methods of the <code>javax.util.concurrent</code> APIs use "await" rather than "wait". One (wait) perphaps implies a
+command to wait, which this is not, and the other (await) perhaps better implies that waiting is possible but not a certainty. So we will use "await" in our annotation names.</p>
+</div>
+<div class="paragraph">
+<p>We make our own <code>@AwaitForever</code> and annotate it with <code>@AccessTimeout(0)</code> and <code>@Metatype</code></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.accesstimeout.api;
+
+import javax.ejb.AccessTimeout;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+@AccessTimeout(-1)
+public @interface AwaitForever {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="__awaitbriefly">@AwaitBriefly</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Non <code>-1</code> and <code>0</code> values to <code>@AccessTimeout</code> actually involve the full breadth of the annotation. Here is where you get to specify the maximum number minutes, seconds,
+milliseconds, etc. where one might await access to the bean instance.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.TYPE})
+
+@AccessTimeout(value = 5, unit = TimeUnit.SECONDS)
+public @interface AwaitBriefly {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_configuration_vs_operation" class="sect0">Configuration vs Operation</h1>
+<div class="paragraph">
+<p>Once you create a few meta-annotations and the fun becomes common-place, questoins start to raise in your mind on how to best get the benefits of meta-annotations.</p>
+</div>
+<div class="paragraph">
+<p>You have to really start thinking about how you want to approach your usage of meta-annotation and really put your designer hat on. The fundamental question is
+<strong>configuration vs operation</strong> and the answer is subjective; how much flexibility do you want to design into your applications and where?</p>
+</div>
+<div class="sect1">
+<h2 id="_configuration_names_small_describing_the_configuration_small">Configuration names <small>describing the configuration</small></h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The simplest approach is to name your meta-annotations after the <strong>configuration</strong> they encapsulate. We’ve been following that format so far with <code>@AwaitNever</code> and <code>@AwaitForever</code>
+to clearly reflect the contents of each meta-annotation (<code>@AccessTimeout(-1)</code> and <code>@AccessTimeout(0)</code> respectively).</p>
+</div>
+<div class="paragraph">
+<p>The <strong>cons</strong> of this approach is that should you want to change the configuration of the application by only changing the meta-annotations — this is one of the potential benefits
+of meta-annotations. Certainly, the <code>@AwaitNever</code> meta-annotation can have no other value than <code>0</code> if it is to live up to its name.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_operation_names_small_describing_the_code_small">Operation names <small>describing the code</small></h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The alternate approach is to name your meta-annotations after the <strong>operations</strong> they apply to. In short, to describe the code itself and not the configuration. So, names like
+<code>@OrderCheckTimeout</code> or <code>@TwitterUpdateTimeout</code>. These names are configuration-change-proof. They would not change if the configuration changes and in fact they can facilitate
+finder-grained control over the configuration of an application.</p>
+</div>
+<div class="paragraph">
+<p>The <strong>cons</strong> are of course it is requires far more deliberation and consideration, not to mention more annotations. Your skills as an architect, designer and ability to think as
+a administrator will be challenged. You must be good at wearing your dev-opts hat.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_pragmatism_small_best_of_both_worlds_small">Pragmatism <small>best of both worlds</small></h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Fortunately, meta-annotations are recursive. You can do a little of both.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+@AwaitBriefly
+public @interface TwitterUpdateTimeout {
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Of course you still need to be very deliberate on how your annotations are used. When using a "configuration" named meta-annotation in code it can help to say to yourself,
+"I do not want to reconfigure this later." If that doesn’t feel quite right, put the extra effort into creating an operation named annotation and use in that code.</p>
+</div>
+</div>
+</div>
+<h1 id="_applying_the_meta_annotations" class="sect0">Applying the Meta-Annotations</h1>
+<div class="paragraph">
+<p>Putting it all together, here’s how we might apply our meta-annotations to the <a href="access-timeout.html">access-timeout</a> example.</p>
+</div>
+<div class="sect1">
+<h2 id="_before">Before</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.accesstimeout;
+
+import javax.ejb.AccessTimeout;
+import javax.ejb.Asynchronous;
+import javax.ejb.Lock;
+import javax.ejb.Singleton;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import static javax.ejb.LockType.WRITE;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@Singleton
+@Lock(WRITE)
+public class BusyBee {
+
+ @Asynchronous
+ public Future stayBusy(CountDownLatch ready) {
+ ready.countDown();
+
+ try {
+ new CountDownLatch(1).await();
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+
+ return null;
+ }
+
+ @AccessTimeout(0)
+ public void doItNow() {
+ // do something
+ }
+
+ @AccessTimeout(value = 5, unit = TimeUnit.SECONDS)
+ public void doItSoon() {
+ // do something
+ }
+
+ @AccessTimeout(-1)
+ public void justDoIt() {
+ // do something
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_after">After</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.accesstimeout;
+
+import org.superbiz.accesstimeout.api.AwaitBriefly;
+import org.superbiz.accesstimeout.api.AwaitForever;
+import org.superbiz.accesstimeout.api.AwaitNever;
+
+import javax.ejb.Asynchronous;
+import javax.ejb.Lock;
+import javax.ejb.Singleton;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Future;
+
+import static javax.ejb.LockType.WRITE;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@Singleton
+@Lock(WRITE)
+public class BusyBee {
+
+ @Asynchronous
+ public Future stayBusy(CountDownLatch ready) {
+ ready.countDown();
+
+ try {
+ new CountDownLatch(1).await();
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+
+ return null;
+ }
+
+ @AwaitNever
+ public void doItNow() {
+ // do something
+ }
+
+ @AwaitBriefly
+ public void doItSoon() {
+ // do something
+ }
+
+ @AwaitForever
+ public void justDoIt() {
+ // do something
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/access-timeout-meta.pdf b/content/examples/access-timeout-meta.pdf
new file mode 100644
index 0000000..a8e0ab9
--- /dev/null
+++ b/content/examples/access-timeout-meta.pdf
Binary files differ
diff --git a/content/examples/access-timeout-meta/README.md b/content/examples/access-timeout-meta/README.md
new file mode 100755
index 0000000..716efb6
--- /dev/null
+++ b/content/examples/access-timeout-meta/README.md
@@ -0,0 +1,249 @@
+Title: @AccessTimeout the Meta-Annotation Way
+
+Any annotation that takes parameters can benefit from meta-annotations. Here we see how `@AccessTimeout` can be far more understandable and manageable through meta-annotations.
+We'll use the [access-timeout](../access-timeout/README.html) example as our use-case.
+
+The value of the parameters supplied to `@AccessTimeout` have a dramatic affect on how what that annotation actually does. Moreover, `@AccessTimeout` has one of those designs
+where `-1` and `0` have signifcantly different meanings. One means "wait forever", the other means "never wait". Only a lucky few can remember which is which on a daily basis.
+For the rest of us it is a constant source of bugs.
+
+Meta-Annotations to the rescue!
+
+# Creating the Meta-Annotations
+
+As a matter of best-practices, we will put our meta-annotations in a package called `api`, for this example that gives us `org.superbiz.accesstimeout.api`. The package `org.superbiz.api` would work just as well.
+
+The basic idea is to have a package where "approved' annotations are used and to prohibit usage of the non-meta versions of the annotations. All the real configuration will
+then be centralized in the `api` package and changes to timeout values will be localized to that package and automatically be reflected throuhout the application.
+
+An interesting side-effect of this approach is that if the `api` package where the meta-annotation definitions exist is kept in a separate jar as well, then one can effectively
+change the configuration of an entire application by simply replacing the `api` jar.
+
+## @Metatype <small>The "root" Meta-Annotation</small>
+
+As with all meta-annotation usage, you first need to create your own "root" meta-annotation. This is as easy as creating an annotation
+named `Metatype` that is annotated with itself and has `ElementType.ANNOTATION_TYPE` as its target.
+
+
+ package org.superbiz.accesstimeout.api;
+
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.ANNOTATION_TYPE)
+ public @interface Metatype {
+ }
+
+## @AwaitNever
+
+When the `@AccessTimeout` annotation has the value of `0` that has the implication that one should never wait to access the bean. If the bean is busy, the caller will immediately
+receive an `ConcurrentAccessException`. This is hard to remember and definitely not self-documenting for those that never knew the details.
+
+To create a meta-annotation version of `@AccessTimeout(0)` we simply need to think of a good annotation name, create that annotation, and annotate it with both `@AccessTimeout`
+and `@Metatype`
+
+ package org.superbiz.accesstimeout.api;
+
+ import javax.ejb.AccessTimeout;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+
+ @AccessTimeout(0)
+ public @interface AwaitNever {
+ }
+
+## @AwaitForever
+
+Just as `0` carries the special meaning of "never wait", a value of `-1` means "wait forever."
+
+As long as we're being picky, which we can be with meta-annotations,
+Technically "wait forever" is not the best description. The actual methods of the `javax.util.concurrent` APIs use "await" rather than "wait". One (wait) perphaps implies a
+command to wait, which this is not, and the other (await) perhaps better implies that waiting is possible but not a certainty. So we will use "await" in our annotation names.
+
+We make our own `@AwaitForever` and annotate it with `@AccessTimeout(0)` and `@Metatype`
+
+ package org.superbiz.accesstimeout.api;
+
+ import javax.ejb.AccessTimeout;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+
+ @AccessTimeout(-1)
+ public @interface AwaitForever {
+ }
+
+## @AwaitBriefly
+
+Non `-1` and `0` values to `@AccessTimeout` actually involve the full breadth of the annotation. Here is where you get to specify the maximum number minutes, seconds,
+milliseconds, etc. where one might await access to the bean instance.
+
+ @Metatype
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.METHOD, ElementType.TYPE})
+
+ @AccessTimeout(value = 5, unit = TimeUnit.SECONDS)
+ public @interface AwaitBriefly {
+ }
+
+# Configuration vs Operation
+
+Once you create a few meta-annotations and the fun becomes common-place, questoins start to raise in your mind on how to best get the benefits of meta-annotations.
+
+You have to really start thinking about how you want to approach your usage of meta-annotation and really put your designer hat on. The fundamental question is
+**configuration vs operation** and the answer is subjective; how much flexibility do you want to design into your applications and where?
+
+## Configuration names <small>describing the configuration</small>
+
+The simplest approach is to name your meta-annotations after the **configuration** they encapsulate. We've been following that format so far with `@AwaitNever` and `@AwaitForever`
+to clearly reflect the contents of each meta-annotation (`@AccessTimeout(-1)` and `@AccessTimeout(0)` respectively).
+
+The **cons** of this approach is that should you want to change the configuration of the application by only changing the meta-annotations -- this is one of the potential benefits
+of meta-annotations. Certainly, the `@AwaitNever` meta-annotation can have no other value than `0` if it is to live up to its name.
+
+## Operation names <small>describing the code</small>
+
+The alternate approach is to name your meta-annotations after the **operations** they apply to. In short, to describe the code itself and not the configuration. So, names like
+`@OrderCheckTimeout` or `@TwitterUpdateTimeout`. These names are configuration-change-proof. They would not change if the configuration changes and in fact they can facilitate
+finder-grained control over the configuration of an application.
+
+The **cons** are of course it is requires far more deliberation and consideration, not to mention more annotations. Your skills as an architect, designer and ability to think as
+a administrator will be challenged. You must be good at wearing your dev-opts hat.
+
+## Pragmatism <small>best of both worlds</small>
+
+Fortunately, meta-annotations are recursive. You can do a little of both.
+
+ @Metatype
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+
+ @AwaitBriefly
+ public @interface TwitterUpdateTimeout {
+ }
+
+Of course you still need to be very deliberate on how your annotations are used. When using a "configuration" named meta-annotation in code it can help to say to yourself,
+"I do not want to reconfigure this later." If that doesn't feel quite right, put the extra effort into creating an operation named annotation and use in that code.
+
+# Applying the Meta-Annotations
+
+Putting it all together, here's how we might apply our meta-annotations to the [access-timeout](../access-timeout/README.html) example.
+
+## Before
+
+ package org.superbiz.accesstimeout;
+
+ import javax.ejb.AccessTimeout;
+ import javax.ejb.Asynchronous;
+ import javax.ejb.Lock;
+ import javax.ejb.Singleton;
+ import java.util.concurrent.CountDownLatch;
+ import java.util.concurrent.Future;
+ import java.util.concurrent.TimeUnit;
+
+ import static javax.ejb.LockType.WRITE;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ @Singleton
+ @Lock(WRITE)
+ public class BusyBee {
+
+ @Asynchronous
+ public Future stayBusy(CountDownLatch ready) {
+ ready.countDown();
+
+ try {
+ new CountDownLatch(1).await();
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+
+ return null;
+ }
+
+ @AccessTimeout(0)
+ public void doItNow() {
+ // do something
+ }
+
+ @AccessTimeout(value = 5, unit = TimeUnit.SECONDS)
+ public void doItSoon() {
+ // do something
+ }
+
+ @AccessTimeout(-1)
+ public void justDoIt() {
+ // do something
+ }
+
+ }
+
+## After
+
+ package org.superbiz.accesstimeout;
+
+ import org.superbiz.accesstimeout.api.AwaitBriefly;
+ import org.superbiz.accesstimeout.api.AwaitForever;
+ import org.superbiz.accesstimeout.api.AwaitNever;
+
+ import javax.ejb.Asynchronous;
+ import javax.ejb.Lock;
+ import javax.ejb.Singleton;
+ import java.util.concurrent.CountDownLatch;
+ import java.util.concurrent.Future;
+
+ import static javax.ejb.LockType.WRITE;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ @Singleton
+ @Lock(WRITE)
+ public class BusyBee {
+
+ @Asynchronous
+ public Future stayBusy(CountDownLatch ready) {
+ ready.countDown();
+
+ try {
+ new CountDownLatch(1).await();
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+
+ return null;
+ }
+
+ @AwaitNever
+ public void doItNow() {
+ // do something
+ }
+
+ @AwaitBriefly
+ public void doItSoon() {
+ // do something
+ }
+
+ @AwaitForever
+ public void justDoIt() {
+ // do something
+ }
+
+ }
diff --git a/content/examples/access-timeout-meta/build.xml b/content/examples/access-timeout-meta/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/access-timeout-meta/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/access-timeout-meta/pom.xml b/content/examples/access-timeout-meta/pom.xml
new file mode 100755
index 0000000..5102378
--- /dev/null
+++ b/content/examples/access-timeout-meta/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>access-timeout-meta</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @AccessTimeout (Meta)</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/BusyBee.java b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/BusyBee.java
new file mode 100755
index 0000000..833d4d0
--- /dev/null
+++ b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/BusyBee.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.accesstimeout;
+
+import org.superbiz.accesstimeout.api.AwaitBriefly;
+import org.superbiz.accesstimeout.api.AwaitForever;
+import org.superbiz.accesstimeout.api.AwaitNever;
+
+import javax.ejb.Asynchronous;
+import javax.ejb.Lock;
+import javax.ejb.Singleton;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Future;
+
+import static javax.ejb.LockType.WRITE;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@Singleton
+@Lock(WRITE)
+public class BusyBee {
+
+ @Asynchronous
+ public Future stayBusy(CountDownLatch ready) {
+ ready.countDown();
+
+ try {
+ new CountDownLatch(1).await();
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+
+ return null;
+ }
+
+ @AwaitNever
+ public void doItNow() {
+ // do something
+ }
+
+ @AwaitBriefly
+ public void doItSoon() {
+ // do something
+ }
+
+ @AwaitForever
+ public void justDoIt() {
+ // do something
+ }
+
+}
diff --git a/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/AwaitBriefly.java b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/AwaitBriefly.java
new file mode 100755
index 0000000..e9540b0
--- /dev/null
+++ b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/AwaitBriefly.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.accesstimeout.api;
+
+import javax.ejb.AccessTimeout;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.concurrent.TimeUnit;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+@AccessTimeout(value = 5, unit = TimeUnit.SECONDS)
+public @interface AwaitBriefly {
+
+}
\ No newline at end of file
diff --git a/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/AwaitForever.java b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/AwaitForever.java
new file mode 100755
index 0000000..1be4545
--- /dev/null
+++ b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/AwaitForever.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.accesstimeout.api;
+
+import javax.ejb.AccessTimeout;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+@AccessTimeout(-1)
+public @interface AwaitForever {
+
+}
diff --git a/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/AwaitNever.java b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/AwaitNever.java
new file mode 100755
index 0000000..ed0085b
--- /dev/null
+++ b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/AwaitNever.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.accesstimeout.api;
+
+import javax.ejb.AccessTimeout;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+@AccessTimeout(1)
+public @interface AwaitNever {
+
+}
\ No newline at end of file
diff --git a/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/Metatype.java b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/Metatype.java
new file mode 100755
index 0000000..3c492c2
--- /dev/null
+++ b/content/examples/access-timeout-meta/src/main/java/org/superbiz/accesstimeout/api/Metatype.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.accesstimeout.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface Metatype {
+
+}
diff --git a/content/examples/access-timeout-meta/src/test/java/org/superbiz/accesstimeout/BusyBeeTest.java b/content/examples/access-timeout-meta/src/test/java/org/superbiz/accesstimeout/BusyBeeTest.java
new file mode 100755
index 0000000..910dd09
--- /dev/null
+++ b/content/examples/access-timeout-meta/src/test/java/org/superbiz/accesstimeout/BusyBeeTest.java
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.accesstimeout;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class BusyBeeTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final CountDownLatch ready = new CountDownLatch(1);
+
+ final BusyBee busyBee = (BusyBee) context.lookup("java:global/access-timeout-meta/BusyBee");
+
+ // This asynchronous method will never exit
+ busyBee.stayBusy(ready);
+
+ // Are you working yet little bee?
+ ready.await();
+
+ // OK, Bee is busy
+
+ { // Timeout Immediately
+ final long start = System.nanoTime();
+
+ try {
+ busyBee.doItNow();
+
+ fail("The bee should be busy");
+ } catch (Exception e) {
+ // the bee is still too busy as expected
+ }
+
+ assertEquals(0, seconds(start));
+ }
+
+ { // Timeout in 5 seconds
+ final long start = System.nanoTime();
+
+ try {
+ busyBee.doItSoon();
+
+ fail("The bee should be busy");
+ } catch (Exception e) {
+ // the bee is still too busy as expected
+ }
+
+ assertEquals(5, seconds(start));
+ }
+
+ // This will wait forever, give it a try if you have that long
+ //busyBee.justDoIt();
+ }
+
+ private long seconds(long start) {
+ return TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
+ }
+}
diff --git a/content/examples/access-timeout.html b/content/examples/access-timeout.html
new file mode 100644
index 0000000..8f374a1
--- /dev/null
+++ b/content/examples/access-timeout.html
@@ -0,0 +1,450 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/access-timeout.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>@AccessTimeout annotation</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example access-timeout can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/access-timeout" class="bare">https://github.com/apache/tomee/tree/master/examples/access-timeout</a></p>
+</div>
+<div class="paragraph">
+<p>Before taking a look at <code>@AccessTimeout</code>, it might help to see when a caller might have to "wait"</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_waiting">Waiting</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_stateful_bean">Stateful Bean</h3>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+By default, clients are allowed to make concurrent calls to a stateful session object and the container is required to serialize such concurrent requests. Note that the container never permits multi-threaded access to the actual stateful session bean instance. For this reason, Read/Write method locking metadata, as well as the bean-managed concurrency mode, are not applicable to stateful session beans and must not be used.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>This means that when a method <code>foo()</code> of a stateful bean instance is being executed and a second request comes in for that method or another method, EJB container would serialize the second request. It would not let the method be executed concurrently but wait until the first request is processed.</p>
+</div>
+<div class="paragraph">
+<p>The client would wait also when <code>@Stateful</code> bean is in a transaction and the client is invoking it from outside that transaction.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_stateless_bean">Stateless Bean</h3>
+<div class="paragraph">
+<p>Say there are 20 instances of a bean in the pool and all of them are busy. Now when the next request comes in, the processing <strong>might wait</strong> for a bean to be available in the pool. (Note: Pooling sematics, if any, are not covered by the spec. The vendor’s pooling semantics might or might not involve a wait condition)</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_singleton_bean">Singleton Bean</h3>
+<div class="paragraph">
+<p>The container enforces a single-threaded access by default to singleton beans. That’s the equivalent of annotating with <code>@Lock(Write)</code>. So when a <code>@Lock(Write)</code> method is executing, all other <code>@Lock(READ)</code> and <code>@Lock(WRITE)</code> method invocations would have to wait.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_summary">Summary</h3>
+<div class="ulist">
+<ul>
+<li>
+<p><code>@Singleton</code> - an <code>@Lock(WRITE)</code> method is being invoked and container-managed concurrency is being used. All methods are <code>@Lock(WRITE)</code> by default.</p>
+</li>
+<li>
+<p><code>@Stateful</code> - any method of the instance is being invoked and a second invocation occurs. OR the <code>@Stateful</code> bean is in a transaction and the caller is invoking it from outside that transaction.</p>
+</li>
+<li>
+<p><code>@Stateless</code> - no instances are available in the pool. As noted, however, pooling sematics, if any, are not covered by the spec. If the vendor’s pooling semantics do involve a wait condition, the @AccessTimeout should apply.</p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+</div>
+<h1 id="__accesstimeout" class="sect0">@AccessTimeout</h1>
+<div class="paragraph">
+<p>The <code>@AccessTimeout</code> is simply a convenience wrapper around the <code>long</code> and <code>TimeUnit</code> tuples commonly used in the <code>java.util.concurrent</code> API.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import java.util.concurrent.TimeUnit;
+@Target({METHOD, TYPE})
+@Retention(RUNTIME)
+public @interface AccessTimeout {
+ long value();
+ TimeUnit unit() default TimeUnit.MILLISECONDS;
+}</code></pre>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_usage">Usage</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>A method or class can be annotated with @AccessTimeout to specify the maximum time a call might wait for access to the bean wait should a wait condition occur.</p>
+</div>
+<div class="paragraph">
+<p>The semantics of the value element are as follows:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>A <code>value</code> > 0 indicates a timeout value in the units specified by the <code>unit</code> element.</p>
+</li>
+<li>
+<p>A <code>value</code> of 0 means concurrent access is not permitted.</p>
+</li>
+<li>
+<p>A <code>value</code> of -1 indicates that the client request will block indefinitely until forward progress it can proceed.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Just as simple as that !</p>
+</div>
+<div class="sect2">
+<h3 id="_what_exception_would_the_client_receive_with_a_timeout">What exception would the client receive, with a timeout ?</h3>
+<div class="paragraph">
+<p>Quoting from the spec, "if a client-invoked business method is in progress on an instance when another client-invoked call, from the same or different client, arrives at the same instance of a stateful session bean, if the second client is a client of the bean�s business interface or no-interface view, the concurrent invocation must result in the second client receiving a javax.ejb.ConcurrentAccessException[15]. If the EJB 2.1 client view is used, the container must throw a java.rmi.RemoteException if the second client is a remote client, or a javax.ejb.EJBException if the second client is a local client"</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_no_standard_default">No standard default</h3>
+<div class="paragraph">
+<p>Note that the <code>value</code> attribute has no default. This was intentional and intended to communicate that if <code>@AccessTimeout</code> is not explicitly used, the behavior you get is vendor-specific.</p>
+</div>
+<div class="paragraph">
+<p>Some vendors will wait for a preconfigured time and throw <code>javax.ejb.ConcurrentAccessException</code>, some vendors will throw it immediately.</p>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_example" class="sect0">Example</h1>
+<div class="paragraph">
+<p>Here we have a simple @Singleton bean that has three synchronous methods and one <code>@Asynchronous</code> method. The bean itself is annotated <code>@Lock(WRITE)</code> so that only one thread may access the <code>@Singleton</code> at a time. This is the default behavior of an <code>@Singleton</code> bean, so explicit usage of <code>@Lock(WRITE)</code> is not needed but is rather nice for clarity as the single-threaded nature of the bean is important to the example.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Singleton
+@Lock(WRITE)
+public class BusyBee {
+
+ @Asynchronous
+ public Future stayBusy(CountDownLatch ready) {
+ ready.countDown();
+
+ try {
+ new CountDownLatch(1).await();
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+
+ return null;
+ }
+
+ @AccessTimeout(0)
+ public void doItNow() {
+ // do something
+ }
+
+ @AccessTimeout(value = 5, unit = TimeUnit.SECONDS)
+ public void doItSoon() {
+ // do something
+ }
+
+ @AccessTimeout(-1)
+ public void justDoIt() {
+ // do something
+ }
+
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The <code>@Asynchronous</code> method is not a critical part of <code>@AccessTimeout</code>, but serves as a simple way to "lock" the bean for testing purposes. It allows us to easily test the concurrent behavior of the bean.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class BusyBeeTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final CountDownLatch ready = new CountDownLatch(1);
+
+ final BusyBee busyBee = (BusyBee) context.lookup("java:global/access-timeout/BusyBee");
+
+ // This asynchronous method will never exit
+ busyBee.stayBusy(ready);
+
+ // Are you working yet little bee?
+ ready.await();
+
+
+ // OK, Bee is busy
+
+
+ { // Timeout Immediately
+ final long start = System.nanoTime();
+
+ try {
+ busyBee.doItNow();
+
+ fail("The bee should be busy");
+ } catch (Exception e) {
+ // the bee is still too busy as expected
+ }
+
+ assertEquals(0, seconds(start));
+ }
+
+ { // Timeout in 5 seconds
+ final long start = System.nanoTime();
+
+ try {
+ busyBee.doItSoon();
+
+ fail("The bee should be busy");
+ } catch (Exception e) {
+ // the bee is still too busy as expected
+ }
+
+ assertEquals(5, seconds(start));
+ }
+
+ // This will wait forever, give it a try if you have that long
+ //busyBee.justDoIt();
+ }
+
+ private long seconds(long start) {
+ return TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.accesstimeout.BusyBeeTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/access-timeout
+INFO - openejb.base = /Users/dblevins/examples/access-timeout
+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/access-timeout/target/classes
+INFO - Beginning load: /Users/dblevins/examples/access-timeout/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/access-timeout
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean BusyBee: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.accesstimeout.BusyBeeTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/access-timeout" loaded.
+INFO - Assembling app: /Users/dblevins/examples/access-timeout
+INFO - Jndi(name="java:global/access-timeout/BusyBee!org.superbiz.accesstimeout.BusyBee")
+INFO - Jndi(name="java:global/access-timeout/BusyBee")
+INFO - Jndi(name="java:global/EjbModule748454644/org.superbiz.accesstimeout.BusyBeeTest!org.superbiz.accesstimeout.BusyBeeTest")
+INFO - Jndi(name="java:global/EjbModule748454644/org.superbiz.accesstimeout.BusyBeeTest")
+INFO - Created Ejb(deployment-id=org.superbiz.accesstimeout.BusyBeeTest, ejb-name=org.superbiz.accesstimeout.BusyBeeTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=BusyBee, ejb-name=BusyBee, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=org.superbiz.accesstimeout.BusyBeeTest, ejb-name=org.superbiz.accesstimeout.BusyBeeTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=BusyBee, ejb-name=BusyBee, container=Default Singleton Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/access-timeout)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.071 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/access-timeout.pdf b/content/examples/access-timeout.pdf
new file mode 100644
index 0000000..7009b4e
--- /dev/null
+++ b/content/examples/access-timeout.pdf
Binary files differ
diff --git a/content/examples/access-timeout/README.md b/content/examples/access-timeout/README.md
new file mode 100755
index 0000000..6dc9e2a
--- /dev/null
+++ b/content/examples/access-timeout/README.md
@@ -0,0 +1,196 @@
+Title: @AccessTimeout annotation
+
+Before taking a look at `@AccessTimeout`, it might help to see when a caller might have to "wait"
+
+## Waiting
+
+###Stateful Bean
+>By default, clients are allowed to make concurrent calls to a stateful session object and the container is required to serialize such concurrent requests. Note that the container never permits multi-threaded access to the actual stateful session bean instance. For this reason, Read/Write method locking metadata, as well as the bean-managed concurrency mode, are not applicable to stateful session beans and must not be used.
+
+This means that when a method `foo()` of a stateful bean instance is being executed and a second request comes in for that method or another method, EJB container would serialize the second request. It would not let the method be executed concurrently but wait until the first request is processed.
+
+The client would wait also when `@Stateful` bean is in a transaction and the client is invoking it from outside that transaction.
+
+###Stateless Bean
+
+Say there are 20 instances of a bean in the pool and all of them are busy. Now when the next request comes in, the processing *might wait* for a bean to be available in the pool. (Note: Pooling sematics, if any, are not covered by the spec. The vendor's pooling semantics might or might not involve a wait condition)
+
+###Singleton Bean
+
+The container enforces a single-threaded access by default to singleton beans. That's the equivalent of annotating with `@Lock(Write)`. So when a `@Lock(Write)` method is executing, all other `@Lock(READ)` and `@Lock(WRITE)` method invocations would have to wait.
+
+### Summary
+
+ - `@Singleton` - an `@Lock(WRITE)` method is being invoked and container-managed concurrency is being used. All methods are `@Lock(WRITE)` by default.
+ - `@Stateful` - any method of the instance is being invoked and a second invocation occurs. OR the `@Stateful` bean is in a transaction and the caller is invoking it from outside that transaction.
+ - `@Stateless` - no instances are available in the pool. As noted, however, pooling sematics, if any, are not covered by the spec. If the vendor's pooling semantics do involve a wait condition, the @AccessTimeout should apply.
+
+# @AccessTimeout
+
+The `@AccessTimeout` is simply a convenience wrapper around the `long` and `TimeUnit` tuples commonly used in the `java.util.concurrent` API.
+
+ import java.util.concurrent.TimeUnit;
+ @Target({METHOD, TYPE})
+ @Retention(RUNTIME)
+ public @interface AccessTimeout {
+ long value();
+ TimeUnit unit() default TimeUnit.MILLISECONDS;
+ }
+
+## Usage
+
+A method or class can be annotated with @AccessTimeout to specify the maximum time a call might wait for access to the bean wait should a wait condition occur.
+
+The semantics of the value element are as follows:
+
+ - A `value` > 0 indicates a timeout value in the units specified by the `unit` element.
+ - A `value` of 0 means concurrent access is not permitted.
+ - A `value` of -1 indicates that the client request will block indefinitely until forward progress it can proceed.
+
+Just as simple as that !
+
+###What exception would the client receive, with a timeout ?
+Quoting from the spec, "if a client-invoked business method is in progress on an instance when another client-invoked call, from the same or different client, arrives at the same instance of a stateful session bean, if the second client is a client of the beanÕs business interface or no-interface view, the concurrent invocation must result in the second client receiving a javax.ejb.ConcurrentAccessException[15]. If the EJB 2.1 client view is used, the container must throw a java.rmi.RemoteException if the second client is a remote client, or a javax.ejb.EJBException if the second client is a local client"
+
+### No standard default
+
+Note that the `value` attribute has no default. This was intentional and intended to communicate that if `@AccessTimeout` is not explicitly used, the behavior you get is vendor-specific.
+
+Some vendors will wait for a preconfigured time and throw `javax.ejb.ConcurrentAccessException`, some vendors will throw it immediately.
+
+# Example
+
+Here we have a simple @Singleton bean that has three synchronous methods and one `@Asynchronous` method. The bean itself is annotated `@Lock(WRITE)` so that only one thread may access the `@Singleton` at a time. This is the default behavior of an `@Singleton` bean, so explicit usage of `@Lock(WRITE)` is not needed but is rather nice for clarity as the single-threaded nature of the bean is important to the example.
+
+ @Singleton
+ @Lock(WRITE)
+ public class BusyBee {
+
+ @Asynchronous
+ public Future stayBusy(CountDownLatch ready) {
+ ready.countDown();
+
+ try {
+ new CountDownLatch(1).await();
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+
+ return null;
+ }
+
+ @AccessTimeout(0)
+ public void doItNow() {
+ // do something
+ }
+
+ @AccessTimeout(value = 5, unit = TimeUnit.SECONDS)
+ public void doItSoon() {
+ // do something
+ }
+
+ @AccessTimeout(-1)
+ public void justDoIt() {
+ // do something
+ }
+
+ }
+
+The `@Asynchronous` method is not a critical part of `@AccessTimeout`, but serves as a simple way to "lock" the bean for testing purposes. It allows us to easily test the concurrent behavior of the bean.
+
+ public class BusyBeeTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final CountDownLatch ready = new CountDownLatch(1);
+
+ final BusyBee busyBee = (BusyBee) context.lookup("java:global/access-timeout/BusyBee");
+
+ // This asynchronous method will never exit
+ busyBee.stayBusy(ready);
+
+ // Are you working yet little bee?
+ ready.await();
+
+
+ // OK, Bee is busy
+
+
+ { // Timeout Immediately
+ final long start = System.nanoTime();
+
+ try {
+ busyBee.doItNow();
+
+ fail("The bee should be busy");
+ } catch (Exception e) {
+ // the bee is still too busy as expected
+ }
+
+ assertEquals(0, seconds(start));
+ }
+
+ { // Timeout in 5 seconds
+ final long start = System.nanoTime();
+
+ try {
+ busyBee.doItSoon();
+
+ fail("The bee should be busy");
+ } catch (Exception e) {
+ // the bee is still too busy as expected
+ }
+
+ assertEquals(5, seconds(start));
+ }
+
+ // This will wait forever, give it a try if you have that long
+ //busyBee.justDoIt();
+ }
+
+ private long seconds(long start) {
+ return TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
+ }
+ }
+
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.accesstimeout.BusyBeeTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/access-timeout
+ INFO - openejb.base = /Users/dblevins/examples/access-timeout
+ 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/access-timeout/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/access-timeout/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/access-timeout
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean BusyBee: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.accesstimeout.BusyBeeTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/access-timeout" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/access-timeout
+ INFO - Jndi(name="java:global/access-timeout/BusyBee!org.superbiz.accesstimeout.BusyBee")
+ INFO - Jndi(name="java:global/access-timeout/BusyBee")
+ INFO - Jndi(name="java:global/EjbModule748454644/org.superbiz.accesstimeout.BusyBeeTest!org.superbiz.accesstimeout.BusyBeeTest")
+ INFO - Jndi(name="java:global/EjbModule748454644/org.superbiz.accesstimeout.BusyBeeTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.accesstimeout.BusyBeeTest, ejb-name=org.superbiz.accesstimeout.BusyBeeTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=BusyBee, ejb-name=BusyBee, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.accesstimeout.BusyBeeTest, ejb-name=org.superbiz.accesstimeout.BusyBeeTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=BusyBee, ejb-name=BusyBee, container=Default Singleton Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/access-timeout)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.071 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/access-timeout/build.xml b/content/examples/access-timeout/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/access-timeout/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/access-timeout/pom.xml b/content/examples/access-timeout/pom.xml
new file mode 100755
index 0000000..9acab47
--- /dev/null
+++ b/content/examples/access-timeout/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>access-timeout</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @AccessTimeout</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/access-timeout/src/main/java/org/superbiz/accesstimeout/BusyBee.java b/content/examples/access-timeout/src/main/java/org/superbiz/accesstimeout/BusyBee.java
new file mode 100755
index 0000000..4fb14d9
--- /dev/null
+++ b/content/examples/access-timeout/src/main/java/org/superbiz/accesstimeout/BusyBee.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.accesstimeout;
+
+import javax.ejb.AccessTimeout;
+import javax.ejb.Asynchronous;
+import javax.ejb.Lock;
+import javax.ejb.Singleton;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import static javax.ejb.LockType.WRITE;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@Singleton
+@Lock(WRITE)
+public class BusyBee {
+
+ @Asynchronous
+ public Future stayBusy(CountDownLatch ready) {
+ ready.countDown();
+
+ try {
+ new CountDownLatch(1).await();
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ }
+
+ return null;
+ }
+
+ @AccessTimeout(0)
+ public void doItNow() {
+ // do something
+ }
+
+ @AccessTimeout(value = 5, unit = TimeUnit.SECONDS)
+ public void doItSoon() {
+ // do something
+ }
+
+ @AccessTimeout(-1)
+ public void justDoIt() {
+ // do something
+ }
+
+}
diff --git a/content/examples/access-timeout/src/test/java/org/superbiz/accesstimeout/BusyBeeTest.java b/content/examples/access-timeout/src/test/java/org/superbiz/accesstimeout/BusyBeeTest.java
new file mode 100755
index 0000000..4c88b11
--- /dev/null
+++ b/content/examples/access-timeout/src/test/java/org/superbiz/accesstimeout/BusyBeeTest.java
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.accesstimeout;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class BusyBeeTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final CountDownLatch ready = new CountDownLatch(1);
+
+ final BusyBee busyBee = (BusyBee) context.lookup("java:global/access-timeout/BusyBee");
+
+ // This asynchronous method will never exit
+ busyBee.stayBusy(ready);
+
+ // Are you working yet little bee?
+ ready.await();
+
+ // OK, Bee is busy
+
+ { // Timeout Immediately
+ final long start = System.nanoTime();
+
+ try {
+ busyBee.doItNow();
+
+ fail("The bee should be busy");
+ } catch (Exception e) {
+ // the bee is still too busy as expected
+ }
+
+ assertEquals(0, seconds(start));
+ }
+
+ { // Timeout in 5 seconds
+ final long start = System.nanoTime();
+
+ try {
+ busyBee.doItSoon();
+
+ fail("The bee should be busy");
+ } catch (Exception e) {
+ // the bee is still too busy as expected
+ }
+
+ assertEquals(5, seconds(start));
+ }
+
+ // This will wait forever, give it a try if you have that long
+ //busyBee.justDoIt();
+ }
+
+ private long seconds(long start) {
+ return TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
+ }
+}
diff --git a/content/examples/alternate-descriptors.html b/content/examples/alternate-descriptors.html
new file mode 100644
index 0000000..bf9eb6a
--- /dev/null
+++ b/content/examples/alternate-descriptors.html
@@ -0,0 +1,440 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/alternate-descriptors.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Alternate Descriptors</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example alternate-descriptors can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/alternate-descriptors" class="bare">https://github.com/apache/tomee/tree/master/examples/alternate-descriptors</a></p>
+</div>
+<div class="paragraph">
+<p>See the <a href="../../alternate-descriptors.html">Alternate Descriptors</a> page for the full details of how this feature works.</p>
+</div>
+<div class="paragraph">
+<p>For our example we’ll use the standard "moviefun" code which contains a <code>Movie</code> entity and <code>Movies</code> session bean. To add a twist
+for testing and demonstrate alternate descriptors, we will create an interceptor that will be used only in our test cases.</p>
+</div>
+<div class="paragraph">
+<p>To add this to our application, we simply need a <code>test.ejb-jar.xml</code> in the same location that the regular <code>ejb-jar.xml</code> would be expected.</p>
+</div>
+<div class="paragraph">
+<p>That gives us the following files in our project:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>src/main/resources/META-INF/ejb-jar.xml</p>
+</li>
+<li>
+<p>src/main/resources/META-INF/persistence.xml</p>
+</li>
+<li>
+<p>src/main/resources/META-INF/test.ejb-jar.xml</p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_test_ejb_jar_xml">The test.ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The normal <code>ejb-jar.xml</code> simply contains <code><ejb-jar/></code>, however the <code>test.ejb-jar.xml</code> we add an extra interceptor:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee">
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>Movies</ejb-name>
+ <interceptor-class>org.superbiz.altdd.MoviesTest$Interceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_testcase">The TestCase</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>To enable our <code>test.ejb-jar.xml</code> in the test case, we simply set the <code>openejb.altdd.prefix</code> property when creating the embedded <code>EJBContainer</code></p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public class MoviesTest extends TestCase {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@EJB
+private Movies movies;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Resource
+private UserTransaction userTransaction;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@PersistenceContext
+private EntityManager entityManager;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>p.put("openejb.altdd.prefix", "test");</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public void test() throws Exception {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>userTransaction.begin();</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>List<Movie> list = movies.getMovies();
+assertEquals("List.size()", 3, list.size());</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>for (Movie movie : list) {
+ movies.deleteMovie(movie);
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>assertEquals("Movies.getMovies()", 0, movies.getMovies().size());</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> } finally {
+ try {
+ userTransaction.commit();
+ fail("Transaction should have been rolled back");
+ } catch (RollbackException e) {
+ // Good, we don't want to clean up the db
+ }
+ }
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public static class Interceptor {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Resource
+private SessionContext sessionContext;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@AroundInvoke
+public Object invoke(InvocationContext context) throws Exception {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>sessionContext.setRollbackOnly();</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> return context.proceed();
+ }
+ }
+}</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>As noted in <a href="../../alternate-descriptors.html">the documentation</a>, several prefixes can be used at once.</p>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.altdd.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/alternate-descriptors
+INFO - openejb.base = /Users/dblevins/examples/alternate-descriptors
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/alternate-descriptors/target/classes
+INFO - Beginning load: /Users/dblevins/examples/alternate-descriptors/target/classes
+INFO - AltDD ejb-jar.xml -> file:/Users/dblevins/examples/alternate-descriptors/target/classes/META-INF/test.ejb-jar.xml
+INFO - Configuring enterprise application: /Users/dblevins/examples/alternate-descriptors
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.altdd.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/alternate-descriptors" loaded.
+INFO - Assembling app: /Users/dblevins/examples/alternate-descriptors
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 411ms
+INFO - Jndi(name="java:global/alternate-descriptors/Movies!org.superbiz.altdd.Movies")
+INFO - Jndi(name="java:global/alternate-descriptors/Movies")
+INFO - Jndi(name="java:global/EjbModule1893321675/org.superbiz.altdd.MoviesTest!org.superbiz.altdd.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1893321675/org.superbiz.altdd.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.altdd.MoviesTest, ejb-name=org.superbiz.altdd.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.altdd.MoviesTest, ejb-name=org.superbiz.altdd.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/alternate-descriptors)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.569 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+<h1 id="_warning_on_tooling" class="sect0">Warning on Tooling</h1>
+<div class="paragraph">
+<p>If you split your descriptors into separate directories, this support will not work. Specifically, this will not work:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>src/main/resources/META-INF/ejb-jar.xml</p>
+</li>
+<li>
+<p>src/main/resources/META-INF/persistence.xml</p>
+</li>
+<li>
+<p>src/<strong>test</strong>/resources/META-INF/test.ejb-jar.xml</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>This support is <strong>not</strong> aware of any Maven, Gradle, Ant, IntelliJ, NetBeans, Eclipse or other settings.</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/alternate-descriptors.pdf b/content/examples/alternate-descriptors.pdf
new file mode 100644
index 0000000..787c32b
--- /dev/null
+++ b/content/examples/alternate-descriptors.pdf
Binary files differ
diff --git a/content/examples/alternate-descriptors/README.md b/content/examples/alternate-descriptors/README.md
new file mode 100755
index 0000000..d8c9b59
--- /dev/null
+++ b/content/examples/alternate-descriptors/README.md
@@ -0,0 +1,160 @@
+Title: Alternate Descriptors
+
+See the [Alternate Descriptors](../../alternate-descriptors.html) page for the full details of how this feature works.
+
+For our example we'll use the standard "moviefun" code which contains a `Movie` entity and `Movies` session bean. To add a twist
+for testing and demonstrate alternate descriptors, we will create an interceptor that will be used only in our test cases.
+
+To add this to our application, we simply need a `test.ejb-jar.xml` in the same location that the regular `ejb-jar.xml` would be expected.
+
+That gives us the following files in our project:
+
+ - src/main/resources/META-INF/ejb-jar.xml
+ - src/main/resources/META-INF/persistence.xml
+ - src/main/resources/META-INF/test.ejb-jar.xml
+
+## The test.ejb-jar.xml
+
+The normal `ejb-jar.xml` simply contains `<ejb-jar/>`, however the `test.ejb-jar.xml` we add an extra interceptor:
+
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee">
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>Movies</ejb-name>
+ <interceptor-class>org.superbiz.altdd.MoviesTest$Interceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
+ </ejb-jar>
+
+## The TestCase
+
+To enable our `test.ejb-jar.xml` in the test case, we simply set the `openejb.altdd.prefix` property when creating the embedded `EJBContainer`
+
+ public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ p.put("openejb.altdd.prefix", "test");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+
+ } finally {
+ try {
+ userTransaction.commit();
+ fail("Transaction should have been rolled back");
+ } catch (RollbackException e) {
+ // Good, we don't want to clean up the db
+ }
+ }
+ }
+
+ public static class Interceptor {
+
+ @Resource
+ private SessionContext sessionContext;
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+
+ sessionContext.setRollbackOnly();
+
+ return context.proceed();
+ }
+ }
+ }
+
+As noted in [the documentation](../../alternate-descriptors.html), several prefixes can be used at once.
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.altdd.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/alternate-descriptors
+ INFO - openejb.base = /Users/dblevins/examples/alternate-descriptors
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/alternate-descriptors/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/alternate-descriptors/target/classes
+ INFO - AltDD ejb-jar.xml -> file:/Users/dblevins/examples/alternate-descriptors/target/classes/META-INF/test.ejb-jar.xml
+ INFO - Configuring enterprise application: /Users/dblevins/examples/alternate-descriptors
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.altdd.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/alternate-descriptors" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/alternate-descriptors
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 411ms
+ INFO - Jndi(name="java:global/alternate-descriptors/Movies!org.superbiz.altdd.Movies")
+ INFO - Jndi(name="java:global/alternate-descriptors/Movies")
+ INFO - Jndi(name="java:global/EjbModule1893321675/org.superbiz.altdd.MoviesTest!org.superbiz.altdd.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1893321675/org.superbiz.altdd.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.altdd.MoviesTest, ejb-name=org.superbiz.altdd.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.altdd.MoviesTest, ejb-name=org.superbiz.altdd.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/alternate-descriptors)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.569 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+# Warning on Tooling
+
+If you split your descriptors into separate directories, this support will not work. Specifically, this will not work:
+
+ - src/main/resources/META-INF/ejb-jar.xml
+ - src/main/resources/META-INF/persistence.xml
+ - src/**test**/resources/META-INF/test.ejb-jar.xml
+
+This support is **not** aware of any Maven, Gradle, Ant, IntelliJ, NetBeans, Eclipse or other settings.
+
+
+
+
+
diff --git a/content/examples/alternate-descriptors/build.xml b/content/examples/alternate-descriptors/build.xml
new file mode 100755
index 0000000..821f630
--- /dev/null
+++ b/content/examples/alternate-descriptors/build.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ <dependency groupId="org.apache.openejb" artifactId="openejb-api" version="4.0.0-beta-1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/alternate-descriptors/pom.xml b/content/examples/alternate-descriptors/pom.xml
new file mode 100755
index 0000000..c783fdd
--- /dev/null
+++ b/content/examples/alternate-descriptors/pom.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>alternate-descriptors</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Alternate Descriptors</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.3.0</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-pool</artifactId>
+ <groupId>commons-pool</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>openjpa</artifactId>
+ <groupId>org.apache.openjpa</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/alternate-descriptors/src/main/java/org/superbiz/altdd/Movie.java b/content/examples/alternate-descriptors/src/main/java/org/superbiz/altdd/Movie.java
new file mode 100755
index 0000000..2da2b47
--- /dev/null
+++ b/content/examples/alternate-descriptors/src/main/java/org/superbiz/altdd/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.altdd;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/alternate-descriptors/src/main/java/org/superbiz/altdd/Movies.java b/content/examples/alternate-descriptors/src/main/java/org/superbiz/altdd/Movies.java
new file mode 100755
index 0000000..0a864c7
--- /dev/null
+++ b/content/examples/alternate-descriptors/src/main/java/org/superbiz/altdd/Movies.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.altdd;
+
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+import static javax.ejb.TransactionAttributeType.MANDATORY;
+
+//START SNIPPET: code
+@Stateful
+@TransactionAttribute(MANDATORY)
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/alternate-descriptors/src/main/resources/META-INF/ejb-jar.xml b/content/examples/alternate-descriptors/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..91be4f8
--- /dev/null
+++ b/content/examples/alternate-descriptors/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
diff --git a/content/examples/alternate-descriptors/src/main/resources/META-INF/persistence.xml b/content/examples/alternate-descriptors/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..f094f7b
--- /dev/null
+++ b/content/examples/alternate-descriptors/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.altdd.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/alternate-descriptors/src/main/resources/META-INF/test.ejb-jar.xml b/content/examples/alternate-descriptors/src/main/resources/META-INF/test.ejb-jar.xml
new file mode 100755
index 0000000..9f40ae3
--- /dev/null
+++ b/content/examples/alternate-descriptors/src/main/resources/META-INF/test.ejb-jar.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee">
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>Movies</ejb-name>
+ <interceptor-class>org.superbiz.altdd.MoviesTest$Interceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar>
diff --git a/content/examples/alternate-descriptors/src/test/java/org/superbiz/altdd/MoviesTest.java b/content/examples/alternate-descriptors/src/test/java/org/superbiz/altdd/MoviesTest.java
new file mode 100755
index 0000000..edfc9fa
--- /dev/null
+++ b/content/examples/alternate-descriptors/src/test/java/org/superbiz/altdd/MoviesTest.java
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.altdd;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.SessionContext;
+import javax.ejb.embeddable.EJBContainer;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.RollbackException;
+import javax.transaction.UserTransaction;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ p.put("openejb.altdd.prefix", "test");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+
+ } finally {
+ try {
+ userTransaction.commit();
+ fail("Transaction should have been rolled back");
+ } catch (RollbackException e) {
+ // Good, we don't want to clean up the db
+ }
+ }
+ }
+
+ public static class Interceptor {
+
+ @Resource
+ private SessionContext sessionContext;
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+
+ sessionContext.setRollbackOnly();
+
+ return context.proceed();
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/applet.html b/content/examples/applet.html
new file mode 100644
index 0000000..0ee9484
--- /dev/null
+++ b/content/examples/applet.html
@@ -0,0 +1,386 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/applet.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Applet</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example applet can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/applet" class="bare">https://github.com/apache/tomee/tree/master/examples/applet</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculator">Calculator</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.applet;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface Calculator {
+ public double add(double x, double y);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorapplet">CalculatorApplet</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.applet;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+import javax.swing.JApplet;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Properties;
+
+public class CalculatorApplet extends JApplet {
+ JTextArea area;
+
+ JTextField field1;
+ JTextField field2;
+ JLabel label1;
+ JLabel label2;
+ JButton button;
+ JLabel label3;
+ Context ctx;
+
+ public void init() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ createUI();
+ }
+ });
+ } catch (Exception e) {
+ System.err.println("createGUI didn't successfully complete");
+ }
+ }
+
+ private void createUI() {
+ field1 = new JTextField();
+ field2 = new JTextField();
+ label1 = new JLabel("Enter first number");
+ label2 = new JLabel("Enter second number");
+ label3 = new JLabel("RESULT=");
+ button = new JButton("Add");
+
+ setLayout(new GridLayout(3, 2));
+ add(label1);
+ add(field1);
+ add(label2);
+ add(field2);
+ add(button);
+ add(label3);
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.client.RemoteInitialContextFactory");
+ props.put(Context.PROVIDER_URL, "http://127.0.0.1:8080/applet/ejb");
+ try {
+ ctx = new InitialContext(props);
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ button.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+
+ try {
+ final Object ref = ctx.lookup("CalculatorImplRemote");
+ Calculator calc = (Calculator) PortableRemoteObject.narrow(
+ ref, Calculator.class);
+ String text1 = field1.getText();
+ String text2 = field2.getText();
+ int num1 = Integer.parseInt(text1);
+ int num2 = Integer.parseInt(text2);
+ double result = calc.add(num1, num2);
+ label3.setText("RESULT=" + result);
+ } catch (NamingException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorimpl">CalculatorImpl</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.applet;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class CalculatorImpl implements Calculator {
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_web_xml">web.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><web-app>
+ <servlet>
+ <servlet-name>ServerServlet</servlet-name>
+ <servlet-class>org.apache.openejb.server.httpd.ServerServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ServerServlet</servlet-name>
+ <url-pattern>/ejb/*</url-pattern>
+ </servlet-mapping>
+</web-app></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_jndilookuptest">JNDILookupTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.superbiz.applet.Calculator;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+import java.util.Properties;
+
+
+public class JNDILookupTest {
+
+ @Test
+ public void test() {
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ props.put(Context.PROVIDER_URL, "http://127.0.0.1:8080/tomee/ejb");
+ try {
+ Context ctx = new InitialContext(props);
+ System.out.println("Found context " + ctx);
+ final Object ref = ctx.lookup("CalculatorImplRemote");
+ Calculator calc = (Calculator) PortableRemoteObject.narrow(ref, Calculator.class);
+ double result = calc.add(10, 30);
+ Assert.assertEquals(40, result, 0.5);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/applet.pdf b/content/examples/applet.pdf
new file mode 100644
index 0000000..3ba0188
--- /dev/null
+++ b/content/examples/applet.pdf
Binary files differ
diff --git a/content/examples/applet/README.md b/content/examples/applet/README.md
new file mode 100755
index 0000000..bda0a08
--- /dev/null
+++ b/content/examples/applet/README.md
@@ -0,0 +1,164 @@
+Title: Applet
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Calculator
+
+ package org.superbiz.applet;
+
+ import javax.ejb.Remote;
+
+ @Remote
+ public interface Calculator {
+ public double add(double x, double y);
+ }
+
+## CalculatorApplet
+
+ package org.superbiz.applet;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.naming.NamingException;
+ import javax.rmi.PortableRemoteObject;
+ import javax.swing.JApplet;
+ import javax.swing.JButton;
+ import javax.swing.JLabel;
+ import javax.swing.JTextArea;
+ import javax.swing.JTextField;
+ import javax.swing.SwingUtilities;
+ import java.awt.GridLayout;
+ import java.awt.event.ActionEvent;
+ import java.awt.event.ActionListener;
+ import java.util.Properties;
+
+ public class CalculatorApplet extends JApplet {
+ JTextArea area;
+
+ JTextField field1;
+ JTextField field2;
+ JLabel label1;
+ JLabel label2;
+ JButton button;
+ JLabel label3;
+ Context ctx;
+
+ public void init() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ createUI();
+ }
+ });
+ } catch (Exception e) {
+ System.err.println("createGUI didn't successfully complete");
+ }
+ }
+
+ private void createUI() {
+ field1 = new JTextField();
+ field2 = new JTextField();
+ label1 = new JLabel("Enter first number");
+ label2 = new JLabel("Enter second number");
+ label3 = new JLabel("RESULT=");
+ button = new JButton("Add");
+
+ setLayout(new GridLayout(3, 2));
+ add(label1);
+ add(field1);
+ add(label2);
+ add(field2);
+ add(button);
+ add(label3);
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.client.RemoteInitialContextFactory");
+ props.put(Context.PROVIDER_URL, "http://127.0.0.1:8080/applet/ejb");
+ try {
+ ctx = new InitialContext(props);
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ button.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+
+ try {
+ final Object ref = ctx.lookup("CalculatorImplRemote");
+ Calculator calc = (Calculator) PortableRemoteObject.narrow(
+ ref, Calculator.class);
+ String text1 = field1.getText();
+ String text2 = field2.getText();
+ int num1 = Integer.parseInt(text1);
+ int num2 = Integer.parseInt(text2);
+ double result = calc.add(num1, num2);
+ label3.setText("RESULT=" + result);
+ } catch (NamingException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ });
+ }
+ }
+
+## CalculatorImpl
+
+ package org.superbiz.applet;
+
+ import javax.ejb.Stateless;
+
+ @Stateless
+ public class CalculatorImpl implements Calculator {
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+ }
+
+## web.xml
+
+ <web-app>
+ <servlet>
+ <servlet-name>ServerServlet</servlet-name>
+ <servlet-class>org.apache.openejb.server.httpd.ServerServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ServerServlet</servlet-name>
+ <url-pattern>/ejb/*</url-pattern>
+ </servlet-mapping>
+ </web-app>
+
+
+## JNDILookupTest
+
+ package org.superbiz;
+
+ import org.junit.Assert;
+ import org.junit.Test;
+ import org.superbiz.applet.Calculator;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.rmi.PortableRemoteObject;
+ import java.util.Properties;
+
+
+ public class JNDILookupTest {
+
+ @Test
+ public void test() {
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ props.put(Context.PROVIDER_URL, "http://127.0.0.1:8080/tomee/ejb");
+ try {
+ Context ctx = new InitialContext(props);
+ System.out.println("Found context " + ctx);
+ final Object ref = ctx.lookup("CalculatorImplRemote");
+ Calculator calc = (Calculator) PortableRemoteObject.narrow(ref, Calculator.class);
+ double result = calc.add(10, 30);
+ Assert.assertEquals(40, result, 0.5);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
diff --git a/content/examples/applet/README.txt b/content/examples/applet/README.txt
new file mode 100755
index 0000000..127589d
--- /dev/null
+++ b/content/examples/applet/README.txt
@@ -0,0 +1,133 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+============
+OVERVIEW
+============
+This example creates an applet which requires the user to enter two numbers.
+It then uses the Calculator EJB to add the numbers and displays the result.
+
+Before you run the example, there are a few things worth noting.
+One has to keep in mind that applets run in a very restrictive environment. A couple of
+them are
+1. Applets can only establish a connection to the host they came from
+2. A signed applet gets around most of the restrictions (e.g. calls to System.getProperty() etc)
+3. Any resources/classes needed by the applet should be available in the same directory where
+the applet originated from, or its sub-directory/ies
+
+Since our applet will establish a connection back to the EJB, so we need to make sure
+we are not trying to establish a connection to some other webapp. We will see in a minute
+what that means.
+We shall also sign our applet using jarsigner, however would would first need to create
+a certificate. We will get to this part also in a minute.
+
+Since our applet would be running in a remote JVM, it would use the RemoteInitialContextFactory
+instead of the LocalInitialContextFactory. The RemoteInitialContextFactory is available
+in openejb-client.jar. The applet would also need the java-ee-api.jar in its class-path.
+
+Lets see how we can use maven + ant to get around the above restrictions of applets:-
+
+The pom.xml of this project
+- adds the client and the ee jars as dependencies.
+- uses the ant jar task (in the maven-antrun-plugin) to jar up all classes in WEB-INF/classes and puts them under the root
+directory of the web app (this is required, since web app clients cannot access anything under
+WEB-INF directory, hence we copied those classes to web-apps root directory)
+[Note:- The ant script puts all classes under WEB-INF/classes inside a jar. All classes
+are not required by the applet. Instead, the applet only needs the EJB interface and Applet
+classes in the jar]
+- uses maven-dependency-plugin to copy javaee-api-embedded and openejb-client jars to src/main/webapp (this is the webapp root directory)
+- uses the signjar ant task to sign all the jar files
+
+The APPLET is located inside index.jsp . Notice how the archive attribute of the applet
+is used to add the applet , java ee and openejb client jars to the applets classpath
+
+Since the APPLET can only communicate from the host it originates, notice how the web context
+root is used in the provider url to obtain the InitialContext.
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.client.RemoteInitialContextFactory");
+ props.put(Context.PROVIDER_URL,"http://127.0.0.1:8080/applet/ejb");
+
+The example web-app has a context root named applet. If you were making another webapp with a
+different context root, then you would use that in the provider url instead.
+If you open the web.xml of this project, you will find a <servlet-mapping> section which
+actually maps the /ejb/* to a servlet named ServerServlet. This is another thing which you need
+too keep in mind in your web-app. Yes, the provider url actually points to a servlet named
+ServerServlet. This servlet is provided by openejb and is automatically added to you webapps
+classpath.
+[Note:- All other clients (except applets) will use a provider url of http://127.0.0.1:8080/tomee/ejb,
+since an applet cannot connect to another web-app, hence the above little trick to work around this
+limitation. If you do not make the change, you will get a HTTP 403 error i.e. server denied
+access to the ServerServlet . A unit test named JNDILookupTest has been added to the example to
+show how a non-applet remote client would obtain the Context]
+
+HOW TO RUN THE EXAMPLE
+======================
+--USE KEYTOOL --
+You would need to do a bit of work (if you have not done that already) in creating a self-signed
+certificate (in case you do not have one from one of the certificate authorities).
+Here is the steps performed to create the certificate (notice the store password is openejb -
+this password is also used in pom.xml while signing the jar -- if your store passwd is different
+please update the pom.xml with the correct password before proceeding forward)
+Use the keytool as shown below (answer all questions asked by keytool -- the answers do not
+have to match as shown below (except for store password and alias <mykey> -- since it is used by maven))
+
+karan@jee:~$ keytool -genkey
+Enter keystore password: openejb
+What is your first and last name?
+ [Unknown]: karan malhi
+What is the name of your organizational unit?
+ [Unknown]: Superbiz
+What is the name of your organization?
+ [Unknown]: Superbiz
+What is the name of your City or Locality?
+ [Unknown]: Deptford
+What is the name of your State or Province?
+ [Unknown]: NJ
+What is the two-letter country code for this unit?
+ [Unknown]: US
+Is CN=karan malhi, OU=Superbiz, O=Superbiz, L=Deptford, ST=NJ, C=US correct?
+ [no]: yes
+
+Enter key password for <mykey>
+ (RETURN if same as keystore password):
+karan@jee:~$
+
+-- INSTALL AND CONFIGURE TOMCAT --
+
+1. Install latest Tomcat
+2. Deploy OpenEJB WAR in tomcat
+3. Open <<tomcat-install>>/conf/tomcat-users.xml and add the following user
+ <user username="admin" password="" roles="manager"/>
+
+-- DEPLOY AND TEST THE EXAMPLE --
+1. Run the following command while in the applet directory
+ mvn clean install war:exploded tomcat:deploy -Dmaven.test.skip=true
+ [It is required to skip the test since the application is not yet deployed on tomcat. If you run
+the test now, it will fail]
+2. The above will deploy this web application to tomcat.
+3. To test the application, open a web browser and navigate to
+ http://localhost:8080/applet
+4. You will be prompted to accept digital signature. Accept it to run the applet
+5. Enter two numbers and click the add button, the result should be displayed next
+to the button
+
+[Note:- If you make changes and want to redeploy the app use the following command:
+ mvn clean install war:exploded tomcat:redeploy]
+
+
+
diff --git a/content/examples/applet/pom.xml b/content/examples/applet/pom.xml
new file mode 100755
index 0000000..41cc75d
--- /dev/null
+++ b/content/examples/applet/pom.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz.applet</groupId>
+ <artifactId>applet</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: Signed Applet EJB Client</name>
+ <url>http://openejb.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-client</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>applet</finalName>
+ <pluginManagement>
+ <plugins>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tomcat.maven</groupId>
+ <artifactId>tomcat7-maven-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <url>http://localhost:8080/manager/html</url>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.5</version>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <jar destfile="${project.build.directory}/${project.build.finalName}/app.jar" basedir="target/classes"/>
+ <signjar jar="${project.build.directory}/${project.build.finalName}/app.jar" alias="mykey"
+ storepass="openejb"/>
+ <signjar jar="${project.build.directory}/${project.build.finalName}/openejb-client.jar" alias="mykey"
+ storepass="openejb"/>
+ <signjar jar="${project.build.directory}/${project.build.finalName}/javaee-api.jar" alias="mykey"
+ storepass="openejb"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-client</artifactId>
+ <version>4.7.1</version>
+ <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
+ <destFileName>openejb-client.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
+ <destFileName>javaee-api.jar</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/applet/src/main/java/org/superbiz/applet/Calculator.java b/content/examples/applet/src/main/java/org/superbiz/applet/Calculator.java
new file mode 100755
index 0000000..73cd714
--- /dev/null
+++ b/content/examples/applet/src/main/java/org/superbiz/applet/Calculator.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.applet;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface Calculator {
+
+ public double add(double x, double y);
+}
diff --git a/content/examples/applet/src/main/java/org/superbiz/applet/CalculatorApplet.java b/content/examples/applet/src/main/java/org/superbiz/applet/CalculatorApplet.java
new file mode 100755
index 0000000..49115bd
--- /dev/null
+++ b/content/examples/applet/src/main/java/org/superbiz/applet/CalculatorApplet.java
@@ -0,0 +1,101 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.applet;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Properties;
+
+public class CalculatorApplet extends JApplet {
+
+ JTextArea area;
+
+ JTextField field1;
+ JTextField field2;
+ JLabel label1;
+ JLabel label2;
+ JButton button;
+ JLabel label3;
+ Context ctx;
+
+ public void init() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ createUI();
+ }
+ });
+ } catch (Exception e) {
+ System.err.println("createGUI didn't successfully complete");
+ }
+
+ }
+
+ private void createUI() {
+ field1 = new JTextField();
+ field2 = new JTextField();
+ label1 = new JLabel("Enter first number");
+ label2 = new JLabel("Enter second number");
+ label3 = new JLabel("RESULT=");
+ button = new JButton("Add");
+
+ setLayout(new GridLayout(3, 2));
+ add(label1);
+ add(field1);
+ add(label2);
+ add(field2);
+ add(button);
+ add(label3);
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.client.RemoteInitialContextFactory");
+ props.put(Context.PROVIDER_URL, "http://127.0.0.1:8080/applet/ejb");
+ try {
+ ctx = new InitialContext(props);
+ } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ button.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+
+ try {
+ final Object ref = ctx.lookup("CalculatorImplRemote");
+ Calculator calc = (Calculator) PortableRemoteObject.narrow(
+ ref, Calculator.class);
+ String text1 = field1.getText();
+ String text2 = field2.getText();
+ int num1 = Integer.parseInt(text1);
+ int num2 = Integer.parseInt(text2);
+ double result = calc.add(num1, num2);
+ label3.setText("RESULT=" + result);
+ } catch (NamingException ex) {
+ throw new RuntimeException(ex);
+ }
+
+ }
+ });
+
+ }
+}
diff --git a/content/examples/applet/src/main/java/org/superbiz/applet/CalculatorImpl.java b/content/examples/applet/src/main/java/org/superbiz/applet/CalculatorImpl.java
new file mode 100755
index 0000000..c80f8bb
--- /dev/null
+++ b/content/examples/applet/src/main/java/org/superbiz/applet/CalculatorImpl.java
@@ -0,0 +1,29 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.applet;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class CalculatorImpl implements Calculator {
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+
+}
diff --git a/content/examples/applet/src/main/webapp/WEB-INF/web.xml b/content/examples/applet/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..a26320c
--- /dev/null
+++ b/content/examples/applet/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+ <servlet>
+ <servlet-name>ServerServlet</servlet-name>
+ <servlet-class>org.apache.openejb.server.httpd.ServerServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ServerServlet</servlet-name>
+ <url-pattern>/ejb/*</url-pattern>
+ </servlet-mapping>
+</web-app>
diff --git a/content/examples/applet/src/main/webapp/index.jsp b/content/examples/applet/src/main/webapp/index.jsp
new file mode 100755
index 0000000..95aecdd
--- /dev/null
+++ b/content/examples/applet/src/main/webapp/index.jsp
@@ -0,0 +1,26 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<html>
+<body>
+<applet alt="could not load applet" height="100" width="300"
+ codebase="."
+ archive="app.jar,javaee-api-embedded.jar,openejb-client.jar"
+ code="org.superbiz.applet.CalculatorApplet">
+</applet>
+</body>
+</html>
diff --git a/content/examples/applet/src/test/java/org/superbiz/JNDILookupTest.java b/content/examples/applet/src/test/java/org/superbiz/JNDILookupTest.java
new file mode 100755
index 0000000..6205173
--- /dev/null
+++ b/content/examples/applet/src/test/java/org/superbiz/JNDILookupTest.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.superbiz.applet.Calculator;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+import java.util.Properties;
+
+public class JNDILookupTest {
+
+ @Test
+ public void test() {
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ props.put(Context.PROVIDER_URL, "http://127.0.0.1:8080/tomee/ejb");
+ try {
+ Context ctx = new InitialContext(props);
+ System.out.println("Found context " + ctx);
+ final Object ref = ctx.lookup("CalculatorImplRemote");
+ Calculator calc = (Calculator) PortableRemoteObject.narrow(ref, Calculator.class);
+ double result = calc.add(10, 30);
+ Assert.assertEquals(40, result, 0.5);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/content/examples/application-composer.html b/content/examples/application-composer.html
new file mode 100644
index 0000000..46314b4
--- /dev/null
+++ b/content/examples/application-composer.html
@@ -0,0 +1,360 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/application-composer.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Application Composer</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example application-composer can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/application-composer" class="bare">https://github.com/apache/tomee/tree/master/examples/application-composer</a></p>
+</div>
+<div class="paragraph">
+<p>The <code>org.apache.openejb.junit.ApplicationComposer</code> is JUnit test runner modeled after the way we’ve done testing internally in OpenEJB for years (since about 2006).
+It involves no classpath scanning at all. If you want something to be in the app, you must build it directly in your testcase.</p>
+</div>
+<div class="paragraph">
+<p>With the <code>ApplicationComposer</code> you can do identical testing that OpenEJB uses internally, but with limited dependency on OpenEJB itself. The main dependency is on the code
+that is used to build the actual applications:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-jee</artifactId>
+ <version>4.0.0-beta-1</version>
+</dependency></code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_composing_an_application" class="sect0">Composing an Application</h1>
+<div class="paragraph">
+<p>The main difference to the embedded <code>EJBContainer</code> API is building the application in the test code. This is done with one or more methods in the test case annotated
+with <code>org.apache.openejb.junit.Module</code> using the following format:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Module
+public <return-value> <module-name>() {
+
+Where **module-name** is the name you wish to use for that module and **return-value** can be any one of the following:
+
+ - java.lang.Class
+ - java.lang.Class[]
+ - org.apache.openejb.jee.EjbJar
+ - org.apache.openejb.jee.EnterpriseBean
+ - org.apache.openejb.jee.Application
+ - org.apache.openejb.jee.Connector
+ - org.apache.openejb.jee.Beans
+ - org.apache.openejb.jee.jpa.unit.Persistence
+ - org.apache.openejb.jee.jpa.unit.PersistenceUnit
+
+# Example
+
+Used in an actual testcase, that might look like so:
+
+import junit.framework.TestCase;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.StatefulBean;
+import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Configuration;
+import org.apache.openejb.junit.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.UserTransaction;
+import java.util.List;
+import java.util.Properties;
+
+@RunWith(ApplicationComposer.class)
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Module
+ public PersistenceUnit persistence() {
+ PersistenceUnit unit = new PersistenceUnit("movie-unit");
+ unit.setJtaDataSource("movieDatabase");
+ unit.setNonJtaDataSource("movieDatabaseUnmanaged");
+ unit.getClazz().add(Movie.class.getName());
+ unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+ return unit;
+ }
+
+ @Module
+ public EjbJar beans() {
+ EjbJar ejbJar = new EjbJar("movie-beans");
+ ejbJar.addEnterpriseBean(new StatefulBean(MoviesImpl.class));
+ return ejbJar;
+ }
+
+ @Configuration
+ public Properties config() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ return p;
+ }
+
+ @Test
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+
+ } finally {
+ userTransaction.commit();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.composed.MoviesTest
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Configuring enterprise application: /Users/dblevins/examples/application-composer/MoviesTest
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.composed.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean MoviesImpl: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/application-composer/MoviesTest" loaded.
+INFO - Assembling app: /Users/dblevins/examples/application-composer/MoviesTest
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 449ms
+INFO - Jndi(name=org.superbiz.composed.MoviesTestLocalBean) --> Ejb(deployment-id=org.superbiz.composed.MoviesTest)
+INFO - Jndi(name=global/MoviesTest/EjbModule2027711095/MoviesTest!org.superbiz.composed.MoviesTest) --> Ejb(deployment-id=org.superbiz.composed.MoviesTest)
+INFO - Jndi(name=global/MoviesTest/EjbModule2027711095/MoviesTest) --> Ejb(deployment-id=org.superbiz.composed.MoviesTest)
+INFO - Jndi(name=MoviesImplLocal) --> Ejb(deployment-id=MoviesImpl)
+INFO - Jndi(name=global/MoviesTest/movie-beans/MoviesImpl!org.superbiz.composed.Movies) --> Ejb(deployment-id=MoviesImpl)
+INFO - Jndi(name=global/MoviesTest/movie-beans/MoviesImpl) --> Ejb(deployment-id=MoviesImpl)
+INFO - Created Ejb(deployment-id=org.superbiz.composed.MoviesTest, ejb-name=MoviesTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=MoviesImpl, ejb-name=MoviesImpl, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.composed.MoviesTest, ejb-name=MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=MoviesImpl, ejb-name=MoviesImpl, container=Default Stateful Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/application-composer/MoviesTest)
+INFO - Undeploying app: /Users/dblevins/examples/application-composer/MoviesTest
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.221 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/application-composer.pdf b/content/examples/application-composer.pdf
new file mode 100644
index 0000000..e13a8eb
--- /dev/null
+++ b/content/examples/application-composer.pdf
Binary files differ
diff --git a/content/examples/application-composer/README.md b/content/examples/application-composer/README.md
new file mode 100755
index 0000000..d9dcdc3
--- /dev/null
+++ b/content/examples/application-composer/README.md
@@ -0,0 +1,158 @@
+Title: Application Composer
+
+The `org.apache.openejb.junit.ApplicationComposer` is JUnit test runner modeled after the way we've done testing internally in OpenEJB for years (since about 2006).
+It involves no classpath scanning at all. If you want something to be in the app, you must build it directly in your testcase.
+
+With the `ApplicationComposer` you can do identical testing that OpenEJB uses internally, but with limited dependency on OpenEJB itself. The main dependency is on the code
+that is used to build the actual applications:
+
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-jee</artifactId>
+ <version>4.0.0-beta-1</version>
+ </dependency>
+
+# Composing an Application
+
+The main difference to the embedded `EJBContainer` API is building the application in the test code. This is done with one or more methods in the test case annotated
+with `org.apache.openejb.junit.Module` using the following format:
+
+ @Module
+ public <return-value> <module-name>() {
+
+Where **module-name** is the name you wish to use for that module and **return-value** can be any one of the following:
+
+ - java.lang.Class
+ - java.lang.Class[]
+ - org.apache.openejb.jee.EjbJar
+ - org.apache.openejb.jee.EnterpriseBean
+ - org.apache.openejb.jee.Application
+ - org.apache.openejb.jee.Connector
+ - org.apache.openejb.jee.Beans
+ - org.apache.openejb.jee.jpa.unit.Persistence
+ - org.apache.openejb.jee.jpa.unit.PersistenceUnit
+
+# Example
+
+Used in an actual testcase, that might look like so:
+
+ import junit.framework.TestCase;
+ import org.apache.openejb.jee.EjbJar;
+ import org.apache.openejb.jee.StatefulBean;
+ import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
+ import org.apache.openejb.junit.ApplicationComposer;
+ import org.apache.openejb.junit.Configuration;
+ import org.apache.openejb.junit.Module;
+ import org.junit.Test;
+ import org.junit.runner.RunWith;
+
+ import javax.annotation.Resource;
+ import javax.ejb.EJB;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.transaction.UserTransaction;
+ import java.util.List;
+ import java.util.Properties;
+
+ @RunWith(ApplicationComposer.class)
+ public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Module
+ public PersistenceUnit persistence() {
+ PersistenceUnit unit = new PersistenceUnit("movie-unit");
+ unit.setJtaDataSource("movieDatabase");
+ unit.setNonJtaDataSource("movieDatabaseUnmanaged");
+ unit.getClazz().add(Movie.class.getName());
+ unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+ return unit;
+ }
+
+ @Module
+ public EjbJar beans() {
+ EjbJar ejbJar = new EjbJar("movie-beans");
+ ejbJar.addEnterpriseBean(new StatefulBean(MoviesImpl.class));
+ return ejbJar;
+ }
+
+ @Configuration
+ public Properties config() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ return p;
+ }
+
+ @Test
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+
+ } finally {
+ userTransaction.commit();
+ }
+ }
+ }
+
+# Running
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.composed.MoviesTest
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Configuring enterprise application: /Users/dblevins/examples/application-composer/MoviesTest
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.composed.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean MoviesImpl: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/application-composer/MoviesTest" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/application-composer/MoviesTest
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 449ms
+ INFO - Jndi(name=org.superbiz.composed.MoviesTestLocalBean) --> Ejb(deployment-id=org.superbiz.composed.MoviesTest)
+ INFO - Jndi(name=global/MoviesTest/EjbModule2027711095/MoviesTest!org.superbiz.composed.MoviesTest) --> Ejb(deployment-id=org.superbiz.composed.MoviesTest)
+ INFO - Jndi(name=global/MoviesTest/EjbModule2027711095/MoviesTest) --> Ejb(deployment-id=org.superbiz.composed.MoviesTest)
+ INFO - Jndi(name=MoviesImplLocal) --> Ejb(deployment-id=MoviesImpl)
+ INFO - Jndi(name=global/MoviesTest/movie-beans/MoviesImpl!org.superbiz.composed.Movies) --> Ejb(deployment-id=MoviesImpl)
+ INFO - Jndi(name=global/MoviesTest/movie-beans/MoviesImpl) --> Ejb(deployment-id=MoviesImpl)
+ INFO - Created Ejb(deployment-id=org.superbiz.composed.MoviesTest, ejb-name=MoviesTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=MoviesImpl, ejb-name=MoviesImpl, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.composed.MoviesTest, ejb-name=MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=MoviesImpl, ejb-name=MoviesImpl, container=Default Stateful Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/application-composer/MoviesTest)
+ INFO - Undeploying app: /Users/dblevins/examples/application-composer/MoviesTest
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.221 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
diff --git a/content/examples/application-composer/build.xml b/content/examples/application-composer/build.xml
new file mode 100755
index 0000000..821f630
--- /dev/null
+++ b/content/examples/application-composer/build.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ <dependency groupId="org.apache.openejb" artifactId="openejb-api" version="4.0.0-beta-1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/application-composer/pom.xml b/content/examples/application-composer/pom.xml
new file mode 100755
index 0000000..2fd9c19
--- /dev/null
+++ b/content/examples/application-composer/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>application-composer</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Application Composer</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/application-composer/src/main/java/org/superbiz/composed/Movie.java b/content/examples/application-composer/src/main/java/org/superbiz/composed/Movie.java
new file mode 100755
index 0000000..d5647c8
--- /dev/null
+++ b/content/examples/application-composer/src/main/java/org/superbiz/composed/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/application-composer/src/main/java/org/superbiz/composed/Movies.java b/content/examples/application-composer/src/main/java/org/superbiz/composed/Movies.java
new file mode 100755
index 0000000..3113c13
--- /dev/null
+++ b/content/examples/application-composer/src/main/java/org/superbiz/composed/Movies.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed;
+
+import java.util.List;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public interface Movies {
+
+ void addMovie(Movie movie) throws Exception;
+
+ void deleteMovie(Movie movie) throws Exception;
+
+ List<Movie> getMovies() throws Exception;
+}
diff --git a/content/examples/application-composer/src/main/java/org/superbiz/composed/MoviesImpl.java b/content/examples/application-composer/src/main/java/org/superbiz/composed/MoviesImpl.java
new file mode 100755
index 0000000..45fe222
--- /dev/null
+++ b/content/examples/application-composer/src/main/java/org/superbiz/composed/MoviesImpl.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed;
+
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+import static javax.ejb.TransactionAttributeType.MANDATORY;
+
+//START SNIPPET: code
+@Stateful(name = "Movies")
+@TransactionAttribute(MANDATORY)
+public class MoviesImpl implements Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/application-composer/src/test/java/org/superbiz/composed/MoviesTest.java b/content/examples/application-composer/src/test/java/org/superbiz/composed/MoviesTest.java
new file mode 100755
index 0000000..35b6e8c
--- /dev/null
+++ b/content/examples/application-composer/src/test/java/org/superbiz/composed/MoviesTest.java
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed;
+
+import junit.framework.TestCase;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.StatefulBean;
+import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.UserTransaction;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+@RunWith(ApplicationComposer.class)
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Module
+ public PersistenceUnit persistence() {
+ PersistenceUnit unit = new PersistenceUnit("movie-unit");
+ unit.setJtaDataSource("movieDatabase");
+ unit.setNonJtaDataSource("movieDatabaseUnmanaged");
+ unit.getClazz().add(Movie.class.getName());
+ unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+ return unit;
+ }
+
+ @Module
+ public EjbJar beans() {
+ EjbJar ejbJar = new EjbJar("movie-beans");
+ ejbJar.addEnterpriseBean(new StatefulBean(MoviesImpl.class));
+ return ejbJar;
+ }
+
+ @Configuration
+ public Properties config() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ return p;
+ }
+
+ @Test
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+
+ } finally {
+ userTransaction.commit();
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/applicationcomposer-jaxws-cdi.html b/content/examples/applicationcomposer-jaxws-cdi.html
new file mode 100644
index 0000000..c800740
--- /dev/null
+++ b/content/examples/applicationcomposer-jaxws-cdi.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/applicationcomposer-jaxws-cdi.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>applicationcomposer-jaxws-cdi</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example applicationcomposer-jaxws-cdi can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/applicationcomposer-jaxws-cdi" class="bare">https://github.com/apache/tomee/tree/master/examples/applicationcomposer-jaxws-cdi</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/applicationcomposer-jaxws-cdi.pdf b/content/examples/applicationcomposer-jaxws-cdi.pdf
new file mode 100644
index 0000000..243e303
--- /dev/null
+++ b/content/examples/applicationcomposer-jaxws-cdi.pdf
Binary files differ
diff --git a/content/examples/applicationcomposer-jaxws-cdi/pom.xml b/content/examples/applicationcomposer-jaxws-cdi/pom.xml
new file mode 100755
index 0000000..0ed47f8
--- /dev/null
+++ b/content/examples/applicationcomposer-jaxws-cdi/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>ws-pojo-cdi</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Application Composer, JAX-WS and CDI are in a boat</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- The <scope>test</scope> guarantees that none of your runtime code
+ is dependent on any OpenEJB classes. -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/Agenda.java b/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/Agenda.java
new file mode 100755
index 0000000..8860e09
--- /dev/null
+++ b/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/Agenda.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.example.jaxws;
+
+import java.util.Date;
+
+public interface Agenda {
+ boolean isBookable(Date d);
+}
diff --git a/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/LazyAgenda.java b/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/LazyAgenda.java
new file mode 100755
index 0000000..024cbf0
--- /dev/null
+++ b/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/LazyAgenda.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.example.jaxws;
+
+import java.util.Date;
+
+public class LazyAgenda implements Agenda {
+ @Override
+ public boolean isBookable(final Date d) {
+ return d.after(new Date());
+ }
+}
diff --git a/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/MeetingPlanner.java b/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/MeetingPlanner.java
new file mode 100755
index 0000000..616dedd
--- /dev/null
+++ b/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/MeetingPlanner.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.example.jaxws;
+
+import javax.jws.WebService;
+import java.util.Date;
+
+@WebService
+public interface MeetingPlanner {
+ boolean book(final Date date);
+}
diff --git a/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/MeetingPlannerImpl.java b/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/MeetingPlannerImpl.java
new file mode 100755
index 0000000..3159598
--- /dev/null
+++ b/content/examples/applicationcomposer-jaxws-cdi/src/main/java/org/superbiz/example/jaxws/MeetingPlannerImpl.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.example.jaxws;
+
+import javax.inject.Inject;
+import javax.jws.WebService;
+import java.util.Date;
+
+@WebService
+public class MeetingPlannerImpl implements MeetingPlanner {
+ @Inject
+ private Agenda agenda;
+
+ @Override
+ public boolean book(final Date date) {
+ return agenda.isBookable(date);
+ }
+}
diff --git a/content/examples/applicationcomposer-jaxws-cdi/src/main/resources/META-INF/beans.xml b/content/examples/applicationcomposer-jaxws-cdi/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..30fc772
--- /dev/null
+++ b/content/examples/applicationcomposer-jaxws-cdi/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/applicationcomposer-jaxws-cdi/src/test/java/org/superbiz/example/jaxws/MeetingPlannerTest.java b/content/examples/applicationcomposer-jaxws-cdi/src/test/java/org/superbiz/example/jaxws/MeetingPlannerTest.java
new file mode 100755
index 0000000..b365c65
--- /dev/null
+++ b/content/examples/applicationcomposer-jaxws-cdi/src/test/java/org/superbiz/example/jaxws/MeetingPlannerTest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.example.jaxws;
+
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+
+import static java.lang.Integer.toString;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.apache.openejb.util.NetworkUtil;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Date;
+import java.util.Properties;
+
+@EnableServices("jax-ws")
+@RunWith(ApplicationComposer.class)
+public class MeetingPlannerTest {
+ private static final int JAX_WS_PORT = NetworkUtil.getNextAvailablePort();
+
+ @Configuration
+ public Properties configuration() {
+ return new PropertiesBuilder().p("httpejbd.port", Integer.toString(JAX_WS_PORT)).build();
+ }
+ @Module
+ @Classes(cdi = true, value = { MeetingPlannerImpl.class, LazyAgenda.class })
+ public WebApp war() {
+ return new WebApp()
+ .contextRoot("/demo")
+ .addServlet("jaxws", MeetingPlannerImpl.class.getName(), "/meeting-planner");
+ }
+
+ @Test
+ public void book() throws MalformedURLException {
+ final Service service = Service.create(
+ new URL("http://127.0.0.1:" + JAX_WS_PORT + "/demo/meeting-planner?wsdl"),
+ new QName("http://jaxws.example.superbiz.org/", "MeetingPlannerImplService"));
+ final MeetingPlanner planner = service.getPort(MeetingPlanner.class);
+ assertTrue(planner.book(new Date(System.currentTimeMillis() + 1000000)));
+ }
+}
diff --git a/content/examples/applicationexception.html b/content/examples/applicationexception.html
new file mode 100644
index 0000000..a530e27
--- /dev/null
+++ b/content/examples/applicationexception.html
@@ -0,0 +1,302 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/applicationexception.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>@ApplicationException annotation</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example applicationexception can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/applicationexception" class="bare">https://github.com/apache/tomee/tree/master/examples/applicationexception</a></p>
+</div>
+</div>
+</div>
+<h1 id="_declaring_an_applicationexception" class="sect0">Declaring an @ApplicationException</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import javax.ejb.ApplicationException;
+
+/**
+ * @version $Rev: 784112 $ $Date: 2009-06-12 06:23:57 -0700 (Fri, 12 Jun 2009) $
+ */
+@ApplicationException(rollback = true)
+public abstract class BusinessException extends RuntimeException {
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>By default, @ApplicationException is inherited</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class ValueRequiredException extends BusinessException {
+}</code></pre>
+</div>
+</div>
+<h1 id="_in_the_bean_code" class="sect0">In the bean code</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stateless
+public class ThrowBusinessExceptionImpl implements ThrowBusinessException {
+
+ public void throwValueRequiredException() throws BusinessException {
+ throw new ValueRequiredException();
+ }
+
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Normally throwing a <code>RuntimeException</code> would cause the container to both rollback the transaction and destroy the bean instance that threw the exception.</p>
+</div>
+<div class="paragraph">
+<p>As <code>BusinessException</code> has been annotated <code>@ApplicationException(rollback = true)</code> only the transaction rollback will occur and the bean will not get destroyed.</p>
+</div>
+<h1 id="_the_testcase" class="sect0">The TestCase</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+public class ThrowBusinessExceptionImplTest {
+
+ private InitialContext initialContext;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ initialContext = new InitialContext(properties);
+ }
+
+ @Test(expected = ValueRequiredException.class)
+ public void testCounterViaRemoteInterface() throws Exception {
+ Object object = initialContext.lookup("ThrowBusinessExceptionImplRemote");
+
+ Assert.assertNotNull(object);
+ Assert.assertTrue(object instanceof ThrowBusinessException);
+ ThrowBusinessException bean = (ThrowBusinessException) object;
+ bean.throwValueRequiredException();
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.appexception.ThrowBusinessExceptionImplTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/applicationexception
+INFO - openejb.base = /Users/dblevins/examples/applicationexception
+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/applicationexception/target/classes
+INFO - Beginning load: /Users/dblevins/examples/applicationexception/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/applicationexception/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean ThrowBusinessExceptionImpl: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "/Users/dblevins/examples/applicationexception/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/applicationexception/classpath.ear
+INFO - Jndi(name=ThrowBusinessExceptionImplRemote) --> Ejb(deployment-id=ThrowBusinessExceptionImpl)
+INFO - Jndi(name=global/classpath.ear/applicationexception/ThrowBusinessExceptionImpl!org.superbiz.appexception.ThrowBusinessException) --> Ejb(deployment-id=ThrowBusinessExceptionImpl)
+INFO - Jndi(name=global/classpath.ear/applicationexception/ThrowBusinessExceptionImpl) --> Ejb(deployment-id=ThrowBusinessExceptionImpl)
+INFO - Created Ejb(deployment-id=ThrowBusinessExceptionImpl, ejb-name=ThrowBusinessExceptionImpl, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=ThrowBusinessExceptionImpl, ejb-name=ThrowBusinessExceptionImpl, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/applicationexception/classpath.ear)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.434 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/applicationexception.pdf b/content/examples/applicationexception.pdf
new file mode 100644
index 0000000..021ba5e
--- /dev/null
+++ b/content/examples/applicationexception.pdf
Binary files differ
diff --git a/content/examples/applicationexception/README.md b/content/examples/applicationexception/README.md
new file mode 100755
index 0000000..dbc73d3
--- /dev/null
+++ b/content/examples/applicationexception/README.md
@@ -0,0 +1,97 @@
+Title: @ApplicationException annotation
+
+# Declaring an @ApplicationException
+
+ import javax.ejb.ApplicationException;
+
+ /**
+ * @version $Rev: 784112 $ $Date: 2009-06-12 06:23:57 -0700 (Fri, 12 Jun 2009) $
+ */
+ @ApplicationException(rollback = true)
+ public abstract class BusinessException extends RuntimeException {
+ }
+
+By default, @ApplicationException is inherited
+
+ public class ValueRequiredException extends BusinessException {
+ }
+
+# In the bean code
+
+ @Stateless
+ public class ThrowBusinessExceptionImpl implements ThrowBusinessException {
+
+ public void throwValueRequiredException() throws BusinessException {
+ throw new ValueRequiredException();
+ }
+
+ }
+
+Normally throwing a `RuntimeException` would cause the container to both rollback the transaction and destroy the bean instance that threw the exception.
+
+As `BusinessException` has been annotated `@ApplicationException(rollback = true)` only the transaction rollback will occur and the bean will not get destroyed.
+
+# The TestCase
+
+ import org.junit.Assert;
+ import org.junit.Before;
+ import org.junit.Test;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.Properties;
+
+ public class ThrowBusinessExceptionImplTest {
+
+ private InitialContext initialContext;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ initialContext = new InitialContext(properties);
+ }
+
+ @Test(expected = ValueRequiredException.class)
+ public void testCounterViaRemoteInterface() throws Exception {
+ Object object = initialContext.lookup("ThrowBusinessExceptionImplRemote");
+
+ Assert.assertNotNull(object);
+ Assert.assertTrue(object instanceof ThrowBusinessException);
+ ThrowBusinessException bean = (ThrowBusinessException) object;
+ bean.throwValueRequiredException();
+ }
+ }
+
+# Running
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.appexception.ThrowBusinessExceptionImplTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/applicationexception
+ INFO - openejb.base = /Users/dblevins/examples/applicationexception
+ 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/applicationexception/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/applicationexception/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/applicationexception/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean ThrowBusinessExceptionImpl: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "/Users/dblevins/examples/applicationexception/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/applicationexception/classpath.ear
+ INFO - Jndi(name=ThrowBusinessExceptionImplRemote) --> Ejb(deployment-id=ThrowBusinessExceptionImpl)
+ INFO - Jndi(name=global/classpath.ear/applicationexception/ThrowBusinessExceptionImpl!org.superbiz.appexception.ThrowBusinessException) --> Ejb(deployment-id=ThrowBusinessExceptionImpl)
+ INFO - Jndi(name=global/classpath.ear/applicationexception/ThrowBusinessExceptionImpl) --> Ejb(deployment-id=ThrowBusinessExceptionImpl)
+ INFO - Created Ejb(deployment-id=ThrowBusinessExceptionImpl, ejb-name=ThrowBusinessExceptionImpl, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=ThrowBusinessExceptionImpl, ejb-name=ThrowBusinessExceptionImpl, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/applicationexception/classpath.ear)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.434 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/applicationexception/build.xml b/content/examples/applicationexception/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/applicationexception/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/applicationexception/pom.xml b/content/examples/applicationexception/pom.xml
new file mode 100755
index 0000000..0c253f4
--- /dev/null
+++ b/content/examples/applicationexception/pom.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>applicationexception</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @ApplicationException inheritance</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <systemPropertyVariables>
+ <openejb.applicationexceptions.inherited>true</openejb.applicationexceptions.inherited>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/applicationexception/src/main/java/org/superbiz/appexception/BusinessException.java b/content/examples/applicationexception/src/main/java/org/superbiz/appexception/BusinessException.java
new file mode 100755
index 0000000..10cfdc7
--- /dev/null
+++ b/content/examples/applicationexception/src/main/java/org/superbiz/appexception/BusinessException.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.appexception;
+
+import javax.ejb.ApplicationException;
+
+/**
+ * @version $Rev: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+@ApplicationException(rollback = true)
+public abstract class BusinessException extends RuntimeException {
+
+}
diff --git a/content/examples/applicationexception/src/main/java/org/superbiz/appexception/ThrowBusinessException.java b/content/examples/applicationexception/src/main/java/org/superbiz/appexception/ThrowBusinessException.java
new file mode 100755
index 0000000..d7a901c
--- /dev/null
+++ b/content/examples/applicationexception/src/main/java/org/superbiz/appexception/ThrowBusinessException.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.appexception;
+
+import javax.ejb.Remote;
+
+/**
+ * This is an EJB 3 remote business interface
+ * A remote business interface must be annotated with the @Remote
+ * annotation
+ */
+//START SNIPPET: code
+@Remote
+public interface ThrowBusinessException {
+
+ public void throwValueRequiredException() throws BusinessException;
+
+}
+//END SNIPPET: code
diff --git a/content/examples/applicationexception/src/main/java/org/superbiz/appexception/ThrowBusinessExceptionImpl.java b/content/examples/applicationexception/src/main/java/org/superbiz/appexception/ThrowBusinessExceptionImpl.java
new file mode 100755
index 0000000..8665751
--- /dev/null
+++ b/content/examples/applicationexception/src/main/java/org/superbiz/appexception/ThrowBusinessExceptionImpl.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.appexception;
+
+import javax.ejb.Stateless;
+
+//START SNIPPET: code
+@Stateless
+public class ThrowBusinessExceptionImpl implements ThrowBusinessException {
+
+ public void throwValueRequiredException() throws BusinessException {
+ throw new ValueRequiredException();
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/applicationexception/src/main/java/org/superbiz/appexception/ValueRequiredException.java b/content/examples/applicationexception/src/main/java/org/superbiz/appexception/ValueRequiredException.java
new file mode 100755
index 0000000..3c0a1ed
--- /dev/null
+++ b/content/examples/applicationexception/src/main/java/org/superbiz/appexception/ValueRequiredException.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.appexception;
+
+/**
+ * @version $Rev: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+public class ValueRequiredException extends BusinessException {
+
+}
diff --git a/content/examples/applicationexception/src/main/resources/META-INF/ejb-jar.xml b/content/examples/applicationexception/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..433757b
--- /dev/null
+++ b/content/examples/applicationexception/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
\ No newline at end of file
diff --git a/content/examples/applicationexception/src/test/java/org/superbiz/appexception/ThrowBusinessExceptionImplTest.java b/content/examples/applicationexception/src/test/java/org/superbiz/appexception/ThrowBusinessExceptionImplTest.java
new file mode 100755
index 0000000..7bba170
--- /dev/null
+++ b/content/examples/applicationexception/src/test/java/org/superbiz/appexception/ThrowBusinessExceptionImplTest.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.appexception;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+// TODO This test case does not actually show that the bean was not destroyed. The effect of @ApplicationException is not demonstrated
+// Maybe have two methods that throw runtime exceptions and compare the behavior of both
+// TODO Remote the business interface and show only POJO usage
+public class ThrowBusinessExceptionImplTest {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ initialContext = new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Lookup the Counter bean via its remote home interface
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remote
+ @Test(expected = ValueRequiredException.class)
+ public void testCounterViaRemoteInterface() throws Exception {
+ Object object = initialContext.lookup("ThrowBusinessExceptionImplRemote");
+
+ Assert.assertNotNull(object);
+ Assert.assertTrue(object instanceof ThrowBusinessException);
+ ThrowBusinessException bean = (ThrowBusinessException) object;
+ bean.throwValueRequiredException();
+ }
+ //END SNIPPET: remote
+
+}
diff --git a/content/examples/arquillian-jpa.html b/content/examples/arquillian-jpa.html
new file mode 100644
index 0000000..29d0859
--- /dev/null
+++ b/content/examples/arquillian-jpa.html
@@ -0,0 +1,362 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/arquillian-jpa.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Arquillian Persistence Extension</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example arquillian-jpa can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/arquillian-jpa" class="bare">https://github.com/apache/tomee/tree/master/examples/arquillian-jpa</a></p>
+</div>
+<div class="paragraph">
+<p>A sample showing how to use TomEE, Arquillian and its Persistence Extension.</p>
+</div>
+<div class="paragraph">
+<p>Note that it doesn’t work with embedded containers (openejb, tomee-embedded)
+if you don’t use workarounds like <a href="https://github.com/rmannibucau/persistence-with-openejb-and-arquillian" class="bare">https://github.com/rmannibucau/persistence-with-openejb-and-arquillian</a>
+(see src/test/resources folder).</p>
+</div>
+</div>
+</div>
+<h1 id="_running_output" class="sect0">Running (output)</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.arquillian.test.persistence.PersistenceTest
+oct. 01, 2014 6:30:23 PM org.apache.openejb.arquillian.common.Setup findHome
+INFOS: Unable to find home in: /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/apache-tomee-remote
+oct. 01, 2014 6:30:23 PM org.apache.openejb.arquillian.common.MavenCache getArtifact
+INFOS: Downloading org.apache.openejb:apache-tomee:7.0.0-SNAPSHOT:zip:webprofile please wait...
+oct. 01, 2014 6:30:23 PM org.apache.openejb.arquillian.common.Zips unzip
+INFOS: Extracting '/home/rmannibucau/.m2/repository/org/apache/openejb/apache-tomee/7.0.0-SNAPSHOT/apache-tomee-7.0.0-SNAPSHOT-webprofile.zip' to '/home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/apache-tomee-remote'
+oct. 01, 2014 6:30:24 PM org.apache.tomee.arquillian.remote.RemoteTomEEContainer configure
+INFOS: Downloaded container to: /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/apache-tomee-remote/apache-tomee-webprofile-7.0.0-SNAPSHOT
+INFOS - Server version: Apache Tomcat/8.0.14
+INFOS - Server built: Sep 24 2014 09:01:51
+INFOS - Server number: 8.0.14.0
+INFOS - OS Name: Linux
+INFOS - OS Version: 3.13.0-35-generic
+INFOS - Architecture: amd64
+INFOS - JVM Version: 1.7.0_67-b01
+INFOS - JVM Vendor: Oracle Corporation
+INFOS - The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
+INFOS - Initializing ProtocolHandler ["http-nio-52256"]
+INFOS - Using a shared selector for servlet write/read
+INFOS - Initializing ProtocolHandler ["ajp-nio-40071"]
+INFOS - Using a shared selector for servlet write/read
+INFOS - Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
+INFOS - ********************************************************************************
+INFOS - OpenEJB http://tomee.apache.org/
+INFOS - Startup: Wed Oct 01 18:30:26 CEST 2014
+INFOS - Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
+INFOS - Version: 7.0.0-SNAPSHOT
+INFOS - Build date: 20141001
+INFOS - Build time: 04:53
+INFOS - ********************************************************************************
+INFOS - openejb.home = /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/apache-tomee-remote/apache-tomee-webprofile-7.0.0-SNAPSHOT
+INFOS - openejb.base = /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/apache-tomee-remote/apache-tomee-webprofile-7.0.0-SNAPSHOT
+INFOS - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@13158bbd
+INFOS - Succeeded in installing singleton service
+INFOS - openejb configuration file is '/home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/apache-tomee-remote/apache-tomee-webprofile-7.0.0-SNAPSHOT/conf/tomee.xml'
+INFOS - Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
+INFOS - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+INFOS - Configuring Service(id=demoDataSource, type=Resource, provider-id=Default JDBC Database)
+INFOS - Using 'openejb.system.apps=true'
+INFOS - Configuring enterprise application: openejb
+INFOS - Using openejb.deploymentId.format '{ejbName}'
+INFOS - Auto-deploying ejb openejb/Deployer: EjbDeployment(deployment-id=openejb/Deployer)
+INFOS - Auto-deploying ejb openejb/ConfigurationInfo: EjbDeployment(deployment-id=openejb/ConfigurationInfo)
+INFOS - Auto-deploying ejb MEJB: EjbDeployment(deployment-id=MEJB)
+INFOS - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFOS - Auto-creating a container for bean openejb/Deployer: Container(type=STATELESS, id=Default Stateless Container)
+INFOS - Enterprise application "openejb" loaded.
+INFOS - Creating TransactionManager(id=Default Transaction Manager)
+INFOS - Creating SecurityService(id=Tomcat Security Service)
+INFOS - Creating Resource(id=demoDataSource)
+INFOS - Disabling testOnBorrow since no validation query is provided
+INFOS - Creating Container(id=Default Stateless Container)
+INFOS - Not creating another application classloader for openejb
+INFOS - Assembling app: openejb
+INFOS - Using 'openejb.jndiname.format={deploymentId}{interfaceType.openejbLegacyName}'
+INFOS - Jndi(name=openejb/DeployerBusinessRemote) --> Ejb(deployment-id=openejb/Deployer)
+INFOS - Jndi(name=global/openejb/openejb/Deployer!org.apache.openejb.assembler.Deployer) --> Ejb(deployment-id=openejb/Deployer)
+INFOS - Jndi(name=global/openejb/openejb/Deployer) --> Ejb(deployment-id=openejb/Deployer)
+INFOS - Jndi(name=openejb/ConfigurationInfoBusinessRemote) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+INFOS - Jndi(name=global/openejb/openejb/ConfigurationInfo!org.apache.openejb.assembler.classic.cmd.ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+INFOS - Jndi(name=global/openejb/openejb/ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+INFOS - Jndi(name=MEJB) --> Ejb(deployment-id=MEJB)
+INFOS - Jndi(name=global/openejb/MEJB!javax.management.j2ee.ManagementHome) --> Ejb(deployment-id=MEJB)
+INFOS - Jndi(name=global/openejb/MEJB) --> Ejb(deployment-id=MEJB)
+INFOS - Created Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+INFOS - Created Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+INFOS - Created Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+INFOS - Started Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+INFOS - Started Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+INFOS - Started Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+INFOS - Deployed MBean(openejb.user.mbeans:application=openejb,group=org.apache.openejb.assembler.monitoring,name=JMXDeployer)
+INFOS - Deployed Application(path=openejb)
+INFOS - Creating ServerService(id=cxf-rs)
+INFOS - ** Bound Services **
+INFOS - NAME IP PORT
+INFOS - -------
+INFOS - Ready!
+INFOS - Initialization processed in 2589 ms
+INFOS - Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
+INFOS - Creating Resource(id=UserDatabase)
+INFOS - Démarrage du service Catalina
+INFOS - Starting Servlet Engine: Apache Tomcat (TomEE)/8.0.14 (7.0.0-SNAPSHOT)
+INFOS - Starting ProtocolHandler ["http-nio-52256"]
+INFOS - Starting ProtocolHandler ["ajp-nio-40071"]
+INFOS - Server startup in 140 ms
+oct. 01, 2014 6:30:30 PM org.apache.openejb.client.EventLogger log
+INFOS: RemoteInitialContextCreated{providerUri=http://localhost:52256/tomee/ejb}
+INFOS - Extracting jar: /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/arquillian-test-working-dir/0/UserPersistenceTest.war
+INFOS - Extracted path: /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/arquillian-test-working-dir/0/UserPersistenceTest
+INFOS - using default host: localhost
+INFOS - ------------------------- localhost -> /UserPersistenceTest
+INFOS - Using 'openejb.session.manager=org.apache.tomee.catalina.session.QuickSessionManager'
+INFOS - Configuring enterprise application: /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/arquillian-test-working-dir/0/UserPersistenceTest
+INFOS - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFOS - Auto-creating a container for bean UserPersistenceTest_org.superbiz.arquillian.test.persistence.PersistenceTest: Container(type=MANAGED, id=Default Managed Container)
+INFOS - Creating Container(id=Default Managed Container)
+INFOS - Using directory /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/apache-tomee-remote/apache-tomee-webprofile-7.0.0-SNAPSHOT/temp for stateful session passivation
+INFOS - Configuring PersistenceUnit(name=demoApplicationPU)
+INFOS - Auto-creating a Resource with id 'demoDataSourceNonJta' of type 'DataSource for 'demoApplicationPU'.
+INFOS - Configuring Service(id=demoDataSourceNonJta, type=Resource, provider-id=demoDataSource)
+INFOS - Creating Resource(id=demoDataSourceNonJta)
+INFOS - Disabling testOnBorrow since no validation query is provided
+INFOS - Adjusting PersistenceUnit demoApplicationPU <non-jta-data-source> to Resource ID 'demoDataSourceNonJta' from 'null'
+INFOS - Enterprise application "/home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/arquillian-test-working-dir/0/UserPersistenceTest" loaded.
+INFOS - Assembling app: /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/arquillian-test-working-dir/0/UserPersistenceTest
+INFOS - OpenJPA dynamically loaded a validation provider.
+INFOS - Starting OpenJPA 2.4.0-nonfinal-1598334
+INFOS - Using dictionary class "org.apache.openjpa.jdbc.sql.HSQLDictionary" (HSQL Database Engine 2.3.2 ,HSQL Database Engine Driver 2.3.2).
+INFOS - Connected to HSQL Database Engine version 2.2 using JDBC driver HSQL Database Engine Driver version 2.3.2.
+INFOS - SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM INFORMATION_SCHEMA.SYSTEM_SEQUENCES --> 0ms
+INFOS - CREATE TABLE User (id BIGINT NOT NULL, name VARCHAR(255), PRIMARY KEY (id)) --> 0ms
+INFOS - PersistenceUnit(name=demoApplicationPU, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 1075ms
+INFOS - Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@13158bbd
+INFOS - OpenWebBeans Container is starting...
+INFOS - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFOS - All injection points were validated successfully.
+INFOS - OpenWebBeans Container has started, it took 224 ms.
+INFOS - Deployed Application(path=/home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/arquillian-test-working-dir/0/UserPersistenceTest)
+INFOS - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
+AVERTISSEMENT - Potential problem found: The configured data type factory 'class org.dbunit.dataset.datatype.DefaultDataTypeFactory' might cause problems with the current database 'HSQL Database Engine' (e.g. some datatypes may not be supported properly). In rare cases you might see this message because the list of supported database products is incomplete (list=[derby]). If so please request a java-class update via the forums.If you are using your own IDataTypeFactory extending DefaultDataTypeFactory, ensure that you override getValidDbProducts() to specify the supported database products.
+INFOS - insert into USER (ID, NAME) values (1, TomEE) --> 1ms
+INFOS - insert into USER (ID, NAME) values (1, 2)TomEE,Old) --> 0ms
+INFOS - SELECT COUNT(t0.id) FROM User t0 --> 0ms
+INFOS - SELECT t0.name FROM User t0 WHERE t0.id = 2 --> 0ms
+INFOS - UPDATE User SET name = OpenEJB WHERE id = 2 --> 1ms
+INFOS - select ID, NAME from USER order by ID --> 0ms
+INFOS - select ID, NAME from USER order by ID --> 0ms
+INFOS - select ID, NAME from USER order by ID --> 0ms
+INFOS - select ID, NAME from USER order by ID --> 0ms
+INFOS - delete from USER --> 0ms
+oct. 01, 2014 6:30:34 PM org.apache.openejb.client.EventLogger log
+INFOS: RemoteInitialContextCreated{providerUri=http://localhost:52256/tomee/ejb}
+INFOS - Undeploying app: /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/arquillian-test-working-dir/0/UserPersistenceTest
+oct. 01, 2014 6:30:34 PM org.apache.openejb.arquillian.common.TomEEContainer undeploy
+INFOS: cleaning /home/rmannibucau/dev/Apache/tomee-trunk/examples/arquillian-jpa/target/arquillian-test-working-dir/0
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.242 sec
+INFOS - A valid shutdown command was received via the shutdown port. Stopping the Server instance.
+INFOS - Pausing ProtocolHandler ["http-nio-52256"]
+INFOS - Pausing ProtocolHandler ["ajp-nio-40071"]
+INFOS - Arrêt du service Catalina
+INFOS - Stopping ProtocolHandler ["http-nio-52256"]
+INFOS - Stopping ProtocolHandler ["ajp-nio-40071"]
+INFOS - Stopping server services
+INFOS - Undeploying app: openejb
+INFOS - Closing DataSource: demoDataSource
+INFOS - Closing DataSource: demoDataSourceNonJta
+INFOS - Destroying ProtocolHandler ["http-nio-52256"]
+INFOS - Destroying ProtocolHandler ["ajp-nio-40071"]
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/arquillian-jpa.pdf b/content/examples/arquillian-jpa.pdf
new file mode 100644
index 0000000..125006f
--- /dev/null
+++ b/content/examples/arquillian-jpa.pdf
Binary files differ
diff --git a/content/examples/async-methods.html b/content/examples/async-methods.html
new file mode 100644
index 0000000..08f6977
--- /dev/null
+++ b/content/examples/async-methods.html
@@ -0,0 +1,392 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/async-methods.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>@Asynchronous Methods</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example async-methods can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/async-methods" class="bare">https://github.com/apache/tomee/tree/master/examples/async-methods</a></p>
+</div>
+<div class="paragraph">
+<p>The @Asynchronous annotation was introduced in EJB 3.1 as a simple way of creating asynchronous processing.</p>
+</div>
+<div class="paragraph">
+<p>Every time a method annotated <code>@Asynchronous</code> is invoked by anyone it will immediately return regardless of how long the method actually takes. Each invocation returns a [Future][1] object that essentially starts out <strong>empty</strong> and will later have its value filled in by the container when the related method call actually completes. Returning a <code>Future</code> object is not required and <code>@Asynchronous</code> methods can of course return <code>void</code>.</p>
+</div>
+</div>
+</div>
+<h1 id="_example" class="sect0">Example</h1>
+<div class="paragraph">
+<p>Here, in <code>JobProcessorTest</code>,</p>
+</div>
+<div class="paragraph">
+<p><code>final Future<String> red = processor.addJob("red");</code>
+proceeds to the next statement,</p>
+</div>
+<div class="paragraph">
+<p><code>final Future<String> orange = processor.addJob("orange");</code></p>
+</div>
+<div class="paragraph">
+<p>without waiting for the addJob() method to complete. And later we could ask for the result using the <code>Future<?>.get()</code> method like</p>
+</div>
+<div class="paragraph">
+<p><code>assertEquals("blue", blue.get());</code></p>
+</div>
+<div class="paragraph">
+<p>It waits for the processing to complete (if its not completed already) and gets the result. If you did not care about the result, you could simply have your asynchronous method as a void method.</p>
+</div>
+<div class="paragraph">
+<p>[Future][1] Object from docs,</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+A Future represents the result of an asynchronous computation. Methods are provided to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation. The result can only be retrieved using method get when the computation has completed, blocking if necessary until it is ready. Cancellation is performed by the cancel method. Additional methods are provided to determine if the task completed normally or was cancelled. Once a computation has completed, the computation cannot be cancelled. If you would like to use a Future for the sake of cancellability but not provide a usable result, you can declare types of the form Future<?> and return null as a result of the underlying task
+</td>
+</tr>
+</table>
+</div>
+<h1 id="_the_code" class="sect0">The code</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Singleton
+public class JobProcessor {
+@Asynchronous
+@Lock(READ)
+@AccessTimeout(-1)
+public Future<String> addJob(String jobName) {
+
+ // Pretend this job takes a while
+ doSomeHeavyLifting();
+
+ // Return our result
+ return new AsyncResult<String>(jobName);
+}</code></pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> private void doSomeHeavyLifting() {
+ try {
+ Thread.sleep(SECONDS.toMillis(10));
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+= Test</pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class JobProcessorTest extends TestCase {
+
+public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final JobProcessor processor = (JobProcessor) context.lookup("java:global/async-methods/JobProcessor");
+
+ final long start = System.nanoTime();
+
+ // Queue up a bunch of work
+ final Future<String> red = processor.addJob("red");
+ final Future<String> orange = processor.addJob("orange");
+ final Future<String> yellow = processor.addJob("yellow");
+ final Future<String> green = processor.addJob("green");
+ final Future<String> blue = processor.addJob("blue");
+ final Future<String> violet = processor.addJob("violet");
+
+ // Wait for the result -- 1 minute worth of work
+ assertEquals("blue", blue.get());
+ assertEquals("orange", orange.get());
+ assertEquals("green", green.get());
+ assertEquals("red", red.get());
+ assertEquals("yellow", yellow.get());
+ assertEquals("violet", violet.get());
+
+ // How long did it take?
+ final long total = TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
+
+ // Execution should be around 9 - 21 seconds
+ // The execution time depends on the number of threads available for asynchronous execution.
+ // In the best case it is 10s plus some minimal processing time.
+ assertTrue("Expected > 9 but was: " + total, total > 9);
+ assertTrue("Expected < 21 but was: " + total, total < 21);
+
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.async.JobProcessorTest
+Apache OpenEJB 7.0.0-SNAPSHOT build: 20110801-04:02
+http://tomee.apache.org/
+INFO - openejb.home = G:\Workspace\fullproject\openejb3\examples\async-methods
+INFO - openejb.base = G:\Workspace\fullproject\openejb3\examples\async-methods
+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: g:\Workspace\fullproject\openejb3\examples\async-methods\target\classes
+INFO - Beginning load: g:\Workspace\fullproject\openejb3\examples\async-methods\target\classes
+INFO - Configuring enterprise application: g:\Workspace\fullproject\openejb3\examples\async-methods
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean JobProcessor: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.async.JobProcessorTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "g:\Workspace\fullproject\openejb3\examples\async-methods" loaded.
+INFO - Assembling app: g:\Workspace\fullproject\openejb3\examples\async-methods
+INFO - Jndi(name="java:global/async-methods/JobProcessor!org.superbiz.async.JobProcessor")
+INFO - Jndi(name="java:global/async-methods/JobProcessor")
+INFO - Jndi(name="java:global/EjbModule100568296/org.superbiz.async.JobProcessorTest!org.superbiz.async.JobProcessorTest")
+INFO - Jndi(name="java:global/EjbModule100568296/org.superbiz.async.JobProcessorTest")
+INFO - Created Ejb(deployment-id=org.superbiz.async.JobProcessorTest, ejb-name=org.superbiz.async.JobProcessorTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=JobProcessor, ejb-name=JobProcessor, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=org.superbiz.async.JobProcessorTest, ejb-name=org.superbiz.async.JobProcessorTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=JobProcessor, ejb-name=JobProcessor, container=Default Singleton Container)
+INFO - Deployed Application(path=g:\Workspace\fullproject\openejb3\examples\async-methods)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.305 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 21.097s
+[INFO] Finished at: Wed Aug 03 22:48:26 IST 2011
+[INFO] Final Memory: 13M/145M
+[INFO] ------------------------------------------------------------------------</pre>
+</div>
+</div>
+<h1 id="_how_it_works_small_under_the_covers_small" class="sect0">How it works <small>under the covers</small></h1>
+<div class="paragraph">
+<p>Under the covers what makes this work is:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>The <code>JobProcessor</code> the caller sees is not actually an instance of <code>JobProcessor</code>. Rather it’s a subclass or proxy that has all the methods overridden. Methods that are supposed to be asynchronous are handled differently.</p>
+</li>
+<li>
+<p>Calls to an asynchronous method simply result in a <code>Runnable</code> being created that wraps the method and parameters you gave. This runnable is given to an [Executor][3] which is simply a work queue attached to a thread pool.</p>
+</li>
+<li>
+<p>After adding the work to the queue, the proxied version of the method returns an implementation of <code>Future</code> that is linked to the <code>Runnable</code> which is now waiting on the queue.</p>
+</li>
+<li>
+<p>When the <code>Runnable</code> finally executes the method on the <strong>real</strong> <code>JobProcessor</code> instance, it will take the return value and set it into the <code>Future</code> making it available to the caller.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Important to note that the <code>AsyncResult</code> object the <code>JobProcessor</code> returns is not the same <code>Future</code> object the caller is holding. It would have been neat if the real <code>JobProcessor</code> could just return <code>String</code> and the caller’s version of <code>JobProcessor</code> could return <code>Future<String></code>, but we didn’t see any way to do that without adding more complexity. So the <code>AsyncResult</code> is a simple wrapper object. The container will pull the <code>String</code> out, throw the <code>AsyncResult</code> away, then put the <code>String</code> in the <strong>real</strong> <code>Future</code> that the caller is holding.</p>
+</div>
+<div class="paragraph">
+<p>To get progress along the way, simply pass a thread-safe object like [AtomicInteger][4] to the <code>@Asynchronous</code> method and have the bean code periodically update it with the percent complete.</p>
+</div>
+<h1 id="_related_examples" class="sect0">Related Examples</h1>
+<div class="paragraph">
+<p>For complex asynchronous processing, JavaEE’s answer is <code>@MessageDrivenBean</code>. Have a look at the <a href="simple-mdb.html">simple-mdb</a> example</p>
+</div>
+<div class="paragraph">
+<p>[1]: <a href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html" class="bare">http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html</a>
+[3]: <a href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Executor.html" class="bare">http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Executor.html</a>
+[4]: <a href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html" class="bare">http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html</a></p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/async-methods.pdf b/content/examples/async-methods.pdf
new file mode 100644
index 0000000..3035d76
--- /dev/null
+++ b/content/examples/async-methods.pdf
Binary files differ
diff --git a/content/examples/async-methods/README.md b/content/examples/async-methods/README.md
new file mode 100755
index 0000000..4849843
--- /dev/null
+++ b/content/examples/async-methods/README.md
@@ -0,0 +1,154 @@
+Title: @Asynchronous Methods
+
+The @Asynchronous annotation was introduced in EJB 3.1 as a simple way of creating asynchronous processing.
+
+Every time a method annotated `@Asynchronous` is invoked by anyone it will immediately return regardless of how long the method actually takes. Each invocation returns a [Future][1] object that essentially starts out *empty* and will later have its value filled in by the container when the related method call actually completes. Returning a `Future` object is not required and `@Asynchronous` methods can of course return `void`.
+
+# Example
+
+Here, in `JobProcessorTest`,
+
+`final Future<String> red = processor.addJob("red");`
+proceeds to the next statement,
+
+`final Future<String> orange = processor.addJob("orange");`
+
+without waiting for the addJob() method to complete. And later we could ask for the result using the `Future<?>.get()` method like
+
+`assertEquals("blue", blue.get());`
+
+It waits for the processing to complete (if its not completed already) and gets the result. If you did not care about the result, you could simply have your asynchronous method as a void method.
+
+[Future][1] Object from docs,
+
+> A Future represents the result of an asynchronous computation. Methods are provided to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation. The result can only be retrieved using method get when the computation has completed, blocking if necessary until it is ready. Cancellation is performed by the cancel method. Additional methods are provided to determine if the task completed normally or was cancelled. Once a computation has completed, the computation cannot be cancelled. If you would like to use a Future for the sake of cancellability but not provide a usable result, you can declare types of the form Future<?> and return null as a result of the underlying task
+
+
+
+# The code
+ @Singleton
+ public class JobProcessor {
+ @Asynchronous
+ @Lock(READ)
+ @AccessTimeout(-1)
+ public Future<String> addJob(String jobName) {
+
+ // Pretend this job takes a while
+ doSomeHeavyLifting();
+
+ // Return our result
+ return new AsyncResult<String>(jobName);
+ }
+
+ private void doSomeHeavyLifting() {
+ try {
+ Thread.sleep(SECONDS.toMillis(10));
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+# Test
+ public class JobProcessorTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final JobProcessor processor = (JobProcessor) context.lookup("java:global/async-methods/JobProcessor");
+
+ final long start = System.nanoTime();
+
+ // Queue up a bunch of work
+ final Future<String> red = processor.addJob("red");
+ final Future<String> orange = processor.addJob("orange");
+ final Future<String> yellow = processor.addJob("yellow");
+ final Future<String> green = processor.addJob("green");
+ final Future<String> blue = processor.addJob("blue");
+ final Future<String> violet = processor.addJob("violet");
+
+ // Wait for the result -- 1 minute worth of work
+ assertEquals("blue", blue.get());
+ assertEquals("orange", orange.get());
+ assertEquals("green", green.get());
+ assertEquals("red", red.get());
+ assertEquals("yellow", yellow.get());
+ assertEquals("violet", violet.get());
+
+ // How long did it take?
+ final long total = TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
+
+ // Execution should be around 9 - 21 seconds
+ // The execution time depends on the number of threads available for asynchronous execution.
+ // In the best case it is 10s plus some minimal processing time.
+ assertTrue("Expected > 9 but was: " + total, total > 9);
+ assertTrue("Expected < 21 but was: " + total, total < 21);
+
+ }
+ }
+#Running
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.async.JobProcessorTest
+ Apache OpenEJB 4.0.0-SNAPSHOT build: 20110801-04:02
+ http://openejb.apache.org/
+ INFO - openejb.home = G:\Workspace\fullproject\openejb3\examples\async-methods
+ INFO - openejb.base = G:\Workspace\fullproject\openejb3\examples\async-methods
+ 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: g:\Workspace\fullproject\openejb3\examples\async-methods\target\classes
+ INFO - Beginning load: g:\Workspace\fullproject\openejb3\examples\async-methods\target\classes
+ INFO - Configuring enterprise application: g:\Workspace\fullproject\openejb3\examples\async-methods
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean JobProcessor: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.async.JobProcessorTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "g:\Workspace\fullproject\openejb3\examples\async-methods" loaded.
+ INFO - Assembling app: g:\Workspace\fullproject\openejb3\examples\async-methods
+ INFO - Jndi(name="java:global/async-methods/JobProcessor!org.superbiz.async.JobProcessor")
+ INFO - Jndi(name="java:global/async-methods/JobProcessor")
+ INFO - Jndi(name="java:global/EjbModule100568296/org.superbiz.async.JobProcessorTest!org.superbiz.async.JobProcessorTest")
+ INFO - Jndi(name="java:global/EjbModule100568296/org.superbiz.async.JobProcessorTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.async.JobProcessorTest, ejb-name=org.superbiz.async.JobProcessorTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=JobProcessor, ejb-name=JobProcessor, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.async.JobProcessorTest, ejb-name=org.superbiz.async.JobProcessorTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=JobProcessor, ejb-name=JobProcessor, container=Default Singleton Container)
+ INFO - Deployed Application(path=g:\Workspace\fullproject\openejb3\examples\async-methods)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.305 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+ [INFO] ------------------------------------------------------------------------
+ [INFO] BUILD SUCCESS
+ [INFO] ------------------------------------------------------------------------
+ [INFO] Total time: 21.097s
+ [INFO] Finished at: Wed Aug 03 22:48:26 IST 2011
+ [INFO] Final Memory: 13M/145M
+ [INFO] ------------------------------------------------------------------------
+
+# How it works <small>under the covers</small>
+
+Under the covers what makes this work is:
+
+ - The `JobProcessor` the caller sees is not actually an instance of `JobProcessor`. Rather it's a subclass or proxy that has all the methods overridden. Methods that are supposed to be asynchronous are handled differently.
+ - Calls to an asynchronous method simply result in a `Runnable` being created that wraps the method and parameters you gave. This runnable is given to an [Executor][3] which is simply a work queue attached to a thread pool.
+ - After adding the work to the queue, the proxied version of the method returns an implementation of `Future` that is linked to the `Runnable` which is now waiting on the queue.
+ - When the `Runnable` finally executes the method on the *real* `JobProcessor` instance, it will take the return value and set it into the `Future` making it available to the caller.
+
+Important to note that the `AsyncResult` object the `JobProcessor` returns is not the same `Future` object the caller is holding. It would have been neat if the real `JobProcessor` could just return `String` and the caller's version of `JobProcessor` could return `Future<String>`, but we didn't see any way to do that without adding more complexity. So the `AsyncResult` is a simple wrapper object. The container will pull the `String` out, throw the `AsyncResult` away, then put the `String` in the *real* `Future` that the caller is holding.
+
+To get progress along the way, simply pass a thread-safe object like [AtomicInteger][4] to the `@Asynchronous` method and have the bean code periodically update it with the percent complete.
+
+#Related Examples
+
+For complex asynchronous processing, JavaEE's answer is `@MessageDrivenBean`. Have a look at the [simple-mdb](../simple-mdb/README.html) example
+
+[1]: http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html
+[3]: http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Executor.html
+[4]: http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/AtomicInteger.html
+
diff --git a/content/examples/async-methods/build.xml b/content/examples/async-methods/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/async-methods/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/async-methods/pom.xml b/content/examples/async-methods/pom.xml
new file mode 100755
index 0000000..1030627
--- /dev/null
+++ b/content/examples/async-methods/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>async-methods</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @Asynchronous Methods</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/async-methods/src/main/java/org/superbiz/async/JobProcessor.java b/content/examples/async-methods/src/main/java/org/superbiz/async/JobProcessor.java
new file mode 100755
index 0000000..d543484
--- /dev/null
+++ b/content/examples/async-methods/src/main/java/org/superbiz/async/JobProcessor.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.async;
+
+import javax.ejb.AccessTimeout;
+import javax.ejb.AsyncResult;
+import javax.ejb.Asynchronous;
+import javax.ejb.Lock;
+import javax.ejb.Singleton;
+import java.util.concurrent.Future;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static javax.ejb.LockType.READ;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@Singleton
+public class JobProcessor {
+
+ @Asynchronous
+ @Lock(READ)
+ @AccessTimeout(-1)
+ public Future<String> addJob(String jobName) {
+
+ // Pretend this job takes a while
+ doSomeHeavyLifting();
+
+ // Return our result
+ return new AsyncResult<String>(jobName);
+ }
+
+ private void doSomeHeavyLifting() {
+ try {
+ Thread.sleep(SECONDS.toMillis(10));
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ throw new IllegalStateException(e);
+ }
+ }
+}
diff --git a/content/examples/async-methods/src/test/java/org/superbiz/async/JobProcessorTest.java b/content/examples/async-methods/src/test/java/org/superbiz/async/JobProcessorTest.java
new file mode 100755
index 0000000..48cf4ee
--- /dev/null
+++ b/content/examples/async-methods/src/test/java/org/superbiz/async/JobProcessorTest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.async;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class JobProcessorTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final JobProcessor processor = (JobProcessor) context.lookup("java:global/async-methods/JobProcessor");
+
+ final long start = System.nanoTime();
+
+ // Queue up a bunch of work
+ final Future<String> red = processor.addJob("red");
+ final Future<String> orange = processor.addJob("orange");
+ final Future<String> yellow = processor.addJob("yellow");
+ final Future<String> green = processor.addJob("green");
+ final Future<String> blue = processor.addJob("blue");
+ final Future<String> violet = processor.addJob("violet");
+
+ // Wait for the result -- 1 minute worth of work
+ assertEquals("blue", blue.get());
+ assertEquals("orange", orange.get());
+ assertEquals("green", green.get());
+ assertEquals("red", red.get());
+ assertEquals("yellow", yellow.get());
+ assertEquals("violet", violet.get());
+
+ // How long did it take?
+ final long total = TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start);
+
+ // Execution should be around 9 - 21 seconds
+ // The execution time depends on the number of threads available for asynchronous execution.
+ // In the best case it is 10s plus some minimal processing time.
+ assertTrue("Expected > 9 but was: " + total, total > 9);
+ assertTrue("Expected < 21 but was: " + total, total < 21);
+
+ }
+
+}
diff --git a/content/examples/async-postconstruct.html b/content/examples/async-postconstruct.html
new file mode 100644
index 0000000..443e332
--- /dev/null
+++ b/content/examples/async-postconstruct.html
@@ -0,0 +1,325 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/async-postconstruct.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>@Asynchronous @PostConstruct</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example async-postconstruct can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/async-postconstruct" class="bare">https://github.com/apache/tomee/tree/master/examples/async-postconstruct</a></p>
+</div>
+<div class="paragraph">
+<p>Placing <code>@Asynchronous</code> on the <code>@PostConstruct</code> of an EJB is not a supported part of Java EE, but this example shows a pattern which works just as well with little effort.</p>
+</div>
+<div class="paragraph">
+<p>The heart of this pattern is to:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>pass the construction "logic" to an <code>@Asynchronous</code> method via a <code>java.util.concurrent.Callable</code></p>
+</li>
+<li>
+<p>ensure the bean does not process invocations till construction is complete via an <code>@AroundInvoke</code> method on the bean and the <code>java.util.concurrent.Future</code></p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Simple and effective. The result is a faster starting application that is still thread-safe.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.asyncpost;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+@Singleton
+@Lock(LockType.READ)
+public class SlowStarter {
+
+ @EJB
+ private Executor executor;
+
+ private Future construct;
+
+ private String color;
+ private String shape;
+
+ @PostConstruct
+ private void construct() throws Exception {
+ construct = executor.submit(new Callable() {
+ @Override
+ public Object call() throws Exception {
+ Thread.sleep(SECONDS.toMillis(10));
+ SlowStarter.this.color = "orange";
+ SlowStarter.this.shape = "circle";
+ return null;
+ }
+ });
+ }
+
+ @AroundInvoke
+ private Object guaranteeConstructionComplete(InvocationContext context) throws Exception {
+ construct.get();
+ return context.proceed();
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public String getShape() {
+ return shape;
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The <code>Executor</code> is a simple pattern, useful for many things, which exposes an interface functionaly equivalent to <code>java.util.concurrent.ExecutorService</code>, but
+with the underlying thread pool controlled by the container.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.asyncpost;
+
+import javax.ejb.AsyncResult;
+import javax.ejb.Asynchronous;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+@Singleton
+@Lock(LockType.READ)
+public class Executor {
+
+ @Asynchronous
+ public <T> Future<T> submit(Callable<T> task) throws Exception {
+ return new AsyncResult<T>(task.call());
+ }
+
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Finally a test case shows the usefulness of <code>@AroundInvoke</code> call in our bean that calls <code>construct.get()</code></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.asyncpost;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+
+public class SlowStarterTest {
+
+ @EJB
+ private SlowStarter slowStarter;
+
+ @Test
+ public void test() throws Exception {
+
+ // Start the Container
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ // Immediately access the fields initialized in the PostConstruct
+ // This will fail without the @AroundInvoke call to construct.get()
+ Assert.assertEquals("orange", slowStarter.getColor());
+ Assert.assertEquals("circle", slowStarter.getShape());
+ }
+}</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/async-postconstruct.pdf b/content/examples/async-postconstruct.pdf
new file mode 100644
index 0000000..16a0a6c
--- /dev/null
+++ b/content/examples/async-postconstruct.pdf
Binary files differ
diff --git a/content/examples/async-postconstruct/README.md b/content/examples/async-postconstruct/README.md
new file mode 100755
index 0000000..f2f7710
--- /dev/null
+++ b/content/examples/async-postconstruct/README.md
@@ -0,0 +1,118 @@
+Title: @Asynchronous @PostConstruct
+
+Placing `@Asynchronous` on the `@PostConstruct` of an EJB is not a supported part of Java EE, but this example shows a pattern which works just as well with little effort.
+
+The heart of this pattern is to:
+
+ - pass the construction "logic" to an `@Asynchronous` method via a `java.util.concurrent.Callable`
+ - ensure the bean does not process invocations till construction is complete via an `@AroundInvoke` method on the bean and the `java.util.concurrent.Future`
+
+Simple and effective. The result is a faster starting application that is still thread-safe.
+
+ package org.superbiz.asyncpost;
+
+ import javax.annotation.PostConstruct;
+ import javax.ejb.EJB;
+ import javax.ejb.Lock;
+ import javax.ejb.LockType;
+ import javax.ejb.Singleton;
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+ import java.util.concurrent.Callable;
+ import java.util.concurrent.Future;
+
+ import static java.util.concurrent.TimeUnit.SECONDS;
+
+ @Singleton
+ @Lock(LockType.READ)
+ public class SlowStarter {
+
+ @EJB
+ private Executor executor;
+
+ private Future construct;
+
+ private String color;
+ private String shape;
+
+ @PostConstruct
+ private void construct() throws Exception {
+ construct = executor.submit(new Callable() {
+ @Override
+ public Object call() throws Exception {
+ Thread.sleep(SECONDS.toMillis(10));
+ SlowStarter.this.color = "orange";
+ SlowStarter.this.shape = "circle";
+ return null;
+ }
+ });
+ }
+
+ @AroundInvoke
+ private Object guaranteeConstructionComplete(InvocationContext context) throws Exception {
+ construct.get();
+ return context.proceed();
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public String getShape() {
+ return shape;
+ }
+ }
+
+
+The `Executor` is a simple pattern, useful for many things, which exposes an interface functionaly equivalent to `java.util.concurrent.ExecutorService`, but
+with the underlying thread pool controlled by the container.
+
+ package org.superbiz.asyncpost;
+
+ import javax.ejb.AsyncResult;
+ import javax.ejb.Asynchronous;
+ import javax.ejb.Lock;
+ import javax.ejb.LockType;
+ import javax.ejb.Singleton;
+ import java.util.concurrent.Callable;
+ import java.util.concurrent.Future;
+
+ @Singleton
+ @Lock(LockType.READ)
+ public class Executor {
+
+ @Asynchronous
+ public <T> Future<T> submit(Callable<T> task) throws Exception {
+ return new AsyncResult<T>(task.call());
+ }
+
+ }
+
+
+Finally a test case shows the usefulness of `@AroundInvoke` call in our bean that calls `construct.get()`
+
+ package org.superbiz.asyncpost;
+
+ import junit.framework.Assert;
+ import org.junit.Test;
+
+ import javax.ejb.EJB;
+ import javax.ejb.embeddable.EJBContainer;
+
+ public class SlowStarterTest {
+
+ @EJB
+ private SlowStarter slowStarter;
+
+ @Test
+ public void test() throws Exception {
+
+ // Start the Container
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ // Immediately access the fields initialized in the PostConstruct
+ // This will fail without the @AroundInvoke call to construct.get()
+ Assert.assertEquals("orange", slowStarter.getColor());
+ Assert.assertEquals("circle", slowStarter.getShape());
+ }
+ }
diff --git a/content/examples/async-postconstruct/build.xml b/content/examples/async-postconstruct/build.xml
new file mode 100755
index 0000000..e22cc00
--- /dev/null
+++ b/content/examples/async-postconstruct/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 16:48:17 -0800 (Sun, 29 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/async-postconstruct/pom.xml b/content/examples/async-postconstruct/pom.xml
new file mode 100755
index 0000000..5afd238
--- /dev/null
+++ b/content/examples/async-postconstruct/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1461000 $ $Date: 2013-03-26 00:13:43 -0700 (Tue, 26 Mar 2013) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>async-postconstruct</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @Asynchronous @PostConstrct</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/async-postconstruct/src/main/java/org/superbiz/asyncpost/Executor.java b/content/examples/async-postconstruct/src/main/java/org/superbiz/asyncpost/Executor.java
new file mode 100755
index 0000000..27e524e
--- /dev/null
+++ b/content/examples/async-postconstruct/src/main/java/org/superbiz/asyncpost/Executor.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.asyncpost;
+
+import javax.ejb.AsyncResult;
+import javax.ejb.Asynchronous;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+@Singleton
+@Lock(LockType.READ)
+public class Executor {
+
+ @Asynchronous
+ public <T> Future<T> submit(Callable<T> task) throws Exception {
+ return new AsyncResult<T>(task.call());
+ }
+
+}
diff --git a/content/examples/async-postconstruct/src/main/java/org/superbiz/asyncpost/SlowStarter.java b/content/examples/async-postconstruct/src/main/java/org/superbiz/asyncpost/SlowStarter.java
new file mode 100755
index 0000000..6d1f915
--- /dev/null
+++ b/content/examples/async-postconstruct/src/main/java/org/superbiz/asyncpost/SlowStarter.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.asyncpost;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.AroundTimeout;
+import javax.interceptor.InvocationContext;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+@Singleton
+@Lock(LockType.READ)
+public class SlowStarter {
+
+ @EJB
+ private Executor executor;
+
+ private Future construct;
+
+ private String color;
+ private String shape;
+
+ @PostConstruct
+ private void construct() throws Exception {
+ construct = executor.submit(new Callable() {
+ @Override
+ public Object call() throws Exception {
+ Thread.sleep(SECONDS.toMillis(10));
+ SlowStarter.this.color = "orange";
+ SlowStarter.this.shape = "circle";
+ return null;
+ }
+ });
+ }
+
+ @AroundTimeout
+ @AroundInvoke
+ private Object guaranteeConstructionComplete(InvocationContext context) throws Exception {
+ construct.get();
+ return context.proceed();
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public String getShape() {
+ return shape;
+ }
+}
diff --git a/content/examples/async-postconstruct/src/test/java/org/superbiz/asyncpost/SlowStarterTest.java b/content/examples/async-postconstruct/src/test/java/org/superbiz/asyncpost/SlowStarterTest.java
new file mode 100755
index 0000000..8d1d51b
--- /dev/null
+++ b/content/examples/async-postconstruct/src/test/java/org/superbiz/asyncpost/SlowStarterTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.asyncpost;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+
+public class SlowStarterTest {
+
+ @EJB
+ private SlowStarter slowStarter;
+
+ @Test
+ public void test() throws Exception {
+
+ // Start the Container
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ // Immediately access the fields initialized in the PostConstruct
+ // This will fail without the @AroundInvoke call to construct.get()
+ Assert.assertEquals("orange", slowStarter.getColor());
+ Assert.assertEquals("circle", slowStarter.getShape());
+ }
+}
diff --git a/content/examples/bean-validation-design-by-contract.html b/content/examples/bean-validation-design-by-contract.html
new file mode 100644
index 0000000..6e58216
--- /dev/null
+++ b/content/examples/bean-validation-design-by-contract.html
@@ -0,0 +1,430 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/bean-validation-design-by-contract.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>bean-validation-design-by-contract</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example bean-validation-design-by-contract can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/bean-validation-design-by-contract" class="bare">https://github.com/apache/tomee/tree/master/examples/bean-validation-design-by-contract</a></p>
+</div>
+</div>
+</div>
+<h1 id="_bean_validation_design_by_contract" class="sect0">Bean Validation - Design By Contract</h1>
+<div class="paragraph">
+<p>Bean Validation (aka JSR 303) contains an optional appendix dealing with method validation.</p>
+</div>
+<div class="paragraph">
+<p>Some implementions of this JSR implement this appendix (Apache bval, Hibernate validator for example).</p>
+</div>
+<div class="paragraph">
+<p>OpenEJB provides an interceptor which allows you to use this feature to do design by contract.</p>
+</div>
+<h1 id="_design_by_contract" class="sect0">Design by contract</h1>
+<div class="paragraph">
+<p>The goal is to be able to configure with a finer grain your contract. In the example you specify
+the minimum centimeters a sport man should jump at pole vaulting:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Local
+public interface PoleVaultingManager {
+ int points(@Min(120) int centimeters);
+}</code></pre>
+</div>
+</div>
+<h1 id="_usage" class="sect0">Usage</h1>
+<div class="paragraph">
+<p>TomEE and OpenEJB do not provide anymore <code>BeanValidationAppendixInterceptor</code> since
+Bean Validation 1.1 does it (with a slighly different usage but the exact same feature).</p>
+</div>
+<div class="paragraph">
+<p>So basically you don’t need to configure anything to use it.
+= Errors</p>
+</div>
+<div class="paragraph">
+<p>If a parameter is not validated an exception is thrown, it is an EJBException wrapping a ConstraintViolationException:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>try {
+ gamesManager.addSportMan("I lose", "EN");
+ fail("no space should be in names");
+} catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+}</pre>
+</div>
+</div>
+<h1 id="_example" class="sect0">Example</h1>
+<div class="sect1">
+<h2 id="_olympicgamesmanager">OlympicGamesManager</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.designbycontract;
+
+import javax.ejb.Stateless;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+
+@Stateless
+public class OlympicGamesManager {
+ public String addSportMan(@Pattern(regexp = "^[A-Za-z]+$") String name, @Size(min = 2, max = 4) String country) {
+ if (country.equals("USA")) {
+ return null;
+ }
+ return new StringBuilder(name).append(" [").append(country).append("]").toString();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_polevaultingmanager">PoleVaultingManager</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.designbycontract;
+
+import javax.ejb.Local;
+import javax.validation.constraints.Min;
+
+@Local
+public interface PoleVaultingManager {
+ int points(@Min(120) int centimeters);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_polevaultingmanagerbean">PoleVaultingManagerBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.designbycontract;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class PoleVaultingManagerBean implements PoleVaultingManager {
+ @Override
+ public int points(int centimeters) {
+ return centimeters - 120;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_olympicgamestest">OlympicGamesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class OlympicGamesTest {
+ private static Context context;
+
+ @EJB
+ private OlympicGamesManager gamesManager;
+
+ @EJB
+ private PoleVaultingManager poleVaultingManager;
+
+ @BeforeClass
+ public static void start() {
+ Properties properties = new Properties();
+ properties.setProperty(BeanContext.USER_INTERCEPTOR_KEY, BeanValidationAppendixInterceptor.class.getName());
+ context = EJBContainer.createEJBContainer(properties).getContext();
+ }
+
+ @Before
+ public void inject() throws Exception {
+ context.bind("inject", this);
+ }
+
+ @AfterClass
+ public static void stop() throws Exception {
+ if (context != null) {
+ context.close();
+ }
+ }
+
+ @Test
+ public void sportMenOk() throws Exception {
+ assertEquals("IWin [FR]", gamesManager.addSportMan("IWin", "FR"));
+ }
+
+ @Test
+ public void sportMenKoBecauseOfName() throws Exception {
+ try {
+ gamesManager.addSportMan("I lose", "EN");
+ fail("no space should be in names");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+ }
+
+ @Test
+ public void sportMenKoBecauseOfCountry() throws Exception {
+ try {
+ gamesManager.addSportMan("ILoseTwo", "TOO-LONG");
+ fail("country should be between 2 and 4 characters");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+ }
+
+ @Test
+ public void polVaulting() throws Exception {
+ assertEquals(100, poleVaultingManager.points(220));
+ }
+
+ @Test
+ public void tooShortPolVaulting() throws Exception {
+ try {
+ poleVaultingManager.points(119);
+ fail("the jump is too short");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running OlympicGamesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/bean-validation-design-by-contract
+INFO - openejb.base = /Users/dblevins/examples/bean-validation-design-by-contract
+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/bean-validation-design-by-contract/target/classes
+INFO - Beginning load: /Users/dblevins/examples/bean-validation-design-by-contract/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/bean-validation-design-by-contract
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean PoleVaultingManagerBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean OlympicGamesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/bean-validation-design-by-contract" loaded.
+INFO - Assembling app: /Users/dblevins/examples/bean-validation-design-by-contract
+INFO - Jndi(name="java:global/bean-validation-design-by-contract/PoleVaultingManagerBean!org.superbiz.designbycontract.PoleVaultingManager")
+INFO - Jndi(name="java:global/bean-validation-design-by-contract/PoleVaultingManagerBean")
+INFO - Jndi(name="java:global/bean-validation-design-by-contract/OlympicGamesManager!org.superbiz.designbycontract.OlympicGamesManager")
+INFO - Jndi(name="java:global/bean-validation-design-by-contract/OlympicGamesManager")
+INFO - Jndi(name="java:global/EjbModule236054577/OlympicGamesTest!OlympicGamesTest")
+INFO - Jndi(name="java:global/EjbModule236054577/OlympicGamesTest")
+INFO - Created Ejb(deployment-id=OlympicGamesManager, ejb-name=OlympicGamesManager, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=PoleVaultingManagerBean, ejb-name=PoleVaultingManagerBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=OlympicGamesTest, ejb-name=OlympicGamesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=OlympicGamesManager, ejb-name=OlympicGamesManager, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=PoleVaultingManagerBean, ejb-name=PoleVaultingManagerBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=OlympicGamesTest, ejb-name=OlympicGamesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/bean-validation-design-by-contract)
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.245 sec
+
+Results :
+
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/bean-validation-design-by-contract.pdf b/content/examples/bean-validation-design-by-contract.pdf
new file mode 100644
index 0000000..a51351d
--- /dev/null
+++ b/content/examples/bean-validation-design-by-contract.pdf
Binary files differ
diff --git a/content/examples/bean-validation-design-by-contract/README.md b/content/examples/bean-validation-design-by-contract/README.md
new file mode 100755
index 0000000..69023f8
--- /dev/null
+++ b/content/examples/bean-validation-design-by-contract/README.md
@@ -0,0 +1,208 @@
+# Bean Validation - Design By Contract
+
+Bean Validation (aka JSR 303) contains an optional appendix dealing with method validation.
+
+Some implementions of this JSR implement this appendix (Apache bval, Hibernate validator for example).
+
+OpenEJB provides an interceptor which allows you to use this feature to do design by contract.
+
+# Design by contract
+
+The goal is to be able to configure with a finer grain your contract. In the example you specify
+the minimum centimeters a sport man should jump at pole vaulting:
+
+ @Local
+ public interface PoleVaultingManager {
+ int points(@Min(120) int centimeters);
+ }
+
+# Usage
+
+To use this feature you have to add the BeanValidationAppendixInterceptor interceptor.
+
+In unit test simply put a properties in your context properties:
+
+ properties.setProperty(BeanContext.USER_INTERCEPTOR_KEY, BeanValidationAppendixInterceptor.class.getName());
+
+In a production environment or in tomcat add the properties in conf/system.properties for example:
+
+ org.apache.openejb.default.system.interceptors = org.apache.openejb.bval.BeanValidationAppendixInterceptor
+
+# Errors
+
+If a parameter is not validated an exception is thrown, it is an EJBException wrapping a ConstraintViolationException:
+
+ try {
+ gamesManager.addSportMan("I lose", "EN");
+ fail("no space should be in names");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+
+# Example
+
+## OlympicGamesManager
+
+ package org.superbiz.designbycontract;
+
+ import javax.ejb.Stateless;
+ import javax.validation.constraints.NotNull;
+ import javax.validation.constraints.Pattern;
+ import javax.validation.constraints.Size;
+
+ @Stateless
+ public class OlympicGamesManager {
+ public String addSportMan(@Pattern(regexp = "^[A-Za-z]+$") String name, @Size(min = 2, max = 4) String country) {
+ if (country.equals("USA")) {
+ return null;
+ }
+ return new StringBuilder(name).append(" [").append(country).append("]").toString();
+ }
+ }
+
+## PoleVaultingManager
+
+ package org.superbiz.designbycontract;
+
+ import javax.ejb.Local;
+ import javax.validation.constraints.Min;
+
+ @Local
+ public interface PoleVaultingManager {
+ int points(@Min(120) int centimeters);
+ }
+
+## PoleVaultingManagerBean
+
+ package org.superbiz.designbycontract;
+
+ import javax.ejb.Stateless;
+
+ @Stateless
+ public class PoleVaultingManagerBean implements PoleVaultingManager {
+ @Override
+ public int points(int centimeters) {
+ return centimeters - 120;
+ }
+ }
+
+## OlympicGamesTest
+
+ public class OlympicGamesTest {
+ private static Context context;
+
+ @EJB
+ private OlympicGamesManager gamesManager;
+
+ @EJB
+ private PoleVaultingManager poleVaultingManager;
+
+ @BeforeClass
+ public static void start() {
+ Properties properties = new Properties();
+ properties.setProperty(BeanContext.USER_INTERCEPTOR_KEY, BeanValidationAppendixInterceptor.class.getName());
+ context = EJBContainer.createEJBContainer(properties).getContext();
+ }
+
+ @Before
+ public void inject() throws Exception {
+ context.bind("inject", this);
+ }
+
+ @AfterClass
+ public static void stop() throws Exception {
+ if (context != null) {
+ context.close();
+ }
+ }
+
+ @Test
+ public void sportMenOk() throws Exception {
+ assertEquals("IWin [FR]", gamesManager.addSportMan("IWin", "FR"));
+ }
+
+ @Test
+ public void sportMenKoBecauseOfName() throws Exception {
+ try {
+ gamesManager.addSportMan("I lose", "EN");
+ fail("no space should be in names");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+ }
+
+ @Test
+ public void sportMenKoBecauseOfCountry() throws Exception {
+ try {
+ gamesManager.addSportMan("ILoseTwo", "TOO-LONG");
+ fail("country should be between 2 and 4 characters");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+ }
+
+ @Test
+ public void polVaulting() throws Exception {
+ assertEquals(100, poleVaultingManager.points(220));
+ }
+
+ @Test
+ public void tooShortPolVaulting() throws Exception {
+ try {
+ poleVaultingManager.points(119);
+ fail("the jump is too short");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running OlympicGamesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/bean-validation-design-by-contract
+ INFO - openejb.base = /Users/dblevins/examples/bean-validation-design-by-contract
+ 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/bean-validation-design-by-contract/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/bean-validation-design-by-contract/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/bean-validation-design-by-contract
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean PoleVaultingManagerBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean OlympicGamesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/bean-validation-design-by-contract" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/bean-validation-design-by-contract
+ INFO - Jndi(name="java:global/bean-validation-design-by-contract/PoleVaultingManagerBean!org.superbiz.designbycontract.PoleVaultingManager")
+ INFO - Jndi(name="java:global/bean-validation-design-by-contract/PoleVaultingManagerBean")
+ INFO - Jndi(name="java:global/bean-validation-design-by-contract/OlympicGamesManager!org.superbiz.designbycontract.OlympicGamesManager")
+ INFO - Jndi(name="java:global/bean-validation-design-by-contract/OlympicGamesManager")
+ INFO - Jndi(name="java:global/EjbModule236054577/OlympicGamesTest!OlympicGamesTest")
+ INFO - Jndi(name="java:global/EjbModule236054577/OlympicGamesTest")
+ INFO - Created Ejb(deployment-id=OlympicGamesManager, ejb-name=OlympicGamesManager, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=PoleVaultingManagerBean, ejb-name=PoleVaultingManagerBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=OlympicGamesTest, ejb-name=OlympicGamesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=OlympicGamesManager, ejb-name=OlympicGamesManager, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=PoleVaultingManagerBean, ejb-name=PoleVaultingManagerBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=OlympicGamesTest, ejb-name=OlympicGamesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/bean-validation-design-by-contract)
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.245 sec
+
+ Results :
+
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
diff --git a/content/examples/bean-validation-design-by-contract/pom.xml b/content/examples/bean-validation-design-by-contract/pom.xml
new file mode 100755
index 0000000..a9e87c8
--- /dev/null
+++ b/content/examples/bean-validation-design-by-contract/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>bean-validation-design-by-contract</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Bean Validation Design By Contract</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The scope test is to avoid to have any openejb binaries delivered by the application.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/OlympicGamesManager.java b/content/examples/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/OlympicGamesManager.java
new file mode 100755
index 0000000..7293a5c
--- /dev/null
+++ b/content/examples/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/OlympicGamesManager.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.designbycontract;
+
+import javax.ejb.Stateless;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+
+@Stateless
+public class OlympicGamesManager {
+
+ public String addSportMan(@Pattern(regexp = "^[A-Za-z]+$") String name, @Size(min = 2, max = 4) String country) {
+ if (country.equals("USA")) {
+ return null;
+ }
+ return new StringBuilder(name).append(" [").append(country).append("]").toString();
+ }
+}
diff --git a/content/examples/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/PoleVaultingManager.java b/content/examples/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/PoleVaultingManager.java
new file mode 100755
index 0000000..fd56af0
--- /dev/null
+++ b/content/examples/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/PoleVaultingManager.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.designbycontract;
+
+import javax.ejb.Local;
+import javax.validation.constraints.Min;
+
+@Local
+public interface PoleVaultingManager {
+
+ int points(@Min(120) int centimeters);
+}
diff --git a/content/examples/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/PoleVaultingManagerBean.java b/content/examples/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/PoleVaultingManagerBean.java
new file mode 100755
index 0000000..c253c8c
--- /dev/null
+++ b/content/examples/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/PoleVaultingManagerBean.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.designbycontract;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class PoleVaultingManagerBean implements PoleVaultingManager {
+
+ @Override
+ public int points(int centimeters) {
+ return centimeters - 120;
+ }
+}
diff --git a/content/examples/bean-validation-design-by-contract/src/test/java/org/superbiz/designbycontract/OlympicGamesTest.java b/content/examples/bean-validation-design-by-contract/src/test/java/org/superbiz/designbycontract/OlympicGamesTest.java
new file mode 100755
index 0000000..9dbc019
--- /dev/null
+++ b/content/examples/bean-validation-design-by-contract/src/test/java/org/superbiz/designbycontract/OlympicGamesTest.java
@@ -0,0 +1,110 @@
+package org.superbiz.designbycontract;/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.openejb.BeanContext;
+import org.apache.openejb.bval.BeanValidationAppendixInterceptor;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.validation.ConstraintViolationException;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class OlympicGamesTest {
+
+ private static Context context;
+
+ @EJB
+ private OlympicGamesManager gamesManager;
+
+ @EJB
+ private PoleVaultingManager poleVaultingManager;
+
+ @BeforeClass
+ public static void start() {
+ Properties properties = new Properties();
+ properties.setProperty(BeanContext.USER_INTERCEPTOR_KEY, BeanValidationAppendixInterceptor.class.getName());
+ context = EJBContainer.createEJBContainer(properties).getContext();
+ }
+
+ @Before
+ public void inject() throws Exception {
+ context.bind("inject", this);
+ }
+
+ @AfterClass
+ public static void stop() throws Exception {
+ if (context != null) {
+ context.close();
+ }
+ }
+
+ @Test
+ public void sportMenOk() throws Exception {
+ assertEquals("IWin [FR]", gamesManager.addSportMan("IWin", "FR"));
+ }
+
+ @Test
+ public void sportMenKoBecauseOfName() throws Exception {
+ try {
+ gamesManager.addSportMan("I lose", "EN");
+ fail("no space should be in names");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+ }
+
+ @Test
+ public void sportMenKoBecauseOfCountry() throws Exception {
+ try {
+ gamesManager.addSportMan("ILoseTwo", "TOO-LONG");
+ fail("country should be between 2 and 4 characters");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+ }
+
+ @Test
+ public void polVaulting() throws Exception {
+ assertEquals(100, poleVaultingManager.points(220));
+ }
+
+ @Test
+ public void tooShortPolVaulting() throws Exception {
+ try {
+ poleVaultingManager.points(119);
+ fail("the jump is too short");
+ } catch (EJBException wrappingException) {
+ assertTrue(wrappingException.getCause() instanceof ConstraintViolationException);
+ ConstraintViolationException exception = ConstraintViolationException.class.cast(wrappingException.getCausedByException());
+ assertEquals(1, exception.getConstraintViolations().size());
+ }
+ }
+}
diff --git a/content/examples/buildbot.mdtext b/content/examples/buildbot.mdtext
new file mode 100755
index 0000000..e609fa8
--- /dev/null
+++ b/content/examples/buildbot.mdtext
@@ -0,0 +1,19 @@
+Notice: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+# Testing
+
+1 ... 2... 3!
diff --git a/content/examples/bval-evaluation-redeployment.html b/content/examples/bval-evaluation-redeployment.html
new file mode 100644
index 0000000..a188093
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment.html
@@ -0,0 +1,189 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/bval-evaluation-redeployment.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>bval-evaluation-redeployment</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example bval-evaluation-redeployment can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/bval-evaluation-redeployment" class="bare">https://github.com/apache/tomee/tree/master/examples/bval-evaluation-redeployment</a></p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/bval-evaluation-redeployment.pdf b/content/examples/bval-evaluation-redeployment.pdf
new file mode 100644
index 0000000..66c625c
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment.pdf
Binary files differ
diff --git a/content/examples/bval-evaluation-redeployment/README.md b/content/examples/bval-evaluation-redeployment/README.md
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/README.md
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/nb-configuration.xml b/content/examples/bval-evaluation-redeployment/WebApp1/nb-configuration.xml
new file mode 100755
index 0000000..1d2b373
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/nb-configuration.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project-shared-configuration>
+ <!--
+This file contains additional configuration written by modules in the NetBeans IDE.
+The configuration is intended to be shared among all the users of project and
+therefore it is assumed to be part of version control checkout.
+Without this configuration present, some functionality in the IDE may be limited or fail altogether.
+-->
+ <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
+ <!--
+Properties that influence various parts of the IDE, especially code formatting and the like.
+You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
+That way multiple projects can share the same settings (useful for formatting rules for example).
+Any value defined here will override the pom.xml file value but is only applicable to the current project.
+-->
+ <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.6-web
+ </org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
+ <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>Tomcat
+ </org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
+ <org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide
+ </org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
+ </properties>
+</project-shared-configuration>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/pom.xml b/content/examples/bval-evaluation-redeployment/WebApp1/pom.xml
new file mode 100755
index 0000000..8935c5a
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/pom.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.superbiz</groupId>
+ <artifactId>bval-evaluation-redeployment</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>WebApp1</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>war</packaging>
+
+ <name>WebApp1</name>
+
+ <properties>
+ <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArguments>
+ <endorseddirs>${endorsed.dir}</endorseddirs>
+ </compilerArguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${endorsed.dir}</outputDirectory>
+ <silent>true</silent>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax</groupId>
+ <artifactId>javaee-endorsed-api</artifactId>
+ <version>6.0</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/ejb/BusinessBean.java b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/ejb/BusinessBean.java
new file mode 100755
index 0000000..bdc8324
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/ejb/BusinessBean.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.webapp1.ejb;
+
+import javax.ejb.Stateless;
+import javax.validation.constraints.Pattern;
+
+@Stateless
+public class BusinessBean {
+
+ public void doStuff(@Pattern(regexp = "valid") final String txt) {
+ System.out.println("Received: " + txt);
+ }
+
+}
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/messages/ErrorList.java b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/messages/ErrorList.java
new file mode 100755
index 0000000..e1076c4
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/messages/ErrorList.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.webapp1.messages;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import java.util.ArrayList;
+import java.util.Collection;
+
+@XmlRootElement
+@XmlSeeAlso(ErrorResponse.class)
+public class ErrorList<T> extends ArrayList<T> {
+
+ private static final long serialVersionUID = -8861634470374757349L;
+
+ public ErrorList() {
+ }
+
+ public ErrorList(final Collection<? extends T> clctn) {
+ addAll(clctn);
+ }
+
+}
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/messages/ErrorResponse.java b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/messages/ErrorResponse.java
new file mode 100755
index 0000000..c5c7d37
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/messages/ErrorResponse.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.webapp1.messages;
+
+import javax.ws.rs.core.Response;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Date;
+
+@XmlRootElement
+public class ErrorResponse implements Serializable {
+ private static final long serialVersionUID = 8888101217538645771L;
+
+ private Long id;
+ private Response.Status status;
+ private String message;
+
+ public ErrorResponse() {
+ this.id = new Date().getTime();
+ }
+
+ public ErrorResponse(final Response.Status status, final String message) {
+ this.id = new Date().getTime();
+ this.status = status;
+ this.message = message;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(final Long id) {
+ this.id = id;
+ }
+
+ public Response.Status getStatus() {
+ return status;
+ }
+
+ @XmlAttribute
+ public void setStatus(final Response.Status status) {
+ this.status = status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ @XmlAttribute
+ public void setMessage(final String message) {
+ this.message = message;
+ }
+
+ // @Override
+// public String toString() {
+// return "{" + "id:" + id + ", status:" + status + ", message:" + message + '}';
+// }
+ @Override
+ public String toString() {
+ return "ErrorResponse:" + "id=" + id + ", status=" + status + ", message=" + message;
+ }
+}
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/provider/ConstraintViolationExceptionMapper.java b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/provider/ConstraintViolationExceptionMapper.java
new file mode 100755
index 0000000..4f19422
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/provider/ConstraintViolationExceptionMapper.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.webapp1.provider;
+
+import org.superbiz.webapp1.messages.ErrorList;
+import org.superbiz.webapp1.messages.ErrorResponse;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+@Provider
+@Produces(MediaType.APPLICATION_JSON)
+public class ConstraintViolationExceptionMapper implements ExceptionMapper<ConstraintViolationException> {
+
+ @Context
+ private HttpHeaders headers;
+
+ @Override
+ public Response toResponse(final ConstraintViolationException t) {
+ final MediaType type = headers.getMediaType();
+ final Locale locale = headers.getLanguage();
+
+ final Object responsObject = getConstraintViolationErrors(t);
+ return Response.status(Response.Status.NOT_ACCEPTABLE).type(type).language(locale).entity(responsObject).build();
+ }
+
+ private static Object getConstraintViolationErrors(final ConstraintViolationException ex) {
+ final List<ErrorResponse> errors = new ArrayList<ErrorResponse>();
+ for (final ConstraintViolation violation : ex.getConstraintViolations()) {
+ final ErrorResponse error = new ErrorResponse();
+ error.setMessage(violation.getMessage());
+ errors.add(error);
+ }
+ return new ErrorList<ErrorResponse>(errors);
+ }
+
+}
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/service/WebApp1Service.java b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/service/WebApp1Service.java
new file mode 100755
index 0000000..a5799ad
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/java/org/superbiz/webapp1/service/WebApp1Service.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.webapp1.service;
+
+import javax.ejb.Singleton;
+import javax.validation.constraints.Pattern;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path("test")
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+@Singleton
+public class WebApp1Service {
+
+ @POST
+ public Response getInfo(@Pattern(regexp = "valid") final String input) {
+ return Response.ok().build();
+ }
+
+}
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/META-INF/context.xml b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/META-INF/context.xml
new file mode 100755
index 0000000..9e8635d
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/META-INF/context.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<Context antiJARLocking="true" path="/WebApp1"/>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/beans.xml b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/beans.xml
new file mode 100755
index 0000000..4070730
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/ejb-jar.xml b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/ejb-jar.xml
new file mode 100755
index 0000000..bfafcc3
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/ejb-jar.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
+ version="3.1"
+ 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/ejb-jar_3_1.xsd">
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>WebApp1Service</ejb-name>
+ <interceptor-class>org.apache.openejb.bval.BeanValidationAppendixInterceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/openejb-jar.xml b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/openejb-jar.xml
new file mode 100755
index 0000000..f4abb23
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/openejb-jar.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
+ <pojo-deployment class-name="jaxrs-application">
+ <properties>
+ cxf.jaxrs.providers =
+ com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider,org.superbiz.webapp1.provider.ConstraintViolationExceptionMapper
+ </properties>
+ </pojo-deployment>
+</openejb-jar>
\ No newline at end of file
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/web.xml b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..73ff18d
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<web-app 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/web-app_3_0.xsd"
+ version="3.0">
+ <session-config>
+ <session-timeout>
+ 30
+ </session-timeout>
+ </session-config>
+</web-app>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/index.jsp b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/index.jsp
new file mode 100755
index 0000000..d7386fe
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp1/src/main/webapp/index.jsp
@@ -0,0 +1,29 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JSP Page</title>
+</head>
+<body>
+<h1>Hello World!</h1>
+</body>
+</html>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/nb-configuration.xml b/content/examples/bval-evaluation-redeployment/WebApp2/nb-configuration.xml
new file mode 100755
index 0000000..1d2b373
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/nb-configuration.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project-shared-configuration>
+ <!--
+This file contains additional configuration written by modules in the NetBeans IDE.
+The configuration is intended to be shared among all the users of project and
+therefore it is assumed to be part of version control checkout.
+Without this configuration present, some functionality in the IDE may be limited or fail altogether.
+-->
+ <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
+ <!--
+Properties that influence various parts of the IDE, especially code formatting and the like.
+You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
+That way multiple projects can share the same settings (useful for formatting rules for example).
+Any value defined here will override the pom.xml file value but is only applicable to the current project.
+-->
+ <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.6-web
+ </org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
+ <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>Tomcat
+ </org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
+ <org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>ide
+ </org-netbeans-modules-maven-jaxws.rest_2e_config_2e_type>
+ </properties>
+</project-shared-configuration>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/pom.xml b/content/examples/bval-evaluation-redeployment/WebApp2/pom.xml
new file mode 100755
index 0000000..8b86921
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/pom.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.superbiz</groupId>
+ <artifactId>bval-evaluation-redeployment</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>WebApp2</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>war</packaging>
+
+ <name>WebApp2</name>
+
+ <properties>
+ <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArguments>
+ <endorseddirs>${endorsed.dir}</endorseddirs>
+ </compilerArguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${endorsed.dir}</outputDirectory>
+ <silent>true</silent>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax</groupId>
+ <artifactId>javaee-endorsed-api</artifactId>
+ <version>6.0</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/messages/ErrorList.java b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/messages/ErrorList.java
new file mode 100755
index 0000000..c3a5237
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/messages/ErrorList.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.webapp2.messages;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import java.util.ArrayList;
+import java.util.Collection;
+
+@XmlRootElement
+@XmlSeeAlso(ErrorResponse.class)
+public class ErrorList<T> extends ArrayList<T> {
+
+ private static final long serialVersionUID = -8861634470374757349L;
+
+ public ErrorList() {
+ }
+
+ public ErrorList(final Collection<? extends T> clctn) {
+ addAll(clctn);
+ }
+
+}
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/messages/ErrorResponse.java b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/messages/ErrorResponse.java
new file mode 100755
index 0000000..4a2928f
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/messages/ErrorResponse.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.webapp2.messages;
+
+import javax.ws.rs.core.Response;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Date;
+
+@XmlRootElement
+public class ErrorResponse implements Serializable {
+ private static final long serialVersionUID = 8888101217538645771L;
+
+ private Long id;
+ private Response.Status status;
+ private String message;
+
+ public ErrorResponse() {
+ this.id = new Date().getTime();
+ }
+
+ public ErrorResponse(final Response.Status status, final String message) {
+ this.id = new Date().getTime();
+ this.status = status;
+ this.message = message;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(final Long id) {
+ this.id = id;
+ }
+
+ public Response.Status getStatus() {
+ return status;
+ }
+
+ @XmlAttribute
+ public void setStatus(final Response.Status status) {
+ this.status = status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ @XmlAttribute
+ public void setMessage(final String message) {
+ this.message = message;
+ }
+
+ // @Override
+// public String toString() {
+// return "{" + "id:" + id + ", status:" + status + ", message:" + message + '}';
+// }
+ @Override
+ public String toString() {
+ return "ErrorResponse:" + "id=" + id + ", status=" + status + ", message=" + message;
+ }
+}
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/provider/ConstraintViolationExceptionMapper.java b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/provider/ConstraintViolationExceptionMapper.java
new file mode 100755
index 0000000..c6d73ae
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/provider/ConstraintViolationExceptionMapper.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.webapp2.provider;
+
+import org.superbiz.webapp2.messages.ErrorList;
+import org.superbiz.webapp2.messages.ErrorResponse;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+@Provider
+@Produces(MediaType.APPLICATION_JSON)
+public class ConstraintViolationExceptionMapper implements ExceptionMapper<ConstraintViolationException> {
+
+ @Context
+ private HttpHeaders headers;
+
+ @Override
+ public Response toResponse(final ConstraintViolationException t) {
+ final MediaType type = headers.getMediaType();
+ final Locale locale = headers.getLanguage();
+
+ final Object responsObject = getConstraintViolationErrors(t);
+ return Response.status(Response.Status.NOT_ACCEPTABLE).type(type).language(locale).entity(responsObject).build();
+ }
+
+ private static Object getConstraintViolationErrors(final ConstraintViolationException ex) {
+ final List<ErrorResponse> errors = new ArrayList<ErrorResponse>();
+ for (final ConstraintViolation violation : ex.getConstraintViolations()) {
+ final ErrorResponse error = new ErrorResponse();
+ error.setMessage(violation.getMessage());
+ errors.add(error);
+ }
+ return new ErrorList<ErrorResponse>(errors);
+ }
+
+}
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/service/WebApp2Service.java b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/service/WebApp2Service.java
new file mode 100755
index 0000000..86d020b
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/java/org/superbiz/webapp2/service/WebApp2Service.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.webapp2.service;
+
+import javax.ejb.Singleton;
+import javax.validation.constraints.Pattern;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Singleton
+@Path("test")
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+public class WebApp2Service {
+
+ @POST
+ public Response getInfo(@Pattern(regexp = "valid") final String input) {
+ return Response.ok().build();
+ }
+
+}
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/META-INF/context.xml b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/META-INF/context.xml
new file mode 100755
index 0000000..4ffacd4
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/META-INF/context.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<Context antiJARLocking="true" path="/WebApp2"/>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/WEB-INF/ejb-jar.xml b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/WEB-INF/ejb-jar.xml
new file mode 100755
index 0000000..e1c9b17
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/WEB-INF/ejb-jar.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
+ version="3.1"
+ 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/ejb-jar_3_1.xsd">
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>WebApp2Service</ejb-name>
+ <interceptor-class>org.apache.openejb.bval.BeanValidationAppendixInterceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/WEB-INF/openejb-jar.xml b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/WEB-INF/openejb-jar.xml
new file mode 100755
index 0000000..3b5a2d8
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/WEB-INF/openejb-jar.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
+ <pojo-deployment class-name="jaxrs-application">
+ <properties>
+ cxf.jaxrs.providers =
+ com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider,org.superbiz.webapp2.provider.ConstraintViolationExceptionMapper
+ </properties>
+ </pojo-deployment>
+</openejb-jar>
\ No newline at end of file
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/WEB-INF/web.xml b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..73ff18d
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<web-app 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/web-app_3_0.xsd"
+ version="3.0">
+ <session-config>
+ <session-timeout>
+ 30
+ </session-timeout>
+ </session-config>
+</web-app>
diff --git a/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/index.jsp b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/index.jsp
new file mode 100755
index 0000000..d7386fe
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/WebApp2/src/main/webapp/index.jsp
@@ -0,0 +1,29 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JSP Page</title>
+</head>
+<body>
+<h1>Hello World!</h1>
+</body>
+</html>
diff --git a/content/examples/bval-evaluation-redeployment/pom.xml b/content/examples/bval-evaluation-redeployment/pom.xml
new file mode 100755
index 0000000..18f7a3b
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/pom.xml
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>bval-evaluation-redeployment</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <tomee.test.version>1.7.1</tomee.test.version>
+ <openejb.test.version>4.7.1</openejb.test.version>
+ </properties>
+
+ <modules>
+ <module>WebApp1</module>
+ <module>WebApp2</module>
+ <module>runner</module>
+ </modules>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>${openejb.test.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>${openejb.test.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.omnifaces</groupId>
+ <artifactId>omnifaces</artifactId>
+ <version>1.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>2.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>2.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-api</artifactId>
+ <version>0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-impl</artifactId>
+ <scope>runtime</scope>
+ <version>0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>1.1.5.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>2.6.13</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <id>Codehaus Snapshots</id>
+ <url>http://snapshots.repository.codehaus.org/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ <pluginRepository>
+ <id>apache-m2-snapshot-plugin</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ <pluginRepository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
\ No newline at end of file
diff --git a/content/examples/bval-evaluation-redeployment/runner/pom.xml b/content/examples/bval-evaluation-redeployment/runner/pom.xml
new file mode 100755
index 0000000..ebe33b4
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/runner/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.superbiz</groupId>
+ <artifactId>bval-evaluation-redeployment</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>runner</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>apache-tomee</artifactId>
+ <version>1.7.1</version>
+ <type>zip</type>
+ <classifier>jaxrs</classifier>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/content/examples/bval-evaluation-redeployment/runner/src/test/java/RedeploymentTest.java b/content/examples/bval-evaluation-redeployment/runner/src/test/java/RedeploymentTest.java
new file mode 100755
index 0000000..9361e8e
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/runner/src/test/java/RedeploymentTest.java
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.jboss.arquillian.container.test.api.Deployer;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.core.MediaType;
+import java.io.File;
+
+@RunWith(Arquillian.class)
+public class RedeploymentTest {
+
+ public RedeploymentTest() {
+ }
+
+ @Deployment(name = "webapp1", managed = false)
+ public static Archive<?> webapp1() {
+ return ShrinkWrap.createFromZipFile(WebArchive.class, new File("../WebApp1/target/WebApp1-1.1.1-SNAPSHOT.war"));
+ }
+
+ @Deployment(name = "webapp2", managed = false)
+ public static Archive<?> webapp2() {
+ return ShrinkWrap.createFromZipFile(WebArchive.class, new File("../WebApp2/target/WebApp2-1.1.1-SNAPSHOT.war"));
+ }
+
+ @ArquillianResource
+ private Deployer deployer;
+
+ @Test
+ public void validateTest() throws Exception {
+
+ final String port = System.getProperty("server.http.port", "8080");
+ System.out.println("");
+ System.out.println("===========================================");
+ System.out.println("Running test on port: " + port);
+
+ deployer.deploy("webapp1");
+ int result = WebClient.create("http://localhost:" + port + "/WebApp1/test/")
+ .type(MediaType.APPLICATION_JSON_TYPE).post("validd").getStatus();
+ System.out.println(result);
+ Assert.assertEquals(406, result);
+
+ //Not interested in webapp2 output
+ // deployer.undeploy("webapp2");
+ deployer.deploy("webapp2");
+
+ result = WebClient.create("http://localhost:" + port + "/WebApp1/test/")
+ .type(MediaType.APPLICATION_JSON_TYPE).post("validd").getStatus();
+ System.out.println(result);
+ Assert.assertEquals(406, result);
+ deployer.undeploy("webapp2");
+ result = WebClient.create("http://localhost:" + port + "/WebApp1/test/")
+ .type(MediaType.APPLICATION_JSON_TYPE).post("validd").getStatus();
+ System.out.println(result);
+ Assert.assertEquals(406, result);
+ result = WebClient.create("http://localhost:" + port + "/WebApp1/test/")
+ .type(MediaType.APPLICATION_JSON_TYPE).post("valid").getStatus();
+ System.out.println(result);
+ Assert.assertEquals(200, result);
+ System.out.println("===========================================");
+ System.out.println("");
+ }
+
+}
diff --git a/content/examples/bval-evaluation-redeployment/runner/src/test/resources/arquillian.xml b/content/examples/bval-evaluation-redeployment/runner/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..65cd667
--- /dev/null
+++ b/content/examples/bval-evaluation-redeployment/runner/src/test/resources/arquillian.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian
+ >
+
+ <container qualifier="tomee" default="true">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="ajpPort">-1</property>
+ <property name="classifier">jaxrs</property>
+ <property name="simpleLog">true</property>
+ <property name="dir">target/apache-tomee-remote</property>
+ <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+ </configuration>
+ </container>
+</arquillian>
diff --git a/content/examples/cdi-alternative-and-stereotypes.html b/content/examples/cdi-alternative-and-stereotypes.html
new file mode 100644
index 0000000..fb59049
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes.html
@@ -0,0 +1,344 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-alternative-and-stereotypes.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>cdi-alternative-and-stereotypes</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example cdi-alternative-and-stereotypes can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-alternative-and-stereotypes" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-alternative-and-stereotypes</a></p>
+</div>
+</div>
+</div>
+<h1 id="_introduction" class="sect0">Introduction</h1>
+<div class="paragraph">
+<p>CDI is a revolution for Java EE world. This specification is the best one to avoid coupling between classes.</p>
+</div>
+<div class="paragraph">
+<p>This example simply aims to override bindings at runtime to simplify mocking work.</p>
+</div>
+<div class="paragraph">
+<p>It uses two kind of mocks:
+1) a mock with no implementation in the classloader
+2) a mock with an implementation in the classloader</p>
+</div>
+<div class="paragraph">
+<p>The mock answer from CDI is called <strong>alternative</strong>.</p>
+</div>
+<div class="paragraph">
+<p>Annotating <code>@Alternative</code> a class will mean it will replace any implementation if there is no other implementation
+or if it is forced (through <code>META-INF/beans.xml</code>).</p>
+</div>
+<h1 id="_code_explanation" class="sect0">Code explanation</h1>
+<div class="sect1">
+<h2 id="_main_code">main code</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>We use an EJB <code>Jouney</code> to modelize a journey where the vehicle and the society can change. Here an EJB is used simply
+because it simplifies the test. A jouney wraps the vehicle and society information.</p>
+</div>
+<div class="paragraph">
+<p>We define then two interfaces to inject it in the <code>Journey</code> EJB: <code>Vehicle</code> and <code>Society</code>.</p>
+</div>
+<div class="paragraph">
+<p>Finally we add an implementation for <code>Scociety</code> interface: <code>LowCostCompanie</code>.</p>
+</div>
+<div class="paragraph">
+<p>If we don’t go further <code>Journey</code> object will not be able to be created because no <code>Vehicle</code> implementation is available.</p>
+</div>
+<div class="paragraph">
+<p>Note: if we suppose we have a <code>Vehicle</code> implementation, the injected Society should be <code>LowCostCompanie</code>.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_test_code">test code</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The goal here is to test our <code>Journey</code> EJB. So we have to provide a <code>Vehicle</code> implementation: <code>SuperCar</code>.</p>
+</div>
+<div class="paragraph">
+<p>We want to force the <code>Society</code> implementation (for any reason) by our test implementation: <code>AirOpenEJB</code>.</p>
+</div>
+<div class="paragraph">
+<p>One solution could simply be to add <code>@Alternative</code> annotation on <code>AirOpenEJB</code> and activate it through
+the <code>META-INF/beans.xml</code> file.</p>
+</div>
+<div class="paragraph">
+<p>Here we want to write more explicit code. So we want to replace the <code>@Alternative</code> annotation by <code>@Mock</code> one.</p>
+</div>
+<div class="paragraph">
+<p>So we simply define an <code>@Mock</code> annotation for classes, resolvable at runtime which is a stereotype (<code>@Stereotype</code>)
+which replace <code>@Alternative</code>.</p>
+</div>
+<div class="paragraph">
+<p>Here is the annotation:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stereotype // we define a stereotype
+@Retention(RUNTIME) // resolvable at runtime
+@Target(TYPE) // this annotation is a class level one
+@Alternative // it replace @Alternative
+public @interface Mock {}
+
+Note: you can add more CDI annotations after `@Alternative` and it will get the behavior expected (the scope for instance).
+
+So now we have our `@Mock` annotation which is a stereotype able to replace `@Alternative` annotation
+we simply add this annotation to our mocks.
+
+If you run it now you'll have this exception:
+
+javax.enterprise.inject.UnsatisfiedResolutionException: Api type [org.superbiz.cdi.stereotype.Vehicle] is not found with the qualifiers
+Qualifiers: [@javax.enterprise.inject.Default()]
+for injection into Field Injection Point, field name : vehicle, Bean Owner : [Journey, Name:null, WebBeans Type:ENTERPRISE, API Types:[java.lang.Object,org.superbiz.cdi.stereotype.Journey], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
+
+It means the stereotype is not activated. To do it simply add it to your `META-INF/beans.xml`:
+
+<alternatives>
+ <stereotype>org.superbiz.cdi.stereotype.Mock</stereotype>
+</alternatives>
+
+Note: if you don't specify `AirOpenEJB` as `@Alternative` (done through our mock annotation) you'll get this exception:
+
+Caused by: javax.enterprise.inject.AmbiguousResolutionException: There is more than one api type with : org.superbiz.cdi.stereotype.Society with qualifiers : Qualifiers: [@javax.enterprise.inject.Default()]
+for injection into Field Injection Point, field name : society, Bean Owner : [Journey, Name:null, WebBeans Type:ENTERPRISE, API Types:[org.superbiz.cdi.stereotype.Journey,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
+found beans:
+AirOpenEJB, Name:null, WebBeans Type:MANAGED, API Types:[org.superbiz.cdi.stereotype.Society,org.superbiz.cdi.stereotype.AirOpenEJB,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]
+LowCostCompanie, Name:null, WebBeans Type:MANAGED, API Types:[org.superbiz.cdi.stereotype.Society,org.superbiz.cdi.stereotype.LowCostCompanie,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]
+
+which simply means two implementations are available for the same injection point (`Journey.society`).
+
+# Conclusion
+
+With CDI it is really easy to define annotations with a strong meaning. You can define business annotations
+or simply technical annotations to simplify your code (as we did with the mock annotation).
+
+Note: if for instance you used qualifiers to inject societies you could have put all these qualifiers on
+the mock class or defined a `@SocietyMock` annotation to be able to inject the same implementation for
+all qualifiers in your tests.
+
+# Output
+
+Running org.superbiz.cdi.stereotype.StereotypeTest
+Apache OpenEJB 7.0.0-SNAPSHOT build: 20111030-07:54
+http://tomee.apache.org/
+INFO - openejb.home = /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes
+INFO - openejb.base = /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes
+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: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes/target/test-classes
+INFO - Found EjbModule in classpath: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes/target/classes
+INFO - Beginning load: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes/target/test-classes
+INFO - Beginning load: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes/target/classes
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean cdi-alternative-and-stereotypes_test.Comp: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean Journey: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Enterprise application "/opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes
+INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/cdi-alternative-and-stereotypes_test.Comp!org.apache.openejb.BeanContext$Comp")
+INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/cdi-alternative-and-stereotypes_test.Comp")
+INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/cdi-alternative-and-stereotypes.Comp!org.apache.openejb.BeanContext$Comp")
+INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/cdi-alternative-and-stereotypes.Comp")
+INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/Journey!org.superbiz.cdi.stereotype.Journey")
+INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/Journey")
+INFO - Jndi(name="java:global/EjbModule162291475/org.superbiz.cdi.stereotype.StereotypeTest!org.superbiz.cdi.stereotype.StereotypeTest")
+INFO - Jndi(name="java:global/EjbModule162291475/org.superbiz.cdi.stereotype.StereotypeTest")
+INFO - Created Ejb(deployment-id=cdi-alternative-and-stereotypes_test.Comp, ejb-name=cdi-alternative-and-stereotypes_test.Comp, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=cdi-alternative-and-stereotypes.Comp, ejb-name=cdi-alternative-and-stereotypes.Comp, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=org.superbiz.cdi.stereotype.StereotypeTest, ejb-name=org.superbiz.cdi.stereotype.StereotypeTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=Journey, ejb-name=Journey, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=cdi-alternative-and-stereotypes_test.Comp, ejb-name=cdi-alternative-and-stereotypes_test.Comp, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=cdi-alternative-and-stereotypes.Comp, ejb-name=cdi-alternative-and-stereotypes.Comp, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=org.superbiz.cdi.stereotype.StereotypeTest, ejb-name=org.superbiz.cdi.stereotype.StereotypeTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Journey, ejb-name=Journey, container=Default Singleton Container)
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes)
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes</code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-alternative-and-stereotypes.pdf b/content/examples/cdi-alternative-and-stereotypes.pdf
new file mode 100644
index 0000000..2b1aa74
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes.pdf
Binary files differ
diff --git a/content/examples/cdi-alternative-and-stereotypes/README.md b/content/examples/cdi-alternative-and-stereotypes/README.md
new file mode 100755
index 0000000..6e2983c
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/README.md
@@ -0,0 +1,126 @@
+# Introduction
+
+CDI is a revolution for Java EE world. This specification is the best one to avoid coupling between classes.
+
+This example simply aims to override bindings at runtime to simplify mocking work.
+
+It uses two kind of mocks:
+1) a mock with no implementation in the classloader
+2) a mock with an implementation in the classloader
+
+The mock answer from CDI is called *alternative*.
+
+Annotating `@Alternative` a class will mean it will replace any implementation if there is no other implementation
+or if it is forced (through `META-INF/beans.xml`).
+
+# Code explanation
+## main code
+
+We use an EJB `Jouney` to modelize a journey where the vehicle and the society can change. Here an EJB is used simply
+because it simplifies the test. A jouney wraps the vehicle and society information.
+
+We define then two interfaces to inject it in the `Journey` EJB: `Vehicle` and `Society`.
+
+Finally we add an implementation for `Scociety` interface: `LowCostCompanie`.
+
+If we don't go further `Journey` object will not be able to be created because no `Vehicle` implementation is available.
+
+Note: if we suppose we have a `Vehicle` implementation, the injected Society should be `LowCostCompanie`.
+
+## test code
+
+The goal here is to test our `Journey` EJB. So we have to provide a `Vehicle` implementation: `SuperCar`.
+
+We want to force the `Society` implementation (for any reason) by our test implementation: `AirOpenEJB`.
+
+One solution could simply be to add `@Alternative` annotation on `AirOpenEJB` and activate it through
+the `META-INF/beans.xml` file.
+
+Here we want to write more explicit code. So we want to replace the `@Alternative` annotation by `@Mock` one.
+
+So we simply define an `@Mock` annotation for classes, resolvable at runtime which is a stereotype (`@Stereotype`)
+which replace `@Alternative`.
+
+Here is the annotation:
+
+ @Stereotype // we define a stereotype
+ @Retention(RUNTIME) // resolvable at runtime
+ @Target(TYPE) // this annotation is a class level one
+ @Alternative // it replace @Alternative
+ public @interface Mock {}
+
+Note: you can add more CDI annotations after `@Alternative` and it will get the behavior expected (the scope for instance).
+
+So now we have our `@Mock` annotation which is a stereotype able to replace `@Alternative` annotation
+we simply add this annotation to our mocks.
+
+If you run it now you'll have this exception:
+
+ javax.enterprise.inject.UnsatisfiedResolutionException: Api type [org.superbiz.cdi.stereotype.Vehicle] is not found with the qualifiers
+ Qualifiers: [@javax.enterprise.inject.Default()]
+ for injection into Field Injection Point, field name : vehicle, Bean Owner : [Journey, Name:null, WebBeans Type:ENTERPRISE, API Types:[java.lang.Object,org.superbiz.cdi.stereotype.Journey], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
+
+It means the stereotype is not activated. To do it simply add it to your `META-INF/beans.xml`:
+
+ <alternatives>
+ <stereotype>org.superbiz.cdi.stereotype.Mock</stereotype>
+ </alternatives>
+
+Note: if you don't specify `AirOpenEJB` as `@Alternative` (done through our mock annotation) you'll get this exception:
+
+ Caused by: javax.enterprise.inject.AmbiguousResolutionException: There is more than one api type with : org.superbiz.cdi.stereotype.Society with qualifiers : Qualifiers: [@javax.enterprise.inject.Default()]
+ for injection into Field Injection Point, field name : society, Bean Owner : [Journey, Name:null, WebBeans Type:ENTERPRISE, API Types:[org.superbiz.cdi.stereotype.Journey,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
+ found beans:
+ AirOpenEJB, Name:null, WebBeans Type:MANAGED, API Types:[org.superbiz.cdi.stereotype.Society,org.superbiz.cdi.stereotype.AirOpenEJB,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]
+ LowCostCompanie, Name:null, WebBeans Type:MANAGED, API Types:[org.superbiz.cdi.stereotype.Society,org.superbiz.cdi.stereotype.LowCostCompanie,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]
+
+which simply means two implementations are available for the same injection point (`Journey.society`).
+
+# Conclusion
+
+With CDI it is really easy to define annotations with a strong meaning. You can define business annotations
+or simply technical annotations to simplify your code (as we did with the mock annotation).
+
+Note: if for instance you used qualifiers to inject societies you could have put all these qualifiers on
+the mock class or defined a `@SocietyMock` annotation to be able to inject the same implementation for
+all qualifiers in your tests.
+
+# Output
+
+ Running org.superbiz.cdi.stereotype.StereotypeTest
+ Apache OpenEJB 4.0.0-beta-2-SNAPSHOT build: 20111030-07:54
+ http://openejb.apache.org/
+ INFO - openejb.home = /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes
+ INFO - openejb.base = /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes
+ 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: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes/target/test-classes
+ INFO - Found EjbModule in classpath: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes/target/classes
+ INFO - Beginning load: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes/target/test-classes
+ INFO - Beginning load: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes/target/classes
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean cdi-alternative-and-stereotypes_test.Comp: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean Journey: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Enterprise application "/opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes
+ INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/cdi-alternative-and-stereotypes_test.Comp!org.apache.openejb.BeanContext$Comp")
+ INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/cdi-alternative-and-stereotypes_test.Comp")
+ INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/cdi-alternative-and-stereotypes.Comp!org.apache.openejb.BeanContext$Comp")
+ INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/cdi-alternative-and-stereotypes.Comp")
+ INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/Journey!org.superbiz.cdi.stereotype.Journey")
+ INFO - Jndi(name="java:global/cdi-alternative-and-stereotypes/Journey")
+ INFO - Jndi(name="java:global/EjbModule162291475/org.superbiz.cdi.stereotype.StereotypeTest!org.superbiz.cdi.stereotype.StereotypeTest")
+ INFO - Jndi(name="java:global/EjbModule162291475/org.superbiz.cdi.stereotype.StereotypeTest")
+ INFO - Created Ejb(deployment-id=cdi-alternative-and-stereotypes_test.Comp, ejb-name=cdi-alternative-and-stereotypes_test.Comp, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=cdi-alternative-and-stereotypes.Comp, ejb-name=cdi-alternative-and-stereotypes.Comp, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.cdi.stereotype.StereotypeTest, ejb-name=org.superbiz.cdi.stereotype.StereotypeTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=Journey, ejb-name=Journey, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=cdi-alternative-and-stereotypes_test.Comp, ejb-name=cdi-alternative-and-stereotypes_test.Comp, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=cdi-alternative-and-stereotypes.Comp, ejb-name=cdi-alternative-and-stereotypes.Comp, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.cdi.stereotype.StereotypeTest, ejb-name=org.superbiz.cdi.stereotype.StereotypeTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Journey, ejb-name=Journey, container=Default Singleton Container)
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes)
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/cdi-alternative-and-stereotypes
diff --git a/content/examples/cdi-alternative-and-stereotypes/pom.xml b/content/examples/cdi-alternative-and-stereotypes/pom.xml
new file mode 100755
index 0000000..cc66b97
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1178411 $ $Date: 2011-10-03 15:35:26 +0200 (lun. 03 oct. 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-alternative-and-stereotypes</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: CDI Stereotypes</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/Journey.java b/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/Journey.java
new file mode 100755
index 0000000..5d02857
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/Journey.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.cdi.stereotype;
+
+import javax.ejb.Singleton;
+import javax.inject.Inject;
+
+@Singleton
+public class Journey {
+
+ @Inject
+ private Vehicle vehicle;
+ @Inject
+ private Society society;
+
+ public String vehicle() {
+ return vehicle.name();
+ }
+
+ public String category() {
+ return society.category();
+ }
+}
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/LowCostCompanie.java b/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/LowCostCompanie.java
new file mode 100755
index 0000000..c57eaee
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/LowCostCompanie.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.cdi.stereotype;
+
+public class LowCostCompanie implements Society {
+
+ @Override
+ public String category() {
+ return "maybe you'll leave...";
+ }
+}
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/Society.java b/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/Society.java
new file mode 100755
index 0000000..465e4c5
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/Society.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.cdi.stereotype;
+
+public interface Society {
+
+ String category();
+}
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/Vehicle.java b/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/Vehicle.java
new file mode 100755
index 0000000..84b11b7
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/main/java/org/superbiz/cdi/stereotype/Vehicle.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.cdi.stereotype;
+
+public interface Vehicle {
+
+ String name();
+}
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/main/resources/META-INF/beans.xml b/content/examples/cdi-alternative-and-stereotypes/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..4692869
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<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"/>
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/AirOpenEJB.java b/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/AirOpenEJB.java
new file mode 100755
index 0000000..bbf54a8
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/AirOpenEJB.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.cdi.stereotype;
+
+/**
+ * without @Mock annotation which specifies this class as an alternative
+ * you'll have this exception:
+ * <p/>
+ * Caused by: javax.enterprise.inject.AmbiguousResolutionException: There is more than one api type with : org.superbiz.cdi.stereotype.Society with qualifiers : Qualifiers: [@javax.enterprise.inject.Default()]
+ * for injection into Field Injection Point, field name : society, Bean Owner : [Journey, Name:null, WebBeans Type:ENTERPRISE, API Types:[org.superbiz.cdi.stereotype.Journey,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
+ * found beans:
+ * AirOpenEJB, Name:null, WebBeans Type:MANAGED, API Types:[org.superbiz.cdi.stereotype.Society,org.superbiz.cdi.stereotype.AirOpenEJB,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]
+ * LowCostCompanie, Name:null, WebBeans Type:MANAGED, API Types:[org.superbiz.cdi.stereotype.Society,org.superbiz.cdi.stereotype.LowCostCompanie,java.lang.Object], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]
+ * <p/>
+ * because 2 implementations match the same injection point (Journey.society).
+ */
+@Mock
+public class AirOpenEJB implements Society {
+
+ @Override
+ public String category() {
+ return "simply the best";
+ }
+}
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/Mock.java b/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/Mock.java
new file mode 100755
index 0000000..805e1bb
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/Mock.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.cdi.stereotype;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+// defining a stereotype for class level
+@Stereotype
+@Retention(RUNTIME)
+@Target(TYPE)
+
+// here define all annotations you want to replace by this one.
+// this stereotype define an alternative
+@Alternative
+public @interface Mock {
+
+}
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/StereotypeTest.java b/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/StereotypeTest.java
new file mode 100755
index 0000000..d4c9988
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/StereotypeTest.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.cdi.stereotype;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.NamingException;
+
+import static org.junit.Assert.assertEquals;
+
+public class StereotypeTest {
+
+ private static EJBContainer container;
+ private static Journey journey;
+
+ @BeforeClass
+ public static void start() throws NamingException {
+ container = EJBContainer.createEJBContainer();
+ journey = (Journey) container.getContext().lookup("java:global/cdi-alternative-and-stereotypes/Journey");
+ }
+
+ @AfterClass
+ public static void shutdown() {
+ if (container != null) {
+ container.close();
+ }
+ }
+
+ @Test
+ public void assertVehicleInjected() {
+ assertEquals("the fatest", journey.vehicle());
+ }
+
+ @Test
+ public void assertMockOverrideWorks() {
+ assertEquals("simply the best", journey.category());
+ }
+}
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/SuperCar.java b/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/SuperCar.java
new file mode 100755
index 0000000..639d1fd
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/test/java/org/superbiz/cdi/stereotype/SuperCar.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.cdi.stereotype;
+
+@Mock
+public class SuperCar implements Vehicle {
+
+ @Override
+ public String name() {
+ return "the fatest";
+ }
+}
diff --git a/content/examples/cdi-alternative-and-stereotypes/src/test/resources/META-INF/beans.xml b/content/examples/cdi-alternative-and-stereotypes/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..df8934b
--- /dev/null
+++ b/content/examples/cdi-alternative-and-stereotypes/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<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">
+ <alternatives>
+ <stereotype>org.superbiz.cdi.stereotype.Mock</stereotype>
+ </alternatives>
+</beans>
diff --git a/content/examples/cdi-application-scope.html b/content/examples/cdi-application-scope.html
new file mode 100644
index 0000000..e68be63
--- /dev/null
+++ b/content/examples/cdi-application-scope.html
@@ -0,0 +1,345 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-application-scope.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>CDI @ApplicationScoped</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example cdi-application-scope can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-application-scope" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-application-scope</a></p>
+</div>
+<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>
+<h1 id="_example" class="sect0">Example</h1>
+<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="sect1">
+<h2 id="_waiter">Waiter</h2>
+<div class="sectionbody">
+<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="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stateless
+public class Waiter {
+
+ @Inject
+ public Soup soup;
+
+ public String orderSoup(String name){
+ soup.setName(name);
+ return soup.getName();
+ }
+
+ public String orderWhatTheOtherGuyHad() {
+ String name = soup.getName();
+ return name;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_soup">Soup</h2>
+<div class="sectionbody">
+<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="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@ApplicationScoped
+public class Soup {
+
+ private String name = "Soup of the day";
+
+ @PostConstruct
+ public void afterCreate() {
+ System.out.println("Soup created");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_test_case" class="sect0">Test Case</h1>
+<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="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class RestaurantTest {
+
+ private static String TOMATO_SOUP = "Tomato Soup";
+ private EJBContainer container;
+
+ @EJB
+ private Waiter joe;
+
+ @Before
+ public void startContainer() throws Exception {
+ container = EJBContainer.createEJBContainer();
+ container.getContext().bind("inject", this);
+ }
+
+ @Test
+ public void orderSoup(){
+ String someSoup = joe.orderSoup(TOMATO_SOUP);
+ assertEquals(TOMATO_SOUP, someSoup);
+
+ String sameSoup = joe.orderWhatTheOtherGuyHad();
+ assertEquals(TOMATO_SOUP, sameSoup);
+ }
+
+ @After
+ public void closeContainer() throws Exception {
+ container.close();
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<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="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.cdi.applicationscope.RestaurantTest
+Apache OpenEJB 7.0.0-SNAPSHOT build: 20111224-11:09
+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 - 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
+INFO - Beginning load: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope\target\classes
+INFO - Configuring enterprise application: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+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 - 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 - 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)
+Soup created
+INFO - Undeploying app: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.42 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-application-scope.pdf b/content/examples/cdi-application-scope.pdf
new file mode 100644
index 0000000..fc6436c
--- /dev/null
+++ b/content/examples/cdi-application-scope.pdf
Binary files differ
diff --git a/content/examples/cdi-application-scope/README.md b/content/examples/cdi-application-scope/README.md
new file mode 100755
index 0000000..2875b09
--- /dev/null
+++ b/content/examples/cdi-application-scope/README.md
@@ -0,0 +1,133 @@
+Title: CDI @ApplicationScoped
+
+This example show the use of `@ApplicationScoped` annotation for injected objects. An object
+which is defined as `@ApplicationScoped` is created once for the duration of the application.
+
+# Example
+
+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.
+
+## Waiter
+
+The `Waiter` session bean receives a request from the test class via the `orderSoup()` method
+and sets the name for the `soup` field. The `orderWhatTheOtherGuyHad()` method returns
+the name of the `soup` field.
+
+ @Stateless
+ public class Waiter {
+
+ @Inject
+ public Soup soup;
+
+ public String orderSoup(String name){
+ soup.setName(name);
+ return soup.getName();
+ }
+
+ public String orderWhatTheOtherGuyHad() {
+ String name = soup.getName();
+ return name;
+ }
+ }
+
+## Soup
+
+The `Soup` class is an injectable POJO, defined as `@ApplicationScoped`. This means that an instance
+will be created only once for the duration of the whole application. Try changing the `@ApplicationScoped`
+annotation to `@RequestScoped` and see what happens.
+
+ @ApplicationScoped
+ public class Soup {
+
+ private String name = "Soup of the day";
+
+ @PostConstruct
+ public void afterCreate() {
+ System.out.println("Soup created");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+ }
+
+
+# Test Case
+
+This is the entry class for this example. First a soup is ordered via `orderSoup()` method.
+This initiates the `soup` field. Next, `orderWhatTheOtherGuyHad()` method returns the soup
+from the application context.
+
+ public class RestaurantTest {
+
+ private static String TOMATO_SOUP = "Tomato Soup";
+ private EJBContainer container;
+
+ @EJB
+ private Waiter joe;
+
+ @Before
+ public void startContainer() throws Exception {
+ container = EJBContainer.createEJBContainer();
+ container.getContext().bind("inject", this);
+ }
+
+ @Test
+ public void orderSoup(){
+ String someSoup = joe.orderSoup(TOMATO_SOUP);
+ assertEquals(TOMATO_SOUP, someSoup);
+
+ String sameSoup = joe.orderWhatTheOtherGuyHad();
+ assertEquals(TOMATO_SOUP, sameSoup);
+ }
+
+ @After
+ public void closeContainer() throws Exception {
+ container.close();
+ }
+ }
+
+# Running
+
+In the output you can see that there is just one `Soup` instance created - one for
+the whole application.
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.cdi.applicationscope.RestaurantTest
+ Apache OpenEJB 4.0.0-beta-2-SNAPSHOT build: 20111224-11:09
+ http://openejb.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 - 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
+ INFO - Beginning load: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope\target\classes
+ INFO - Configuring enterprise application: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ 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 - 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 - 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)
+ Soup created
+ INFO - Undeploying app: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-application-scope
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.42 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
diff --git a/content/examples/cdi-application-scope/pom.xml b/content/examples/cdi-application-scope/pom.xml
new file mode 100755
index 0000000..1112534
--- /dev/null
+++ b/content/examples/cdi-application-scope/pom.xml
@@ -0,0 +1,77 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-application-scope</artifactId>
+ <name>OpenEJB :: Examples :: CDI Application Scope</name>
+ <version>1.1.1-SNAPSHOT</version>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/cdi-application-scope/src/main/java/org/superbiz/cdi/applicationscope/Soup.java b/content/examples/cdi-application-scope/src/main/java/org/superbiz/cdi/applicationscope/Soup.java
new file mode 100755
index 0000000..39773ec
--- /dev/null
+++ b/content/examples/cdi-application-scope/src/main/java/org/superbiz/cdi/applicationscope/Soup.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.applicationscope;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+public class Soup {
+
+ private String name = "Soup of the day";
+
+ @PostConstruct
+ public void afterCreate() {
+ System.out.println("Soup created");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/content/examples/cdi-application-scope/src/main/java/org/superbiz/cdi/applicationscope/Waiter.java b/content/examples/cdi-application-scope/src/main/java/org/superbiz/cdi/applicationscope/Waiter.java
new file mode 100755
index 0000000..9752ec4
--- /dev/null
+++ b/content/examples/cdi-application-scope/src/main/java/org/superbiz/cdi/applicationscope/Waiter.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.applicationscope;
+
+import javax.ejb.Stateless;
+import javax.inject.Inject;
+
+@Stateless
+public class Waiter {
+
+ @Inject
+ public Soup soup;
+
+ public String orderSoup(String name) {
+ soup.setName(name);
+ return soup.getName();
+ }
+
+ public String orderWhatTheOtherGuyHad() {
+ String name = soup.getName();
+ return name;
+ }
+
+}
diff --git a/content/examples/cdi-application-scope/src/main/resources/META-INF/beans.xml b/content/examples/cdi-application-scope/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..6668db4
--- /dev/null
+++ b/content/examples/cdi-application-scope/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,19 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans>
+</beans>
\ No newline at end of file
diff --git a/content/examples/cdi-application-scope/src/test/java/org/superbiz/cdi/applicationscope/RestaurantTest.java b/content/examples/cdi-application-scope/src/test/java/org/superbiz/cdi/applicationscope/RestaurantTest.java
new file mode 100755
index 0000000..c2e34fd
--- /dev/null
+++ b/content/examples/cdi-application-scope/src/test/java/org/superbiz/cdi/applicationscope/RestaurantTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.applicationscope;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+
+import static org.junit.Assert.assertEquals;
+
+public class RestaurantTest {
+
+ private static String TOMATO_SOUP = "Tomato Soup";
+ private EJBContainer container;
+
+ @EJB
+ private Waiter joe;
+
+ @Before
+ public void startContainer() throws Exception {
+ container = EJBContainer.createEJBContainer();
+ container.getContext().bind("inject", this);
+ }
+
+ @Test
+ public void orderSoup() {
+ String someSoup = joe.orderSoup(TOMATO_SOUP);
+ assertEquals(TOMATO_SOUP, someSoup);
+
+ String sameSoup = joe.orderWhatTheOtherGuyHad();
+ assertEquals(TOMATO_SOUP, sameSoup);
+ }
+
+ @After
+ public void closeContainer() throws Exception {
+ container.close();
+ }
+}
diff --git a/content/examples/cdi-basic.html b/content/examples/cdi-basic.html
new file mode 100644
index 0000000..5876419
--- /dev/null
+++ b/content/examples/cdi-basic.html
@@ -0,0 +1,374 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-basic.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>CDI @Inject</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example cdi-basic can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-basic" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-basic</a></p>
+</div>
+<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
+about 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>
+<h1 id="_example" class="sect0">Example</h1>
+<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
+into it 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 everyting injected.</p>
+</div>
+<div class="sect1">
+<h2 id="_faculty_small_a_basic_injectable_pojo_small">Faculty <small>a basic injectable pojo</small></h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class Faculty {
+
+ private List<String> facultyMembers;
+
+ private String facultyName;
+
+ @PostConstruct
+ public void initialize() {
+ this.facultyMembers = new ArrayList<String>();
+ facultyMembers.add("Ian Schultz");
+ facultyMembers.add("Diane Reyes");
+ facultyName = "Computer Science";
+ }
+
+ public List<String> getFacultyMembers() {
+ return facultyMembers;
+ }
+
+ public String getFacultyName() {
+ return facultyName;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_course_small_a_simple_session_bean_small">Course <small>a simple session bean</small></h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stateless
+public class Course {
+
+ @Inject
+ private Faculty faculty;
+
+ private String courseName;
+
+ private int capacity;
+
+ @PostConstruct
+ private void init() {
+ assert faculty != null;
+
+ // These strings can be externalized
+ // We'll see how to do that later
+ this.courseName = "CDI 101 - Introduction to CDI";
+ this.capacity = 100;
+ }
+
+ public String getCourseName() {
+ return courseName;
+ }
+
+ public int getCapacity() {
+ return capacity;
+ }
+
+ public Faculty getFaculty() {
+ return faculty;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_test_case" class="sect0">Test Case</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class CourseTest extends TestCase {
+
+ @EJB
+ private Course course;
+
+ @Before
+ public void setUp() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+ }
+
+ @Test
+ public void test() {
+
+ // Was the EJB injected?
+ assertTrue(course != null);
+
+ // Was the Course @PostConstruct called?
+ assertNotNull(course.getCourseName());
+ assertTrue(course.getCapacity() > 0);
+
+ // Was a Faculty instance injected into Course?
+ final Faculty faculty = course.getFaculty();
+ assertTrue(faculty != null);
+
+ // Was the @PostConstruct called on Faculty?
+ assertEquals(faculty.getFacultyName(), "Computer Science");
+ assertEquals(faculty.getFacultyMembers().size(), 2);
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.cdi.basic.CourseTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+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 - 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
+INFO - Beginning load: /Users/dblevins/examples/cdi-basic/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/cdi-basic
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+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 - 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 - 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)
+INFO - Started Ejb(deployment-id=Course, ejb-name=Course, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=cdi-basic.Comp, ejb-name=cdi-basic.Comp, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=org.superbiz.cdi.basic.CourseTest, ejb-name=org.superbiz.cdi.basic.CourseTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/cdi-basic)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.126 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-basic.pdf b/content/examples/cdi-basic.pdf
new file mode 100644
index 0000000..3bdff3f
--- /dev/null
+++ b/content/examples/cdi-basic.pdf
Binary files differ
diff --git a/content/examples/cdi-basic/README.md b/content/examples/cdi-basic/README.md
new file mode 100755
index 0000000..156e24e
--- /dev/null
+++ b/content/examples/cdi-basic/README.md
@@ -0,0 +1,164 @@
+Title: CDI @Inject
+
+To use `@Inject`, the first thing you need is a `META-INF/beans.xml` file in the module
+or jar. This effectively turns on CDI and allows the `@Inject` references to work.
+No `META-INF/beans.xml` 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
+about of resources by design.
+
+When the container constructs a bean with an `@Inject` reference,
+it will first find or create the object that will be injected. For the sake of
+simplicity, the is example has a basic `Faculty` pojo with a no-arg constructor. Anyone
+referencing `@Inject Faculty` will get their own instance of `Faculty`. If the desire
+is to share the same instance of `Faculty`, see the concept of `scopes` -- this is
+exactly what scopes are for.
+
+# Example
+
+In this example we have an `@Stateless` bean `Course` with an `@Inject` reference to an
+object of type `Faculty`. When `Course` is created, the container will also create an
+instance of `Faculty`. The `@PostConstruct` will be called on the `Faculty`,
+then the `Faculty` instance will be injected into the `Course` bean. Finally, the
+`@PostConstruct` will be invoked on `Course` and then we're done. All instances will
+have been created.
+
+The `CourseTest` test case drives this creation process by having `Course` injected
+into it in its `@Setup` method. By the time our `@Test` 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 `@PostConstruct` methods
+called and everyting injected.
+
+## Faculty <small>a basic injectable pojo</small>
+
+ public class Faculty {
+
+ private List<String> facultyMembers;
+
+ private String facultyName;
+
+ @PostConstruct
+ public void initialize() {
+ this.facultyMembers = new ArrayList<String>();
+ facultyMembers.add("Ian Schultz");
+ facultyMembers.add("Diane Reyes");
+ facultyName = "Computer Science";
+ }
+
+ public List<String> getFacultyMembers() {
+ return facultyMembers;
+ }
+
+ public String getFacultyName() {
+ return facultyName;
+ }
+
+ }
+
+## Course <small>a simple session bean</small>
+
+ @Stateless
+ public class Course {
+
+ @Inject
+ private Faculty faculty;
+
+ private String courseName;
+
+ private int capacity;
+
+ @PostConstruct
+ private void init() {
+ assert faculty != null;
+
+ // These strings can be externalized
+ // We'll see how to do that later
+ this.courseName = "CDI 101 - Introduction to CDI";
+ this.capacity = 100;
+ }
+
+ public String getCourseName() {
+ return courseName;
+ }
+
+ public int getCapacity() {
+ return capacity;
+ }
+
+ public Faculty getFaculty() {
+ return faculty;
+ }
+ }
+
+# Test Case
+
+ public class CourseTest extends TestCase {
+
+ @EJB
+ private Course course;
+
+ @Before
+ public void setUp() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+ }
+
+ @Test
+ public void test() {
+
+ // Was the EJB injected?
+ assertTrue(course != null);
+
+ // Was the Course @PostConstruct called?
+ assertNotNull(course.getCourseName());
+ assertTrue(course.getCapacity() > 0);
+
+ // Was a Faculty instance injected into Course?
+ final Faculty faculty = course.getFaculty();
+ assertTrue(faculty != null);
+
+ // Was the @PostConstruct called on Faculty?
+ assertEquals(faculty.getFacultyName(), "Computer Science");
+ assertEquals(faculty.getFacultyMembers().size(), 2);
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.cdi.basic.CourseTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.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 - 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
+ INFO - Beginning load: /Users/dblevins/examples/cdi-basic/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/cdi-basic
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ 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 - 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 - 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)
+ INFO - Started Ejb(deployment-id=Course, ejb-name=Course, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=cdi-basic.Comp, ejb-name=cdi-basic.Comp, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.cdi.basic.CourseTest, ejb-name=org.superbiz.cdi.basic.CourseTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/cdi-basic)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.126 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
diff --git a/content/examples/cdi-basic/pom.xml b/content/examples/cdi-basic/pom.xml
new file mode 100755
index 0000000..4234fb9
--- /dev/null
+++ b/content/examples/cdi-basic/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-basic</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Basic CDI</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- The <scope>test</scope> guarantees that none of your runtime code
+ is dependent on any OpenEJB classes. -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/cdi-basic/src/main/java/org/superbiz/cdi/basic/Course.java b/content/examples/cdi-basic/src/main/java/org/superbiz/cdi/basic/Course.java
new file mode 100755
index 0000000..a515897
--- /dev/null
+++ b/content/examples/cdi-basic/src/main/java/org/superbiz/cdi/basic/Course.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.basic;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Stateless;
+import javax.inject.Inject;
+
+@Stateless
+public class Course {
+
+ @Inject
+ private Faculty faculty;
+
+ private String courseName;
+
+ private int capacity;
+
+ @PostConstruct
+ private void init() {
+ assert faculty != null;
+
+ // These strings can be externalized
+ // We'll see how to do that later
+ this.courseName = "CDI 101 - Introduction to CDI";
+ this.capacity = 100;
+ }
+
+ public String getCourseName() {
+ return courseName;
+ }
+
+ public int getCapacity() {
+ return capacity;
+ }
+
+ public Faculty getFaculty() {
+ return faculty;
+ }
+}
diff --git a/content/examples/cdi-basic/src/main/java/org/superbiz/cdi/basic/Faculty.java b/content/examples/cdi-basic/src/main/java/org/superbiz/cdi/basic/Faculty.java
new file mode 100755
index 0000000..2cf8d8a
--- /dev/null
+++ b/content/examples/cdi-basic/src/main/java/org/superbiz/cdi/basic/Faculty.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.basic;
+
+import javax.annotation.PostConstruct;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Faculty {
+
+ private List<String> facultyMembers;
+
+ private String facultyName;
+
+ @PostConstruct
+ public void initialize() {
+ this.facultyMembers = new ArrayList<String>();
+ facultyMembers.add("Ian Schultz");
+ facultyMembers.add("Diane Reyes");
+ facultyName = "Computer Science";
+ }
+
+ public List<String> getFacultyMembers() {
+ return facultyMembers;
+ }
+
+ public String getFacultyName() {
+ return facultyName;
+ }
+
+}
diff --git a/content/examples/cdi-basic/src/main/resources/META-INF/beans.xml b/content/examples/cdi-basic/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..6668db4
--- /dev/null
+++ b/content/examples/cdi-basic/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,19 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans>
+</beans>
\ No newline at end of file
diff --git a/content/examples/cdi-basic/src/test/java/org/superbiz/cdi/basic/CourseTest.java b/content/examples/cdi-basic/src/test/java/org/superbiz/cdi/basic/CourseTest.java
new file mode 100755
index 0000000..3271f33
--- /dev/null
+++ b/content/examples/cdi-basic/src/test/java/org/superbiz/cdi/basic/CourseTest.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.basic;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class CourseTest {
+
+ private static EJBContainer container;
+
+ @EJB
+ private Course course;
+
+ @BeforeClass
+ public static void start() {
+ container = EJBContainer.createEJBContainer();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ container.getContext().bind("inject", this);
+ }
+
+ @Test
+ public void test() {
+
+ // Was the EJB injected?
+ assertTrue(course != null);
+
+ // Was the Course @PostConstruct called?
+ assertNotNull(course.getCourseName());
+ assertTrue(course.getCapacity() > 0);
+
+ // Was a Faculty instance injected into Course?
+ final Faculty faculty = course.getFaculty();
+ assertTrue(faculty != null);
+
+ // Was the @PostConstruct called on Faculty?
+ assertEquals(faculty.getFacultyName(), "Computer Science");
+ assertEquals(faculty.getFacultyMembers().size(), 2);
+ }
+
+ @AfterClass
+ public static void stop() {
+ container.close();
+ }
+}
diff --git a/content/examples/cdi-ejbcontext-jaas.html b/content/examples/cdi-ejbcontext-jaas.html
new file mode 100644
index 0000000..be0c564
--- /dev/null
+++ b/content/examples/cdi-ejbcontext-jaas.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-ejbcontext-jaas.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>cdi-ejbcontext-jaas</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example cdi-ejbcontext-jaas can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-ejbcontext-jaas" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-ejbcontext-jaas</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-ejbcontext-jaas.pdf b/content/examples/cdi-ejbcontext-jaas.pdf
new file mode 100644
index 0000000..b37a407
--- /dev/null
+++ b/content/examples/cdi-ejbcontext-jaas.pdf
Binary files differ
diff --git a/content/examples/cdi-ejbcontext-jaas/pom.xml b/content/examples/cdi-ejbcontext-jaas/pom.xml
new file mode 100755
index 0000000..e23ab6b
--- /dev/null
+++ b/content/examples/cdi-ejbcontext-jaas/pom.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-ejbcontext-jaas</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>OpenEJB :: Examples :: CDI, EJBContext and JAAS</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-catalina</artifactId>
+ <version>7.0.29</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ <configuration>
+ <systemVariables>
+ <java.security.auth.login.config>${project.build.directory}/apache-tomee/conf/login.config</java.security.auth.login.config>
+ <org.apache.catalina.STRICT_SERVLET_COMPLIANCE>false</org.apache.catalina.STRICT_SERVLET_COMPLIANCE>
+ </systemVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot-plugin</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+</project>
diff --git a/content/examples/cdi-ejbcontext-jaas/src/main/java/org/superbiz/cdi/ejbcontext/LogginServlet.java b/content/examples/cdi-ejbcontext-jaas/src/main/java/org/superbiz/cdi/ejbcontext/LogginServlet.java
new file mode 100755
index 0000000..1918916
--- /dev/null
+++ b/content/examples/cdi-ejbcontext-jaas/src/main/java/org/superbiz/cdi/ejbcontext/LogginServlet.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.ejbcontext;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebServlet(urlPatterns = "/ejbcontext")
+public class LogginServlet extends HttpServlet {
+
+ @Inject
+ private PrinciaplEjb bean;
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ req.login(req.getParameter("myUser"), req.getParameter("myPass"));
+ // think to persist the information in the session if you need it later
+ resp.getWriter().write("logged user ==> " + bean.info() + "; isUserInRole(admin)? " + req.isUserInRole("admin"));
+ }
+}
diff --git a/content/examples/cdi-ejbcontext-jaas/src/main/java/org/superbiz/cdi/ejbcontext/PrinciaplEjb.java b/content/examples/cdi-ejbcontext-jaas/src/main/java/org/superbiz/cdi/ejbcontext/PrinciaplEjb.java
new file mode 100755
index 0000000..b0ed888
--- /dev/null
+++ b/content/examples/cdi-ejbcontext-jaas/src/main/java/org/superbiz/cdi/ejbcontext/PrinciaplEjb.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.ejbcontext;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBContext;
+import javax.ejb.Stateless;
+
+@Stateless
+public class PrinciaplEjb {
+
+ @Resource
+ private EJBContext context;
+
+ public String info() {
+ return context.getCallerPrincipal().getName();
+ }
+}
diff --git a/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/groups.properties b/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/groups.properties
new file mode 100755
index 0000000..e05c5f2
--- /dev/null
+++ b/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/groups.properties
@@ -0,0 +1 @@
+admin=tomee
diff --git a/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/login.config b/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/login.config
new file mode 100755
index 0000000..6665d32
--- /dev/null
+++ b/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/login.config
@@ -0,0 +1,6 @@
+PropertiesLoginModule {
+ org.apache.openejb.core.security.jaas.PropertiesLoginModule required
+ Debug=false
+ UsersFile="users.properties"
+ GroupsFile="groups.properties";
+};
diff --git a/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/server.xml b/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/server.xml
new file mode 100755
index 0000000..62be947
--- /dev/null
+++ b/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/server.xml
@@ -0,0 +1,40 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<Server port="8005" shutdown="SHUTDOWN">
+ <Listener className="org.apache.tomee.catalina.ServerListener"/>
+ <Listener className="org.apache.catalina.security.SecurityListener"/>
+
+ <Service name="Catalina">
+ <Connector port="8080" protocol="HTTP/1.1"
+ connectionTimeout="20000"
+ redirectPort="8443"/>
+ <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
+ <Engine name="Catalina" defaultHost="localhost">
+
+ <Realm className="org.apache.catalina.realm.JAASRealm" appName="PropertiesLoginModule"
+ userClassNames="org.apache.openejb.core.security.jaas.UserPrincipal"
+ roleClassNames="org.apache.openejb.core.security.jaas.GroupPrincipal">
+ </Realm>
+
+ <Host name="localhost" appBase="webapps"
+ unpackWARs="true" autoDeploy="true"/>
+ </Engine>
+ </Service>
+</Server>
diff --git a/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/users.properties b/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/users.properties
new file mode 100755
index 0000000..22679bc
--- /dev/null
+++ b/content/examples/cdi-ejbcontext-jaas/src/main/tomee/conf/users.properties
@@ -0,0 +1 @@
+tomee=tomee
diff --git a/content/examples/cdi-events.html b/content/examples/cdi-events.html
new file mode 100644
index 0000000..e542ca2
--- /dev/null
+++ b/content/examples/cdi-events.html
@@ -0,0 +1,233 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-events.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>cdi-events</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example cdi-events can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-events" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-events</a></p>
+</div>
+</div>
+</div>
+<h1 id="_cdi_events_loose_coupling_and_extensibility" class="sect0">CDI events: loose coupling and extensibility</h1>
+<div class="paragraph">
+<p>CDI allows you to extend business code by the Notifier/Observer pattern.</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="paragraph">
+<p>Note: of course you can add qualifiers to be more precise on your events.</p>
+</div>
+<h1 id="_the_example" class="sect0">The example</h1>
+<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>
+</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>
+</div>
+<h1 id="_conclusion" class="sect0">Conclusion</h1>
+<div class="paragraph">
+<p>CDI let’s 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>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-events.pdf b/content/examples/cdi-events.pdf
new file mode 100644
index 0000000..8c7f8fc
--- /dev/null
+++ b/content/examples/cdi-events.pdf
Binary files differ
diff --git a/content/examples/cdi-events/README.md b/content/examples/cdi-events/README.md
new file mode 100755
index 0000000..5e4801d
--- /dev/null
+++ b/content/examples/cdi-events/README.md
@@ -0,0 +1,32 @@
+# CDI events: loose coupling and extensibility
+
+CDI allows you to extend business code by the Notifier/Observer pattern.
+
+To do it you simply inject a field `Event` 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!).
+
+On the other side you annotated a method parameter `@Observes` and the parameter type is the sent type
+by the notifier.
+
+Note: of course you can add qualifiers to be more precise on your events.
+
+# The example
+
+The example is pretty simple: an ejb uses the `@Schedule` annotation to get a notification each second.
+The each second this EJB will send the current date through CDI events.
+
+This is our "business" code. It is a simple behavior (nothing).
+
+In our test (which is considered as an extension) we created an observer (`Observer` class)
+which simply store and log each received date.
+
+The test itself (`EventTest`) simply verifies the dates were received.
+
+# Conclusion
+
+CDI let's implement very easily plugins through this event mecanism.
+
+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.
diff --git a/content/examples/cdi-events/pom.xml b/content/examples/cdi-events/pom.xml
new file mode 100755
index 0000000..2256514
--- /dev/null
+++ b/content/examples/cdi-events/pom.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1178411 $ $Date: 2011-10-03 15:35:26 +0200 (lun. 03 oct. 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-events</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: CDI Events</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- to show events we log them in the test -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>1.7.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.6</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/cdi-events/src/main/java/org/superbiz/cdi/events/Notifier.java b/content/examples/cdi-events/src/main/java/org/superbiz/cdi/events/Notifier.java
new file mode 100755
index 0000000..ac2eb96
--- /dev/null
+++ b/content/examples/cdi-events/src/main/java/org/superbiz/cdi/events/Notifier.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.events;
+
+import javax.ejb.Schedule;
+import javax.ejb.Singleton;
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+import java.util.Date;
+
+@Singleton
+public class Notifier {
+
+ @Inject
+ private Event<Date> dateEvent;
+
+ @Schedule(second = "*", minute = "*", hour = "*")
+ public void sendHour() {
+ dateEvent.fire(new Date());
+ }
+}
diff --git a/content/examples/cdi-events/src/main/resources/META-INF/beans.xml b/content/examples/cdi-events/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..4692869
--- /dev/null
+++ b/content/examples/cdi-events/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<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"/>
diff --git a/content/examples/cdi-events/src/test/java/org/superbiz/cdi/events/EventTest.java b/content/examples/cdi-events/src/test/java/org/superbiz/cdi/events/EventTest.java
new file mode 100755
index 0000000..bb330be
--- /dev/null
+++ b/content/examples/cdi-events/src/test/java/org/superbiz/cdi/events/EventTest.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.events;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.NamingException;
+
+import static org.junit.Assert.assertTrue;
+
+public class EventTest {
+
+ private static EJBContainer container;
+ private static String initialLogProperty;
+
+ @Inject
+ private Observer observer;
+
+ @BeforeClass
+ public static void start() throws NamingException {
+ initialLogProperty = System.getProperty("openejb.logger.external");
+ System.setProperty("openejb.logger.external", "true");
+ container = EJBContainer.createEJBContainer();
+ }
+
+ @AfterClass
+ public static void shutdown() {
+ if (container != null) {
+ container.close();
+ }
+ if (initialLogProperty != null) {
+ System.setProperty("openejb.logger.external", initialLogProperty);
+ } else {
+ System.getProperties().remove("openejb.logger.external");
+ }
+ }
+
+ @Before
+ public void inject() throws NamingException {
+ container.getContext().bind("inject", this);
+ }
+
+ @After
+ public void reset() throws NamingException {
+ container.getContext().unbind("inject");
+ }
+
+ @Test
+ public void observe() throws InterruptedException {
+ Thread.sleep(4000);
+ assertTrue(observer.getDates().size() > 3); // in 4s normally at least 3 events were received
+ }
+}
diff --git a/content/examples/cdi-events/src/test/java/org/superbiz/cdi/events/Observer.java b/content/examples/cdi-events/src/test/java/org/superbiz/cdi/events/Observer.java
new file mode 100755
index 0000000..5d58369
--- /dev/null
+++ b/content/examples/cdi-events/src/test/java/org/superbiz/cdi/events/Observer.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.events;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.event.Observes;
+import javax.inject.Singleton;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Singleton
+public class Observer {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Observer.class);
+
+ private List<Date> dates = new ArrayList<Date>();
+
+ public void saveDate(@Observes Date date) {
+ dates.add(date);
+ LOGGER.info("received date '{}'", date);
+ }
+
+ public List<Date> getDates() {
+ return dates;
+ }
+}
diff --git a/content/examples/cdi-events/src/test/resources/META-INF/beans.xml b/content/examples/cdi-events/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..ff3508e
--- /dev/null
+++ b/content/examples/cdi-events/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<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"/>
+
diff --git a/content/examples/cdi-interceptors.html b/content/examples/cdi-interceptors.html
new file mode 100644
index 0000000..6a8d375
--- /dev/null
+++ b/content/examples/cdi-interceptors.html
@@ -0,0 +1,460 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-interceptors.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>CDI Interceptors</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example cdi-interceptors can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-interceptors" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-interceptors</a></p>
+</div>
+<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="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Log
+public void aMethod(){...}
+
+or
+
+@TimeRestricted
+public void bMethod(){...}
+
+Let's create these annotations that would "mark" a method for interception.
+
+@InterceptorBinding
+@Target({ TYPE, METHOD })
+@Retention(RUNTIME)
+public @interface Log {
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>And</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@InterceptorBinding
+@Target({ TYPE, METHOD })
+@Retention(RUNTIME)
+public @interface TimeRestricted {
+}</code></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="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@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");
+ @AroundInvoke
+ public Object logMethodEntry(InvocationContext ctx) throws Exception {
+ 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>
+</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>
+</div>
+<div class="paragraph">
+<p>That done, let’s annotate at class-level or method-level and have fun intercepting!</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@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");
+ return moviesAvailable;
+ }
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ // assume more methods are present
+}</code></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>
+</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>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><beans>
+ <interceptors>
+ <class>org.superbiz.cdi.bookshow.interceptors.BookForAShowLoggingInterceptor
+ </class>
+ <class>org.superbiz.cdi.bookshow.interceptors.TimeBasedRestrictingInterceptor
+ </class>
+ </interceptors>
+</beans></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>By default, a bean archive has no enabled interceptors bound via interceptor
+bindings. An interceptor must be explicitly enabled by listing its class
+in the <code>beans.xml</code>.</p>
+</div>
+<div class="paragraph">
+<p>Those lines in <code>beans.xml</code> not only "enable" the interceptors, but also define the "order of execution" of the interceptors.</p>
+</div>
+<div class="paragraph">
+<p>The order in with a method is annotated has no real significance.
+Eg:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@TimeRestrict
+@Log
+void cMethod(){}
+
+Here the `BookForAShowLoggingInterceptor` would be applied first and then `TimeBasedRestrictingInterceptor`
+
+So now you know that the order is only determined by the order of definition in `beans.xml`. Interceptors which occur earlier in the list are called first.
+
+Also note that a method can be marked for interception by multiple interceptors by applying multiple annotations as above.
+
+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?
+
+No worries! Just create a custom annotation which inherits from others
+
+@Inherited
+@InterceptorBinding
+@Target({ TYPE, METHOD })
+@Retention(RUNTIME)
+@Log
+@TimeRestricted
+public @interface TimeRestrictAndLog {
+}</code></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>
+</div>
+</div>
+</div>
+<h1 id="_the_code" class="sect0">The Code</h1>
+<div class="sect1">
+<h2 id="_bookforashowoneinterceptorapplied">BookForAShowOneInterceptorApplied</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p><code>BookForAShowOneInterceptorApplied</code> shows a simple <code>@Log</code> interceptor applied.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.bookshow.beans;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+
+import javax.ejb.Stateful;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@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");
+ return moviesAvailable;
+ }
+
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_bookforashowtwointerceptorsapplied">BookForAShowTwoInterceptorsApplied</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p><code>BookForAShowTwoInterceptorsApplied</code> shows both <code>@Log</code> and <code>@TimeRestricted</code> being applied.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.bookshow.beans;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestricted;
+
+import javax.ejb.Stateful;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@Log
+@Stateful
+public class BookForAShowTwoInterceptorsApplied 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");
+ return moviesAvailable;
+ }
+
+ @TimeRestricted
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_bookshowinterceptorbindinginheritanceexplored">BookShowInterceptorBindingInheritanceExplored</h2>
+<div class="sectionbody">
+<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="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.bookshow.beans;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestrictAndLog;
+
+import javax.ejb.Stateful;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@Stateful
+public class BookShowInterceptorBindingInheritanceExplored 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");
+ return moviesAvailable;
+ }
+
+ @TimeRestrictAndLog
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-interceptors.pdf b/content/examples/cdi-interceptors.pdf
new file mode 100644
index 0000000..85fc8fc
--- /dev/null
+++ b/content/examples/cdi-interceptors.pdf
Binary files differ
diff --git a/content/examples/cdi-interceptors/README.md b/content/examples/cdi-interceptors/README.md
new file mode 100755
index 0000000..31325d8
--- /dev/null
+++ b/content/examples/cdi-interceptors/README.md
@@ -0,0 +1,216 @@
+Title: CDI Interceptors
+
+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.
+
+How do we mark which methods are to be intercepted? Wouldn't it be handy to annotate a method like
+
+ @Log
+ public void aMethod(){...}
+
+or
+
+ @TimeRestricted
+ public void bMethod(){...}
+
+Let's create these annotations that would "mark" a method for interception.
+
+ @InterceptorBinding
+ @Target({ TYPE, METHOD })
+ @Retention(RUNTIME)
+ public @interface Log {
+ }
+
+And
+
+ @InterceptorBinding
+ @Target({ TYPE, METHOD })
+ @Retention(RUNTIME)
+ public @interface TimeRestricted {
+ }
+
+Sure, you haven't missed the `@InterceptorBinding` annotation above! Now that our custom annotations are created, lets attach them (or to use a better term for it, "bind them") to interceptors.
+
+So here's our logging interceptor. An `@AroundInvoke` method and we are almost done.
+
+ @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");
+ @AroundInvoke
+ public Object logMethodEntry(InvocationContext ctx) throws Exception {
+ logger.info("Before entering method:" + ctx.getMethod().getName());
+ InterceptionOrderTracker.getMethodsInterceptedList().add(ctx.getMethod().getName());
+ InterceptionOrderTracker.getInterceptedByList().add(this.getClass().getSimpleName());
+ return ctx.proceed();
+ }
+ }
+
+Now the `@Log` annotation we created is bound to this interceptor. (Likewise we bind `@TimeRestrict` for `TimeBasedRestrictingInterceptor`. See links below for source)
+
+That done, let's annotate at class-level or method-level and have fun intercepting!
+
+ @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");
+ return moviesAvailable;
+ }
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ // assume more methods are present
+ }
+
+The `@Log` annotation applied at class level denotes that all the methods should be intercepted with `BookForAShowLoggingInterceptor`.
+
+Before we say "all done" there's one last thing we are left with! To enable the interceptors!
+
+Lets quickly put up a `beans.xml` file like the following in `src/main/resources/META-INF/beans.xml`:
+
+ <beans>
+ <interceptors>
+ <class>org.superbiz.cdi.bookshow.interceptors.BookForAShowLoggingInterceptor
+ </class>
+ <class>org.superbiz.cdi.bookshow.interceptors.TimeBasedRestrictingInterceptor
+ </class>
+ </interceptors>
+ </beans>
+
+
+By default, a bean archive has no enabled interceptors bound via interceptor
+bindings. An interceptor must be explicitly enabled by listing its class
+in the `beans.xml`.
+
+Those lines in `beans.xml` not only "enable" the interceptors, but also define the "order of execution" of the interceptors.
+
+The order in with a method is annotated has no real significance.
+Eg:
+
+ @TimeRestrict
+ @Log
+ void cMethod(){}
+
+Here the `BookForAShowLoggingInterceptor` would be applied first and then `TimeBasedRestrictingInterceptor`
+
+So now you know that the order is only determined by the order of definition in `beans.xml`. Interceptors which occur earlier in the list are called first.
+
+Also note that a method can be marked for interception by multiple interceptors by applying multiple annotations as above.
+
+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?
+
+No worries! Just create a custom annotation which inherits from others
+
+ @Inherited
+ @InterceptorBinding
+ @Target({ TYPE, METHOD })
+ @Retention(RUNTIME)
+ @Log
+ @TimeRestricted
+ public @interface TimeRestrictAndLog {
+ }
+
+This is interceptor binding inheritance.
+
+The code below demonstrates the many cases that we have discussed.
+
+Not to forget, the old style binding with `@Interceptors(WhicheverInterceptor.class)` is also supported. Have a look at `BookForAShowOldStyleInterceptorBinding` where the comments explain how the newer way discussed above is better.
+
+# The Code
+
+## BookForAShowOneInterceptorApplied
+
+`BookForAShowOneInterceptorApplied` shows a simple `@Log` interceptor applied.
+
+ package org.superbiz.cdi.bookshow.beans;
+
+ import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+
+ import javax.ejb.Stateful;
+ import java.io.Serializable;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ @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");
+ return moviesAvailable;
+ }
+
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ }
+
+## BookForAShowTwoInterceptorsApplied
+
+`BookForAShowTwoInterceptorsApplied` shows both `@Log` and `@TimeRestricted` being applied.
+
+ package org.superbiz.cdi.bookshow.beans;
+
+ import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+ import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestricted;
+
+ import javax.ejb.Stateful;
+ import java.io.Serializable;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ @Log
+ @Stateful
+ public class BookForAShowTwoInterceptorsApplied 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");
+ return moviesAvailable;
+ }
+
+ @TimeRestricted
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ }
+
+## BookShowInterceptorBindingInheritanceExplored
+
+`BookShowInterceptorBindingInheritanceExplored` shows how `@TimeRestrictAndLog` (interceptor-binding-inheritance) can be used as an alternative for annotating a method with multiple annotations explicitly.
+
+ package org.superbiz.cdi.bookshow.beans;
+
+ import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestrictAndLog;
+
+ import javax.ejb.Stateful;
+ import java.io.Serializable;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ @Stateful
+ public class BookShowInterceptorBindingInheritanceExplored 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");
+ return moviesAvailable;
+ }
+
+ @TimeRestrictAndLog
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ }
+
diff --git a/content/examples/cdi-interceptors/pom.xml b/content/examples/cdi-interceptors/pom.xml
new file mode 100755
index 0000000..fae06a7
--- /dev/null
+++ b/content/examples/cdi-interceptors/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011)
+ $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-interceptors</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: CDI Interceptors</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ <!-- The <scope>test</scope> guarantees that non of your runtime code is
+ dependent on any OpenEJB classes. -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/AccessDeniedException.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/AccessDeniedException.java
new file mode 100755
index 0000000..9d038a2
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/AccessDeniedException.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi;
+
+import javax.ejb.ApplicationException;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@ApplicationException
+public class AccessDeniedException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public AccessDeniedException(String s) {
+ super(s);
+ }
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookForAShowOldStyleInterceptorBinding.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookForAShowOldStyleInterceptorBinding.java
new file mode 100755
index 0000000..99e2071
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookForAShowOldStyleInterceptorBinding.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.beans;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+import org.superbiz.cdi.bookshow.interceptors.BookForAShowLoggingInterceptor;
+
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * CDI supports binding an interceptor using @Interceptors
+ * Not recommended though. Has its disadvantages
+ * Cannot be disabled easily
+ * Order dependent on how it is listed in class
+ * Instead, create interceptor bindings using @InterceptorBinding and bind them
+ * See {@link Log}, {@link BookForAShowOneInterceptorApplied}, {@link BookForAShowLoggingInterceptor}
+ */
+@Interceptors(BookForAShowLoggingInterceptor.class)
+@Stateful
+public class BookForAShowOldStyleInterceptorBinding implements Serializable {
+
+ private static final long serialVersionUID = 6350400892234496909L;
+
+ public List<String> getMoviesList() {
+ List<String> moviesAvailable = new ArrayList<String>();
+ moviesAvailable.add("KungFu Panda 2");
+ moviesAvailable.add("Kings speech");
+ return moviesAvailable;
+ }
+
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ // assume more methods are present
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookForAShowOneInterceptorApplied.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookForAShowOneInterceptorApplied.java
new file mode 100755
index 0000000..ee5127d
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookForAShowOneInterceptorApplied.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.beans;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+
+import javax.ejb.Stateful;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@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");
+ return moviesAvailable;
+ }
+
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ // assume more methods are present
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookForAShowTwoInterceptorsApplied.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookForAShowTwoInterceptorsApplied.java
new file mode 100755
index 0000000..a3b98f5
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookForAShowTwoInterceptorsApplied.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.beans;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestricted;
+
+import javax.ejb.Stateful;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@Log
+@Stateful
+public class BookForAShowTwoInterceptorsApplied 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");
+ return moviesAvailable;
+ }
+
+ @TimeRestricted
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ // assume more methods are present
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookShowInterceptorBindingInheritanceExplored.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookShowInterceptorBindingInheritanceExplored.java
new file mode 100755
index 0000000..766a6f1
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/beans/BookShowInterceptorBindingInheritanceExplored.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.superbiz.cdi.bookshow.beans;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestrictAndLog;
+
+import javax.ejb.Stateful;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@Stateful
+public class BookShowInterceptorBindingInheritanceExplored 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");
+ return moviesAvailable;
+ }
+
+ @TimeRestrictAndLog
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ // assume more methods are present
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/Log.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/Log.java
new file mode 100755
index 0000000..6516dbc
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/Log.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptorbinding;
+
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+public @interface Log {
+
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/TimeRestrictAndLog.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/TimeRestrictAndLog.java
new file mode 100755
index 0000000..67c7232
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/TimeRestrictAndLog.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptorbinding;
+
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * This InterceptorBinding inherits from @Log and @TimeRestricted Interceptor-Bindings.
+ */
+@Inherited
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+@Log
+@TimeRestricted
+public @interface TimeRestrictAndLog {
+
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/TimeRestricted.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/TimeRestricted.java
new file mode 100755
index 0000000..3409482
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/TimeRestricted.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptorbinding;
+
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+public @interface TimeRestricted {
+
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowLoggingInterceptor.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowLoggingInterceptor.java
new file mode 100755
index 0000000..c467dc1
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowLoggingInterceptor.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptors;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+import org.superbiz.cdi.bookshow.tracker.InterceptionOrderTracker;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+import java.util.logging.Logger;
+
+@Interceptor
+@Log
+public class BookForAShowLoggingInterceptor implements Serializable {
+
+ private static final long serialVersionUID = 8139854519874743530L;
+ private Logger logger = Logger.getLogger("BookForAShowApplicationLogger");
+
+ @AroundInvoke
+ public Object logMethodEntry(InvocationContext ctx) throws Exception {
+ logger.info("Before entering method:" + ctx.getMethod().getName());
+ InterceptionOrderTracker.getMethodsInterceptedList().add(ctx.getMethod().getName());
+ InterceptionOrderTracker.getInterceptedByList().add(this.getClass().getSimpleName());
+ return ctx.proceed();
+ }
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptors/TimeBasedRestrictingInterceptor.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptors/TimeBasedRestrictingInterceptor.java
new file mode 100755
index 0000000..cc64771
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/interceptors/TimeBasedRestrictingInterceptor.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptors;
+
+import org.superbiz.cdi.AccessDeniedException;
+import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestricted;
+import org.superbiz.cdi.bookshow.tracker.InterceptionOrderTracker;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+
+@Interceptor
+@TimeRestricted
+public class TimeBasedRestrictingInterceptor implements Serializable {
+
+ private static final long serialVersionUID = 8139854519874743530L;
+
+ @AroundInvoke
+ public Object restrictAccessBasedOnTime(InvocationContext ctx) throws Exception {
+ InterceptionOrderTracker.getMethodsInterceptedList().add(ctx.getMethod().getName());
+ InterceptionOrderTracker.getInterceptedByList().add(this.getClass().getSimpleName());
+ if (!isWorkingHours()) {
+ throw new AccessDeniedException("You are not allowed to access the method at this time");
+ }
+ return ctx.proceed();
+ }
+
+ private boolean isWorkingHours() {
+ /*
+ * int hourOfDay = Calendar.getInstance().get(Calendar.HOUR_OF_DAY); if (hourOfDay >= 9 && hourOfDay <= 21) {
+ * return true; } else { return false; }
+ */
+ return true; // Let's assume
+ }
+}
diff --git a/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/tracker/InterceptionOrderTracker.java b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/tracker/InterceptionOrderTracker.java
new file mode 100755
index 0000000..81fabb8
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/java/org/superbiz/cdi/bookshow/tracker/InterceptionOrderTracker.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.tracker;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A helper class for the test.
+ * Keeps track of methods intercepted during one testXXX run
+ * Keeps track of interceptors applied during one textXXX run
+ */
+public class InterceptionOrderTracker {
+
+ /*
+ * Contains method names that were intercepted by the interceptors
+ */
+ private static List<String> methodsInterceptedList = new ArrayList<String>();
+ /*
+ * Contains the name of the interceptor class that intercepted a method
+ */
+ private static List<String> interceptedByList = new ArrayList<String>();
+
+ public static List<String> getInterceptedByList() {
+ return interceptedByList;
+ }
+
+ public static void setInterceptedByList(List<String> interceptedByList) {
+ InterceptionOrderTracker.interceptedByList = interceptedByList;
+ }
+
+ public static List<String> getMethodsInterceptedList() {
+ return methodsInterceptedList;
+ }
+}
diff --git a/content/examples/cdi-interceptors/src/main/resources/META-INF/beans.xml b/content/examples/cdi-interceptors/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c9ecdd7
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,33 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans>
+ <!-- By default, a bean archive has no enabled interceptors bound via interceptor
+ bindings. An interceptor must be explicitly enabled by listing its class
+ under the element of the beans.xml file of the bean archive. The order of
+ the interceptor declarations determines the interceptor ordering. Interceptors
+ which occur earlier in the list are called first. If the same class is listed
+ twice under the interceptors element, the container automatically detects
+ the problem and treats it as a deployment problem. -->
+
+ <interceptors>
+ <class>org.superbiz.cdi.bookshow.interceptors.BookForAShowLoggingInterceptor
+ </class>
+ <class>org.superbiz.cdi.bookshow.interceptors.TimeBasedRestrictingInterceptor
+ </class>
+ </interceptors>
+</beans>
diff --git a/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowOldStyleInterceptorBindingTest.java b/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowOldStyleInterceptorBindingTest.java
new file mode 100755
index 0000000..82f79c0
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowOldStyleInterceptorBindingTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptors;
+
+import junit.framework.TestCase;
+import org.superbiz.cdi.bookshow.beans.BookForAShowOldStyleInterceptorBinding;
+import org.superbiz.cdi.bookshow.tracker.InterceptionOrderTracker;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+
+public class BookForAShowOldStyleInterceptorBindingTest extends TestCase {
+
+ @EJB
+ private BookForAShowOldStyleInterceptorBinding bookForAShowBean;
+ EJBContainer ejbContainer;
+
+ /**
+ * Bootstrap the Embedded EJB Container
+ *
+ * @throws Exception
+ */
+ protected void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ ejbContainer.getContext().bind("inject", this);
+ }
+
+ /**
+ * Test basic interception
+ */
+ public void testMethodShouldBeIntercepted() {
+ // action
+ bookForAShowBean.getMoviesList();
+ // verify
+ assertTrue(InterceptionOrderTracker.getMethodsInterceptedList().contains("getMoviesList"));
+ }
+
+ protected void tearDown() {
+ // clear the lists after each test
+ InterceptionOrderTracker.getInterceptedByList().clear();
+ InterceptionOrderTracker.getMethodsInterceptedList().clear();
+ ejbContainer.close();
+ }
+}
diff --git a/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowOneInterceptorAppliedTest.java b/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowOneInterceptorAppliedTest.java
new file mode 100755
index 0000000..3d2319e
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowOneInterceptorAppliedTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptors;
+
+import junit.framework.TestCase;
+import org.superbiz.cdi.bookshow.beans.BookForAShowOneInterceptorApplied;
+import org.superbiz.cdi.bookshow.tracker.InterceptionOrderTracker;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+
+public class BookForAShowOneInterceptorAppliedTest extends TestCase {
+
+ @EJB
+ private BookForAShowOneInterceptorApplied bookForAShowBean;
+ EJBContainer ejbContainer;
+
+ /**
+ * Bootstrap the Embedded EJB Container
+ *
+ * @throws Exception
+ */
+ protected void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ ejbContainer.getContext().bind("inject", this);
+ }
+
+ /**
+ * Test basic interception
+ */
+ public void testMethodShouldBeIntercepted() {
+ // action
+ bookForAShowBean.getMoviesList();
+ // verify
+ assertTrue(InterceptionOrderTracker.getMethodsInterceptedList().contains("getMoviesList"));
+ }
+
+ protected void tearDown() {
+ // clear the list after each test
+ InterceptionOrderTracker.getInterceptedByList().clear();
+ InterceptionOrderTracker.getMethodsInterceptedList().clear();
+ ejbContainer.close();
+ }
+}
diff --git a/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowTwoInterceptorsAppiledTest.java b/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowTwoInterceptorsAppiledTest.java
new file mode 100755
index 0000000..192e2bc
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookForAShowTwoInterceptorsAppiledTest.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptors;
+
+import junit.framework.TestCase;
+import org.superbiz.cdi.bookshow.beans.BookForAShowTwoInterceptorsApplied;
+import org.superbiz.cdi.bookshow.tracker.InterceptionOrderTracker;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+
+public class BookForAShowTwoInterceptorsAppiledTest extends TestCase {
+
+ @EJB
+ private BookForAShowTwoInterceptorsApplied bookForAShowBean;
+ EJBContainer ejbContainer;
+
+ /**
+ * Bootstrap the Embedded EJB Container
+ *
+ * @throws Exception
+ */
+ protected void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ ejbContainer.getContext().bind("inject", this);
+ }
+
+ /**
+ * Interceptors should be applied in order as defined in beans.xml
+ */
+ public void testInterceptorsShouldBeAppliedInOrder() {
+ // action
+ bookForAShowBean.getDiscountedPrice(100);
+ // verify
+ List<String> interceptedByList = InterceptionOrderTracker.getInterceptedByList();
+ int indexOfLogger = interceptedByList.indexOf("BookForAShowLoggingInterceptor");
+ int indexOfTimeBasedRestrictor = interceptedByList.indexOf("TimeBasedRestrictingInterceptor");
+ assertTrue(indexOfLogger < indexOfTimeBasedRestrictor);
+ }
+
+ public void testTwoInterceptorsWereInvoked() {
+ // action
+ bookForAShowBean.getDiscountedPrice(100);
+ // verify
+ List<String> interceptedByList = InterceptionOrderTracker.getInterceptedByList();
+ assertTrue(interceptedByList.contains("BookForAShowLoggingInterceptor") && interceptedByList.contains("TimeBasedRestrictingInterceptor"));
+ }
+
+ protected void tearDown() {
+ // clear the lists after each test
+ InterceptionOrderTracker.getInterceptedByList().clear();
+ InterceptionOrderTracker.getMethodsInterceptedList().clear();
+ ejbContainer.close();
+ }
+}
diff --git a/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookShowInterceptorBindingInheritanceTest.java b/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookShowInterceptorBindingInheritanceTest.java
new file mode 100755
index 0000000..20ca275
--- /dev/null
+++ b/content/examples/cdi-interceptors/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookShowInterceptorBindingInheritanceTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptors;
+
+import junit.framework.TestCase;
+import org.superbiz.cdi.bookshow.beans.BookShowInterceptorBindingInheritanceExplored;
+import org.superbiz.cdi.bookshow.tracker.InterceptionOrderTracker;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+
+public class BookShowInterceptorBindingInheritanceTest extends TestCase {
+
+ @EJB
+ private BookShowInterceptorBindingInheritanceExplored bookForAShowBean;
+ EJBContainer ejbContainer;
+
+ /**
+ * Bootstrap the Embedded EJB Container
+ *
+ * @throws Exception
+ */
+ protected void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ ejbContainer.getContext().bind("inject", this);
+ }
+
+ public void testInterceptorBindingCanInheritFromAnotherBinding() {
+ // action
+ bookForAShowBean.getDiscountedPrice(100);
+ // verify both interceptors were invoked
+ List<String> interceptedByList = InterceptionOrderTracker.getInterceptedByList();
+ System.out.println("Intercepted by:" + interceptedByList);
+ assertTrue(interceptedByList.contains("BookForAShowLoggingInterceptor") && interceptedByList.contains("TimeBasedRestrictingInterceptor"));
+ }
+
+ protected void tearDown() {
+ // clear the list after each test
+ InterceptionOrderTracker.getInterceptedByList().clear();
+ InterceptionOrderTracker.getMethodsInterceptedList().clear();
+ ejbContainer.close();
+ }
+}
diff --git a/content/examples/cdi-produces-disposes.html b/content/examples/cdi-produces-disposes.html
new file mode 100644
index 0000000..653ca89
--- /dev/null
+++ b/content/examples/cdi-produces-disposes.html
@@ -0,0 +1,506 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-produces-disposes.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>CDI Produces Disposes</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example cdi-produces-disposes can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-produces-disposes" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-produces-disposes</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_consolehandler">ConsoleHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.disposes;
+
+public class ConsoleHandler implements LogHandler {
+
+ private String name;
+
+ public ConsoleHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_databasehandler">DatabaseHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.disposes;
+
+public class DatabaseHandler implements LogHandler {
+
+ private String name;
+
+ public DatabaseHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+ // Use connection to write log to database
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_filehandler">FileHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.disposes;
+
+public class FileHandler implements LogHandler {
+
+ private String name;
+
+ public FileHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+ // Write to log file
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logfactory">LogFactory</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.disposes;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+
+public class LogFactory {
+
+ private int type = 2;
+
+ @Produces
+ public LogHandler getLogHandler() {
+ switch (type) {
+ case 1:
+ return new FileHandler("@Produces created FileHandler!");
+ case 2:
+ return new DatabaseHandler("@Produces created DatabaseHandler!");
+ case 3:
+ default:
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
+ }
+ }
+
+ public void closeLogHandler(@Disposes LogHandler handler) {
+ switch (type) {
+ case 1:
+ System.out.println("Closing File handler!");
+ break;
+ case 2:
+ System.out.println("Closing DB handler!");
+ break;
+ case 3:
+ default:
+ System.out.println("Closing Console handler!");
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logger">Logger</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.disposes;
+
+public interface Logger {
+
+ public void log(String s);
+
+ public LogHandler getHandler();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggerimpl">LoggerImpl</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.disposes;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named("logger")
+public class LoggerImpl implements Logger {
+
+ @Inject
+ private LogHandler handler;
+
+ @Override
+ public void log(String s) {
+ getHandler().writeLog(s);
+ }
+
+ public LogHandler getHandler() {
+ return handler;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loghandler">LogHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.disposes;
+
+public interface LogHandler {
+
+ public String getName();
+
+ public void writeLog(String s);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_beans_xml">beans.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><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>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggertest">LoggerTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.disposes;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.Context;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class LoggerTest {
+
+ @Inject
+ Logger logger;
+
+ private Context ctxt;
+
+ @Before
+ public void setUp() {
+ try {
+ ctxt = EJBContainer.createEJBContainer().getContext();
+ ctxt.bind("inject", this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @After
+ public void cleanUp() {
+ try {
+ ctxt.unbind("inject");
+ ctxt.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @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");
+ logger = null;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.cdi.produces.disposes.LoggerTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+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 - 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
+INFO - Beginning load: /Users/dblevins/examples/cdi-produces-disposes/target/classes
+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 - 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 - 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)
+INFO - Started Ejb(deployment-id=org.superbiz.cdi.produces.disposes.LoggerTest, ejb-name=org.superbiz.cdi.produces.disposes.LoggerTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/cdi-produces-disposes)
+##### Handler: @Produces created DatabaseHandler!, Writing to the database!
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.02 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-produces-disposes.pdf b/content/examples/cdi-produces-disposes.pdf
new file mode 100644
index 0000000..aa22122
--- /dev/null
+++ b/content/examples/cdi-produces-disposes.pdf
Binary files differ
diff --git a/content/examples/cdi-produces-disposes/README.md b/content/examples/cdi-produces-disposes/README.md
new file mode 100755
index 0000000..66a0219
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/README.md
@@ -0,0 +1,259 @@
+Title: CDI Produces Disposes
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## ConsoleHandler
+
+ package org.superbiz.cdi.produces.disposes;
+
+ public class ConsoleHandler implements LogHandler {
+
+ private String name;
+
+ public ConsoleHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+ }
+ }
+
+## DatabaseHandler
+
+ package org.superbiz.cdi.produces.disposes;
+
+ public class DatabaseHandler implements LogHandler {
+
+ private String name;
+
+ public DatabaseHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+ // Use connection to write log to database
+ }
+ }
+
+## FileHandler
+
+ package org.superbiz.cdi.produces.disposes;
+
+ public class FileHandler implements LogHandler {
+
+ private String name;
+
+ public FileHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+ // Write to log file
+ }
+ }
+
+## LogFactory
+
+ package org.superbiz.cdi.produces.disposes;
+
+ import javax.enterprise.inject.Disposes;
+ import javax.enterprise.inject.Produces;
+
+ public class LogFactory {
+
+ private int type = 2;
+
+ @Produces
+ public LogHandler getLogHandler() {
+ switch (type) {
+ case 1:
+ return new FileHandler("@Produces created FileHandler!");
+ case 2:
+ return new DatabaseHandler("@Produces created DatabaseHandler!");
+ case 3:
+ default:
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
+ }
+ }
+
+ public void closeLogHandler(@Disposes LogHandler handler) {
+ switch (type) {
+ case 1:
+ System.out.println("Closing File handler!");
+ break;
+ case 2:
+ System.out.println("Closing DB handler!");
+ break;
+ case 3:
+ default:
+ System.out.println("Closing Console handler!");
+ }
+ }
+ }
+
+## Logger
+
+ package org.superbiz.cdi.produces.disposes;
+
+ public interface Logger {
+
+ public void log(String s);
+
+ public LogHandler getHandler();
+ }
+
+## LoggerImpl
+
+ package org.superbiz.cdi.produces.disposes;
+
+ import javax.inject.Inject;
+ import javax.inject.Named;
+
+ @Named("logger")
+ public class LoggerImpl implements Logger {
+
+ @Inject
+ private LogHandler handler;
+
+ @Override
+ public void log(String s) {
+ getHandler().writeLog(s);
+ }
+
+ public LogHandler getHandler() {
+ return handler;
+ }
+ }
+
+## LogHandler
+
+ package org.superbiz.cdi.produces.disposes;
+
+ public interface LogHandler {
+
+ public String getName();
+
+ public void writeLog(String s);
+ }
+
+## beans.xml
+
+ <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>
+
+## LoggerTest
+
+ package org.superbiz.cdi.produces.disposes;
+
+ import org.junit.After;
+ import org.junit.Before;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.inject.Inject;
+ import javax.naming.Context;
+
+ import static junit.framework.Assert.assertNotNull;
+ import static org.junit.Assert.assertFalse;
+ import static org.junit.Assert.assertTrue;
+
+ public class LoggerTest {
+
+ @Inject
+ Logger logger;
+
+ private Context ctxt;
+
+ @Before
+ public void setUp() {
+ try {
+ ctxt = EJBContainer.createEJBContainer().getContext();
+ ctxt.bind("inject", this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @After
+ public void cleanUp() {
+ try {
+ ctxt.unbind("inject");
+ ctxt.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @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");
+ logger = null;
+ }
+
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.cdi.produces.disposes.LoggerTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.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 - 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
+ INFO - Beginning load: /Users/dblevins/examples/cdi-produces-disposes/target/classes
+ 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 - 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 - 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)
+ INFO - Started Ejb(deployment-id=org.superbiz.cdi.produces.disposes.LoggerTest, ejb-name=org.superbiz.cdi.produces.disposes.LoggerTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/cdi-produces-disposes)
+ ##### Handler: @Produces created DatabaseHandler!, Writing to the database!
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.02 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/cdi-produces-disposes/README.txt b/content/examples/cdi-produces-disposes/README.txt
new file mode 100755
index 0000000..bca92da
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/README.txt
@@ -0,0 +1,18 @@
+This example shows how to use the concept of CDI in a simple POJO context
+
+This functionality is often referred as dependency injection (see
+http://www.martinfowler.com/articles/injection.html), and has been recently introduced in
+Java EE 5.
+
+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.
+
+ * A DatabaseHandler
+ * A FileHandler
+ * A ConsoleHandler
+
+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.
+
diff --git a/content/examples/cdi-produces-disposes/pom.xml b/content/examples/cdi-produces-disposes/pom.xml
new file mode 100755
index 0000000..2b5177f
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-produces-disposes</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: CDI-Disposes</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/ConsoleHandler.java b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/ConsoleHandler.java
new file mode 100755
index 0000000..25d9231
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/ConsoleHandler.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.disposes;
+
+public class ConsoleHandler implements LogHandler {
+
+ private String name;
+
+ public ConsoleHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+ }
+
+}
diff --git a/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/DatabaseHandler.java b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/DatabaseHandler.java
new file mode 100755
index 0000000..790f216
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/DatabaseHandler.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.disposes;
+
+public class DatabaseHandler implements LogHandler {
+
+ private String name;
+
+ public DatabaseHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+ // Use connection to write log to database
+ }
+
+}
diff --git a/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/FileHandler.java b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/FileHandler.java
new file mode 100755
index 0000000..afd20b9
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/FileHandler.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.disposes;
+
+public class FileHandler implements LogHandler {
+
+ private String name;
+
+ public FileHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+ // Write to log file
+ }
+
+}
diff --git a/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/LogFactory.java b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/LogFactory.java
new file mode 100755
index 0000000..94b8f43
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/LogFactory.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.disposes;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+
+public class LogFactory {
+
+ private int type = 2;
+
+ @Produces
+ public LogHandler getLogHandler() {
+ switch (type) {
+ case 1:
+ return new FileHandler("@Produces created FileHandler!");
+ case 2:
+ return new DatabaseHandler("@Produces created DatabaseHandler!");
+ case 3:
+ default:
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
+ }
+
+ }
+
+ public void closeLogHandler(@Disposes LogHandler handler) {
+ switch (type) {
+ case 1:
+ System.out.println("Closing File handler!");
+ break;
+ case 2:
+ System.out.println("Closing DB handler!");
+ break;
+ case 3:
+ default:
+ System.out.println("Closing Console handler!");
+ }
+ }
+
+}
diff --git a/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/LogHandler.java b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/LogHandler.java
new file mode 100755
index 0000000..87faca5
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/LogHandler.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.disposes;
+
+public interface LogHandler {
+
+ public String getName();
+
+ public void writeLog(String s);
+
+}
diff --git a/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/Logger.java b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/Logger.java
new file mode 100755
index 0000000..a8f4193
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/Logger.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.disposes;
+
+public interface Logger {
+
+ public void log(String s);
+
+ public LogHandler getHandler();
+
+}
diff --git a/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/LoggerImpl.java b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/LoggerImpl.java
new file mode 100755
index 0000000..39a6045
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/src/main/java/org/superbiz/cdi/produces/disposes/LoggerImpl.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.disposes;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named("logger")
+public class LoggerImpl implements Logger {
+
+ @Inject
+ private LogHandler handler;
+
+ @Override
+ public void log(String s) {
+ getHandler().writeLog(s);
+ }
+
+ public LogHandler getHandler() {
+ return handler;
+ }
+
+}
diff --git a/content/examples/cdi-produces-disposes/src/main/resources/META-INF/beans.xml b/content/examples/cdi-produces-disposes/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..084709d
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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>
\ No newline at end of file
diff --git a/content/examples/cdi-produces-disposes/src/test/java/org/superbiz/cdi/produces/disposes/LoggerTest.java b/content/examples/cdi-produces-disposes/src/test/java/org/superbiz/cdi/produces/disposes/LoggerTest.java
new file mode 100755
index 0000000..10f24bf
--- /dev/null
+++ b/content/examples/cdi-produces-disposes/src/test/java/org/superbiz/cdi/produces/disposes/LoggerTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.disposes;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class LoggerTest {
+
+ @Inject
+ Logger logger;
+
+ private EJBContainer container;
+
+ @Before
+ public void setUp() {
+ try {
+ container = EJBContainer.createEJBContainer();
+ container.getContext().bind("inject", this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @After
+ public void cleanUp() {
+ try {
+ container.getContext().unbind("inject");
+ container.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @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");
+ logger = null;
+ }
+
+}
diff --git a/content/examples/cdi-produces-field.html b/content/examples/cdi-produces-field.html
new file mode 100644
index 0000000..e3002d2
--- /dev/null
+++ b/content/examples/cdi-produces-field.html
@@ -0,0 +1,538 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-produces-field.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>CDI field producer</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example cdi-produces-field can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-produces-field" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-produces-field</a></p>
+</div>
+<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>
+</div>
+<div class="sect1">
+<h2 id="_consolehandler">ConsoleHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.field;
+
+public class ConsoleHandler implements LogHandler {
+
+ private String name;
+
+ public ConsoleHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_databasehandler">DatabaseHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.field;
+
+public class DatabaseHandler implements LogHandler {
+
+ private String name;
+
+ public DatabaseHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+ // Use connection to write log to database
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_filehandler">FileHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.field;
+
+public class FileHandler implements LogHandler {
+
+ private String name;
+
+ public FileHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+ // Write to log file
+ }
+}</code></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;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>import javax.enterprise.inject.Produces;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public class LogFactory {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>private int type = 2;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Produces
+LogHandler handler;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public LogFactory(){
+ handler = getLogHandler();
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public LogHandler getLogHandler() {
+ switch (type) {
+ case 1:
+ return new FileHandler("@Produces created FileHandler!");
+ case 2:
+ return new DatabaseHandler("@Produces created DatabaseHandler!");
+ case 3:
+ default:
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
+ }</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> }
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logger">Logger</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.field;
+
+public interface Logger {
+
+ public void log(String s);
+
+ public LogHandler getHandler();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggerimpl">LoggerImpl</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.field;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named("logger")
+public class LoggerImpl implements Logger {
+
+ @Inject
+ private LogHandler handler;
+
+ @Override
+ public void log(String s) {
+ getHandler().writeLog(s);
+ }
+
+ public LogHandler getHandler() {
+ return handler;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loghandler">LogHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.field;
+
+public interface LogHandler {
+
+ public String getName();
+
+ public void writeLog(String s);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_beans_xml">beans.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><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>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggertest">LoggerTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.produces.field;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.Context;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class LoggerTest {
+
+ @Inject
+ Logger logger;
+
+ private Context ctxt;
+
+ @Before
+ public void setUp() {
+ try {
+ ctxt = EJBContainer.createEJBContainer().getContext();
+ ctxt.bind("inject", this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @After
+ public void cleanUp() {
+ try {
+ ctxt.unbind("inject");
+ ctxt.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @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");
+ logger = null;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.cdi.produces.field.LoggerTest
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://tomee.apache.org/
+ INFO - Startup: Thu May 10 01:28:19 CDT 2012
+ INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 7.0.0-SNAPSHOT
+ INFO - Build date: 20120510
+ INFO - Build time: 04:06
+ INFO - ********************************************************************************
+ INFO - openejb.home = /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+ 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 - 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 - 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
+ INFO - Auto-deploying ejb cdi-produces-field.Comp: EjbDeployment(deployment-id=cdi-produces-field.Comp)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ 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 - Assembling app: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+ INFO - ignoreXmlConfiguration == true
+ INFO - ignoreXmlConfiguration == true
+ INFO - existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@a81b1fb
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points were validated successfully.
+ INFO - OpenWebBeans Container has started, it took [69] ms.
+ INFO - Deployed Application(path=/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field)
+ ##### Handler: @Produces created DatabaseHandler!, Writing to the database!
+ INFO - Undeploying app: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.79 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-produces-field.pdf b/content/examples/cdi-produces-field.pdf
new file mode 100644
index 0000000..0346030
--- /dev/null
+++ b/content/examples/cdi-produces-field.pdf
Binary files differ
diff --git a/content/examples/cdi-produces-field/README.md b/content/examples/cdi-produces-field/README.md
new file mode 100755
index 0000000..1b8e466
--- /dev/null
+++ b/content/examples/cdi-produces-field/README.md
@@ -0,0 +1,270 @@
+Title: CDI field producer
+
+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.
+
+## ConsoleHandler
+
+ package org.superbiz.cdi.produces.field;
+
+ public class ConsoleHandler implements LogHandler {
+
+ private String name;
+
+ public ConsoleHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+ }
+ }
+
+## DatabaseHandler
+
+ package org.superbiz.cdi.produces.field;
+
+ public class DatabaseHandler implements LogHandler {
+
+ private String name;
+
+ public DatabaseHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+ // Use connection to write log to database
+ }
+ }
+
+## FileHandler
+
+ package org.superbiz.cdi.produces.field;
+
+ public class FileHandler implements LogHandler {
+
+ private String name;
+
+ public FileHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+ // Write to log file
+ }
+ }
+
+## LogFactory
+
+ package org.superbiz.cdi.produces.field;
+
+ import javax.enterprise.inject.Produces;
+
+ public class LogFactory {
+
+ private int type = 2;
+
+ @Produces
+ LogHandler handler;
+
+ public LogFactory(){
+ handler = getLogHandler();
+ }
+
+ public LogHandler getLogHandler() {
+ switch (type) {
+ case 1:
+ return new FileHandler("@Produces created FileHandler!");
+ case 2:
+ return new DatabaseHandler("@Produces created DatabaseHandler!");
+ case 3:
+ default:
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
+ }
+
+ }
+ }
+
+## Logger
+
+ package org.superbiz.cdi.produces.field;
+
+ public interface Logger {
+
+ public void log(String s);
+
+ public LogHandler getHandler();
+ }
+
+## LoggerImpl
+
+ package org.superbiz.cdi.produces.field;
+
+ import javax.inject.Inject;
+ import javax.inject.Named;
+
+ @Named("logger")
+ public class LoggerImpl implements Logger {
+
+ @Inject
+ private LogHandler handler;
+
+ @Override
+ public void log(String s) {
+ getHandler().writeLog(s);
+ }
+
+ public LogHandler getHandler() {
+ return handler;
+ }
+ }
+
+## LogHandler
+
+ package org.superbiz.cdi.produces.field;
+
+ public interface LogHandler {
+
+ public String getName();
+
+ public void writeLog(String s);
+ }
+
+## beans.xml
+
+ <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>
+
+## LoggerTest
+
+ package org.superbiz.cdi.produces.field;
+
+ import org.junit.After;
+ import org.junit.Before;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.inject.Inject;
+ import javax.naming.Context;
+
+ import static junit.framework.Assert.assertNotNull;
+ import static org.junit.Assert.assertFalse;
+ import static org.junit.Assert.assertTrue;
+
+ public class LoggerTest {
+
+ @Inject
+ Logger logger;
+
+ private Context ctxt;
+
+ @Before
+ public void setUp() {
+ try {
+ ctxt = EJBContainer.createEJBContainer().getContext();
+ ctxt.bind("inject", this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @After
+ public void cleanUp() {
+ try {
+ ctxt.unbind("inject");
+ ctxt.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @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");
+ logger = null;
+ }
+
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.cdi.produces.field.LoggerTest
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://openejb.apache.org/
+ INFO - Startup: Thu May 10 01:28:19 CDT 2012
+ INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 4.0.0-beta-3-SNAPSHOT
+ INFO - Build date: 20120510
+ INFO - Build time: 04:06
+ INFO - ********************************************************************************
+ INFO - openejb.home = /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+ 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 - 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 - 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
+ INFO - Auto-deploying ejb cdi-produces-field.Comp: EjbDeployment(deployment-id=cdi-produces-field.Comp)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ 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 - Assembling app: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+ INFO - ignoreXmlConfiguration == true
+ INFO - ignoreXmlConfiguration == true
+ INFO - existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@a81b1fb
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points were validated successfully.
+ INFO - OpenWebBeans Container has started, it took [69] ms.
+ INFO - Deployed Application(path=/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field)
+ ##### Handler: @Produces created DatabaseHandler!, Writing to the database!
+ INFO - Undeploying app: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.79 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/cdi-produces-field/pom.xml b/content/examples/cdi-produces-field/pom.xml
new file mode 100755
index 0000000..d905255
--- /dev/null
+++ b/content/examples/cdi-produces-field/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-produces-field</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: CDI-Field Producer</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/ConsoleHandler.java b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/ConsoleHandler.java
new file mode 100755
index 0000000..ad4bfc0
--- /dev/null
+++ b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/ConsoleHandler.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public class ConsoleHandler implements LogHandler {
+
+ private String name;
+
+ public ConsoleHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+ }
+
+}
diff --git a/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/DatabaseHandler.java b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/DatabaseHandler.java
new file mode 100755
index 0000000..e5ecd81
--- /dev/null
+++ b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/DatabaseHandler.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public class DatabaseHandler implements LogHandler {
+
+ private String name;
+
+ public DatabaseHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+ // Use connection to write log to database
+ }
+
+}
diff --git a/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/FileHandler.java b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/FileHandler.java
new file mode 100755
index 0000000..5930293
--- /dev/null
+++ b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/FileHandler.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public class FileHandler implements LogHandler {
+
+ private String name;
+
+ public FileHandler(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void writeLog(String s) {
+ System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+ // Write to log file
+ }
+
+}
diff --git a/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogFactory.java b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogFactory.java
new file mode 100755
index 0000000..5926392
--- /dev/null
+++ b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogFactory.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+import javax.enterprise.inject.Produces;
+
+public class LogFactory {
+
+ private int type = 2;
+
+ @Produces
+ LogHandler handler;
+
+ public LogFactory() {
+ handler = getLogHandler();
+ }
+
+ public LogHandler getLogHandler() {
+ switch (type) {
+ case 1:
+ return new FileHandler("@Produces created FileHandler!");
+ case 2:
+ return new DatabaseHandler("@Produces created DatabaseHandler!");
+ case 3:
+ default:
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
+ }
+
+ }
+}
diff --git a/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogHandler.java b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogHandler.java
new file mode 100755
index 0000000..a72b7f2
--- /dev/null
+++ b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogHandler.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public interface LogHandler {
+
+ public String getName();
+
+ public void writeLog(String s);
+
+}
diff --git a/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/Logger.java b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/Logger.java
new file mode 100755
index 0000000..85e625c
--- /dev/null
+++ b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/Logger.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public interface Logger {
+
+ public void log(String s);
+
+ public LogHandler getHandler();
+
+}
diff --git a/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LoggerImpl.java b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LoggerImpl.java
new file mode 100755
index 0000000..073b93f
--- /dev/null
+++ b/content/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LoggerImpl.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named("logger")
+public class LoggerImpl implements Logger {
+
+ @Inject
+ private LogHandler handler;
+
+ @Override
+ public void log(String s) {
+ getHandler().writeLog(s);
+ }
+
+ public LogHandler getHandler() {
+ return handler;
+ }
+
+}
diff --git a/content/examples/cdi-produces-field/src/main/resources/META-INF/beans.xml b/content/examples/cdi-produces-field/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..04392fd
--- /dev/null
+++ b/content/examples/cdi-produces-field/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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>
diff --git a/content/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/field/LoggerTest.java b/content/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/field/LoggerTest.java
new file mode 100755
index 0000000..8d1fc21
--- /dev/null
+++ b/content/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/field/LoggerTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class LoggerTest {
+
+ @Inject
+ Logger logger;
+
+ private EJBContainer container;
+
+ @Before
+ public void setUp() {
+ try {
+ container = EJBContainer.createEJBContainer();
+ container.getContext().bind("inject", this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @After
+ public void cleanUp() {
+ try {
+ container.getContext().unbind("inject");
+ container.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @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");
+ logger = null;
+ }
+
+}
diff --git a/content/examples/cdi-query/pom.xml b/content/examples/cdi-query/pom.xml
new file mode 100755
index 0000000..540fca0
--- /dev/null
+++ b/content/examples/cdi-query/pom.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-query</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: CDI Query</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.mysema.querydsl</groupId>
+ <artifactId>querydsl-jpa</artifactId>
+ <version>2.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.ctp.cdi.query</groupId>
+ <artifactId>cdi-query-api</artifactId>
+ <version>1.0.0.Alpha5</version>
+ </dependency>
+ <dependency>
+ <groupId>com.ctp.cdi.query</groupId>
+ <artifactId>cdi-query-impl</artifactId>
+ <version>1.0.0.Alpha5</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-servlet</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.17.1-GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
+
diff --git a/content/examples/cdi-query/src/main/java/org/superbiz/dynamic/EntityManagerProducer.java b/content/examples/cdi-query/src/main/java/org/superbiz/dynamic/EntityManagerProducer.java
new file mode 100755
index 0000000..45b0fa2
--- /dev/null
+++ b/content/examples/cdi-query/src/main/java/org/superbiz/dynamic/EntityManagerProducer.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Stateless
+public class EntityManagerProducer {
+
+ @PersistenceContext
+ @Produces
+ private EntityManager em;
+}
diff --git a/content/examples/cdi-query/src/main/java/org/superbiz/dynamic/User.java b/content/examples/cdi-query/src/main/java/org/superbiz/dynamic/User.java
new file mode 100755
index 0000000..bbc4198
--- /dev/null
+++ b/content/examples/cdi-query/src/main/java/org/superbiz/dynamic/User.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class User {
+
+ @Id
+ @GeneratedValue
+ private long id;
+ private String name;
+ private int age;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
diff --git a/content/examples/cdi-query/src/main/java/org/superbiz/dynamic/UserDao.java b/content/examples/cdi-query/src/main/java/org/superbiz/dynamic/UserDao.java
new file mode 100755
index 0000000..4302bcb
--- /dev/null
+++ b/content/examples/cdi-query/src/main/java/org/superbiz/dynamic/UserDao.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import com.ctp.cdi.query.Dao;
+import com.ctp.cdi.query.EntityDao;
+
+@Dao
+public interface UserDao extends EntityDao<User, Long> {
+
+}
diff --git a/content/examples/cdi-query/src/main/resources/META-INF/beans.xml b/content/examples/cdi-query/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/cdi-query/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/cdi-query/src/main/resources/META-INF/persistence.xml b/content/examples/cdi-query/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..97d2ba5
--- /dev/null
+++ b/content/examples/cdi-query/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="dynamic" transaction-type="JTA">
+ <jta-data-source>jdbc/dynamicDB</jta-data-source>
+ <class>org.superbiz.dynamic.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/cdi-query/src/test/java/org/superbiz/dynamic/CdiQueryTest.java b/content/examples/cdi-query/src/test/java/org/superbiz/dynamic/CdiQueryTest.java
new file mode 100755
index 0000000..0a37ec7
--- /dev/null
+++ b/content/examples/cdi-query/src/test/java/org/superbiz/dynamic/CdiQueryTest.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.NamingException;
+import java.util.Collection;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * the UserDao can be injected but doesn't manage transaction so we create
+ * a TxProvider bean which provides the tx context.
+ * <p/>
+ * In this sample it simply delegates but in real life it often aggregates multiple calls.
+ */
+public class CdiQueryTest {
+
+ private static EJBContainer container;
+ private static boolean initialized = false;
+
+ @Inject
+ private TxProvider dao;
+
+ @Test
+ public void findAll() {
+ Collection<User> users = dao.findAll();
+ assertEquals(10, users.size());
+ }
+
+ @BeforeClass
+ public static void start() throws Exception {
+ final Properties p = new Properties();
+
+ p.setProperty("jdbc/CdiQueryTest", "new://Resource?type=DataSource");
+ p.setProperty("jdbc/CdiQueryTest.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.setProperty("jdbc/CdiQueryTest.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.setProperty("jdbc/CdiQueryTest.UserName", "sa");
+ p.setProperty("jdbc/CdiQueryTest.Password", "");
+
+ container = EJBContainer.createEJBContainer(p);
+ }
+
+ @Before
+ public void injectAndInit() throws NamingException {
+ container.getContext().bind("inject", this);
+ if (!initialized) {
+ for (int i = 0; i < 10; i++) {
+ final User u = new User();
+ u.setAge(i % 4);
+ if (i % 3 == 0) {
+ u.setName("foo");
+ } else {
+ u.setName("bar-" + i);
+ }
+ dao.save(u);
+ }
+ initialized = true;
+ }
+ }
+
+ @AfterClass
+ public static void close() {
+ container.close();
+ }
+
+ @Singleton
+ @Lock(LockType.READ)
+ public static class TxProvider { // just here to provide the transactional context
+ @Inject
+ private UserDao dao;
+
+ public Collection<User> findAll() {
+ return dao.findAll();
+ }
+
+ public void save(final User u) {
+ dao.save(u);
+ }
+ }
+}
diff --git a/content/examples/cdi-realm.html b/content/examples/cdi-realm.html
new file mode 100644
index 0000000..187b842
--- /dev/null
+++ b/content/examples/cdi-realm.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-realm.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>cdi-realm</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example cdi-realm can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-realm" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-realm</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-realm.pdf b/content/examples/cdi-realm.pdf
new file mode 100644
index 0000000..d156aef
--- /dev/null
+++ b/content/examples/cdi-realm.pdf
Binary files differ
diff --git a/content/examples/cdi-realm/pom.xml b/content/examples/cdi-realm/pom.xml
new file mode 100755
index 0000000..027b066
--- /dev/null
+++ b/content/examples/cdi-realm/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-realm</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: CDI Realm</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/cdi-realm/src/main/java/org/superbiz/AuthBean.java b/content/examples/cdi-realm/src/main/java/org/superbiz/AuthBean.java
new file mode 100755
index 0000000..66fb943
--- /dev/null
+++ b/content/examples/cdi-realm/src/main/java/org/superbiz/AuthBean.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import javax.enterprise.context.RequestScoped;
+import java.security.Principal;
+
+@RequestScoped
+public class AuthBean {
+
+ public Principal authenticate(final String username, String password) {
+ if (("userA".equals(username) || "userB".equals(username)) && "test".equals(password)) {
+ return new Principal() {
+ @Override
+ public String getName() {
+ return username;
+ }
+
+ @Override
+ public String toString() {
+ return username;
+ }
+ };
+ }
+ return null;
+ }
+
+ public boolean hasRole(Principal principal, String role) {
+ if (principal == null) {
+ return false;
+ }
+ if (principal.getName().equals("userA") && (role.equals("admin") || role.equals("user"))) {
+ return true;
+ }
+ if (principal.getName().equals("userB") && (role.equals("user"))) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/content/examples/cdi-realm/src/main/webapp/META-INF/context.xml b/content/examples/cdi-realm/src/main/webapp/META-INF/context.xml
new file mode 100755
index 0000000..d7959ae
--- /dev/null
+++ b/content/examples/cdi-realm/src/main/webapp/META-INF/context.xml
@@ -0,0 +1,20 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<Context>
+ <Realm cdi="true" className="org.apache.tomee.catalina.realm.LazyRealm" realmClass="org.superbiz.AuthBean"/>
+</Context>
\ No newline at end of file
diff --git a/content/examples/cdi-realm/src/main/webapp/WEB-INF/beans.xml b/content/examples/cdi-realm/src/main/webapp/WEB-INF/beans.xml
new file mode 100755
index 0000000..9b0b74f
--- /dev/null
+++ b/content/examples/cdi-realm/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,18 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans/>
diff --git a/content/examples/cdi-request-scope.html b/content/examples/cdi-request-scope.html
new file mode 100644
index 0000000..2e86582
--- /dev/null
+++ b/content/examples/cdi-request-scope.html
@@ -0,0 +1,369 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-request-scope.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>CDI @RequestScoped</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example cdi-request-scope can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-request-scope" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-request-scope</a></p>
+</div>
+<div class="paragraph">
+<p>This example show the use of <code>@RequestScoped</code> annotation for injected objects. An object
+which is defined as <code>@RequestScoped</code> is created once for every request and is shared by all the
+bean that inject it throughout a request.</p>
+</div>
+</div>
+</div>
+<h1 id="_example" class="sect0">Example</h1>
+<div class="paragraph">
+<p>This example depicts a similar scenario to cdi-application-scope. A restaurant guest orders
+a soup from the waiter. The order is passed to the chef who prepares it and passes it back
+the waiter who in turn delivers it to the guest.</p>
+</div>
+<div class="sect1">
+<h2 id="_waiter">Waiter</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The <code>Waiter</code> session bean receives a request from the test class via the <code>orderSoup()</code> method.
+A <code>Soup</code> insance will be created in this method and will be shared throughout the request with
+the <code>Chef</code> bean. The method passes the request to the <code>Chef</code> bean. It then returns the name of
+the soup to the test class.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stateless
+public class Waiter {
+
+ @Inject
+ private Soup soup;
+
+ @EJB
+ private Chef chef;
+
+ public String orderSoup(String name){
+ soup.setName(name);
+ return chef.prepareSoup().getName();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_soup">Soup</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The <code>Soup</code> class is an injectable POJO, defined as <code>@RequestScoped</code>. This means that an instance
+will be created only once for every request and will be shared by all the beans injecting it.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@RequestScoped
+public class Soup {
+
+ private String name = "Soup of the day";
+
+ @PostConstruct
+ public void afterCreate() {
+ System.out.println("Soup created");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chef">Chef</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The <code>Chef</code> class is a simple session bean with an injected <code>Soup</code> field. Normally, the soup
+parameter would be passed as a <code>prepareSoup()</code> argument, but for the need of this example
+it’s passed by the request context.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stateless
+public class Chef {
+
+ @Inject
+ private Soup soup;
+
+ public Soup prepareSoup() {
+ return soup;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_test_case" class="sect0">Test Case</h1>
+<div class="paragraph">
+<p>This is the entry class for this example.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class RestaurantTest {
+
+ private static String TOMATO_SOUP = "Tomato Soup";
+ private EJBContainer container;
+
+ @EJB
+ private Waiter joe;
+
+ @Before
+ public void startContainer() throws Exception {
+ container = EJBContainer.createEJBContainer();
+ container.getContext().bind("inject", this);
+ }
+
+ @Test
+ public void orderSoup(){
+ String soup = joe.orderSoup(TOMATO_SOUP);
+ assertEquals(TOMATO_SOUP, soup);
+ soup = joe.orderSoup(POTATO_SOUP);
+ assertEquals(POTATO_SOUP, soup);
+ }
+
+ @After
+ public void closeContainer() throws Exception {
+ container.close();
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>In the output you can see that there were two <code>Soup</code> instances created - one for
+each request.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.cdi.requestscope.RestaurantTest
+Apache OpenEJB 7.0.0-SNAPSHOT build: 20111224-11:09
+http://tomee.apache.org/
+INFO - openejb.home = C:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+INFO - openejb.base = C:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+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-request-scope\target\classes
+INFO - Beginning load: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope\target\classes
+INFO - Configuring enterprise application: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean cdi-request-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 Chef: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope" loaded.
+INFO - Assembling app: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+INFO - Jndi(name="java:global/cdi-request-scope/Chef!org.superbiz.cdi.requestscope.Chef")
+INFO - Jndi(name="java:global/cdi-request-scope/Chef")
+INFO - Jndi(name="java:global/cdi-request-scope/Waiter!org.superbiz.cdi.requestscope.Waiter")
+INFO - Jndi(name="java:global/cdi-request-scope/Waiter")
+INFO - Created Ejb(deployment-id=Chef, ejb-name=Chef, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=Waiter, ejb-name=Waiter, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=Chef, ejb-name=Chef, 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-request-scope)
+Soup created
+Soup created
+INFO - Undeploying app: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.412 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-request-scope.pdf b/content/examples/cdi-request-scope.pdf
new file mode 100644
index 0000000..e449dd1
--- /dev/null
+++ b/content/examples/cdi-request-scope.pdf
Binary files differ
diff --git a/content/examples/cdi-request-scope/README.md b/content/examples/cdi-request-scope/README.md
new file mode 100755
index 0000000..c771b20
--- /dev/null
+++ b/content/examples/cdi-request-scope/README.md
@@ -0,0 +1,150 @@
+Title: CDI @RequestScoped
+
+This example show the use of `@RequestScoped` annotation for injected objects. An object
+which is defined as `@RequestScoped` is created once for every request and is shared by all the
+bean that inject it throughout a request.
+
+# Example
+
+This example depicts a similar scenario to cdi-application-scope. A restaurant guest orders
+a soup from the waiter. The order is passed to the chef who prepares it and passes it back
+the waiter who in turn delivers it to the guest.
+
+## Waiter
+
+The `Waiter` session bean receives a request from the test class via the `orderSoup()` method.
+A `Soup` insance will be created in this method and will be shared throughout the request with
+the `Chef` bean. The method passes the request to the `Chef` bean. It then returns the name of
+the soup to the test class.
+
+ @Stateless
+ public class Waiter {
+
+ @Inject
+ private Soup soup;
+
+ @EJB
+ private Chef chef;
+
+ public String orderSoup(String name){
+ soup.setName(name);
+ return chef.prepareSoup().getName();
+ }
+ }
+
+## Soup
+
+The `Soup` class is an injectable POJO, defined as `@RequestScoped`. This means that an instance
+will be created only once for every request and will be shared by all the beans injecting it.
+
+ @RequestScoped
+ public class Soup {
+
+ private String name = "Soup of the day";
+
+ @PostConstruct
+ public void afterCreate() {
+ System.out.println("Soup created");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+ }
+
+## Chef
+
+The `Chef` class is a simple session bean with an injected `Soup` field. Normally, the soup
+parameter would be passed as a `prepareSoup()` argument, but for the need of this example
+it's passed by the request context.
+
+ @Stateless
+ public class Chef {
+
+ @Inject
+ private Soup soup;
+
+ public Soup prepareSoup() {
+ return soup;
+ }
+ }
+
+# Test Case
+
+This is the entry class for this example.
+
+ public class RestaurantTest {
+
+ private static String TOMATO_SOUP = "Tomato Soup";
+ private EJBContainer container;
+
+ @EJB
+ private Waiter joe;
+
+ @Before
+ public void startContainer() throws Exception {
+ container = EJBContainer.createEJBContainer();
+ container.getContext().bind("inject", this);
+ }
+
+ @Test
+ public void orderSoup(){
+ String soup = joe.orderSoup(TOMATO_SOUP);
+ assertEquals(TOMATO_SOUP, soup);
+ soup = joe.orderSoup(POTATO_SOUP);
+ assertEquals(POTATO_SOUP, soup);
+ }
+
+ @After
+ public void closeContainer() throws Exception {
+ container.close();
+ }
+ }
+
+# Running
+
+In the output you can see that there were two `Soup` instances created - one for
+each request.
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.cdi.requestscope.RestaurantTest
+ Apache OpenEJB 4.0.0-beta-2-SNAPSHOT build: 20111224-11:09
+ http://openejb.apache.org/
+ INFO - openejb.home = C:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+ INFO - openejb.base = C:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+ 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-request-scope\target\classes
+ INFO - Beginning load: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope\target\classes
+ INFO - Configuring enterprise application: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean cdi-request-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 Chef: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope" loaded.
+ INFO - Assembling app: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+ INFO - Jndi(name="java:global/cdi-request-scope/Chef!org.superbiz.cdi.requestscope.Chef")
+ INFO - Jndi(name="java:global/cdi-request-scope/Chef")
+ INFO - Jndi(name="java:global/cdi-request-scope/Waiter!org.superbiz.cdi.requestscope.Waiter")
+ INFO - Jndi(name="java:global/cdi-request-scope/Waiter")
+ INFO - Created Ejb(deployment-id=Chef, ejb-name=Chef, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=Waiter, ejb-name=Waiter, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=Chef, ejb-name=Chef, 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-request-scope)
+ Soup created
+ Soup created
+ INFO - Undeploying app: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.412 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/cdi-request-scope/pom.xml b/content/examples/cdi-request-scope/pom.xml
new file mode 100755
index 0000000..e79e9e4
--- /dev/null
+++ b/content/examples/cdi-request-scope/pom.xml
@@ -0,0 +1,77 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-request-scope</artifactId>
+ <name>OpenEJB :: Examples :: CDI Request Scope</name>
+ <version>1.1.1-SNAPSHOT</version>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/cdi-request-scope/src/main/java/org/superbiz/cdi/requestscope/Chef.java b/content/examples/cdi-request-scope/src/main/java/org/superbiz/cdi/requestscope/Chef.java
new file mode 100755
index 0000000..941a847
--- /dev/null
+++ b/content/examples/cdi-request-scope/src/main/java/org/superbiz/cdi/requestscope/Chef.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.requestscope;
+
+import javax.ejb.Stateless;
+import javax.inject.Inject;
+
+@Stateless
+public class Chef {
+
+ @Inject
+ private Soup soup;
+
+ public Soup prepareSoup() {
+ return soup;
+ }
+}
diff --git a/content/examples/cdi-request-scope/src/main/java/org/superbiz/cdi/requestscope/Soup.java b/content/examples/cdi-request-scope/src/main/java/org/superbiz/cdi/requestscope/Soup.java
new file mode 100755
index 0000000..ed428fb
--- /dev/null
+++ b/content/examples/cdi-request-scope/src/main/java/org/superbiz/cdi/requestscope/Soup.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.requestscope;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+
+@RequestScoped
+public class Soup {
+
+ private String name = "Soup of the day";
+
+ @PostConstruct
+ public void afterCreate() {
+ System.out.println("Soup created");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/content/examples/cdi-request-scope/src/main/java/org/superbiz/cdi/requestscope/Waiter.java b/content/examples/cdi-request-scope/src/main/java/org/superbiz/cdi/requestscope/Waiter.java
new file mode 100755
index 0000000..84c2849
--- /dev/null
+++ b/content/examples/cdi-request-scope/src/main/java/org/superbiz/cdi/requestscope/Waiter.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.requestscope;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.inject.Inject;
+
+@Stateless
+public class Waiter {
+
+ @Inject
+ private Soup soup;
+
+ @EJB
+ private Chef chef;
+
+ public String orderSoup(String name) {
+ soup.setName(name);
+ return chef.prepareSoup().getName();
+ }
+
+}
diff --git a/content/examples/cdi-request-scope/src/main/resources/META-INF/beans.xml b/content/examples/cdi-request-scope/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..6668db4
--- /dev/null
+++ b/content/examples/cdi-request-scope/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,19 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans>
+</beans>
\ No newline at end of file
diff --git a/content/examples/cdi-request-scope/src/test/java/org/superbiz/cdi/requestscope/RestaurantTest.java b/content/examples/cdi-request-scope/src/test/java/org/superbiz/cdi/requestscope/RestaurantTest.java
new file mode 100755
index 0000000..612f65f
--- /dev/null
+++ b/content/examples/cdi-request-scope/src/test/java/org/superbiz/cdi/requestscope/RestaurantTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.requestscope;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+
+import static org.junit.Assert.assertEquals;
+
+public class RestaurantTest {
+
+ private static final String TOMATO_SOUP = "Tomato Soup";
+ private static final String POTATO_SOUP = "Potato Soup";
+ private EJBContainer container;
+
+ @EJB
+ private Waiter joe;
+
+ @Before
+ public void startContainer() throws Exception {
+ container = EJBContainer.createEJBContainer();
+ container.getContext().bind("inject", this);
+ }
+
+ @Test
+ public void orderSoup() {
+ String soup = joe.orderSoup(TOMATO_SOUP);
+ assertEquals(TOMATO_SOUP, soup);
+ soup = joe.orderSoup(POTATO_SOUP);
+ assertEquals(POTATO_SOUP, soup);
+ }
+
+ @After
+ public void closeContainer() throws Exception {
+ container.close();
+ }
+}
diff --git a/content/examples/cdi-session-scope.html b/content/examples/cdi-session-scope.html
new file mode 100644
index 0000000..829bbbb
--- /dev/null
+++ b/content/examples/cdi-session-scope.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cdi-session-scope.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>cdi-session-scope</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example cdi-session-scope can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cdi-session-scope" class="bare">https://github.com/apache/tomee/tree/master/examples/cdi-session-scope</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cdi-session-scope.pdf b/content/examples/cdi-session-scope.pdf
new file mode 100644
index 0000000..4bb8974
--- /dev/null
+++ b/content/examples/cdi-session-scope.pdf
Binary files differ
diff --git a/content/examples/cdi-session-scope/pom.xml b/content/examples/cdi-session-scope/pom.xml
new file mode 100755
index 0000000..c3e592e
--- /dev/null
+++ b/content/examples/cdi-session-scope/pom.xml
@@ -0,0 +1,99 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cdi-session-scope</artifactId>
+ <name>OpenEJB :: Examples :: CDI Session Scope</name>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>war</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/AnswerBean.java b/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/AnswerBean.java
new file mode 100755
index 0000000..bc8327b
--- /dev/null
+++ b/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/AnswerBean.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.session;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+
+// just to take care to refresh it, otherwise using postcontruct you can see kind of cache effect on session bean
+@RequestScoped
+public class AnswerBean {
+
+ @Inject
+ private SessionBean bean;
+
+ private String value;
+
+ @PostConstruct
+ public void init() {
+ value = '{' + bean.getName() + '}';
+ }
+
+ public String value() {
+ return value;
+ }
+}
diff --git a/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/InputServlet.java b/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/InputServlet.java
new file mode 100755
index 0000000..21b056f
--- /dev/null
+++ b/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/InputServlet.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.session;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebServlet(name = "input-servlet", urlPatterns = {"/set-name"})
+public class InputServlet extends HttpServlet {
+
+ @Inject
+ private SessionBean bean;
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ final String name = req.getParameter("name");
+ if (name == null || name.isEmpty()) {
+ resp.getWriter().write("please add a parameter name=xxx");
+ } else {
+ bean.setName(name);
+ resp.getWriter().write("done, go to /name servlet");
+ }
+
+ }
+}
diff --git a/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/OutputServlet.java b/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/OutputServlet.java
new file mode 100755
index 0000000..d65edf9
--- /dev/null
+++ b/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/OutputServlet.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.session;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebServlet(name = "output-servlet", urlPatterns = {"/name"})
+public class OutputServlet extends HttpServlet {
+
+ @Inject
+ private AnswerBean bean;
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ final String name = bean.value();
+ if (name == null || name.isEmpty()) {
+ resp.getWriter().write("please go to servlet /set-name please");
+ } else {
+ resp.getWriter().write("name = " + name);
+ }
+ }
+}
diff --git a/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/SessionBean.java b/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/SessionBean.java
new file mode 100755
index 0000000..f17ac80
--- /dev/null
+++ b/content/examples/cdi-session-scope/src/main/java/org/superbiz/cdi/session/SessionBean.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.session;
+
+import javax.enterprise.context.SessionScoped;
+import java.io.Serializable;
+
+@SessionScoped
+public class SessionBean implements Serializable {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/content/examples/cdi-session-scope/src/main/webapp/WEB-INF/beans.xml b/content/examples/cdi-session-scope/src/main/webapp/WEB-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/cdi-session-scope/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/change-jaxws-url.html b/content/examples/change-jaxws-url.html
new file mode 100644
index 0000000..61e9214
--- /dev/null
+++ b/content/examples/change-jaxws-url.html
@@ -0,0 +1,315 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/change-jaxws-url.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Change JAXWS URL</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example change-jaxws-url can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/change-jaxws-url" class="bare">https://github.com/apache/tomee/tree/master/examples/change-jaxws-url</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+<div class="paragraph">
+<p>To change a webservice deployment URI one solution is to use openejb-jar.xml.</p>
+</div>
+<div class="paragraph">
+<p>In this sample we have a webservice though the class Rot13:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.jaxws;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.jws.WebService;
+
+@Lock(LockType.READ)
+@Singleton
+@WebService
+public class Rot13 {
+ public String rot13(final String in) {
+ final StringBuilder builder = new StringBuilder(in.length());
+ for (int b : in.toCharArray()) {
+ int cap = b & 32;
+ b &= ~cap;
+ if (Character.isUpperCase(b)) {
+ b = (b - 'A' + 13) % 26 + 'A';
+ } else {
+ b = cap;
+ }
+ b |= cap;
+ builder.append((char) b);
+ }
+ return builder.toString();
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>We decide to deploy to /tool/rot13 url.</p>
+</div>
+<div class="paragraph">
+<p>To do so we first define it in openejb-jar.xml:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
+ <enterprise-beans>
+ <session>
+ <ejb-name>Rot13</ejb-name>
+ <web-service-address>/tool/rot13</web-service-address>
+ </session>
+ </enterprise-beans>
+</openejb-jar></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>It is not enough since by default TomEE deploys the webservices in a subcontext called webservices. To skip it
+simply set the system property tomee.jaxws.subcontext to / (done in arquillian.xml for our test).</p>
+</div>
+<div class="paragraph">
+<p>Then now our Rot13 webservice is deployed as expected to /tool/rot13 and we check it with arquillian and tomee embedded:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.jaxws;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>import org.apache.ziplock.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>import java.net.URL;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>import static org.junit.Assert.assertThat;
+import static org.junit.internal.matchers.StringContains.containsString;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@RunWith(Arquillian.class)
+public class Rot13Test {
+ @ArquillianResource
+ private URL url;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Deployment(testable = false)
+public static WebArchive war() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addClass(Rot13.class)
+ .addAsWebInfResource(new ClassLoaderAsset("META-INF/openejb-jar.xml"), ArchivePaths.create("openejb-jar.xml"));
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> @Test
+ public void checkWSDLIsDeployedWhereItIsConfigured() throws Exception {
+ final String wsdl = IO.slurp(new URL(url.toExternalForm() + "tool/rot13?wsdl"));
+ assertThat(wsdl, containsString("Rot13"));
+ }
+}</pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/change-jaxws-url.pdf b/content/examples/change-jaxws-url.pdf
new file mode 100644
index 0000000..ba73f74
--- /dev/null
+++ b/content/examples/change-jaxws-url.pdf
Binary files differ
diff --git a/content/examples/change-jaxws-url/README.md b/content/examples/change-jaxws-url/README.md
new file mode 100755
index 0000000..1860d75
--- /dev/null
+++ b/content/examples/change-jaxws-url/README.md
@@ -0,0 +1,99 @@
+Title: Change JAXWS URL
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+To change a webservice deployment URI one solution is to use openejb-jar.xml.
+
+In this sample we have a webservice though the class Rot13:
+
+ package org.superbiz.jaxws;
+
+ import javax.ejb.Lock;
+ import javax.ejb.LockType;
+ import javax.ejb.Singleton;
+ import javax.jws.WebService;
+
+ @Lock(LockType.READ)
+ @Singleton
+ @WebService
+ public class Rot13 {
+ public String rot13(final String in) {
+ final StringBuilder builder = new StringBuilder(in.length());
+ for (int b : in.toCharArray()) {
+ int cap = b & 32;
+ b &= ~cap;
+ if (Character.isUpperCase(b)) {
+ b = (b - 'A' + 13) % 26 + 'A';
+ } else {
+ b = cap;
+ }
+ b |= cap;
+ builder.append((char) b);
+ }
+ return builder.toString();
+ }
+ }
+
+We decide to deploy to /tool/rot13 url.
+
+To do so we first define it in openejb-jar.xml:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
+ <enterprise-beans>
+ <session>
+ <ejb-name>Rot13</ejb-name>
+ <web-service-address>/tool/rot13</web-service-address>
+ </session>
+ </enterprise-beans>
+ </openejb-jar>
+
+
+It is not enough since by default TomEE deploys the webservices in a subcontext called webservices. To skip it
+simply set the system property tomee.jaxws.subcontext to / (done in arquillian.xml for our test).
+
+Then now our Rot13 webservice is deployed as expected to /tool/rot13 and we check it with arquillian and tomee embedded:
+
+ package org.superbiz.jaxws;
+
+ import org.apache.ziplock.IO;
+ import org.jboss.arquillian.container.test.api.Deployment;
+ import org.jboss.arquillian.junit.Arquillian;
+ import org.jboss.arquillian.test.api.ArquillianResource;
+ import org.jboss.shrinkwrap.api.ArchivePaths;
+ import org.jboss.shrinkwrap.api.ShrinkWrap;
+ import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+ import org.jboss.shrinkwrap.api.spec.WebArchive;
+ import org.junit.AfterClass;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+ import org.junit.runner.RunWith;
+
+ import java.net.URL;
+
+ import static org.junit.Assert.assertThat;
+ import static org.junit.internal.matchers.StringContains.containsString;
+
+ @RunWith(Arquillian.class)
+ public class Rot13Test {
+ @ArquillianResource
+ private URL url;
+
+ @Deployment(testable = false)
+ public static WebArchive war() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addClass(Rot13.class)
+ .addAsWebInfResource(new ClassLoaderAsset("META-INF/openejb-jar.xml"), ArchivePaths.create("openejb-jar.xml"));
+ }
+
+ @Test
+ public void checkWSDLIsDeployedWhereItIsConfigured() throws Exception {
+ final String wsdl = IO.slurp(new URL(url.toExternalForm() + "tool/rot13?wsdl"));
+ assertThat(wsdl, containsString("Rot13"));
+ }
+ }
+
+
+
+
+
diff --git a/content/examples/change-jaxws-url/pom.xml b/content/examples/change-jaxws-url/pom.xml
new file mode 100755
index 0000000..8633375
--- /dev/null
+++ b/content/examples/change-jaxws-url/pom.xml
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>change-jaxws-url</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: Change JAXWS URL</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ <tomee.version>1.7.1</tomee.version>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ <repository>
+ <id>tomcat-m2-repo</id>
+ <name>Tomcat Dev Repository</name>
+ <url>http://tomcat.apache.org/dev/dist/m2-repository/</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <defaultGoal>package</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>${tomee.version}</version>
+ <configuration>
+ <tomeeVersion>${tomee.version}</tomeeVersion>
+ <tomeeClassifier>plus</tomeeClassifier>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-embedded-maven-plugin</artifactId>
+ <version>${tomee.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>apache-tomee</artifactId>
+ <version>${tomee.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-embedded</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-webservices</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-embedded</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>local-release-repo</id>
+ <url>file://${project.build.outputDirectory}/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>local-snapshot-repo</id>
+ <url>file://${project.build.outputDirectory}/repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/change-jaxws-url/src/main/java/org/superbiz/jaxws/Rot13.java b/content/examples/change-jaxws-url/src/main/java/org/superbiz/jaxws/Rot13.java
new file mode 100755
index 0000000..0ae1243
--- /dev/null
+++ b/content/examples/change-jaxws-url/src/main/java/org/superbiz/jaxws/Rot13.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jaxws;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.jws.WebService;
+
+@Lock(LockType.READ)
+@Singleton
+@WebService
+public class Rot13 {
+
+ public String rot13(final String in) {
+ final StringBuilder builder = new StringBuilder(in.length());
+ for (int b : in.toCharArray()) {
+ int cap = b & 32;
+ b &= ~cap;
+ if (Character.isUpperCase(b)) {
+ b = (b - 'A' + 13) % 26 + 'A';
+ } else {
+ b = cap;
+ }
+ b |= cap;
+ builder.append((char) b);
+ }
+ return builder.toString();
+ }
+}
diff --git a/content/examples/change-jaxws-url/src/main/resources/META-INF/openejb-jar.xml b/content/examples/change-jaxws-url/src/main/resources/META-INF/openejb-jar.xml
new file mode 100755
index 0000000..6c0ba44
--- /dev/null
+++ b/content/examples/change-jaxws-url/src/main/resources/META-INF/openejb-jar.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
+ <enterprise-beans>
+ <session>
+ <ejb-name>Rot13</ejb-name>
+ <web-service-address>/tool/rot13</web-service-address>
+ </session>
+ </enterprise-beans>
+</openejb-jar>
diff --git a/content/examples/change-jaxws-url/src/test/java/org/superbiz/jaxws/Rot13Test.java b/content/examples/change-jaxws-url/src/test/java/org/superbiz/jaxws/Rot13Test.java
new file mode 100755
index 0000000..0ac6472
--- /dev/null
+++ b/content/examples/change-jaxws-url/src/test/java/org/superbiz/jaxws/Rot13Test.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jaxws;
+
+import org.apache.ziplock.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.net.URL;
+
+@RunWith(Arquillian.class)
+public class Rot13Test {
+
+ @ArquillianResource
+ private URL url;
+
+ @Deployment(testable = false)
+ public static WebArchive war() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addClass(Rot13.class)
+ .addAsWebInfResource(new ClassLoaderAsset("META-INF/openejb-jar.xml"), ArchivePaths.create("openejb-jar.xml"));
+ }
+
+ @Test
+ public void checkWSDLIsDeployedWhereItIsConfigured() throws Exception {
+ final String wsdl = IO.slurp(new URL(url.toExternalForm() + "tool/rot13?wsdl"));
+ Assert.assertTrue(wsdl.contains("Rot13"));
+ }
+}
diff --git a/content/examples/change-jaxws-url/src/test/resources/arquillian.xml b/content/examples/change-jaxws-url/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..d18205e
--- /dev/null
+++ b/content/examples/change-jaxws-url/src/test/resources/arquillian.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+ <container qualifier="tomee" default="true">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="appWorkingDir">target/tomee-embedded</property>
+ <property name="properties">
+ tomee.jaxws.subcontext = /
+ </property>
+ </configuration>
+ </container>
+</arquillian>
diff --git a/content/examples/client-resource-lookup-preview.html b/content/examples/client-resource-lookup-preview.html
new file mode 100644
index 0000000..5fe95fd
--- /dev/null
+++ b/content/examples/client-resource-lookup-preview.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/client-resource-lookup-preview.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>client-resource-lookup-preview</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example client-resource-lookup-preview can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/client-resource-lookup-preview" class="bare">https://github.com/apache/tomee/tree/master/examples/client-resource-lookup-preview</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/client-resource-lookup-preview.pdf b/content/examples/client-resource-lookup-preview.pdf
new file mode 100644
index 0000000..c25fca7
--- /dev/null
+++ b/content/examples/client-resource-lookup-preview.pdf
Binary files differ
diff --git a/content/examples/client-resource-lookup-preview/pom.xml b/content/examples/client-resource-lookup-preview/pom.xml
new file mode 100755
index 0000000..7d5439a
--- /dev/null
+++ b/content/examples/client-resource-lookup-preview/pom.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>client-resource-lookup-preview</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Client Resource Lookup</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- here what is needed to use client lookup with jms resources -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-client</artifactId>
+ <version>4.7.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-ejbd</artifactId>
+ <version>4.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-broker</artifactId>
+ <version>5.10.0</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- test deps -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java b/content/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
new file mode 100755
index 0000000..a45bdad
--- /dev/null
+++ b/content/examples/client-resource-lookup-preview/src/test/java/org/superbiz/client/SenderTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.client;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class SenderTest {
+
+ @BeforeClass
+ public static void configureClientResources() {
+ // can be set this way or with the key Resource/<type>
+ // in fact we create on client side a mini jndi tree
+ // the key is the jndi name (the one used for the lookup)
+ System.setProperty("aConnectionFactory", "connectionfactory:org.apache.activemq.ActiveMQConnectionFactory:tcp://localhost:11616");
+ System.setProperty("aQueue", "queue:org.apache.activemq.command.ActiveMQQueue:LISTENER");
+ }
+
+ @Test
+ public void send() throws Exception {
+ final Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ final Context context = new InitialContext(properties);
+
+ final Queue destination = (Queue) context.lookup("java:aQueue");
+ assertNotNull(destination);
+ assertEquals("LISTENER", destination.getQueueName());
+
+ final ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("java:aConnectionFactory");
+ assertNotNull(connectionFactory);
+ }
+}
diff --git a/content/examples/component-interfaces.html b/content/examples/component-interfaces.html
new file mode 100644
index 0000000..8089af0
--- /dev/null
+++ b/content/examples/component-interfaces.html
@@ -0,0 +1,686 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/component-interfaces.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Component Interfaces</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example component-interfaces can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/component-interfaces" class="bare">https://github.com/apache/tomee/tree/master/examples/component-interfaces</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friendlyperson">FriendlyPerson</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+import javax.ejb.Init;
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Properties;
+
+/**
+ * This is an EJB 3 style pojo stateful session bean
+ * it does not need to implement javax.ejb.SessionBean
+ *
+ */
+//START SNIPPET: code
+
+// EJB 3.0 Style business interfaces
+// Each of these interfaces are already annotated in the classes
+// themselves with @Remote and @Local, so annotating them here
+// in the bean class again is not really required.
+@Remote({FriendlyPersonRemote.class})
+@Local({FriendlyPersonLocal.class})
+
+// EJB 2.1 Style component interfaces
+// These interfaces, however, must be annotated here in the bean class.
+// Use of @RemoteHome in the FriendlyPersonEjbHome class itself is not allowed.
+// Use of @LocalHome in the FriendlyPersonEjbLocalHome class itself is also not allowed.
+@RemoteHome(FriendlyPersonEjbHome.class)
+@LocalHome(FriendlyPersonEjbLocalHome.class)
+
+@Stateful
+public class FriendlyPerson implements FriendlyPersonLocal, FriendlyPersonRemote {
+
+ private final HashMap<String, MessageFormat> greetings;
+ private final Properties languagePreferences;
+
+ private String defaultLanguage;
+
+ public FriendlyPerson() {
+ greetings = new HashMap();
+ languagePreferences = new Properties();
+ defaultLanguage = Locale.getDefault().getLanguage();
+
+ addGreeting("en", "Hello {0}!");
+ addGreeting("es", "Hola {0}!");
+ addGreeting("fr", "Bonjour {0}!");
+ addGreeting("pl", "Witaj {0}!");
+ }
+
+ /**
+ * This method corresponds to the FriendlyPersonEjbHome.create() method
+ * and the FriendlyPersonEjbLocalHome.create()
+ * <p/>
+ * If you do not have an EJBHome or EJBLocalHome interface, this method
+ * can be deleted.
+ */
+ @Init
+ public void create() {
+ }
+
+ /**
+ * This method corresponds to the following methods:
+ * - EJBObject.remove()
+ * - EJBHome.remove(ejbObject)
+ * - EJBLocalObject.remove()
+ * - EJBLocalHome.remove(ejbObject)
+ * <p/>
+ * If you do not have an EJBHome or EJBLocalHome interface, this method
+ * can be deleted.
+ */
+ @Remove
+ public void remove() {
+ }
+
+ public String greet(String friend) {
+ String language = languagePreferences.getProperty(friend, defaultLanguage);
+ return greet(language, friend);
+ }
+
+ public String greet(String language, String friend) {
+ MessageFormat greeting = greetings.get(language);
+ if (greeting == null) {
+ Locale locale = new Locale(language);
+ return "Sorry, I don't speak " + locale.getDisplayLanguage() + ".";
+ }
+
+ return greeting.format(new Object[]{friend});
+ }
+
+ public void addGreeting(String language, String message) {
+ greetings.put(language, new MessageFormat(message));
+ }
+
+ public void setLanguagePreferences(String friend, String language) {
+ languagePreferences.put(friend, language);
+ }
+
+ public String getDefaultLanguage() {
+ return defaultLanguage;
+ }
+
+ public void setDefaultLanguage(String defaultLanguage) {
+ this.defaultLanguage = defaultLanguage;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friendlypersonejbhome">FriendlyPersonEjbHome</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+//START SNIPPET: code
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+import java.rmi.RemoteException;
+
+public interface FriendlyPersonEjbHome extends EJBHome {
+ FriendlyPersonEjbObject create() throws CreateException, RemoteException;
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friendlypersonejblocalhome">FriendlyPersonEjbLocalHome</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+//START SNIPPET: code
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import java.rmi.RemoteException;
+
+public interface FriendlyPersonEjbLocalHome extends EJBLocalHome {
+ FriendlyPersonEjbLocalObject create() throws CreateException, RemoteException;
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friendlypersonejblocalobject">FriendlyPersonEjbLocalObject</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+import javax.ejb.EJBLocalObject;
+
+public interface FriendlyPersonEjbLocalObject extends EJBLocalObject {
+ String greet(String friend);
+
+ String greet(String language, String friend);
+
+ void addGreeting(String language, String message);
+
+ void setLanguagePreferences(String friend, String language);
+
+ String getDefaultLanguage();
+
+ void setDefaultLanguage(String defaultLanguage);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friendlypersonejbobject">FriendlyPersonEjbObject</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+//START SNIPPET: code
+
+import javax.ejb.EJBObject;
+import java.rmi.RemoteException;
+
+public interface FriendlyPersonEjbObject extends EJBObject {
+ String greet(String friend) throws RemoteException;
+
+ String greet(String language, String friend) throws RemoteException;
+
+ void addGreeting(String language, String message) throws RemoteException;
+
+ void setLanguagePreferences(String friend, String language) throws RemoteException;
+
+ String getDefaultLanguage() throws RemoteException;
+
+ void setDefaultLanguage(String defaultLanguage) throws RemoteException;
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friendlypersonlocal">FriendlyPersonLocal</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+//START SNIPPET: code
+
+import javax.ejb.Local;
+
+@Local
+public interface FriendlyPersonLocal {
+ String greet(String friend);
+
+ String greet(String language, String friend);
+
+ void addGreeting(String language, String message);
+
+ void setLanguagePreferences(String friend, String language);
+
+ String getDefaultLanguage();
+
+ void setDefaultLanguage(String defaultLanguage);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friendlypersonremote">FriendlyPersonRemote</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+import javax.ejb.Remote;
+
+//START SNIPPET: code
+@Remote
+public interface FriendlyPersonRemote {
+ String greet(String friend);
+
+ String greet(String language, String friend);
+
+ void addGreeting(String language, String message);
+
+ void setLanguagePreferences(String friend, String language);
+
+ String getDefaultLanguage();
+
+ void setDefaultLanguage(String defaultLanguage);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friendlypersontest">FriendlyPersonTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.Locale;
+
+/**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+public class FriendlyPersonTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBHome and EJBObject interfaces
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remotehome
+ public void testEjbHomeAndEjbObject() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbHome");
+ FriendlyPersonEjbHome home = (FriendlyPersonEjbHome) object;
+ FriendlyPersonEjbObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //END SNIPPET: remotehome
+
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBLocalHome and EJBLocalObject interfaces
+ *
+ * @throws Exception
+ */
+ public void testEjbLocalHomeAndEjbLocalObject() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbLocalHome");
+ FriendlyPersonEjbLocalHome home = (FriendlyPersonEjbLocalHome) object;
+ FriendlyPersonEjbLocalObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business remote interface
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remote
+ public void testBusinessRemote() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonRemote");
+
+ FriendlyPersonRemote friendlyPerson = (FriendlyPersonRemote) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //START SNIPPET: remote
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business local interface
+ *
+ * @throws Exception
+ */
+ public void testBusinessLocal() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonLocal");
+
+ FriendlyPersonLocal friendlyPerson = (FriendlyPersonLocal) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.FriendlyPersonTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/component-interfaces
+INFO - openejb.base = /Users/dblevins/examples/component-interfaces
+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/component-interfaces/target/classes
+INFO - Beginning load: /Users/dblevins/examples/component-interfaces/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/component-interfaces
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean FriendlyPerson: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.FriendlyPersonTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/component-interfaces" loaded.
+INFO - Assembling app: /Users/dblevins/examples/component-interfaces
+INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonLocal")
+INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonRemote")
+INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbLocalHome")
+INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbHome")
+INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson")
+INFO - Jndi(name="java:global/EjbModule803660549/org.superbiz.FriendlyPersonTest!org.superbiz.FriendlyPersonTest")
+INFO - Jndi(name="java:global/EjbModule803660549/org.superbiz.FriendlyPersonTest")
+INFO - Created Ejb(deployment-id=FriendlyPerson, ejb-name=FriendlyPerson, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.FriendlyPersonTest, ejb-name=org.superbiz.FriendlyPersonTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=FriendlyPerson, ejb-name=FriendlyPerson, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.FriendlyPersonTest, ejb-name=org.superbiz.FriendlyPersonTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/component-interfaces)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.444 sec
+
+Results :
+
+Tests run: 4, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/component-interfaces.pdf b/content/examples/component-interfaces.pdf
new file mode 100644
index 0000000..a2ec287
--- /dev/null
+++ b/content/examples/component-interfaces.pdf
Binary files differ
diff --git a/content/examples/component-interfaces/README.md b/content/examples/component-interfaces/README.md
new file mode 100755
index 0000000..6bcc924
--- /dev/null
+++ b/content/examples/component-interfaces/README.md
@@ -0,0 +1,445 @@
+Title: Component Interfaces
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## FriendlyPerson
+
+ package org.superbiz;
+
+ import javax.ejb.Init;
+ import javax.ejb.Local;
+ import javax.ejb.LocalHome;
+ import javax.ejb.Remote;
+ import javax.ejb.RemoteHome;
+ import javax.ejb.Remove;
+ import javax.ejb.Stateful;
+ import java.text.MessageFormat;
+ import java.util.HashMap;
+ import java.util.Locale;
+ import java.util.Properties;
+
+ /**
+ * This is an EJB 3 style pojo stateful session bean
+ * it does not need to implement javax.ejb.SessionBean
+ *
+ */
+ //START SNIPPET: code
+
+ // EJB 3.0 Style business interfaces
+ // Each of these interfaces are already annotated in the classes
+ // themselves with @Remote and @Local, so annotating them here
+ // in the bean class again is not really required.
+ @Remote({FriendlyPersonRemote.class})
+ @Local({FriendlyPersonLocal.class})
+
+ // EJB 2.1 Style component interfaces
+ // These interfaces, however, must be annotated here in the bean class.
+ // Use of @RemoteHome in the FriendlyPersonEjbHome class itself is not allowed.
+ // Use of @LocalHome in the FriendlyPersonEjbLocalHome class itself is also not allowed.
+ @RemoteHome(FriendlyPersonEjbHome.class)
+ @LocalHome(FriendlyPersonEjbLocalHome.class)
+
+ @Stateful
+ public class FriendlyPerson implements FriendlyPersonLocal, FriendlyPersonRemote {
+
+ private final HashMap<String, MessageFormat> greetings;
+ private final Properties languagePreferences;
+
+ private String defaultLanguage;
+
+ public FriendlyPerson() {
+ greetings = new HashMap();
+ languagePreferences = new Properties();
+ defaultLanguage = Locale.getDefault().getLanguage();
+
+ addGreeting("en", "Hello {0}!");
+ addGreeting("es", "Hola {0}!");
+ addGreeting("fr", "Bonjour {0}!");
+ addGreeting("pl", "Witaj {0}!");
+ }
+
+ /**
+ * This method corresponds to the FriendlyPersonEjbHome.create() method
+ * and the FriendlyPersonEjbLocalHome.create()
+ * <p/>
+ * If you do not have an EJBHome or EJBLocalHome interface, this method
+ * can be deleted.
+ */
+ @Init
+ public void create() {
+ }
+
+ /**
+ * This method corresponds to the following methods:
+ * - EJBObject.remove()
+ * - EJBHome.remove(ejbObject)
+ * - EJBLocalObject.remove()
+ * - EJBLocalHome.remove(ejbObject)
+ * <p/>
+ * If you do not have an EJBHome or EJBLocalHome interface, this method
+ * can be deleted.
+ */
+ @Remove
+ public void remove() {
+ }
+
+ public String greet(String friend) {
+ String language = languagePreferences.getProperty(friend, defaultLanguage);
+ return greet(language, friend);
+ }
+
+ public String greet(String language, String friend) {
+ MessageFormat greeting = greetings.get(language);
+ if (greeting == null) {
+ Locale locale = new Locale(language);
+ return "Sorry, I don't speak " + locale.getDisplayLanguage() + ".";
+ }
+
+ return greeting.format(new Object[]{friend});
+ }
+
+ public void addGreeting(String language, String message) {
+ greetings.put(language, new MessageFormat(message));
+ }
+
+ public void setLanguagePreferences(String friend, String language) {
+ languagePreferences.put(friend, language);
+ }
+
+ public String getDefaultLanguage() {
+ return defaultLanguage;
+ }
+
+ public void setDefaultLanguage(String defaultLanguage) {
+ this.defaultLanguage = defaultLanguage;
+ }
+ }
+
+## FriendlyPersonEjbHome
+
+ package org.superbiz;
+
+ //START SNIPPET: code
+
+ import javax.ejb.CreateException;
+ import javax.ejb.EJBHome;
+ import java.rmi.RemoteException;
+
+ public interface FriendlyPersonEjbHome extends EJBHome {
+ FriendlyPersonEjbObject create() throws CreateException, RemoteException;
+ }
+
+## FriendlyPersonEjbLocalHome
+
+ package org.superbiz;
+
+ //START SNIPPET: code
+
+ import javax.ejb.CreateException;
+ import javax.ejb.EJBLocalHome;
+ import java.rmi.RemoteException;
+
+ public interface FriendlyPersonEjbLocalHome extends EJBLocalHome {
+ FriendlyPersonEjbLocalObject create() throws CreateException, RemoteException;
+ }
+
+## FriendlyPersonEjbLocalObject
+
+ package org.superbiz;
+
+ import javax.ejb.EJBLocalObject;
+
+ public interface FriendlyPersonEjbLocalObject extends EJBLocalObject {
+ String greet(String friend);
+
+ String greet(String language, String friend);
+
+ void addGreeting(String language, String message);
+
+ void setLanguagePreferences(String friend, String language);
+
+ String getDefaultLanguage();
+
+ void setDefaultLanguage(String defaultLanguage);
+ }
+
+## FriendlyPersonEjbObject
+
+ package org.superbiz;
+
+ //START SNIPPET: code
+
+ import javax.ejb.EJBObject;
+ import java.rmi.RemoteException;
+
+ public interface FriendlyPersonEjbObject extends EJBObject {
+ String greet(String friend) throws RemoteException;
+
+ String greet(String language, String friend) throws RemoteException;
+
+ void addGreeting(String language, String message) throws RemoteException;
+
+ void setLanguagePreferences(String friend, String language) throws RemoteException;
+
+ String getDefaultLanguage() throws RemoteException;
+
+ void setDefaultLanguage(String defaultLanguage) throws RemoteException;
+ }
+
+## FriendlyPersonLocal
+
+ package org.superbiz;
+
+ //START SNIPPET: code
+
+ import javax.ejb.Local;
+
+ @Local
+ public interface FriendlyPersonLocal {
+ String greet(String friend);
+
+ String greet(String language, String friend);
+
+ void addGreeting(String language, String message);
+
+ void setLanguagePreferences(String friend, String language);
+
+ String getDefaultLanguage();
+
+ void setDefaultLanguage(String defaultLanguage);
+ }
+
+## FriendlyPersonRemote
+
+ package org.superbiz;
+
+ import javax.ejb.Remote;
+
+ //START SNIPPET: code
+ @Remote
+ public interface FriendlyPersonRemote {
+ String greet(String friend);
+
+ String greet(String language, String friend);
+
+ void addGreeting(String language, String message);
+
+ void setLanguagePreferences(String friend, String language);
+
+ String getDefaultLanguage();
+
+ void setDefaultLanguage(String defaultLanguage);
+ }
+
+## FriendlyPersonTest
+
+ package org.superbiz;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import java.util.Locale;
+
+ /**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+ public class FriendlyPersonTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBHome and EJBObject interfaces
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remotehome
+ public void testEjbHomeAndEjbObject() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbHome");
+ FriendlyPersonEjbHome home = (FriendlyPersonEjbHome) object;
+ FriendlyPersonEjbObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //END SNIPPET: remotehome
+
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBLocalHome and EJBLocalObject interfaces
+ *
+ * @throws Exception
+ */
+ public void testEjbLocalHomeAndEjbLocalObject() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbLocalHome");
+ FriendlyPersonEjbLocalHome home = (FriendlyPersonEjbLocalHome) object;
+ FriendlyPersonEjbLocalObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business remote interface
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remote
+ public void testBusinessRemote() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonRemote");
+
+ FriendlyPersonRemote friendlyPerson = (FriendlyPersonRemote) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //START SNIPPET: remote
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business local interface
+ *
+ * @throws Exception
+ */
+ public void testBusinessLocal() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonLocal");
+
+ FriendlyPersonLocal friendlyPerson = (FriendlyPersonLocal) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.FriendlyPersonTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/component-interfaces
+ INFO - openejb.base = /Users/dblevins/examples/component-interfaces
+ 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/component-interfaces/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/component-interfaces/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/component-interfaces
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean FriendlyPerson: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.FriendlyPersonTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/component-interfaces" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/component-interfaces
+ INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonLocal")
+ INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonRemote")
+ INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbLocalHome")
+ INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbHome")
+ INFO - Jndi(name="java:global/component-interfaces/FriendlyPerson")
+ INFO - Jndi(name="java:global/EjbModule803660549/org.superbiz.FriendlyPersonTest!org.superbiz.FriendlyPersonTest")
+ INFO - Jndi(name="java:global/EjbModule803660549/org.superbiz.FriendlyPersonTest")
+ INFO - Created Ejb(deployment-id=FriendlyPerson, ejb-name=FriendlyPerson, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.FriendlyPersonTest, ejb-name=org.superbiz.FriendlyPersonTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=FriendlyPerson, ejb-name=FriendlyPerson, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.FriendlyPersonTest, ejb-name=org.superbiz.FriendlyPersonTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/component-interfaces)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.444 sec
+
+ Results :
+
+ Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/component-interfaces/build.xml b/content/examples/component-interfaces/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/component-interfaces/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/component-interfaces/pom.xml b/content/examples/component-interfaces/pom.xml
new file mode 100755
index 0000000..1adfed8
--- /dev/null
+++ b/content/examples/component-interfaces/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>component-interfaces</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: EJB 2.1 Component Interfaces</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <!-- argLine>-agentlib:jdwp=transport=dt_socket,server=y,address=5005</argLine -->
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPerson.java b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPerson.java
new file mode 100755
index 0000000..f1bdc2b
--- /dev/null
+++ b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPerson.java
@@ -0,0 +1,126 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import javax.ejb.Init;
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Properties;
+
+/**
+ * This is an EJB 3 style pojo stateful session bean
+ * it does not need to implement javax.ejb.SessionBean
+ */
+//START SNIPPET: code
+
+// EJB 3.0 Style business interfaces
+// Each of these interfaces are already annotated in the classes
+// themselves with @Remote and @Local, so annotating them here
+// in the bean class again is not really required.
+@Remote({FriendlyPersonRemote.class})
+@Local({FriendlyPersonLocal.class})
+
+// EJB 2.1 Style component interfaces
+// These interfaces, however, must be annotated here in the bean class.
+// Use of @RemoteHome in the FriendlyPersonEjbHome class itself is not allowed.
+// Use of @LocalHome in the FriendlyPersonEjbLocalHome class itself is also not allowed.
+@RemoteHome(FriendlyPersonEjbHome.class)
+@LocalHome(FriendlyPersonEjbLocalHome.class)
+
+@Stateful
+public class FriendlyPerson implements FriendlyPersonLocal, FriendlyPersonRemote {
+
+ private final HashMap<String, MessageFormat> greetings;
+ private final Properties languagePreferences;
+
+ private String defaultLanguage;
+
+ public FriendlyPerson() {
+ greetings = new HashMap();
+ languagePreferences = new Properties();
+ defaultLanguage = Locale.getDefault().getLanguage();
+
+ addGreeting("en", "Hello {0}!");
+ addGreeting("es", "Hola {0}!");
+ addGreeting("fr", "Bonjour {0}!");
+ addGreeting("pl", "Witaj {0}!");
+ }
+
+ /**
+ * This method corresponds to the FriendlyPersonEjbHome.create() method
+ * and the FriendlyPersonEjbLocalHome.create()
+ * <p/>
+ * If you do not have an EJBHome or EJBLocalHome interface, this method
+ * can be deleted.
+ */
+ @Init
+ public void create() {
+ }
+
+ /**
+ * This method corresponds to the following methods:
+ * - EJBObject.remove()
+ * - EJBHome.remove(ejbObject)
+ * - EJBLocalObject.remove()
+ * - EJBLocalHome.remove(ejbObject)
+ * <p/>
+ * If you do not have an EJBHome or EJBLocalHome interface, this method
+ * can be deleted.
+ */
+ @Remove
+ public void remove() {
+ }
+
+ public String greet(String friend) {
+ String language = languagePreferences.getProperty(friend, defaultLanguage);
+ return greet(language, friend);
+ }
+
+ public String greet(String language, String friend) {
+ MessageFormat greeting = greetings.get(language);
+ if (greeting == null) {
+ Locale locale = new Locale(language);
+ return "Sorry, I don't speak " + locale.getDisplayLanguage() + ".";
+ }
+
+ return greeting.format(new Object[]{friend});
+ }
+
+ public void addGreeting(String language, String message) {
+ greetings.put(language, new MessageFormat(message));
+ }
+
+ public void setLanguagePreferences(String friend, String language) {
+ languagePreferences.put(friend, language);
+ }
+
+ public String getDefaultLanguage() {
+ return defaultLanguage;
+ }
+
+ public void setDefaultLanguage(String defaultLanguage) {
+ this.defaultLanguage = defaultLanguage;
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbHome.java b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbHome.java
new file mode 100755
index 0000000..634ea9d
--- /dev/null
+++ b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbHome.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+//START SNIPPET: code
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+import java.rmi.RemoteException;
+
+public interface FriendlyPersonEjbHome extends EJBHome {
+
+ FriendlyPersonEjbObject create() throws CreateException, RemoteException;
+}
+//END SNIPPET: code
diff --git a/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbLocalHome.java b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbLocalHome.java
new file mode 100755
index 0000000..8e20836
--- /dev/null
+++ b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbLocalHome.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+//START SNIPPET: code
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+import java.rmi.RemoteException;
+
+public interface FriendlyPersonEjbLocalHome extends EJBLocalHome {
+
+ FriendlyPersonEjbLocalObject create() throws CreateException, RemoteException;
+}
+//END SNIPPET: code
diff --git a/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbLocalObject.java b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbLocalObject.java
new file mode 100755
index 0000000..f729962
--- /dev/null
+++ b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbLocalObject.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import javax.ejb.EJBLocalObject;
+
+public interface FriendlyPersonEjbLocalObject extends EJBLocalObject {
+
+ String greet(String friend);
+
+ String greet(String language, String friend);
+
+ void addGreeting(String language, String message);
+
+ void setLanguagePreferences(String friend, String language);
+
+ String getDefaultLanguage();
+
+ void setDefaultLanguage(String defaultLanguage);
+
+}
diff --git a/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbObject.java b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbObject.java
new file mode 100755
index 0000000..d1642de
--- /dev/null
+++ b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonEjbObject.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+//START SNIPPET: code
+
+import javax.ejb.EJBObject;
+import java.rmi.RemoteException;
+
+public interface FriendlyPersonEjbObject extends EJBObject {
+
+ String greet(String friend) throws RemoteException;
+
+ String greet(String language, String friend) throws RemoteException;
+
+ void addGreeting(String language, String message) throws RemoteException;
+
+ void setLanguagePreferences(String friend, String language) throws RemoteException;
+
+ String getDefaultLanguage() throws RemoteException;
+
+ void setDefaultLanguage(String defaultLanguage) throws RemoteException;
+
+}
+//END SNIPPET: code
diff --git a/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonLocal.java b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonLocal.java
new file mode 100755
index 0000000..2371215
--- /dev/null
+++ b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonLocal.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+//START SNIPPET: code
+
+import javax.ejb.Local;
+
+@Local
+public interface FriendlyPersonLocal {
+
+ String greet(String friend);
+
+ String greet(String language, String friend);
+
+ void addGreeting(String language, String message);
+
+ void setLanguagePreferences(String friend, String language);
+
+ String getDefaultLanguage();
+
+ void setDefaultLanguage(String defaultLanguage);
+
+}
+//END SNIPPET: code
diff --git a/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonRemote.java b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonRemote.java
new file mode 100755
index 0000000..92f352a
--- /dev/null
+++ b/content/examples/component-interfaces/src/main/java/org/superbiz/FriendlyPersonRemote.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import javax.ejb.Remote;
+
+//START SNIPPET: code
+@Remote
+public interface FriendlyPersonRemote {
+
+ String greet(String friend);
+
+ String greet(String language, String friend);
+
+ void addGreeting(String language, String message);
+
+ void setLanguagePreferences(String friend, String language);
+
+ String getDefaultLanguage();
+
+ void setDefaultLanguage(String defaultLanguage);
+
+}
+//END SNIPPET: code
diff --git a/content/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java b/content/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java
new file mode 100755
index 0000000..c10e8bc
--- /dev/null
+++ b/content/examples/component-interfaces/src/test/java/org/superbiz/FriendlyPersonTest.java
@@ -0,0 +1,180 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.Locale;
+
+/**
+ * @version $Rev: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+public class FriendlyPersonTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBHome and EJBObject interfaces
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remotehome
+ public void testEjbHomeAndEjbObject() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbHome");
+ FriendlyPersonEjbHome home = (FriendlyPersonEjbHome) object;
+ FriendlyPersonEjbObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //END SNIPPET: remotehome
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBLocalHome and EJBLocalObject interfaces
+ *
+ * @throws Exception
+ */
+ public void testEjbLocalHomeAndEjbLocalObject() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonEjbLocalHome");
+ FriendlyPersonEjbLocalHome home = (FriendlyPersonEjbLocalHome) object;
+ FriendlyPersonEjbLocalObject friendlyPerson = home.create();
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business remote interface
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remote
+ public void testBusinessRemote() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonRemote");
+
+ FriendlyPersonRemote friendlyPerson = (FriendlyPersonRemote) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+ //START SNIPPET: remote
+
+ /**
+ * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business local interface
+ *
+ * @throws Exception
+ */
+ public void testBusinessLocal() throws Exception {
+ Object object = context.lookup("java:global/component-interfaces/FriendlyPerson!org.superbiz.FriendlyPersonLocal");
+
+ FriendlyPersonLocal friendlyPerson = (FriendlyPersonLocal) object;
+
+ friendlyPerson.setDefaultLanguage("en");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
+
+ friendlyPerson.setLanguagePreferences("Amelia", "es");
+
+ assertEquals("Hello David!", friendlyPerson.greet("David"));
+ assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
+
+ // Amelia took some French, let's see if she remembers
+ assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr", "Amelia"));
+
+ // Dave should take some Polish and if he had, he could say Hi in Polish
+ assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
+
+ // Let's see if I speak Portuguese
+ assertEquals("Sorry, I don't speak " + new Locale("pt").getDisplayLanguage() + ".", friendlyPerson.greet("pt", "David"));
+
+ // Ok, well I've been meaning to learn, so...
+ friendlyPerson.addGreeting("pt", "Ola {0}!");
+
+ assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
+ }
+
+}
diff --git a/content/examples/cucumber-jvm.html b/content/examples/cucumber-jvm.html
new file mode 100644
index 0000000..ce72d05
--- /dev/null
+++ b/content/examples/cucumber-jvm.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/cucumber-jvm.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>cucumber-jvm</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example cucumber-jvm can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/cucumber-jvm" class="bare">https://github.com/apache/tomee/tree/master/examples/cucumber-jvm</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/cucumber-jvm.pdf b/content/examples/cucumber-jvm.pdf
new file mode 100644
index 0000000..f281977
--- /dev/null
+++ b/content/examples/cucumber-jvm.pdf
Binary files differ
diff --git a/content/examples/cucumber-jvm/pom.xml b/content/examples/cucumber-jvm/pom.xml
new file mode 100755
index 0000000..5c6550b
--- /dev/null
+++ b/content/examples/cucumber-jvm/pom.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>cucumber-jvm</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Cucumber JVM</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- The <scope>test</scope> guarantees that none of your runtime code
+ is dependent on any OpenEJB classes. -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>info.cukes</groupId>
+ <artifactId>cucumber-openejb</artifactId>
+ <version>1.0.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>info.cukes</groupId>
+ <artifactId>cucumber-junit</artifactId>
+ <version>1.0.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency> <!-- needed by last released versino of cucumber-openejb -->
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/cucumber-jvm/src/main/java/org/superbiz/cucumber/Hello.java b/content/examples/cucumber-jvm/src/main/java/org/superbiz/cucumber/Hello.java
new file mode 100755
index 0000000..c45dc4d
--- /dev/null
+++ b/content/examples/cucumber-jvm/src/main/java/org/superbiz/cucumber/Hello.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cucumber;
+
+public class Hello {
+
+ public String hello(final String name) {
+ return "hello " + name;
+ }
+}
diff --git a/content/examples/cucumber-jvm/src/main/resources/META-INF/beans.xml b/content/examples/cucumber-jvm/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..9b0b74f
--- /dev/null
+++ b/content/examples/cucumber-jvm/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,18 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans/>
diff --git a/content/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/CucumberTest.java b/content/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/CucumberTest.java
new file mode 100755
index 0000000..28bbafe
--- /dev/null
+++ b/content/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/CucumberTest.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cucumber;
+
+import cucumber.junit.Cucumber;
+import org.junit.runner.RunWith;
+
+@RunWith(Cucumber.class)
+public class CucumberTest {
+ // the suite, will load automatically the features
+}
diff --git a/content/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/HelloStepDef.java b/content/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/HelloStepDef.java
new file mode 100755
index 0000000..7d21a88
--- /dev/null
+++ b/content/examples/cucumber-jvm/src/test/java/org/superbiz/cucumber/HelloStepDef.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cucumber;
+
+import cucumber.annotation.en.Given;
+import cucumber.annotation.en.Then;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertEquals;
+
+public class HelloStepDef {
+
+ @Inject
+ private Hello hello;
+
+ private String name;
+
+ @Given("^A name '([a-z]*)'$")
+ public void initName(final String name) {
+ this.name = name;
+ }
+
+ @Then("^The bean says '([ a-z]*)'$")
+ public void checkResult(final String result) {
+ assertEquals(result, hello.hello(name));
+ }
+}
diff --git a/content/examples/cucumber-jvm/src/test/resources/org/superbiz/cucumber/hello.feature b/content/examples/cucumber-jvm/src/test/resources/org/superbiz/cucumber/hello.feature
new file mode 100755
index 0000000..0f001d2
--- /dev/null
+++ b/content/examples/cucumber-jvm/src/test/resources/org/superbiz/cucumber/hello.feature
@@ -0,0 +1,5 @@
+Feature: Hello
+
+ Scenario: Say Hello
+ Given A name 'foo'
+ Then The bean says 'hello foo'
diff --git a/content/examples/custom-injection.html b/content/examples/custom-injection.html
new file mode 100644
index 0000000..3d28c56
--- /dev/null
+++ b/content/examples/custom-injection.html
@@ -0,0 +1,442 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/custom-injection.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Custom Injection</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example custom-injection can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/custom-injection" class="bare">https://github.com/apache/tomee/tree/master/examples/custom-injection</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_pickup">Pickup</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.enventries;
+
+
+//START SNIPPET: code
+
+import java.beans.PropertyEditorManager;
+
+public enum Pickup {
+
+ HUMBUCKER,
+ SINGLE_COIL;
+
+ // Here's the little magic where we register the PickupEditor
+ // which knows how to create this object from a string.
+ // You can add any of your own Property Editors in the same way.
+ static {
+ PropertyEditorManager.registerEditor(Pickup.class, PickupEditor.class);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_pickupeditor">PickupEditor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.enventries;
+
+/**
+ * With a java.beans.PropertyEditor, you can go way beyond the built-in
+ * types that OpenEJB supports and can extend dependency injection to
+ * just about anywhere.
+ * <p/>
+ * In the world of electric guitars, two types of pickups are used: humbucking, and single-coil.
+ * Guitarists often refer to their guitars as HSS, meaning a guitar with 1 humbucker and
+ * 2 single coil pickups, and so on. This little PropertyEditor supports that shorthand notation.
+ *
+ * @version $Revision$ $Date$
+ */
+//START SNIPPET: code
+public class PickupEditor extends java.beans.PropertyEditorSupport {
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ text = text.trim();
+
+ if (text.equalsIgnoreCase("H")) setValue(Pickup.HUMBUCKER);
+ else if (text.equalsIgnoreCase("S")) setValue(Pickup.SINGLE_COIL);
+ else throw new IllegalStateException("H and S are the only supported Pickup aliases");
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_stratocaster">Stratocaster</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.enventries;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * In addition to the standard env-entry types (String, Integer, Long, Short, Byte, Boolean, Double, Float, Character)
+ * OpenEJB supports many other types.
+ */
+//START SNIPPET: code
+@Stateless
+public class Stratocaster {
+
+
+ @Resource(name = "pickups")
+ private List<Pickup> pickups;
+
+ @Resource(name = "style")
+ private Style style;
+
+ @Resource(name = "dateCreated")
+ private Date dateCreated;
+
+ @Resource(name = "guitarStringGuages")
+ private Map<String, Float> guitarStringGuages;
+
+ @Resource(name = "certificateOfAuthenticity")
+ private File certificateOfAuthenticity;
+
+ public Date getDateCreated() {
+ return dateCreated;
+ }
+
+ /**
+ * Gets the guage of the electric guitar strings
+ * used in this guitar.
+ *
+ * @param string
+ * @return
+ */
+ public float getStringGuage(String string) {
+ return guitarStringGuages.get(string);
+ }
+
+ public List<Pickup> getPickups() {
+ return pickups;
+ }
+
+ public Style getStyle() {
+ return style;
+ }
+
+ public File getCertificateOfAuthenticity() {
+ return certificateOfAuthenticity;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_style">Style</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.enventries;
+
+/**
+ * @version $Revision$ $Date$
+ */
+//START SNIPPET: code
+public enum Style {
+
+ STANDARD,
+ DELUX,
+ VINTAGE;
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_stratocastertest">StratocasterTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.enventries;
+
+import junit.framework.TestCase;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import java.io.File;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import static java.util.Arrays.asList;
+
+/**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+//START SNIPPET: code
+public class StratocasterTest extends TestCase {
+
+ @EJB
+ private Stratocaster strat;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ Date date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1962");
+ assertEquals("Strat.getDateCreated()", date, strat.getDateCreated());
+
+ List<Pickup> pickups = asList(Pickup.SINGLE_COIL, Pickup.SINGLE_COIL, Pickup.SINGLE_COIL);
+ assertEquals("Strat.getPickups()", pickups, strat.getPickups());
+
+ assertEquals("Strat.getStyle()", Style.VINTAGE, strat.getStyle());
+
+ assertEquals("Strat.getStringGuage(\"E1\")", 0.052F, strat.getStringGuage("E1"));
+ assertEquals("Strat.getStringGuage(\"A\")", 0.042F, strat.getStringGuage("A"));
+ assertEquals("Strat.getStringGuage(\"D\")", 0.030F, strat.getStringGuage("D"));
+ assertEquals("Strat.getStringGuage(\"G\")", 0.017F, strat.getStringGuage("G"));
+ assertEquals("Strat.getStringGuage(\"B\")", 0.013F, strat.getStringGuage("B"));
+ assertEquals("Strat.getStringGuage(\"E\")", 0.010F, strat.getStringGuage("E"));
+
+ File file = new File("/tmp/strat-certificate.txt");
+ assertEquals("Strat.getCertificateOfAuthenticity()", file, strat.getCertificateOfAuthenticity());
+
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.enventries.StratocasterTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/custom-injection
+INFO - openejb.base = /Users/dblevins/examples/custom-injection
+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/custom-injection/target/classes
+INFO - Beginning load: /Users/dblevins/examples/custom-injection/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/custom-injection
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean Stratocaster: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.enventries.StratocasterTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/custom-injection" loaded.
+INFO - Assembling app: /Users/dblevins/examples/custom-injection
+INFO - Jndi(name="java:global/custom-injection/Stratocaster!org.superbiz.enventries.Stratocaster")
+INFO - Jndi(name="java:global/custom-injection/Stratocaster")
+INFO - Jndi(name="java:global/EjbModule1663626738/org.superbiz.enventries.StratocasterTest!org.superbiz.enventries.StratocasterTest")
+INFO - Jndi(name="java:global/EjbModule1663626738/org.superbiz.enventries.StratocasterTest")
+INFO - Created Ejb(deployment-id=Stratocaster, ejb-name=Stratocaster, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.enventries.StratocasterTest, ejb-name=org.superbiz.enventries.StratocasterTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Stratocaster, ejb-name=Stratocaster, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.enventries.StratocasterTest, ejb-name=org.superbiz.enventries.StratocasterTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/custom-injection)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.11 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/custom-injection.pdf b/content/examples/custom-injection.pdf
new file mode 100644
index 0000000..47b2ee6
--- /dev/null
+++ b/content/examples/custom-injection.pdf
Binary files differ
diff --git a/content/examples/custom-injection/README.md b/content/examples/custom-injection/README.md
new file mode 100755
index 0000000..613cc78
--- /dev/null
+++ b/content/examples/custom-injection/README.md
@@ -0,0 +1,219 @@
+Title: Custom Injection
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Pickup
+
+ package org.superbiz.enventries;
+
+
+ //START SNIPPET: code
+
+ import java.beans.PropertyEditorManager;
+
+ public enum Pickup {
+
+ HUMBUCKER,
+ SINGLE_COIL;
+
+ // Here's the little magic where we register the PickupEditor
+ // which knows how to create this object from a string.
+ // You can add any of your own Property Editors in the same way.
+ static {
+ PropertyEditorManager.registerEditor(Pickup.class, PickupEditor.class);
+ }
+ }
+
+## PickupEditor
+
+ package org.superbiz.enventries;
+
+ /**
+ * With a java.beans.PropertyEditor, you can go way beyond the built-in
+ * types that OpenEJB supports and can extend dependency injection to
+ * just about anywhere.
+ * <p/>
+ * In the world of electric guitars, two types of pickups are used: humbucking, and single-coil.
+ * Guitarists often refer to their guitars as HSS, meaning a guitar with 1 humbucker and
+ * 2 single coil pickups, and so on. This little PropertyEditor supports that shorthand notation.
+ *
+ * @version $Revision$ $Date$
+ */
+ //START SNIPPET: code
+ public class PickupEditor extends java.beans.PropertyEditorSupport {
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ text = text.trim();
+
+ if (text.equalsIgnoreCase("H")) setValue(Pickup.HUMBUCKER);
+ else if (text.equalsIgnoreCase("S")) setValue(Pickup.SINGLE_COIL);
+ else throw new IllegalStateException("H and S are the only supported Pickup aliases");
+ }
+ }
+
+## Stratocaster
+
+ package org.superbiz.enventries;
+
+ import javax.annotation.Resource;
+ import javax.ejb.Stateless;
+ import java.io.File;
+ import java.util.Date;
+ import java.util.List;
+ import java.util.Map;
+
+ /**
+ * In addition to the standard env-entry types (String, Integer, Long, Short, Byte, Boolean, Double, Float, Character)
+ * OpenEJB supports many other types.
+ */
+ //START SNIPPET: code
+ @Stateless
+ public class Stratocaster {
+
+
+ @Resource(name = "pickups")
+ private List<Pickup> pickups;
+
+ @Resource(name = "style")
+ private Style style;
+
+ @Resource(name = "dateCreated")
+ private Date dateCreated;
+
+ @Resource(name = "guitarStringGuages")
+ private Map<String, Float> guitarStringGuages;
+
+ @Resource(name = "certificateOfAuthenticity")
+ private File certificateOfAuthenticity;
+
+ public Date getDateCreated() {
+ return dateCreated;
+ }
+
+ /**
+ * Gets the guage of the electric guitar strings
+ * used in this guitar.
+ *
+ * @param string
+ * @return
+ */
+ public float getStringGuage(String string) {
+ return guitarStringGuages.get(string);
+ }
+
+ public List<Pickup> getPickups() {
+ return pickups;
+ }
+
+ public Style getStyle() {
+ return style;
+ }
+
+ public File getCertificateOfAuthenticity() {
+ return certificateOfAuthenticity;
+ }
+ }
+
+## Style
+
+ package org.superbiz.enventries;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ //START SNIPPET: code
+ public enum Style {
+
+ STANDARD,
+ DELUX,
+ VINTAGE;
+ }
+
+## StratocasterTest
+
+ package org.superbiz.enventries;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.EJB;
+ import javax.ejb.embeddable.EJBContainer;
+ import java.io.File;
+ import java.text.DateFormat;
+ import java.util.Date;
+ import java.util.List;
+ import java.util.Locale;
+
+ import static java.util.Arrays.asList;
+
+ /**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+ //START SNIPPET: code
+ public class StratocasterTest extends TestCase {
+
+ @EJB
+ private Stratocaster strat;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ Date date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1962");
+ assertEquals("Strat.getDateCreated()", date, strat.getDateCreated());
+
+ List<Pickup> pickups = asList(Pickup.SINGLE_COIL, Pickup.SINGLE_COIL, Pickup.SINGLE_COIL);
+ assertEquals("Strat.getPickups()", pickups, strat.getPickups());
+
+ assertEquals("Strat.getStyle()", Style.VINTAGE, strat.getStyle());
+
+ assertEquals("Strat.getStringGuage(\"E1\")", 0.052F, strat.getStringGuage("E1"));
+ assertEquals("Strat.getStringGuage(\"A\")", 0.042F, strat.getStringGuage("A"));
+ assertEquals("Strat.getStringGuage(\"D\")", 0.030F, strat.getStringGuage("D"));
+ assertEquals("Strat.getStringGuage(\"G\")", 0.017F, strat.getStringGuage("G"));
+ assertEquals("Strat.getStringGuage(\"B\")", 0.013F, strat.getStringGuage("B"));
+ assertEquals("Strat.getStringGuage(\"E\")", 0.010F, strat.getStringGuage("E"));
+
+ File file = new File("/tmp/strat-certificate.txt");
+ assertEquals("Strat.getCertificateOfAuthenticity()", file, strat.getCertificateOfAuthenticity());
+
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.enventries.StratocasterTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/custom-injection
+ INFO - openejb.base = /Users/dblevins/examples/custom-injection
+ 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/custom-injection/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/custom-injection/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/custom-injection
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean Stratocaster: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.enventries.StratocasterTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/custom-injection" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/custom-injection
+ INFO - Jndi(name="java:global/custom-injection/Stratocaster!org.superbiz.enventries.Stratocaster")
+ INFO - Jndi(name="java:global/custom-injection/Stratocaster")
+ INFO - Jndi(name="java:global/EjbModule1663626738/org.superbiz.enventries.StratocasterTest!org.superbiz.enventries.StratocasterTest")
+ INFO - Jndi(name="java:global/EjbModule1663626738/org.superbiz.enventries.StratocasterTest")
+ INFO - Created Ejb(deployment-id=Stratocaster, ejb-name=Stratocaster, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.enventries.StratocasterTest, ejb-name=org.superbiz.enventries.StratocasterTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Stratocaster, ejb-name=Stratocaster, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.enventries.StratocasterTest, ejb-name=org.superbiz.enventries.StratocasterTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/custom-injection)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.11 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/custom-injection/build.xml b/content/examples/custom-injection/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/custom-injection/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/custom-injection/pom.xml b/content/examples/custom-injection/pom.xml
new file mode 100755
index 0000000..c17d062
--- /dev/null
+++ b/content/examples/custom-injection/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>custom-injection</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Expanded support for Env Entries</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/custom-injection/src/main/java/org/superbiz/enventries/Pickup.java b/content/examples/custom-injection/src/main/java/org/superbiz/enventries/Pickup.java
new file mode 100755
index 0000000..650a4fa
--- /dev/null
+++ b/content/examples/custom-injection/src/main/java/org/superbiz/enventries/Pickup.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.enventries;
+
+//START SNIPPET: code
+
+import java.beans.PropertyEditorManager;
+
+public enum Pickup {
+
+ HUMBUCKER,
+ SINGLE_COIL;
+
+ // Here's the little magic where we register the PickupEditor
+ // which knows how to create this object from a string.
+ // You can add any of your own Property Editors in the same way.
+ static {
+ PropertyEditorManager.registerEditor(Pickup.class, PickupEditor.class);
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/custom-injection/src/main/java/org/superbiz/enventries/PickupEditor.java b/content/examples/custom-injection/src/main/java/org/superbiz/enventries/PickupEditor.java
new file mode 100755
index 0000000..05b8207
--- /dev/null
+++ b/content/examples/custom-injection/src/main/java/org/superbiz/enventries/PickupEditor.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.enventries;
+
+/**
+ * With a java.beans.PropertyEditor, you can go way beyond the built-in
+ * types that OpenEJB supports and can extend dependency injection to
+ * just about anywhere.
+ * <p/>
+ * In the world of electric guitars, two types of pickups are used: humbucking, and single-coil.
+ * Guitarists often refer to their guitars as HSS, meaning a guitar with 1 humbucker and
+ * 2 single coil pickups, and so on. This little PropertyEditor supports that shorthand notation.
+ *
+ * @version $Revision$ $Date$
+ */
+//START SNIPPET: code
+public class PickupEditor extends java.beans.PropertyEditorSupport {
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ text = text.trim();
+
+ if (text.equalsIgnoreCase("H")) {
+ setValue(Pickup.HUMBUCKER);
+ } else if (text.equalsIgnoreCase("S")) {
+ setValue(Pickup.SINGLE_COIL);
+ } else {
+ throw new IllegalStateException("H and S are the only supported Pickup aliases");
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/custom-injection/src/main/java/org/superbiz/enventries/Stratocaster.java b/content/examples/custom-injection/src/main/java/org/superbiz/enventries/Stratocaster.java
new file mode 100755
index 0000000..29f5f9f
--- /dev/null
+++ b/content/examples/custom-injection/src/main/java/org/superbiz/enventries/Stratocaster.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.enventries;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * In addition to the standard env-entry types (String, Integer, Long, Short, Byte, Boolean, Double, Float, Character)
+ * OpenEJB supports many other types.
+ */
+//START SNIPPET: code
+@Stateless
+public class Stratocaster {
+
+ @Resource(name = "pickups")
+ private List<Pickup> pickups;
+
+ @Resource(name = "style")
+ private Style style;
+
+ @Resource(name = "dateCreated")
+ private Date dateCreated;
+
+ @Resource(name = "guitarStringGuages")
+ private Map<String, Float> guitarStringGuages;
+
+ @Resource(name = "certificateOfAuthenticity")
+ private File certificateOfAuthenticity;
+
+ public Date getDateCreated() {
+ return dateCreated;
+ }
+
+ /**
+ * Gets the guage of the electric guitar strings
+ * used in this guitar.
+ *
+ * @param string
+ * @return
+ */
+ public float getStringGuage(String string) {
+ return guitarStringGuages.get(string);
+ }
+
+ public List<Pickup> getPickups() {
+ return pickups;
+ }
+
+ public Style getStyle() {
+ return style;
+ }
+
+ public File getCertificateOfAuthenticity() {
+ return certificateOfAuthenticity;
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/custom-injection/src/main/java/org/superbiz/enventries/Style.java b/content/examples/custom-injection/src/main/java/org/superbiz/enventries/Style.java
new file mode 100755
index 0000000..6956a40
--- /dev/null
+++ b/content/examples/custom-injection/src/main/java/org/superbiz/enventries/Style.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.enventries;
+
+/**
+ * @version $Revision$ $Date$
+ */
+//START SNIPPET: code
+public enum Style {
+
+ STANDARD,
+ DELUX,
+ VINTAGE;
+
+}
+//END SNIPPET: code
diff --git a/content/examples/custom-injection/src/main/resources/META-INF/env-entries.properties b/content/examples/custom-injection/src/main/resources/META-INF/env-entries.properties
new file mode 100755
index 0000000..f6032f2
--- /dev/null
+++ b/content/examples/custom-injection/src/main/resources/META-INF/env-entries.properties
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# $Rev: 649757 $ $Date: 2008-04-19 06:53:33 +0200 (Sat, 19 Apr 2008) $
+#
+# START SNIPPET: props
+guitarStringGuages=E1=0.052\nA=0.042\nD=0.030\nG=0.017\nB=0.013\nE=0.010
+certificateOfAuthenticity=/tmp/strat-certificate.txt
+dateCreated=1962-03-01
+pickups=S,S,S
+style=VINTAGE
+# END SNIPPET: props
+
diff --git a/content/examples/custom-injection/src/test/java/org/superbiz/enventries/StratocasterTest.java b/content/examples/custom-injection/src/test/java/org/superbiz/enventries/StratocasterTest.java
new file mode 100755
index 0000000..c8bdc7d
--- /dev/null
+++ b/content/examples/custom-injection/src/test/java/org/superbiz/enventries/StratocasterTest.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.enventries;
+
+import junit.framework.TestCase;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import java.io.File;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import static java.util.Arrays.asList;
+
+/**
+ * @version $Rev: 1591459 $ $Date: 2014-04-30 21:29:47 +0200 (Wed, 30 Apr 2014) $
+ */
+//START SNIPPET: code
+public class StratocasterTest extends TestCase {
+
+ @EJB
+ private Stratocaster strat;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ Date date = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).parse("Mar 1, 1962");
+ assertEquals("Strat.getDateCreated()", date, strat.getDateCreated());
+
+ List<Pickup> pickups = asList(Pickup.SINGLE_COIL, Pickup.SINGLE_COIL, Pickup.SINGLE_COIL);
+ assertEquals("Strat.getPickups()", pickups, strat.getPickups());
+
+ assertEquals("Strat.getStyle()", Style.VINTAGE, strat.getStyle());
+
+ assertEquals("Strat.getStringGuage(\"E1\")", 0.052F, strat.getStringGuage("E1"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"A\")", 0.042F, strat.getStringGuage("A"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"D\")", 0.030F, strat.getStringGuage("D"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"G\")", 0.017F, strat.getStringGuage("G"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"B\")", 0.013F, strat.getStringGuage("B"), 1e-15);
+ assertEquals("Strat.getStringGuage(\"E\")", 0.010F, strat.getStringGuage("E"), 1e-15);
+
+ File file = new File("/tmp/strat-certificate.txt");
+ assertEquals("Strat.getCertificateOfAuthenticity()", file, strat.getCertificateOfAuthenticity());
+
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/datasource-ciphered-password.html b/content/examples/datasource-ciphered-password.html
new file mode 100644
index 0000000..7c7acf9
--- /dev/null
+++ b/content/examples/datasource-ciphered-password.html
@@ -0,0 +1,414 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/datasource-ciphered-password.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>DataSource Ciphered Password</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example datasource-ciphered-password can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/datasource-ciphered-password" class="bare">https://github.com/apache/tomee/tree/master/examples/datasource-ciphered-password</a></p>
+</div>
+</div>
+</div>
+<h1 id="_datasource_ciphered_password_example" class="sect0">Datasource Ciphered Password example</h1>
+<div class="paragraph">
+<p>This example shows how to use a ciphered password with an OpenEJB datasource.</p>
+</div>
+<div class="paragraph">
+<p>It shows how to implement its own encryption too.</p>
+</div>
+<h1 id="_configuration" class="sect0">Configuration</h1>
+<div class="paragraph">
+<p>The configuration is simply a datasource configuration with an additionnal parameter
+"PasswordCipher" to specify the encryption to use.</p>
+</div>
+<div class="paragraph">
+<p>Example using Static3DES encryption:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
+properties.setProperty("ProtectedDatasource.UserName", "user");
+// the plain text password is "YouLLN3v3rFindM3"
+properties.setProperty("ProtectedDatasource.Password", "fEroTNXjaL5SOTyRQ92x3DNVS/ksbtgs");
+properties.setProperty("ProtectedDatasource.PasswordCipher", "Static3DES");
+properties.setProperty("ProtectedDatasource.JtaManaged", "true");</pre>
+</div>
+</div>
+<h1 id="_using_its_own_implementation" class="sect0">Using its own implementation</h1>
+<div class="paragraph">
+<p>The example implement a reverse encryption which simply reverse the password to encrypt/decrypt.</p>
+</div>
+<div class="paragraph">
+<p>The implementation is done with commons-lang library:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public static class ReverseEncryption implements PasswordCipher {
+ @Override public char[] encrypt(String plainPassword) {
+ return StringUtils.reverse(plainPassword).toCharArray();
+ }
+
+ @Override public String decrypt(char[] encryptedPassword) {
+ return new String(encrypt(new String(encryptedPassword)));
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>To be functional it needs the file <code>META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/reverse</code>.</p>
+</div>
+<div class="paragraph">
+<p>The file name (reverse) define the encryption name to use for the PasswordCipher parameter.</p>
+</div>
+<div class="paragraph">
+<p>This file simply contains the implementation class of the encryption.</p>
+</div>
+<div class="paragraph">
+<p>Then you simply declare this encryption for your datasource:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
+properties.setProperty("ProtectedDatasource.UserName", USER);
+properties.setProperty("ProtectedDatasource.Password", "3MdniFr3v3NLLuoY");
+properties.setProperty("ProtectedDatasource.PasswordCipher", "reverse");
+properties.setProperty("ProtectedDatasource.JtaManaged", "true");</pre>
+</div>
+</div>
+<h1 id="_documentation" class="sect0">Documentation</h1>
+<div class="paragraph">
+<p>For more information please see the <a href="http://tomee.apache.org/3.0/datasource-password-encryption.html">documentation</a></p>
+</div>
+<h1 id="_full_test_source" class="sect0">Full Test Source</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.openejb.resource.jdbc.PasswordCipher;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.annotation.Resource;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Properties;
+
+import static junit.framework.Assert.assertNotNull;
+
+public class DataSourceCipheredExampleTest {
+ private static final String USER = DataSourceCipheredExampleTest.class.getSimpleName().toUpperCase();
+ private static final String PASSWORD = "YouLLN3v3rFindM3";
+ private static final String DATASOURCE_URL = "jdbc:hsqldb:mem:protected";
+
+ @Resource
+ private DataSource dataSource;
+
+ @BeforeClass
+ public static void addDatabaseUserWithPassword() throws Exception {
+ Class.forName("org.hsqldb.jdbcDriver");
+ Connection conn = DriverManager.getConnection(DATASOURCE_URL, "sa", "");
+ conn.setAutoCommit(true);
+ Statement st = conn.createStatement();
+ st.executeUpdate("CREATE USER " + USER + " PASSWORD '" + PASSWORD + "';");
+ st.close();
+ conn.commit();
+ conn.close();
+ }
+
+ @Test
+ public void accessDatasource() throws Exception {
+ // define the datasource
+ Properties properties = new Properties();
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", DATASOURCE_URL);
+ properties.setProperty("ProtectedDatasource.UserName", USER);
+ properties.setProperty("ProtectedDatasource.Password", "fEroTNXjaL5SOTyRQ92x3DNVS/ksbtgs");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "Static3DES");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+ // start the context and makes junit test injections
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+ Context context = container.getContext();
+ context.bind("inject", this);
+
+ // test the datasource
+ assertNotNull(dataSource);
+ assertNotNull(dataSource.getConnection());
+
+ // closing the context
+ container.close();
+ }
+
+ @Test
+ public void accessDatasourceWithMyImplementation() throws Exception {
+ // define the datasource
+ Properties properties = new Properties();
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
+ properties.setProperty("ProtectedDatasource.UserName", USER);
+ properties.setProperty("ProtectedDatasource.Password", "3MdniFr3v3NLLuoY");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "reverse");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+ // start the context and makes junit test injections
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+ Context context = container.getContext();
+ context.bind("inject", this);
+
+ // test the datasource
+ assertNotNull(dataSource);
+ assertNotNull(dataSource.getConnection());
+
+ // closing the context
+ container.close();
+ }
+
+ public static class ReverseEncryption implements PasswordCipher {
+ @Override
+ public char[] encrypt(String plainPassword) {
+ return StringUtils.reverse(plainPassword).toCharArray();
+ }
+
+ @Override
+ public String decrypt(char[] encryptedPassword) {
+ return new String(encrypt(new String(encryptedPassword)));
+ }
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.DataSourceCipheredExampleTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/datasource-ciphered-password
+INFO - openejb.base = /Users/dblevins/examples/datasource-ciphered-password
+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 - Configuring Service(id=ProtectedDatasource, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/datasource-ciphered-password/target/test-classes
+INFO - Beginning load: /Users/dblevins/examples/datasource-ciphered-password/target/test-classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/datasource-ciphered-password
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean datasource-ciphered-password.Comp: Container(type=MANAGED, id=Default Managed Container)
+INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.DataSourceCipheredExampleTest/dataSource' in bean datasource-ciphered-password.Comp to Resource(id=ProtectedDatasource)
+INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.DataSourceCipheredExampleTest/dataSource' in bean org.superbiz.DataSourceCipheredExampleTest to Resource(id=ProtectedDatasource)
+INFO - Enterprise application "/Users/dblevins/examples/datasource-ciphered-password" loaded.
+INFO - Assembling app: /Users/dblevins/examples/datasource-ciphered-password
+INFO - Jndi(name="java:global/datasource-ciphered-password/datasource-ciphered-password.Comp!org.apache.openejb.BeanContext$Comp")
+INFO - Jndi(name="java:global/datasource-ciphered-password/datasource-ciphered-password.Comp")
+INFO - Jndi(name="java:global/EjbModule86823325/org.superbiz.DataSourceCipheredExampleTest!org.superbiz.DataSourceCipheredExampleTest")
+INFO - Jndi(name="java:global/EjbModule86823325/org.superbiz.DataSourceCipheredExampleTest")
+INFO - Created Ejb(deployment-id=datasource-ciphered-password.Comp, ejb-name=datasource-ciphered-password.Comp, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=org.superbiz.DataSourceCipheredExampleTest, ejb-name=org.superbiz.DataSourceCipheredExampleTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=datasource-ciphered-password.Comp, ejb-name=datasource-ciphered-password.Comp, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=org.superbiz.DataSourceCipheredExampleTest, ejb-name=org.superbiz.DataSourceCipheredExampleTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/datasource-ciphered-password)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.331 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/datasource-ciphered-password.pdf b/content/examples/datasource-ciphered-password.pdf
new file mode 100644
index 0000000..177a18f
--- /dev/null
+++ b/content/examples/datasource-ciphered-password.pdf
Binary files differ
diff --git a/content/examples/datasource-ciphered-password/README.md b/content/examples/datasource-ciphered-password/README.md
new file mode 100755
index 0000000..d23b545
--- /dev/null
+++ b/content/examples/datasource-ciphered-password/README.md
@@ -0,0 +1,206 @@
+Title: DataSource Ciphered Password
+
+# Datasource Ciphered Password example
+
+This example shows how to use a ciphered password with an OpenEJB datasource.
+
+It shows how to implement its own encryption too.
+
+# Configuration
+
+The configuration is simply a datasource configuration with an additionnal parameter
+"PasswordCipher" to specify the encryption to use.
+
+Example using Static3DES encryption:
+
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
+ properties.setProperty("ProtectedDatasource.UserName", "user");
+ // the plain text password is "YouLLN3v3rFindM3"
+ properties.setProperty("ProtectedDatasource.Password", "fEroTNXjaL5SOTyRQ92x3DNVS/ksbtgs");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "Static3DES");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+
+# Using its own implementation
+
+The example implement a reverse encryption which simply reverse the password to encrypt/decrypt.
+
+The implementation is done with commons-lang library:
+
+ public static class ReverseEncryption implements PasswordCipher {
+ @Override public char[] encrypt(String plainPassword) {
+ return StringUtils.reverse(plainPassword).toCharArray();
+ }
+
+ @Override public String decrypt(char[] encryptedPassword) {
+ return new String(encrypt(new String(encryptedPassword)));
+ }
+ }
+
+
+To be functional it needs the file `META-INF/org.apache.openejb.resource.jdbc.PasswordCipher/reverse`.
+
+The file name (reverse) define the encryption name to use for the PasswordCipher parameter.
+
+This file simply contains the implementation class of the encryption.
+
+Then you simply declare this encryption for your datasource:
+
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
+ properties.setProperty("ProtectedDatasource.UserName", USER);
+ properties.setProperty("ProtectedDatasource.Password", "3MdniFr3v3NLLuoY");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "reverse");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+# Documentation
+
+For more information please see the [documentation](http://openejb.apache.org/3.0/datasource-password-encryption.html)
+
+# Full Test Source
+
+ package org.superbiz;
+
+ import org.apache.commons.lang.StringUtils;
+ import org.apache.openejb.resource.jdbc.PasswordCipher;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+
+ import javax.annotation.Resource;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import javax.sql.DataSource;
+ import java.sql.Connection;
+ import java.sql.DriverManager;
+ import java.sql.Statement;
+ import java.util.Properties;
+
+ import static junit.framework.Assert.assertNotNull;
+
+ public class DataSourceCipheredExampleTest {
+ private static final String USER = DataSourceCipheredExampleTest.class.getSimpleName().toUpperCase();
+ private static final String PASSWORD = "YouLLN3v3rFindM3";
+ private static final String DATASOURCE_URL = "jdbc:hsqldb:mem:protected";
+
+ @Resource
+ private DataSource dataSource;
+
+ @BeforeClass
+ public static void addDatabaseUserWithPassword() throws Exception {
+ Class.forName("org.hsqldb.jdbcDriver");
+ Connection conn = DriverManager.getConnection(DATASOURCE_URL, "sa", "");
+ conn.setAutoCommit(true);
+ Statement st = conn.createStatement();
+ st.executeUpdate("CREATE USER " + USER + " PASSWORD '" + PASSWORD + "';");
+ st.close();
+ conn.commit();
+ conn.close();
+ }
+
+ @Test
+ public void accessDatasource() throws Exception {
+ // define the datasource
+ Properties properties = new Properties();
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", DATASOURCE_URL);
+ properties.setProperty("ProtectedDatasource.UserName", USER);
+ properties.setProperty("ProtectedDatasource.Password", "fEroTNXjaL5SOTyRQ92x3DNVS/ksbtgs");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "Static3DES");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+ // start the context and makes junit test injections
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+ Context context = container.getContext();
+ context.bind("inject", this);
+
+ // test the datasource
+ assertNotNull(dataSource);
+ assertNotNull(dataSource.getConnection());
+
+ // closing the context
+ container.close();
+ }
+
+ @Test
+ public void accessDatasourceWithMyImplementation() throws Exception {
+ // define the datasource
+ Properties properties = new Properties();
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
+ properties.setProperty("ProtectedDatasource.UserName", USER);
+ properties.setProperty("ProtectedDatasource.Password", "3MdniFr3v3NLLuoY");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "reverse");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+ // start the context and makes junit test injections
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+ Context context = container.getContext();
+ context.bind("inject", this);
+
+ // test the datasource
+ assertNotNull(dataSource);
+ assertNotNull(dataSource.getConnection());
+
+ // closing the context
+ container.close();
+ }
+
+ public static class ReverseEncryption implements PasswordCipher {
+ @Override
+ public char[] encrypt(String plainPassword) {
+ return StringUtils.reverse(plainPassword).toCharArray();
+ }
+
+ @Override
+ public String decrypt(char[] encryptedPassword) {
+ return new String(encrypt(new String(encryptedPassword)));
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.DataSourceCipheredExampleTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/datasource-ciphered-password
+ INFO - openejb.base = /Users/dblevins/examples/datasource-ciphered-password
+ 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 - Configuring Service(id=ProtectedDatasource, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/datasource-ciphered-password/target/test-classes
+ INFO - Beginning load: /Users/dblevins/examples/datasource-ciphered-password/target/test-classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/datasource-ciphered-password
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean datasource-ciphered-password.Comp: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.DataSourceCipheredExampleTest/dataSource' in bean datasource-ciphered-password.Comp to Resource(id=ProtectedDatasource)
+ INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.DataSourceCipheredExampleTest/dataSource' in bean org.superbiz.DataSourceCipheredExampleTest to Resource(id=ProtectedDatasource)
+ INFO - Enterprise application "/Users/dblevins/examples/datasource-ciphered-password" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/datasource-ciphered-password
+ INFO - Jndi(name="java:global/datasource-ciphered-password/datasource-ciphered-password.Comp!org.apache.openejb.BeanContext$Comp")
+ INFO - Jndi(name="java:global/datasource-ciphered-password/datasource-ciphered-password.Comp")
+ INFO - Jndi(name="java:global/EjbModule86823325/org.superbiz.DataSourceCipheredExampleTest!org.superbiz.DataSourceCipheredExampleTest")
+ INFO - Jndi(name="java:global/EjbModule86823325/org.superbiz.DataSourceCipheredExampleTest")
+ INFO - Created Ejb(deployment-id=datasource-ciphered-password.Comp, ejb-name=datasource-ciphered-password.Comp, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.DataSourceCipheredExampleTest, ejb-name=org.superbiz.DataSourceCipheredExampleTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=datasource-ciphered-password.Comp, ejb-name=datasource-ciphered-password.Comp, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.DataSourceCipheredExampleTest, ejb-name=org.superbiz.DataSourceCipheredExampleTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/datasource-ciphered-password)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.331 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/datasource-ciphered-password/pom.xml b/content/examples/datasource-ciphered-password/pom.xml
new file mode 100755
index 0000000..47704d2
--- /dev/null
+++ b/content/examples/datasource-ciphered-password/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>datasource-ciphered-password</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Datasource Ciphered Password</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExampleTest.java b/content/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExampleTest.java
new file mode 100755
index 0000000..d42a495
--- /dev/null
+++ b/content/examples/datasource-ciphered-password/src/test/java/org/superbiz/DataSourceCipheredExampleTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.openejb.resource.jdbc.cipher.PasswordCipher;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.annotation.Resource;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Properties;
+
+import static org.junit.Assert.assertNotNull;
+
+public class DataSourceCipheredExampleTest {
+
+ private static final String USER = DataSourceCipheredExampleTest.class.getSimpleName().toUpperCase();
+ private static final String PASSWORD = "YouLLN3v3rFindM3";
+ private static final String DATASOURCE_URL = "jdbc:hsqldb:mem:protected";
+
+ @Resource
+ private DataSource dataSource;
+
+ @BeforeClass
+ public static void addDatabaseUserWithPassword() throws Exception {
+ Class.forName("org.hsqldb.jdbcDriver");
+ Connection conn = DriverManager.getConnection(DATASOURCE_URL, "sa", "");
+ conn.setAutoCommit(true);
+ Statement st = conn.createStatement();
+ st.executeUpdate("CREATE USER " + USER + " PASSWORD '" + PASSWORD + "';");
+ st.close();
+ conn.commit();
+ conn.close();
+ }
+
+ @Test
+ public void accessDatasource() throws Exception {
+ // define the datasource
+ Properties properties = new Properties();
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", DATASOURCE_URL);
+ properties.setProperty("ProtectedDatasource.UserName", USER);
+ properties.setProperty("ProtectedDatasource.Password", "fEroTNXjaL5SOTyRQ92x3DNVS/ksbtgs");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "Static3DES");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+ // start the context and makes junit test injections
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+ Context context = container.getContext();
+ context.bind("inject", this);
+
+ // test the datasource
+ assertNotNull(dataSource);
+ assertNotNull(dataSource.getConnection());
+
+ // closing the context
+ container.close();
+ }
+
+ @Test
+ public void accessDatasourceWithMyImplementation() throws Exception {
+ // define the datasource
+ Properties properties = new Properties();
+ properties.setProperty("ProtectedDatasource", "new://Resource?type=DataSource");
+ properties.setProperty("ProtectedDatasource.JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty("ProtectedDatasource.JdbcUrl", "jdbc:hsqldb:mem:protected");
+ properties.setProperty("ProtectedDatasource.UserName", USER);
+ properties.setProperty("ProtectedDatasource.Password", "3MdniFr3v3NLLuoY");
+ properties.setProperty("ProtectedDatasource.PasswordCipher", "reverse");
+ properties.setProperty("ProtectedDatasource.JtaManaged", "true");
+
+ // start the context and makes junit test injections
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+ Context context = container.getContext();
+ context.bind("inject", this);
+
+ // test the datasource
+ assertNotNull(dataSource);
+ assertNotNull(dataSource.getConnection());
+
+ // closing the context
+ container.close();
+ }
+
+ public static class ReverseEncryption implements PasswordCipher {
+
+ @Override
+ public char[] encrypt(String plainPassword) {
+ return StringUtils.reverse(plainPassword).toCharArray();
+ }
+
+ @Override
+ public String decrypt(char[] encryptedPassword) {
+ return new String(encrypt(new String(encryptedPassword)));
+ }
+ }
+}
diff --git a/content/examples/datasource-ciphered-password/src/test/resources/META-INF/beans.xml b/content/examples/datasource-ciphered-password/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c4955f0
--- /dev/null
+++ b/content/examples/datasource-ciphered-password/src/test/resources/META-INF/beans.xml
@@ -0,0 +1 @@
+<beans/>
diff --git a/content/examples/datasource-ciphered-password/src/test/resources/META-INF/org.apache.openejb.resource.jdbc.cipher.PasswordCipher/reverse b/content/examples/datasource-ciphered-password/src/test/resources/META-INF/org.apache.openejb.resource.jdbc.cipher.PasswordCipher/reverse
new file mode 100755
index 0000000..84d0e9d
--- /dev/null
+++ b/content/examples/datasource-ciphered-password/src/test/resources/META-INF/org.apache.openejb.resource.jdbc.cipher.PasswordCipher/reverse
@@ -0,0 +1 @@
+org.superbiz.DataSourceCipheredExampleTest$ReverseEncryption
diff --git a/content/examples/datasource-definition.html b/content/examples/datasource-definition.html
new file mode 100644
index 0000000..bd483b8
--- /dev/null
+++ b/content/examples/datasource-definition.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/datasource-definition.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>datasource-definition</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example datasource-definition can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/datasource-definition" class="bare">https://github.com/apache/tomee/tree/master/examples/datasource-definition</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/datasource-definition.pdf b/content/examples/datasource-definition.pdf
new file mode 100644
index 0000000..b2d7df0
--- /dev/null
+++ b/content/examples/datasource-definition.pdf
Binary files differ
diff --git a/content/examples/datasource-definition/pom.xml b/content/examples/datasource-definition/pom.xml
new file mode 100755
index 0000000..af94e6b
--- /dev/null
+++ b/content/examples/datasource-definition/pom.xml
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>datasource-definition</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Datasource Definition</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.geronimo.buildsupport</groupId>
+ <artifactId>geronimo-property-plugin</artifactId>
+ <version>3.0-M1</version>
+ <configuration>
+ <propertyName>annotations.endorsed</propertyName>
+ <listFiles>false</listFiles>
+ <classpath>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.1_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ </classpath>
+ </configuration>
+ <executions>
+ <execution>
+ <id>set-endorsed-property</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>set-property</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArguments>
+ <endorseddirs>${annotations.endorsed}</endorseddirs>
+ </compilerArguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <systemPropertyVariables>
+ <java.endorsed.dirs>${annotations.endorsed}</java.endorsed.dirs>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency> <!-- for the plugin to endorse the build -->
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.1_spec</artifactId>
+ <version>1.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.3.166</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/datasource-definition/src/main/java/org/superbiz/dsdef/Persister.java b/content/examples/datasource-definition/src/main/java/org/superbiz/dsdef/Persister.java
new file mode 100755
index 0000000..4b70bd3
--- /dev/null
+++ b/content/examples/datasource-definition/src/main/java/org/superbiz/dsdef/Persister.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dsdef;
+
+import javax.annotation.Resource;
+import javax.annotation.sql.DataSourceDefinition;
+import javax.inject.Named;
+import javax.sql.DataSource;
+
+@DataSourceDefinition(transactional = true,
+ url = "jdbc:h2:mem:persister",
+ className = "org.h2.jdbcx.JdbcDataSource",
+ user = "sa",
+ password = "",
+ name = "java:app/jdbc/persister",
+ initialPoolSize = 1,
+ maxPoolSize = 3
+)
+@Named
+public class Persister {
+
+ @Resource(lookup = "java:app/jdbc/persister")
+ private DataSource ds;
+
+ public DataSource getDs() {
+ return ds;
+ }
+}
diff --git a/content/examples/datasource-definition/src/main/resources/META-INF/beans.xml b/content/examples/datasource-definition/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/datasource-definition/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/datasource-definition/src/test/java/org/superbiz/dsdef/DataSourceDefinitionTest.java b/content/examples/datasource-definition/src/test/java/org/superbiz/dsdef/DataSourceDefinitionTest.java
new file mode 100755
index 0000000..ba9c3f2
--- /dev/null
+++ b/content/examples/datasource-definition/src/test/java/org/superbiz/dsdef/DataSourceDefinitionTest.java
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dsdef;
+
+import org.apache.openejb.resource.jdbc.dbcp.DbcpManagedDataSource;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class DataSourceDefinitionTest {
+
+ private static EJBContainer container;
+
+ @Inject
+ private Persister persister;
+
+ @BeforeClass
+ public static void start() {
+ container = EJBContainer.createEJBContainer();
+ }
+
+ @Before
+ public void inject() throws NamingException {
+ container.getContext().bind("inject", this);
+ }
+
+ @AfterClass
+ public static void stop() {
+ container.close();
+ }
+
+ @Test
+ public void checkDs() throws SQLException {
+ final DataSource ds = persister.getDs();
+ assertNotNull(ds);
+ assertThat(ds, instanceOf(DbcpManagedDataSource.class));
+
+ final DbcpManagedDataSource castedDs = (DbcpManagedDataSource) ds;
+
+ final String driver = castedDs.getDriverClassName();
+ assertEquals("org.h2.jdbcx.JdbcDataSource", driver);
+
+ final String user = castedDs.getUserName();
+ assertEquals("sa", user);
+
+ final String url = castedDs.getUrl();
+ assertEquals("jdbc:h2:mem:persister", url);
+
+ final int initPoolSize = castedDs.getInitialSize();
+ assertEquals(1, initPoolSize);
+
+ final int maxIdle = castedDs.getMaxIdle();
+ assertEquals(3, maxIdle);
+
+ final Connection connection = ds.getConnection();
+ assertNotNull(connection);
+
+ execute(connection, "CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
+ execute(connection, "INSERT INTO TEST(ID, NAME) VALUES(1, 'foo')");
+ connection.commit();
+
+ final PreparedStatement statement = ds.getConnection().prepareStatement("SELECT NAME FROM TEST");
+ statement.execute();
+ final ResultSet set = statement.getResultSet();
+
+ assertTrue(set.next());
+ assertEquals("foo", set.getString("NAME"));
+ }
+
+ @Test
+ public void lookup() throws NamingException {
+ final Object o = container.getContext().lookup("java:app/jdbc/persister");
+ assertNotNull(o);
+ assertEquals(persister.getDs(), o);
+ }
+
+ private void execute(final Connection connection, final String sql) throws SQLException {
+ connection.prepareStatement(sql).execute();
+ }
+}
diff --git a/content/examples/datasource-versioning.html b/content/examples/datasource-versioning.html
new file mode 100644
index 0000000..3176040
--- /dev/null
+++ b/content/examples/datasource-versioning.html
@@ -0,0 +1,592 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/datasource-versioning.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>DataSource Versioning</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example datasource-versioning can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/datasource-versioning" class="bare">https://github.com/apache/tomee/tree/master/examples/datasource-versioning</a></p>
+</div>
+<div class="paragraph">
+<p>This example shows you how to use versioned DataSources of the same provider using the classpath attribute.</p>
+</div>
+</div>
+</div>
+<h1 id="_configuration" class="sect0">Configuration</h1>
+<div class="paragraph">
+<p>The DataSource configuration can be made several ways and here we layout two common methods in the form of unit tests.
+Before we start, if you take a peek in the project pom.xml and look for the maven-dependency-plugin usage you will see that we pull in
+two completely different driver files for this example.</p>
+</div>
+<h1 id="_alternatedatasourcetest_java" class="sect0">AlternateDataSourceTest.java</h1>
+<div class="paragraph">
+<p>This test utilizes the Arquillian testing framework. See <a href="http://tomee.apache.org/arquillian-available-adapters.html">here</a> for more details.</p>
+</div>
+<div class="paragraph">
+<p>The example uses src/test/resources/arquillian.xml and src/test/conf/tomee.xml to define the DataSources.
+Note the differing driver version paths, yet still using the same provider (org.apache.derby.jdbc.EmbeddedDriver):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><tomee>
+
+ <Resource id="DatabaseOne" type="DataSource" classpath="${catalina.base}/../../drivers/derby-10.10.1.1.jar">
+ JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
+ JdbcUrl jdbc:derby:databaseOne;create=true
+ UserName SA
+ </Resource>
+
+ <Resource id="DatabaseTwo" type="DataSource" classpath="${catalina.base}/../../drivers/derby-10.9.1.0.jar">
+ JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
+ JdbcUrl jdbc:derby:databaseTwo;create=true
+ UserName SA
+ </Resource>
+
+</tomee></code></pre>
+</div>
+</div>
+<h1 id="_developer_information" class="sect0">Developer Information</h1>
+<div class="paragraph">
+<p>When testing within a Maven environment it is also possible to use direct maven coordinates rather than a file link, like so:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> ....
+<Resource id="DatabaseOne" type="DataSource" classpath="mvn:org.apache.derby:derby:10.10.1.1">
+....</pre>
+</div>
+</div>
+<h1 id="_alternatedriverjartest_java" class="sect0">AlternateDriverJarTest.java</h1>
+<div class="paragraph">
+<p>This test takes an embedded approach and as you can see the driver paths are specified as a DataSource parameter.
+Both examples demonstrate the same, in that two driver versions can be loaded and used within the same application.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Configuration
+public Properties config() {
+
+ final File drivers = new File(new File("target"), "drivers").getAbsoluteFile();
+
+ final Properties p = new Properties();
+ p.put("openejb.jdbc.datasource-creator", "dbcp-alternative");
+
+ File file = new File(drivers, "derby-10.10.1.1.jar");
+ Assert.assertTrue("Failed to find: " + file, file.exists());
+
+ p.put("JdbcOne", "new://Resource?type=DataSource&classpath="
+ + file.getAbsolutePath().replace("\\", "/"));
+ p.put("JdbcOne.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+ p.put("JdbcOne.JdbcUrl", "jdbc:derby:memory:JdbcOne;create=true");
+ p.put("JdbcOne.UserName", USER);
+ p.put("JdbcOne.Password", PASSWORD);
+ p.put("JdbcOne.JtaManaged", "false");
+
+ file = new File(drivers, "derby-10.9.1.0.jar");
+ Assert.assertTrue("Failed to find: " + file, file.exists());
+
+ p.put("JdbcTwo", "new://Resource?type=DataSource&classpath="
+ + file.getAbsolutePath().replace("\\", "/"));
+ p.put("JdbcTwo.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+ p.put("JdbcTwo.JdbcUrl", "jdbc:derby:memory:JdbcTwo;create=true");
+ p.put("JdbcTwo.UserName", USER);
+ p.put("JdbcTwo.Password", PASSWORD);
+ p.put("JdbcTwo.JtaManaged", "false");
+ return p;
+}</code></pre>
+</div>
+</div>
+<h1 id="_full_test_source_for_alternatedatasourcetest_java" class="sect0">Full Test Source for AlternateDataSourceTest.java</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+
+@RunWith(Arquillian.class)
+public class AlternateDataSourceTest {
+
+ @Deployment
+ public static WebArchive createDeployment() {
+
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(DataSourceTester.class)
+ .addAsResource(new ClassLoaderAsset("META-INF/ejb-jar.xml"), "META-INF/ejb-jar.xml");
+ //We are using src/test/conf/tomee.xml, but this also works - .addAsResource(new ClassLoaderAsset("META-INF/resources.xml"), "META-INF/resources.xml");
+ //Or even using a persistence context - .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
+ }
+
+ @EJB
+ private DataSourceTester tester;
+
+ @Test
+ public void testDataSourceOne() throws Exception {
+ Assert.assertEquals("Should be using 10.10.1.1 - (1458268)", "10.10.1.1 - (1458268)", tester.getOne());
+ }
+
+ @Test
+ public void testDataSourceTwo() throws Exception {
+ Assert.assertEquals("Should be using 10.9.1.0 - (1344872)", "10.9.1.0 - (1344872)", tester.getTwo());
+ }
+
+ @Test
+ public void testDataSourceBoth() throws Exception {
+ Assert.assertEquals("Should be using 10.10.1.1 - (1458268)|10.9.1.0 - (1344872)", "10.10.1.1 - (1458268)|10.9.1.0 - (1344872)", tester.getBoth());
+ }
+
+ @Stateless
+ public static class DataSourceTester {
+
+ @Resource(name = "DatabaseOne")
+ DataSource dataSourceOne;
+
+ @Resource(name = "DatabaseTwo")
+ DataSource dataSourceTwo;
+
+ public String getOne() throws Exception {
+ return getVersion(dataSourceOne);
+ }
+
+ public String getTwo() throws Exception {
+ return getVersion(dataSourceTwo);
+ }
+
+ public String getBoth() throws Exception {
+ return getOne() + "|" + getTwo();
+ }
+
+ private static String getVersion(final DataSource ds) throws SQLException {
+ Connection con = null;
+ try {
+ con = ds.getConnection();
+ final DatabaseMetaData md = con.getMetaData();
+ return md.getDriverVersion();
+ } finally {
+ if (con != null) {
+ con.close();
+ }
+ }
+ }
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.AlternateDataSourceTest
+Apr 17, 2014 2:19:45 PM org.apache.openejb.arquillian.common.Setup findHome
+INFO: Unable to find home in: C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote
+Apr 17, 2014 2:19:45 PM org.apache.openejb.arquillian.common.MavenCache getArtifact
+INFO: Downloading org.apache.openejb:apache-tomee:1.6.1-SNAPSHOT:zip:webprofile please wait...
+Apr 17, 2014 2:19:45 PM org.apache.openejb.arquillian.common.Zips unzip
+INFO: Extracting 'C:\Users\Andy\.m2\repository\org\apache\openejb\apache-tomee\1.6.1-SNAPSHOT\apache-tomee-1.6.1-SNAPSHOT-webprofile.zip' to 'C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote'
+Apr 17, 2014 2:19:47 PM org.apache.tomee.arquillian.remote.RemoteTomEEContainer configure
+INFO: Downloaded container to: C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT
+INFO - The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_45\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\SlikSvn\bin;C:\dev\apache-maven-3.2.1\bin;C:\dev\apache-ant-1.9.3\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files\TortoiseSVN\bin;.
+INFO - Initializing ProtocolHandler ["http-bio-55243"]
+INFO - Initializing ProtocolHandler ["ajp-bio-55245"]
+INFO - Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
+INFO - Optional service not installed: org.apache.tomee.webservices.TomeeJaxRsService
+INFO - Optional service not installed: org.apache.tomee.webservices.TomeeJaxWsService
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Thu Apr 17 14:19:55 CEST 2014
+INFO - Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 7.0.0-SNAPSHOT
+INFO - Build date: 20140417
+INFO - Build time: 01:37
+INFO - ********************************************************************************
+INFO - openejb.home = C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT
+INFO - openejb.base = C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@22c2e2dd
+INFO - Succeeded in installing singleton service
+INFO - openejb configuration file is 'C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT\conf\tomee.xml'
+INFO - Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
+INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+INFO - Configuring Service(id=DatabaseOne, type=Resource, provider-id=Default JDBC Database)
+INFO - Configuring Service(id=DatabaseTwo, type=Resource, provider-id=Default JDBC Database)
+INFO - Using 'openejb.system.apps=true'
+INFO - Configuring enterprise application: openejb
+INFO - Using openejb.deploymentId.format '{ejbName}'
+INFO - Auto-deploying ejb openejb/Deployer: EjbDeployment(deployment-id=openejb/Deployer)
+INFO - Auto-deploying ejb openejb/ConfigurationInfo: EjbDeployment(deployment-id=openejb/ConfigurationInfo)
+INFO - Auto-deploying ejb MEJB: EjbDeployment(deployment-id=MEJB)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean openejb/Deployer: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "openejb" loaded.
+INFO - Creating TransactionManager(id=Default Transaction Manager)
+INFO - Creating SecurityService(id=Tomcat Security Service)
+INFO - Creating Resource(id=DatabaseOne)
+INFO - Disabling testOnBorrow since no validation query is provided
+INFO - Creating Resource(id=DatabaseTwo)
+INFO - Disabling testOnBorrow since no validation query is provided
+INFO - Creating Container(id=Default Stateless Container)
+INFO - Assembling app: openejb
+INFO - Using 'openejb.jndiname.format={deploymentId}{interfaceType.openejbLegacyName}'
+INFO - Jndi(name=openejb/DeployerBusinessRemote) --> Ejb(deployment-id=openejb/Deployer)
+INFO - Jndi(name=global/openejb/openejb/Deployer!org.apache.openejb.assembler.Deployer) --> Ejb(deployment-id=openejb/Deployer)
+INFO - Jndi(name=global/openejb/openejb/Deployer) --> Ejb(deployment-id=openejb/Deployer)
+INFO - Jndi(name=openejb/ConfigurationInfoBusinessRemote) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+INFO - Jndi(name=global/openejb/openejb/ConfigurationInfo!org.apache.openejb.assembler.classic.cmd.ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+INFO - Jndi(name=global/openejb/openejb/ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+INFO - Jndi(name=MEJB) --> Ejb(deployment-id=MEJB)
+INFO - Jndi(name=global/openejb/MEJB!javax.management.j2ee.ManagementHome) --> Ejb(deployment-id=MEJB)
+INFO - Jndi(name=global/openejb/MEJB) --> Ejb(deployment-id=MEJB)
+INFO - Created Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+INFO - Deployed MBean(openejb.user.mbeans:application=openejb,group=org.apache.openejb.assembler.monitoring,name=JMXDeployer)
+INFO - Deployed Application(path=openejb)
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - -------
+INFO - Ready!
+INFO - Initialization processed in 7959 ms
+INFO - Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
+INFO - Creating Resource(id=UserDatabase)
+INFO - Starting service Catalina
+INFO - Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.53 (1.6.1-SNAPSHOT)
+INFO - Starting ProtocolHandler ["http-bio-55243"]
+INFO - Starting ProtocolHandler ["ajp-bio-55245"]
+INFO - Server startup in 288 ms
+WARNING - StandardServer.await: Invalid command '' received
+Apr 17, 2014 2:20:04 PM org.apache.openejb.client.EventLogger log
+INFO: RemoteInitialContextCreated{providerUri=http://localhost:55243/tomee/ejb}
+INFO - Extracting jar: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test.war
+INFO - Extracted path: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test
+INFO - using default host: localhost
+INFO - ------------------------- localhost -> /test
+INFO - Using 'openejb.session.manager=org.apache.tomee.catalina.session.QuickSessionManager'
+INFO - Configuring enterprise application: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test
+INFO - Auto-deploying ejb DataSourceTester: EjbDeployment(deployment-id=DataSourceTester)
+INFO - Auto-linking resource-ref 'java:comp/env/DatabaseTwo' in bean DataSourceTester to Resource(id=DatabaseTwo)
+INFO - Auto-linking resource-ref 'java:comp/env/DatabaseOne' in bean DataSourceTester to Resource(id=DatabaseOne)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.AlternateDataSourceTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Using directory C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT\temp for stateful session passivation
+INFO - Enterprise application "C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test" loaded.
+INFO - Assembling app: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test
+INFO - Jndi(name=DataSourceTesterLocalBean) --> Ejb(deployment-id=DataSourceTester)
+INFO - Jndi(name=global/test/DataSourceTester!org.superbiz.AlternateDataSourceTest$DataSourceTester) --> Ejb(deployment-id=DataSourceTester)
+INFO - Jndi(name=global/test/DataSourceTester) --> Ejb(deployment-id=DataSourceTester)
+INFO - Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@22c2e2dd
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points were validated successfully.
+INFO - OpenWebBeans Container has started, it took 203 ms.
+INFO - Created Ejb(deployment-id=DataSourceTester, ejb-name=DataSourceTester, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=DataSourceTester, ejb-name=DataSourceTester, container=Default Stateless Container)
+INFO - Deployed Application(path=C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test)
+Apr 17, 2014 2:20:11 PM org.apache.openejb.client.EventLogger log
+INFO: RemoteInitialContextCreated{providerUri=http://localhost:55243/tomee/ejb}
+INFO - Undeploying app: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test
+Apr 17, 2014 2:20:13 PM org.apache.openejb.arquillian.common.TomEEContainer undeploy
+INFO: cleaning C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0
+Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 30.155 sec
+Running org.superbiz.AlternateDriverJarTest
+Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigUtils searchForConfiguration
+INFO: Cannot find the configuration file [conf/openejb.xml]. Will attempt to create one for the beans deployed.
+Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=JdbcTwo, type=Resource, provider-id=Default JDBC Database)
+Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=JdbcOne, type=Resource, provider-id=Default JDBC Database)
+Apr 17, 2014 2:20:13 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating TransactionManager(id=Default Transaction Manager)
+Apr 17, 2014 2:20:14 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating SecurityService(id=Default Security Service)
+Apr 17, 2014 2:20:14 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating Resource(id=JdbcTwo)
+Apr 17, 2014 2:20:15 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating Resource(id=JdbcOne)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.config.ConfigurationFactory configureApplication
+INFO: Configuring enterprise application: C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest
+Apr 17, 2014 2:20:16 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AutoConfig createContainer
+INFO: Auto-creating a container for bean org.superbiz.AlternateDriverJarTest: Container(type=MANAGED, id=Default Managed Container)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating Container(id=Default Managed Container)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.core.managed.SimplePassivater init
+INFO: Using directory C:\Users\Andy\AppData\Local\Temp for stateful session passivation
+Apr 17, 2014 2:20:16 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AutoConfig createContainer
+INFO: Auto-creating a container for bean JdbcOne: Container(type=SINGLETON, id=Default Singleton Container)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating Container(id=Default Singleton Container)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'java:comp/env/JdbcOne' in bean JdbcOne to Resource(id=JdbcOne)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'java:comp/env/JdbcTwo' in bean JdbcTwo to Resource(id=JdbcTwo)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AppInfoBuilder build
+INFO: Enterprise application "C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest" loaded.
+Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.Assembler createApplication
+INFO: Assembling app: C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest
+Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=JdbcOneLocalBean) --> Ejb(deployment-id=JdbcOne)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/AlternateDriverJarTest/app/JdbcOne!org.superbiz.AlternateDriverJarTest$JdbcOne) --> Ejb(deployment-id=JdbcOne)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/AlternateDriverJarTest/app/JdbcOne) --> Ejb(deployment-id=JdbcOne)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=JdbcTwoLocalBean) --> Ejb(deployment-id=JdbcTwo)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/AlternateDriverJarTest/app/JdbcTwo!org.superbiz.AlternateDriverJarTest$JdbcTwo) --> Ejb(deployment-id=JdbcTwo)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/AlternateDriverJarTest/app/JdbcTwo) --> Ejb(deployment-id=JdbcTwo)
+Apr 17, 2014 2:20:16 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
+INFO: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@5ddd4e70
+Apr 17, 2014 2:20:16 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
+INFO: Succeeded in installing singleton service
+Apr 17, 2014 2:20:17 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+INFO: OpenWebBeans Container is starting...
+Apr 17, 2014 2:20:17 PM org.apache.webbeans.plugins.PluginLoader startUp
+INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
+Apr 17, 2014 2:20:17 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
+INFO: All injection points were validated successfully.
+Apr 17, 2014 2:20:17 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+INFO: OpenWebBeans Container has started, it took 223 ms.
+Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Created Ejb(deployment-id=JdbcTwo, ejb-name=JdbcTwo, container=Default Singleton Container)
+Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Created Ejb(deployment-id=JdbcOne, ejb-name=JdbcOne, container=Default Singleton Container)
+Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Started Ejb(deployment-id=JdbcTwo, ejb-name=JdbcTwo, container=Default Singleton Container)
+Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Started Ejb(deployment-id=JdbcOne, ejb-name=JdbcOne, container=Default Singleton Container)
+Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler createApplication
+INFO: Deployed Application(path=C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest)
+Apr 17, 2014 2:20:20 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
+INFO: Undeploying app: C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest
+Apr 17, 2014 2:20:20 PM org.apache.openejb.assembler.classic.Assembler destroyResource
+INFO: Closing DataSource: JdbcTwo
+Apr 17, 2014 2:20:20 PM org.apache.openejb.assembler.classic.Assembler destroyResource
+INFO: Closing DataSource: JdbcOne
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.857 sec
+INFO - A valid shutdown command was received via the shutdown port. Stopping the Server instance.
+INFO - Pausing ProtocolHandler ["http-bio-55243"]
+INFO - Pausing ProtocolHandler ["ajp-bio-55245"]
+INFO - Stopping service Catalina
+INFO - Stopping ProtocolHandler ["http-bio-55243"]
+INFO - Stopping ProtocolHandler ["ajp-bio-55245"]
+INFO - Stopping server services
+INFO - Undeploying app: openejb
+INFO - Closing DataSource: DatabaseOne
+INFO - Closing DataSource: DatabaseTwo
+INFO - Destroying ProtocolHandler ["http-bio-55243"]
+INFO - Destroying ProtocolHandler ["ajp-bio-55245"]
+
+Results :
+
+Tests run: 4, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/datasource-versioning.pdf b/content/examples/datasource-versioning.pdf
new file mode 100644
index 0000000..d1b72df
--- /dev/null
+++ b/content/examples/datasource-versioning.pdf
Binary files differ
diff --git a/content/examples/datasource-versioning/README.md b/content/examples/datasource-versioning/README.md
new file mode 100755
index 0000000..925b42e
--- /dev/null
+++ b/content/examples/datasource-versioning/README.md
@@ -0,0 +1,386 @@
+Title: DataSource Versioning
+
+This example shows you how to use versioned DataSources of the same provider using the classpath attribute.
+
+# Configuration
+
+The DataSource configuration can be made several ways and here we layout two common methods in the form of unit tests.
+Before we start, if you take a peek in the project pom.xml and look for the maven-dependency-plugin usage you will see that we pull in
+two completely different driver files for this example.
+
+# AlternateDataSourceTest.java
+This test utilizes the Arquillian testing framework. See [here](http://tomee.apache.org/arquillian-available-adapters.html) for more details.
+
+The example uses src/test/resources/arquillian.xml and src/test/conf/tomee.xml to define the DataSources.
+Note the differing driver version paths, yet still using the same provider (org.apache.derby.jdbc.EmbeddedDriver):
+
+ <tomee>
+
+ <Resource id="DatabaseOne" type="DataSource" classpath="${catalina.base}/../../drivers/derby-10.10.1.1.jar">
+ JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
+ JdbcUrl jdbc:derby:databaseOne;create=true
+ UserName SA
+ </Resource>
+
+ <Resource id="DatabaseTwo" type="DataSource" classpath="${catalina.base}/../../drivers/derby-10.9.1.0.jar">
+ JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
+ JdbcUrl jdbc:derby:databaseTwo;create=true
+ UserName SA
+ </Resource>
+
+ </tomee>
+
+# Developer Information
+When testing within a Maven environment it is also possible to use direct maven coordinates rather than a file link, like so:
+
+ ....
+ <Resource id="DatabaseOne" type="DataSource" classpath="mvn:org.apache.derby:derby:10.10.1.1">
+ ....
+
+
+# AlternateDriverJarTest.java
+
+This test takes an embedded approach and as you can see the driver paths are specified as a DataSource parameter.
+Both examples demonstrate the same, in that two driver versions can be loaded and used within the same application.
+
+ @Configuration
+ public Properties config() {
+
+ final File drivers = new File(new File("target"), "drivers").getAbsoluteFile();
+
+ final Properties p = new Properties();
+ p.put("openejb.jdbc.datasource-creator", "dbcp-alternative");
+
+ File file = new File(drivers, "derby-10.10.1.1.jar");
+ Assert.assertTrue("Failed to find: " + file, file.exists());
+
+ p.put("JdbcOne", "new://Resource?type=DataSource&classpath="
+ + file.getAbsolutePath().replace("\\", "/"));
+ p.put("JdbcOne.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+ p.put("JdbcOne.JdbcUrl", "jdbc:derby:memory:JdbcOne;create=true");
+ p.put("JdbcOne.UserName", USER);
+ p.put("JdbcOne.Password", PASSWORD);
+ p.put("JdbcOne.JtaManaged", "false");
+
+ file = new File(drivers, "derby-10.9.1.0.jar");
+ Assert.assertTrue("Failed to find: " + file, file.exists());
+
+ p.put("JdbcTwo", "new://Resource?type=DataSource&classpath="
+ + file.getAbsolutePath().replace("\\", "/"));
+ p.put("JdbcTwo.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+ p.put("JdbcTwo.JdbcUrl", "jdbc:derby:memory:JdbcTwo;create=true");
+ p.put("JdbcTwo.UserName", USER);
+ p.put("JdbcTwo.Password", PASSWORD);
+ p.put("JdbcTwo.JtaManaged", "false");
+ return p;
+ }
+
+# Full Test Source for AlternateDataSourceTest.java
+
+ package org.superbiz;
+
+ import org.jboss.arquillian.container.test.api.Deployment;
+ import org.jboss.arquillian.junit.Arquillian;
+ import org.jboss.shrinkwrap.api.ShrinkWrap;
+ import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+ import org.jboss.shrinkwrap.api.spec.WebArchive;
+ import org.junit.Assert;
+ import org.junit.Test;
+ import org.junit.runner.RunWith;
+
+ import javax.annotation.Resource;
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+ import javax.sql.DataSource;
+ import java.sql.Connection;
+ import java.sql.DatabaseMetaData;
+ import java.sql.SQLException;
+
+ @RunWith(Arquillian.class)
+ public class AlternateDataSourceTest {
+
+ @Deployment
+ public static WebArchive createDeployment() {
+
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(DataSourceTester.class)
+ .addAsResource(new ClassLoaderAsset("META-INF/ejb-jar.xml"), "META-INF/ejb-jar.xml");
+ //We are using src/test/conf/tomee.xml, but this also works - .addAsResource(new ClassLoaderAsset("META-INF/resources.xml"), "META-INF/resources.xml");
+ //Or even using a persistence context - .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
+ }
+
+ @EJB
+ private DataSourceTester tester;
+
+ @Test
+ public void testDataSourceOne() throws Exception {
+ Assert.assertEquals("Should be using 10.10.1.1 - (1458268)", "10.10.1.1 - (1458268)", tester.getOne());
+ }
+
+ @Test
+ public void testDataSourceTwo() throws Exception {
+ Assert.assertEquals("Should be using 10.9.1.0 - (1344872)", "10.9.1.0 - (1344872)", tester.getTwo());
+ }
+
+ @Test
+ public void testDataSourceBoth() throws Exception {
+ Assert.assertEquals("Should be using 10.10.1.1 - (1458268)|10.9.1.0 - (1344872)", "10.10.1.1 - (1458268)|10.9.1.0 - (1344872)", tester.getBoth());
+ }
+
+ @Stateless
+ public static class DataSourceTester {
+
+ @Resource(name = "DatabaseOne")
+ DataSource dataSourceOne;
+
+ @Resource(name = "DatabaseTwo")
+ DataSource dataSourceTwo;
+
+ public String getOne() throws Exception {
+ return getVersion(dataSourceOne);
+ }
+
+ public String getTwo() throws Exception {
+ return getVersion(dataSourceTwo);
+ }
+
+ public String getBoth() throws Exception {
+ return getOne() + "|" + getTwo();
+ }
+
+ private static String getVersion(final DataSource ds) throws SQLException {
+ Connection con = null;
+ try {
+ con = ds.getConnection();
+ final DatabaseMetaData md = con.getMetaData();
+ return md.getDriverVersion();
+ } finally {
+ if (con != null) {
+ con.close();
+ }
+ }
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.AlternateDataSourceTest
+ Apr 17, 2014 2:19:45 PM org.apache.openejb.arquillian.common.Setup findHome
+ INFO: Unable to find home in: C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote
+ Apr 17, 2014 2:19:45 PM org.apache.openejb.arquillian.common.MavenCache getArtifact
+ INFO: Downloading org.apache.openejb:apache-tomee:1.6.1-SNAPSHOT:zip:webprofile please wait...
+ Apr 17, 2014 2:19:45 PM org.apache.openejb.arquillian.common.Zips unzip
+ INFO: Extracting 'C:\Users\Andy\.m2\repository\org\apache\openejb\apache-tomee\1.6.1-SNAPSHOT\apache-tomee-1.6.1-SNAPSHOT-webprofile.zip' to 'C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote'
+ Apr 17, 2014 2:19:47 PM org.apache.tomee.arquillian.remote.RemoteTomEEContainer configure
+ INFO: Downloaded container to: C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT
+ INFO - The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.7.0_45\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\SlikSvn\bin;C:\dev\apache-maven-3.2.1\bin;C:\dev\apache-ant-1.9.3\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files\TortoiseSVN\bin;.
+ INFO - Initializing ProtocolHandler ["http-bio-55243"]
+ INFO - Initializing ProtocolHandler ["ajp-bio-55245"]
+ INFO - Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
+ INFO - Optional service not installed: org.apache.tomee.webservices.TomeeJaxRsService
+ INFO - Optional service not installed: org.apache.tomee.webservices.TomeeJaxWsService
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://openejb.apache.org/
+ INFO - Startup: Thu Apr 17 14:19:55 CEST 2014
+ INFO - Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 4.6.1-SNAPSHOT
+ INFO - Build date: 20140417
+ INFO - Build time: 01:37
+ INFO - ********************************************************************************
+ INFO - openejb.home = C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT
+ INFO - openejb.base = C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@22c2e2dd
+ INFO - Succeeded in installing singleton service
+ INFO - openejb configuration file is 'C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT\conf\tomee.xml'
+ INFO - Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
+ INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+ INFO - Configuring Service(id=DatabaseOne, type=Resource, provider-id=Default JDBC Database)
+ INFO - Configuring Service(id=DatabaseTwo, type=Resource, provider-id=Default JDBC Database)
+ INFO - Using 'openejb.system.apps=true'
+ INFO - Configuring enterprise application: openejb
+ INFO - Using openejb.deploymentId.format '{ejbName}'
+ INFO - Auto-deploying ejb openejb/Deployer: EjbDeployment(deployment-id=openejb/Deployer)
+ INFO - Auto-deploying ejb openejb/ConfigurationInfo: EjbDeployment(deployment-id=openejb/ConfigurationInfo)
+ INFO - Auto-deploying ejb MEJB: EjbDeployment(deployment-id=MEJB)
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean openejb/Deployer: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "openejb" loaded.
+ INFO - Creating TransactionManager(id=Default Transaction Manager)
+ INFO - Creating SecurityService(id=Tomcat Security Service)
+ INFO - Creating Resource(id=DatabaseOne)
+ INFO - Disabling testOnBorrow since no validation query is provided
+ INFO - Creating Resource(id=DatabaseTwo)
+ INFO - Disabling testOnBorrow since no validation query is provided
+ INFO - Creating Container(id=Default Stateless Container)
+ INFO - Assembling app: openejb
+ INFO - Using 'openejb.jndiname.format={deploymentId}{interfaceType.openejbLegacyName}'
+ INFO - Jndi(name=openejb/DeployerBusinessRemote) --> Ejb(deployment-id=openejb/Deployer)
+ INFO - Jndi(name=global/openejb/openejb/Deployer!org.apache.openejb.assembler.Deployer) --> Ejb(deployment-id=openejb/Deployer)
+ INFO - Jndi(name=global/openejb/openejb/Deployer) --> Ejb(deployment-id=openejb/Deployer)
+ INFO - Jndi(name=openejb/ConfigurationInfoBusinessRemote) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+ INFO - Jndi(name=global/openejb/openejb/ConfigurationInfo!org.apache.openejb.assembler.classic.cmd.ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+ INFO - Jndi(name=global/openejb/openejb/ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+ INFO - Jndi(name=MEJB) --> Ejb(deployment-id=MEJB)
+ INFO - Jndi(name=global/openejb/MEJB!javax.management.j2ee.ManagementHome) --> Ejb(deployment-id=MEJB)
+ INFO - Jndi(name=global/openejb/MEJB) --> Ejb(deployment-id=MEJB)
+ INFO - Created Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+ INFO - Deployed MBean(openejb.user.mbeans:application=openejb,group=org.apache.openejb.assembler.monitoring,name=JMXDeployer)
+ INFO - Deployed Application(path=openejb)
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - -------
+ INFO - Ready!
+ INFO - Initialization processed in 7959 ms
+ INFO - Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
+ INFO - Creating Resource(id=UserDatabase)
+ INFO - Starting service Catalina
+ INFO - Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.53 (1.6.1-SNAPSHOT)
+ INFO - Starting ProtocolHandler ["http-bio-55243"]
+ INFO - Starting ProtocolHandler ["ajp-bio-55245"]
+ INFO - Server startup in 288 ms
+ WARNING - StandardServer.await: Invalid command '' received
+ Apr 17, 2014 2:20:04 PM org.apache.openejb.client.EventLogger log
+ INFO: RemoteInitialContextCreated{providerUri=http://localhost:55243/tomee/ejb}
+ INFO - Extracting jar: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test.war
+ INFO - Extracted path: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test
+ INFO - using default host: localhost
+ INFO - ------------------------- localhost -> /test
+ INFO - Using 'openejb.session.manager=org.apache.tomee.catalina.session.QuickSessionManager'
+ INFO - Configuring enterprise application: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test
+ INFO - Auto-deploying ejb DataSourceTester: EjbDeployment(deployment-id=DataSourceTester)
+ INFO - Auto-linking resource-ref 'java:comp/env/DatabaseTwo' in bean DataSourceTester to Resource(id=DatabaseTwo)
+ INFO - Auto-linking resource-ref 'java:comp/env/DatabaseOne' in bean DataSourceTester to Resource(id=DatabaseOne)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.AlternateDataSourceTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Creating Container(id=Default Managed Container)
+ INFO - Using directory C:\dev\svn\tomee\examples\datasource-versioning\target\apache-tomee-remote\apache-tomee-webprofile-1.6.1-SNAPSHOT\temp for stateful session passivation
+ INFO - Enterprise application "C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test" loaded.
+ INFO - Assembling app: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test
+ INFO - Jndi(name=DataSourceTesterLocalBean) --> Ejb(deployment-id=DataSourceTester)
+ INFO - Jndi(name=global/test/DataSourceTester!org.superbiz.AlternateDataSourceTest$DataSourceTester) --> Ejb(deployment-id=DataSourceTester)
+ INFO - Jndi(name=global/test/DataSourceTester) --> Ejb(deployment-id=DataSourceTester)
+ INFO - Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@22c2e2dd
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
+ INFO - All injection points were validated successfully.
+ INFO - OpenWebBeans Container has started, it took 203 ms.
+ INFO - Created Ejb(deployment-id=DataSourceTester, ejb-name=DataSourceTester, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=DataSourceTester, ejb-name=DataSourceTester, container=Default Stateless Container)
+ INFO - Deployed Application(path=C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test)
+ Apr 17, 2014 2:20:11 PM org.apache.openejb.client.EventLogger log
+ INFO: RemoteInitialContextCreated{providerUri=http://localhost:55243/tomee/ejb}
+ INFO - Undeploying app: C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0\test
+ Apr 17, 2014 2:20:13 PM org.apache.openejb.arquillian.common.TomEEContainer undeploy
+ INFO: cleaning C:\dev\svn\tomee\examples\datasource-versioning\target\arquillian-test-working-dir\0
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 30.155 sec
+ Running org.superbiz.AlternateDriverJarTest
+ Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigUtils searchForConfiguration
+ INFO: Cannot find the configuration file [conf/openejb.xml]. Will attempt to create one for the beans deployed.
+ Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigurationFactory configureService
+ INFO: Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+ Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigurationFactory configureService
+ INFO: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+ Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigurationFactory configureService
+ INFO: Configuring Service(id=JdbcTwo, type=Resource, provider-id=Default JDBC Database)
+ Apr 17, 2014 2:20:13 PM org.apache.openejb.config.ConfigurationFactory configureService
+ INFO: Configuring Service(id=JdbcOne, type=Resource, provider-id=Default JDBC Database)
+ Apr 17, 2014 2:20:13 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+ INFO: Creating TransactionManager(id=Default Transaction Manager)
+ Apr 17, 2014 2:20:14 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+ INFO: Creating SecurityService(id=Default Security Service)
+ Apr 17, 2014 2:20:14 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+ INFO: Creating Resource(id=JdbcTwo)
+ Apr 17, 2014 2:20:15 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+ INFO: Creating Resource(id=JdbcOne)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.config.ConfigurationFactory configureApplication
+ INFO: Configuring enterprise application: C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.config.ConfigurationFactory configureService
+ INFO: Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AutoConfig createContainer
+ INFO: Auto-creating a container for bean org.superbiz.AlternateDriverJarTest: Container(type=MANAGED, id=Default Managed Container)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+ INFO: Creating Container(id=Default Managed Container)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.core.managed.SimplePassivater init
+ INFO: Using directory C:\Users\Andy\AppData\Local\Temp for stateful session passivation
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.config.ConfigurationFactory configureService
+ INFO: Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AutoConfig createContainer
+ INFO: Auto-creating a container for bean JdbcOne: Container(type=SINGLETON, id=Default Singleton Container)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+ INFO: Creating Container(id=Default Singleton Container)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AutoConfig processResourceRef
+ INFO: Auto-linking resource-ref 'java:comp/env/JdbcOne' in bean JdbcOne to Resource(id=JdbcOne)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AutoConfig processResourceRef
+ INFO: Auto-linking resource-ref 'java:comp/env/JdbcTwo' in bean JdbcTwo to Resource(id=JdbcTwo)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.config.AppInfoBuilder build
+ INFO: Enterprise application "C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest" loaded.
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.Assembler createApplication
+ INFO: Assembling app: C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+ INFO: Jndi(name=JdbcOneLocalBean) --> Ejb(deployment-id=JdbcOne)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+ INFO: Jndi(name=global/AlternateDriverJarTest/app/JdbcOne!org.superbiz.AlternateDriverJarTest$JdbcOne) --> Ejb(deployment-id=JdbcOne)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+ INFO: Jndi(name=global/AlternateDriverJarTest/app/JdbcOne) --> Ejb(deployment-id=JdbcOne)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+ INFO: Jndi(name=JdbcTwoLocalBean) --> Ejb(deployment-id=JdbcTwo)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+ INFO: Jndi(name=global/AlternateDriverJarTest/app/JdbcTwo!org.superbiz.AlternateDriverJarTest$JdbcTwo) --> Ejb(deployment-id=JdbcTwo)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+ INFO: Jndi(name=global/AlternateDriverJarTest/app/JdbcTwo) --> Ejb(deployment-id=JdbcTwo)
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
+ INFO: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@5ddd4e70
+ Apr 17, 2014 2:20:16 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
+ INFO: Succeeded in installing singleton service
+ Apr 17, 2014 2:20:17 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+ INFO: OpenWebBeans Container is starting...
+ Apr 17, 2014 2:20:17 PM org.apache.webbeans.plugins.PluginLoader startUp
+ INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
+ Apr 17, 2014 2:20:17 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
+ INFO: All injection points were validated successfully.
+ Apr 17, 2014 2:20:17 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+ INFO: OpenWebBeans Container has started, it took 223 ms.
+ Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+ INFO: Created Ejb(deployment-id=JdbcTwo, ejb-name=JdbcTwo, container=Default Singleton Container)
+ Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+ INFO: Created Ejb(deployment-id=JdbcOne, ejb-name=JdbcOne, container=Default Singleton Container)
+ Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+ INFO: Started Ejb(deployment-id=JdbcTwo, ejb-name=JdbcTwo, container=Default Singleton Container)
+ Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+ INFO: Started Ejb(deployment-id=JdbcOne, ejb-name=JdbcOne, container=Default Singleton Container)
+ Apr 17, 2014 2:20:17 PM org.apache.openejb.assembler.classic.Assembler createApplication
+ INFO: Deployed Application(path=C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest)
+ Apr 17, 2014 2:20:20 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
+ INFO: Undeploying app: C:\dev\svn\tomee\examples\datasource-versioning\AlternateDriverJarTest
+ Apr 17, 2014 2:20:20 PM org.apache.openejb.assembler.classic.Assembler destroyResource
+ INFO: Closing DataSource: JdbcTwo
+ Apr 17, 2014 2:20:20 PM org.apache.openejb.assembler.classic.Assembler destroyResource
+ INFO: Closing DataSource: JdbcOne
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.857 sec
+ INFO - A valid shutdown command was received via the shutdown port. Stopping the Server instance.
+ INFO - Pausing ProtocolHandler ["http-bio-55243"]
+ INFO - Pausing ProtocolHandler ["ajp-bio-55245"]
+ INFO - Stopping service Catalina
+ INFO - Stopping ProtocolHandler ["http-bio-55243"]
+ INFO - Stopping ProtocolHandler ["ajp-bio-55245"]
+ INFO - Stopping server services
+ INFO - Undeploying app: openejb
+ INFO - Closing DataSource: DatabaseOne
+ INFO - Closing DataSource: DatabaseTwo
+ INFO - Destroying ProtocolHandler ["http-bio-55243"]
+ INFO - Destroying ProtocolHandler ["ajp-bio-55245"]
+
+ Results :
+
+ Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
diff --git a/content/examples/datasource-versioning/pom.xml b/content/examples/datasource-versioning/pom.xml
new file mode 100755
index 0000000..f29cc25
--- /dev/null
+++ b/content/examples/datasource-versioning/pom.xml
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>datasource-versioning</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Datasource Versioning</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <version.tomee>1.7.1</version.tomee>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>${version.tomee}</version>
+ <configuration>
+ <tomeeClassifier>plus</tomeeClassifier>
+ <args>-Xmx512m -XX:PermSize=256m</args>
+ <config>${project.basedir}/src/main/tomee/</config>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <id>AlternateDriverJarTest</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.10.1.1</version>
+ <type>jar</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}/drivers</outputDirectory>
+ <destFileName>derby-10.10.1.1.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.9.1.0</version>
+ <type>jar</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}/drivers</outputDirectory>
+ <destFileName>derby-10.9.1.0.jar</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Override dependency resolver with test version. This must go *BEFORE*
+ the Arquillian BOM. -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-bom</artifactId>
+ <version>2.1.0</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ <!-- Now pull in our server-based unit testing framework -->
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-bom</artifactId>
+ <version>1.1.5.Final</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${version.tomee}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/datasource-versioning/src/main/webapp/WEB-INF/web.xml b/content/examples/datasource-versioning/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..c5f9843
--- /dev/null
+++ b/content/examples/datasource-versioning/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<web-app 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/web-app_3_0.xsd"
+ version="3.0">
+</web-app>
diff --git a/content/examples/datasource-versioning/src/main/webapp/index.jsp b/content/examples/datasource-versioning/src/main/webapp/index.jsp
new file mode 100755
index 0000000..fe7658e
--- /dev/null
+++ b/content/examples/datasource-versioning/src/main/webapp/index.jsp
@@ -0,0 +1,26 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<html>
+<head>
+ <title>Just an empty page for now</title>
+</head>
+<body>
+<h1>Home</h1>
+</body>
+</html>
diff --git a/content/examples/datasource-versioning/src/test/conf/tomee.xml b/content/examples/datasource-versioning/src/test/conf/tomee.xml
new file mode 100755
index 0000000..9efc47a
--- /dev/null
+++ b/content/examples/datasource-versioning/src/test/conf/tomee.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<tomee>
+
+ <Resource id="DatabaseOne" type="DataSource" classpath="${catalina.base}/../../drivers/derby-10.10.1.1.jar">
+ JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
+ JdbcUrl jdbc:derby:target/databaseOne;create=true
+ UserName SA
+ </Resource>
+
+ <Resource id="DatabaseTwo" type="DataSource" classpath="${catalina.base}/../../drivers/derby-10.9.1.0.jar">
+ JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
+ JdbcUrl jdbc:derby:target/databaseTwo;create=true
+ UserName SA
+ </Resource>
+
+</tomee>
diff --git a/content/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDataSourceTest.java b/content/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDataSourceTest.java
new file mode 100755
index 0000000..252429e
--- /dev/null
+++ b/content/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDataSourceTest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+
+@RunWith(Arquillian.class)
+public class AlternateDataSourceTest {
+
+ @Deployment
+ public static WebArchive createDeployment() {
+
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(DataSourceTester.class)
+ .addAsResource(new ClassLoaderAsset("META-INF/ejb-jar.xml"), "META-INF/ejb-jar.xml");
+ //We are using src/test/conf/tomee.xml, but this also works - .addAsResource(new ClassLoaderAsset("META-INF/resources.xml"), "META-INF/resources.xml");
+ //Or even using a persistence context - .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
+ }
+
+ @EJB
+ private DataSourceTester tester;
+
+ @Test
+ public void testDataSourceOne() throws Exception {
+ Assert.assertEquals("Should be using 10.10.1.1 - (1458268)", "10.10.1.1 - (1458268)", tester.getOne());
+ }
+
+ @Test
+ public void testDataSourceTwo() throws Exception {
+ Assert.assertEquals("Should be using 10.9.1.0 - (1344872)", "10.9.1.0 - (1344872)", tester.getTwo());
+ }
+
+ @Test
+ public void testDataSourceBoth() throws Exception {
+ Assert.assertEquals("Should be using 10.10.1.1 - (1458268)|10.9.1.0 - (1344872)", "10.10.1.1 - (1458268)|10.9.1.0 - (1344872)", tester.getBoth());
+ }
+
+ @Stateless
+ public static class DataSourceTester {
+
+ @Resource(name = "DatabaseOne")
+ DataSource dataSourceOne;
+
+ @Resource(name = "DatabaseTwo")
+ DataSource dataSourceTwo;
+
+ public String getOne() throws Exception {
+ return getVersion(dataSourceOne);
+ }
+
+ public String getTwo() throws Exception {
+ return getVersion(dataSourceTwo);
+ }
+
+ public String getBoth() throws Exception {
+ return getOne() + "|" + getTwo();
+ }
+
+ private static String getVersion(final DataSource ds) throws SQLException {
+ Connection con = null;
+ try {
+ con = ds.getConnection();
+ final DatabaseMetaData md = con.getMetaData();
+ return md.getDriverVersion();
+ } finally {
+ if (con != null) {
+ con.close();
+ }
+ }
+ }
+ }
+}
diff --git a/content/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarTest.java b/content/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarTest.java
new file mode 100755
index 0000000..32fa5d6
--- /dev/null
+++ b/content/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarTest.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.Module;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.sql.DataSource;
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.util.Properties;
+
+@RunWith(ApplicationComposer.class)
+public class AlternateDriverJarTest {
+
+ private static final String USER = "SA";
+ private static final String PASSWORD = "";
+
+ @Configuration
+ public Properties config() {
+
+ final File drivers = new File(new File("target"), "drivers").getAbsoluteFile();
+
+ final Properties p = new Properties();
+ p.put("openejb.jdbc.datasource-creator", "dbcp-alternative");
+
+ File file = new File(drivers, "derby-10.10.1.1.jar");
+ Assert.assertTrue("Failed to find: " + file, file.exists());
+
+ p.put("JdbcOne", "new://Resource?type=DataSource&classpath="
+ + file.getAbsolutePath().replace("\\", "/"));
+ p.put("JdbcOne.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+ p.put("JdbcOne.JdbcUrl", "jdbc:derby:memory:JdbcOne;create=true");
+ p.put("JdbcOne.UserName", USER);
+ p.put("JdbcOne.Password", PASSWORD);
+ p.put("JdbcOne.JtaManaged", "false");
+
+ file = new File(drivers, "derby-10.9.1.0.jar");
+ Assert.assertTrue("Failed to find: " + file, file.exists());
+
+ p.put("JdbcTwo", "new://Resource?type=DataSource&classpath="
+ + file.getAbsolutePath().replace("\\", "/"));
+ p.put("JdbcTwo.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+ p.put("JdbcTwo.JdbcUrl", "jdbc:derby:memory:JdbcTwo;create=true");
+ p.put("JdbcTwo.UserName", USER);
+ p.put("JdbcTwo.Password", PASSWORD);
+ p.put("JdbcTwo.JtaManaged", "false");
+ return p;
+ }
+
+ @Module
+ public EjbJar app() throws Exception {
+ return new EjbJar()
+ .enterpriseBean(new SingletonBean(JdbcOne.class).localBean())
+ .enterpriseBean(new SingletonBean(JdbcTwo.class).localBean());
+ }
+
+ @EJB
+ private JdbcOne one;
+
+ @EJB
+ private JdbcTwo two;
+
+ @Test
+ public void testBoth() throws Exception {
+ Assert.assertEquals("Should be using 10.10.1.1 - (1458268)", "10.10.1.1 - (1458268)", one.getDriverVersion());
+ Assert.assertEquals("Should be using 10.9.1.0 - (1344872)", "10.9.1.0 - (1344872)", two.getDriverVersion());
+ }
+
+ @LocalBean
+ @Singleton
+ public static class JdbcOne {
+
+ @Resource(name = "JdbcOne")
+ private DataSource ds;
+
+ public String getDriverVersion() throws Exception {
+
+ final Connection con = ds.getConnection();
+ final DatabaseMetaData md = con.getMetaData();
+ return md.getDriverVersion();
+ }
+ }
+
+ @LocalBean
+ @Singleton
+ public static class JdbcTwo {
+
+ @Resource(name = "JdbcTwo")
+ private DataSource ds;
+
+ public String getDriverVersion() throws Exception {
+
+ final Connection con = ds.getConnection();
+ final DatabaseMetaData md = con.getMetaData();
+ return md.getDriverVersion();
+ }
+ }
+}
diff --git a/content/examples/datasource-versioning/src/test/resources/META-INF/application-client.xml b/content/examples/datasource-versioning/src/test/resources/META-INF/application-client.xml
new file mode 100755
index 0000000..3044a1e
--- /dev/null
+++ b/content/examples/datasource-versioning/src/test/resources/META-INF/application-client.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<application-client/>
\ No newline at end of file
diff --git a/content/examples/datasource-versioning/src/test/resources/META-INF/beans.xml b/content/examples/datasource-versioning/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..d93dcba
--- /dev/null
+++ b/content/examples/datasource-versioning/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans/>
diff --git a/content/examples/datasource-versioning/src/test/resources/META-INF/resources.xml b/content/examples/datasource-versioning/src/test/resources/META-INF/resources.xml
new file mode 100755
index 0000000..62c12dc
--- /dev/null
+++ b/content/examples/datasource-versioning/src/test/resources/META-INF/resources.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<resources>
+
+ <!--Not used, just here as an example-->
+
+ <Resource id="DatabaseOne" type="DataSource" classpath="${catalina.base}/../../drivers/derby-10.10.1.1.jar">
+ JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
+ JdbcUrl jdbc:derby:target/databaseOne;create=true
+ UserName SA
+ </Resource>
+
+ <Resource id="DatabaseTwo" type="DataSource" classpath="${catalina.base}/../../drivers/derby-10.9.1.0.jar">
+ JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
+ JdbcUrl jdbc:derby:target/databaseTwo;create=true
+ UserName SA
+ </Resource>
+
+</resources>
\ No newline at end of file
diff --git a/content/examples/datasource-versioning/src/test/resources/arquillian.xml b/content/examples/datasource-versioning/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..81fb836
--- /dev/null
+++ b/content/examples/datasource-versioning/src/test/resources/arquillian.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+
+ <container qualifier="tomee" default="true">
+ <configuration>
+ <property name="conf">src/test/conf/</property>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="ajpPort">-1</property>
+ <property name="simpleLog">true</property>
+ <property name="dir">target/apache-tomee-remote</property>
+ <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+ </configuration>
+ </container>
+</arquillian>
diff --git a/content/examples/decorators.html b/content/examples/decorators.html
new file mode 100644
index 0000000..72bb654
--- /dev/null
+++ b/content/examples/decorators.html
@@ -0,0 +1,623 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/decorators.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Decorators</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example decorators can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/decorators" class="bare">https://github.com/apache/tomee/tree/master/examples/decorators</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_accessdeniedexception">AccessDeniedException</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.decorators;
+
+import javax.ejb.ApplicationException;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@ApplicationException
+public class AccessDeniedException extends RuntimeException {
+ public AccessDeniedException(String s) {
+ super(s);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculator">Calculator</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.decorators;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public interface Calculator {
+
+ public int add(int a, int b);
+
+ public int subtract(int a, int b);
+
+ public int multiply(int a, int b);
+
+ public int divide(int a, int b);
+
+ public int remainder(int a, int b);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorbean">CalculatorBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.decorators;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Produces;
+
+@Stateless
+public class CalculatorBean implements Calculator {
+
+ @Produces
+ @Resource
+ private SessionContext sessionContext;
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorlogging">CalculatorLogging</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.decorators;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+import java.util.logging.Logger;
+
+@Decorator
+public class CalculatorLogging implements Calculator {
+
+ private Logger logger = Logger.getLogger("Calculator");
+
+ @Inject
+ @Delegate
+ private Calculator calculator;
+
+ @Override
+ public int add(int a, int b) {
+ logger.fine(String.format("add(%s, %s)", a, b));
+ return calculator.add(a, b);
+ }
+
+ @Override
+ public int subtract(int a, int b) {
+ return calculator.subtract(a, b);
+ }
+
+ @Override
+ public int multiply(int a, int b) {
+ logger.finest(String.format("multiply(%s, %s)", a, b));
+ return calculator.multiply(a, b);
+ }
+
+ @Override
+ public int divide(int a, int b) {
+ return calculator.divide(a, b);
+ }
+
+ @Override
+ public int remainder(int a, int b) {
+ logger.info(String.format("remainder(%s, %s)", a, b));
+ return calculator.remainder(a, b);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorsecurity">CalculatorSecurity</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.decorators;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.ejb.SessionContext;
+import javax.inject.Inject;
+
+@Decorator
+public class CalculatorSecurity implements Calculator {
+
+ @Inject
+ @Delegate
+ private Calculator calculator;
+
+ @Inject
+ private SessionContext sessionContext;
+
+ @Override
+ public int add(int a, int b) {
+ return calculator.add(a, b);
+ }
+
+ @Override
+ public int subtract(int a, int b) {
+ // Caller must pass a security check to call subtract
+ if (!sessionContext.isCallerInRole("Manager")) throw new AccessDeniedException(sessionContext.getCallerPrincipal().getName());
+
+ return calculator.subtract(a, b);
+ }
+
+ @Override
+ public int multiply(int a, int b) {
+ return calculator.multiply(a, b);
+ }
+
+ @Override
+ public int divide(int a, int b) {
+ return calculator.divide(a, b);
+ }
+
+ @Override
+ public int remainder(int a, int b) {
+ return calculator.remainder(a, b);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_beans_xml">beans.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><beans>
+ <!--
+ Explicitly declaring decorators is required by the CDI specification.
+ The order decorators are listed in the xml is the order in which they are invoked.
+ -->
+ <decorators>
+ <class>org.superbiz.cdi.decorators.CalculatorSecurity</class>
+ <class>org.superbiz.cdi.decorators.CalculatorLogging</class>
+ </decorators>
+</beans></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatortest">CalculatorTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cdi.decorators;
+
+import junit.framework.TestCase;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.concurrent.Callable;
+
+public class CalculatorTest extends TestCase {
+
+ @EJB
+ private Calculator calculator;
+
+ @EJB
+ private ManagerBean manager;
+
+ /**
+ * Bootstrap the Embedded EJB Container
+ *
+ * @throws Exception
+ */
+ protected void setUp() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+ }
+
+ /**
+ * Test Add method
+ */
+ public void testAdd() {
+
+ assertEquals(10, calculator.add(4, 6));
+ }
+
+ /**
+ * Test Subtract method
+ */
+ public void testSubtract() {
+
+ try {
+ calculator.subtract(4, 6);
+
+ fail("AccessDeniedException should have been thrown for unauthenticated access");
+ } catch (AccessDeniedException expected) {
+ // pass
+ }
+
+ final int result = manager.call(new Callable<Integer>() {
+ public Integer call() {
+ return calculator.subtract(4, 6);
+ }
+ });
+
+ assertEquals(-2, result);
+ }
+
+ /**
+ * Test Multiply method
+ */
+ public void testMultiply() {
+
+ assertEquals(24, calculator.multiply(4, 6));
+ }
+
+ /**
+ * Test Divide method
+ */
+ public void testDivide() {
+
+ assertEquals(2, calculator.divide(12, 6));
+ }
+
+ /**
+ * Test Remainder method
+ */
+ public void testRemainder() {
+
+ assertEquals(4, calculator.remainder(46, 6));
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ public static class ManagerBean {
+
+ public <V> V call(Callable<V> callable) {
+ try {
+ return callable.call();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.cdi.decorators.CalculatorTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/decorators
+INFO - openejb.base = /Users/dblevins/examples/decorators
+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/decorators/target/classes
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/decorators/target/test-classes
+INFO - Beginning load: /Users/dblevins/examples/decorators/target/classes
+INFO - Beginning load: /Users/dblevins/examples/decorators/target/test-classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/decorators
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean decorators.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 CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "/Users/dblevins/examples/decorators" loaded.
+INFO - Assembling app: /Users/dblevins/examples/decorators
+INFO - Jndi(name="java:global/decorators/decorators.Comp!org.apache.openejb.BeanContext$Comp")
+INFO - Jndi(name="java:global/decorators/decorators.Comp")
+INFO - Jndi(name="java:global/decorators/CalculatorBean!org.superbiz.cdi.decorators.Calculator")
+INFO - Jndi(name="java:global/decorators/CalculatorBean")
+INFO - Jndi(name="java:global/decorators/ManagerBean!org.superbiz.cdi.decorators.CalculatorTest$ManagerBean")
+INFO - Jndi(name="java:global/decorators/ManagerBean")
+INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest!org.superbiz.cdi.decorators.CalculatorTest")
+INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest")
+INFO - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=decorators.Comp, ejb-name=decorators.Comp, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.cdi.decorators.CalculatorTest, ejb-name=org.superbiz.cdi.decorators.CalculatorTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=decorators.Comp, ejb-name=decorators.Comp, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.cdi.decorators.CalculatorTest, ejb-name=org.superbiz.cdi.decorators.CalculatorTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/decorators)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Oct 29, 2011 11:41:04 AM org.apache.webbeans.decorator.DelegateHandler invoke
+SEVERE: Exception in calling method : [subtract] in decorator class : [org.superbiz.cdi.decorators.CalculatorSecurity]. Look in the log for target checked exception.
+org.superbiz.cdi.decorators.AccessDeniedException: guest
+ at org.superbiz.cdi.decorators.CalculatorSecurity.subtract(CalculatorSecurity.java:43)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
+ at java.lang.reflect.Method.invoke(Method.java:597)
+ at org.apache.webbeans.decorator.DelegateHandler.invoke(DelegateHandler.java:98)
+ at org.apache.openejb.cdi.CdiInterceptor.invoke(CdiInterceptor.java:127)
+ at org.apache.openejb.cdi.CdiInterceptor.access$000(CdiInterceptor.java:45)
+ at org.apache.openejb.cdi.CdiInterceptor$1.call(CdiInterceptor.java:66)
+ at org.apache.openejb.cdi.CdiInterceptor.aroundInvoke(CdiInterceptor.java:72)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
+ at java.lang.reflect.Method.invoke(Method.java:597)
+ at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
+ at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
+ at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:130)
+ at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:226)
+ at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:178)
+ at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:255)
+ at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:235)
+ at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
+ at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:284)
+ at $Proxy44.subtract(Unknown Source)
+ at org.superbiz.cdi.decorators.CalculatorTest.testSubtract(CalculatorTest.java:59)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
+ at java.lang.reflect.Method.invoke(Method.java:597)
+ at junit.framework.TestCase.runTest(TestCase.java:168)
+ at junit.framework.TestCase.runBare(TestCase.java:134)
+ at junit.framework.TestResult$1.protect(TestResult.java:110)
+ at junit.framework.TestResult.runProtected(TestResult.java:128)
+ at junit.framework.TestResult.run(TestResult.java:113)
+ at junit.framework.TestCase.run(TestCase.java:124)
+ at junit.framework.TestSuite.runTest(TestSuite.java:232)
+ at junit.framework.TestSuite.run(TestSuite.java:227)
+ at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
+ at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
+ at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
+ at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
+ at java.lang.reflect.Method.invoke(Method.java:597)
+ at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
+ at $Proxy0.invoke(Unknown Source)
+ at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
+ at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
+ at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.338 sec
+
+Results :
+
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/decorators.pdf b/content/examples/decorators.pdf
new file mode 100644
index 0000000..bb731c7
--- /dev/null
+++ b/content/examples/decorators.pdf
Binary files differ
diff --git a/content/examples/decorators/README.md b/content/examples/decorators/README.md
new file mode 100755
index 0000000..81b9dcd
--- /dev/null
+++ b/content/examples/decorators/README.md
@@ -0,0 +1,389 @@
+Title: Decorators
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## AccessDeniedException
+
+ package org.superbiz.cdi.decorators;
+
+ import javax.ejb.ApplicationException;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ @ApplicationException
+ public class AccessDeniedException extends RuntimeException {
+ public AccessDeniedException(String s) {
+ super(s);
+ }
+ }
+
+## Calculator
+
+ package org.superbiz.cdi.decorators;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public interface Calculator {
+
+ public int add(int a, int b);
+
+ public int subtract(int a, int b);
+
+ public int multiply(int a, int b);
+
+ public int divide(int a, int b);
+
+ public int remainder(int a, int b);
+ }
+
+## CalculatorBean
+
+ package org.superbiz.cdi.decorators;
+
+ import javax.annotation.Resource;
+ import javax.ejb.SessionContext;
+ import javax.ejb.Stateless;
+ import javax.enterprise.inject.Produces;
+
+ @Stateless
+ public class CalculatorBean implements Calculator {
+
+ @Produces
+ @Resource
+ private SessionContext sessionContext;
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+ }
+
+## CalculatorLogging
+
+ package org.superbiz.cdi.decorators;
+
+ import javax.decorator.Decorator;
+ import javax.decorator.Delegate;
+ import javax.inject.Inject;
+ import java.util.logging.Logger;
+
+ @Decorator
+ public class CalculatorLogging implements Calculator {
+
+ private Logger logger = Logger.getLogger("Calculator");
+
+ @Inject
+ @Delegate
+ private Calculator calculator;
+
+ @Override
+ public int add(int a, int b) {
+ logger.fine(String.format("add(%s, %s)", a, b));
+ return calculator.add(a, b);
+ }
+
+ @Override
+ public int subtract(int a, int b) {
+ return calculator.subtract(a, b);
+ }
+
+ @Override
+ public int multiply(int a, int b) {
+ logger.finest(String.format("multiply(%s, %s)", a, b));
+ return calculator.multiply(a, b);
+ }
+
+ @Override
+ public int divide(int a, int b) {
+ return calculator.divide(a, b);
+ }
+
+ @Override
+ public int remainder(int a, int b) {
+ logger.info(String.format("remainder(%s, %s)", a, b));
+ return calculator.remainder(a, b);
+ }
+ }
+
+## CalculatorSecurity
+
+ package org.superbiz.cdi.decorators;
+
+ import javax.decorator.Decorator;
+ import javax.decorator.Delegate;
+ import javax.ejb.SessionContext;
+ import javax.inject.Inject;
+
+ @Decorator
+ public class CalculatorSecurity implements Calculator {
+
+ @Inject
+ @Delegate
+ private Calculator calculator;
+
+ @Inject
+ private SessionContext sessionContext;
+
+ @Override
+ public int add(int a, int b) {
+ return calculator.add(a, b);
+ }
+
+ @Override
+ public int subtract(int a, int b) {
+ // Caller must pass a security check to call subtract
+ if (!sessionContext.isCallerInRole("Manager")) throw new AccessDeniedException(sessionContext.getCallerPrincipal().getName());
+
+ return calculator.subtract(a, b);
+ }
+
+ @Override
+ public int multiply(int a, int b) {
+ return calculator.multiply(a, b);
+ }
+
+ @Override
+ public int divide(int a, int b) {
+ return calculator.divide(a, b);
+ }
+
+ @Override
+ public int remainder(int a, int b) {
+ return calculator.remainder(a, b);
+ }
+ }
+
+## beans.xml
+
+ <beans>
+ <!--
+ Explicitly declaring decorators is required by the CDI specification.
+ The order decorators are listed in the xml is the order in which they are invoked.
+ -->
+ <decorators>
+ <class>org.superbiz.cdi.decorators.CalculatorSecurity</class>
+ <class>org.superbiz.cdi.decorators.CalculatorLogging</class>
+ </decorators>
+ </beans>
+
+
+## CalculatorTest
+
+ package org.superbiz.cdi.decorators;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.security.RunAs;
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+ import javax.ejb.embeddable.EJBContainer;
+ import java.util.concurrent.Callable;
+
+ public class CalculatorTest extends TestCase {
+
+ @EJB
+ private Calculator calculator;
+
+ @EJB
+ private ManagerBean manager;
+
+ /**
+ * Bootstrap the Embedded EJB Container
+ *
+ * @throws Exception
+ */
+ protected void setUp() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+ }
+
+ /**
+ * Test Add method
+ */
+ public void testAdd() {
+
+ assertEquals(10, calculator.add(4, 6));
+ }
+
+ /**
+ * Test Subtract method
+ */
+ public void testSubtract() {
+
+ try {
+ calculator.subtract(4, 6);
+
+ fail("AccessDeniedException should have been thrown for unauthenticated access");
+ } catch (AccessDeniedException expected) {
+ // pass
+ }
+
+ final int result = manager.call(new Callable<Integer>() {
+ public Integer call() {
+ return calculator.subtract(4, 6);
+ }
+ });
+
+ assertEquals(-2, result);
+ }
+
+ /**
+ * Test Multiply method
+ */
+ public void testMultiply() {
+
+ assertEquals(24, calculator.multiply(4, 6));
+ }
+
+ /**
+ * Test Divide method
+ */
+ public void testDivide() {
+
+ assertEquals(2, calculator.divide(12, 6));
+ }
+
+ /**
+ * Test Remainder method
+ */
+ public void testRemainder() {
+
+ assertEquals(4, calculator.remainder(46, 6));
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ public static class ManagerBean {
+
+ public <V> V call(Callable<V> callable) {
+ try {
+ return callable.call();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.cdi.decorators.CalculatorTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/decorators
+ INFO - openejb.base = /Users/dblevins/examples/decorators
+ 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/decorators/target/classes
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/decorators/target/test-classes
+ INFO - Beginning load: /Users/dblevins/examples/decorators/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/decorators/target/test-classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/decorators
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean decorators.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 CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "/Users/dblevins/examples/decorators" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/decorators
+ INFO - Jndi(name="java:global/decorators/decorators.Comp!org.apache.openejb.BeanContext$Comp")
+ INFO - Jndi(name="java:global/decorators/decorators.Comp")
+ INFO - Jndi(name="java:global/decorators/CalculatorBean!org.superbiz.cdi.decorators.Calculator")
+ INFO - Jndi(name="java:global/decorators/CalculatorBean")
+ INFO - Jndi(name="java:global/decorators/ManagerBean!org.superbiz.cdi.decorators.CalculatorTest$ManagerBean")
+ INFO - Jndi(name="java:global/decorators/ManagerBean")
+ INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest!org.superbiz.cdi.decorators.CalculatorTest")
+ INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest")
+ INFO - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=decorators.Comp, ejb-name=decorators.Comp, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.cdi.decorators.CalculatorTest, ejb-name=org.superbiz.cdi.decorators.CalculatorTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=decorators.Comp, ejb-name=decorators.Comp, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.cdi.decorators.CalculatorTest, ejb-name=org.superbiz.cdi.decorators.CalculatorTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/decorators)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Oct 29, 2011 11:41:04 AM org.apache.webbeans.decorator.DelegateHandler invoke
+ SEVERE: Exception in calling method : [subtract] in decorator class : [org.superbiz.cdi.decorators.CalculatorSecurity]. Look in the log for target checked exception.
+ org.superbiz.cdi.decorators.AccessDeniedException: guest
+ at org.superbiz.cdi.decorators.CalculatorSecurity.subtract(CalculatorSecurity.java:43)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
+ at java.lang.reflect.Method.invoke(Method.java:597)
+ at org.apache.webbeans.decorator.DelegateHandler.invoke(DelegateHandler.java:98)
+ at org.apache.openejb.cdi.CdiInterceptor.invoke(CdiInterceptor.java:127)
+ at org.apache.openejb.cdi.CdiInterceptor.access$000(CdiInterceptor.java:45)
+ at org.apache.openejb.cdi.CdiInterceptor$1.call(CdiInterceptor.java:66)
+ at org.apache.openejb.cdi.CdiInterceptor.aroundInvoke(CdiInterceptor.java:72)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
+ at java.lang.reflect.Method.invoke(Method.java:597)
+ at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
+ at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
+ at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:130)
+ at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:226)
+ at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:178)
+ at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:255)
+ at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:235)
+ at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
+ at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:284)
+ at $Proxy44.subtract(Unknown Source)
+ at org.superbiz.cdi.decorators.CalculatorTest.testSubtract(CalculatorTest.java:59)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
+ at java.lang.reflect.Method.invoke(Method.java:597)
+ at junit.framework.TestCase.runTest(TestCase.java:168)
+ at junit.framework.TestCase.runBare(TestCase.java:134)
+ at junit.framework.TestResult$1.protect(TestResult.java:110)
+ at junit.framework.TestResult.runProtected(TestResult.java:128)
+ at junit.framework.TestResult.run(TestResult.java:113)
+ at junit.framework.TestCase.run(TestCase.java:124)
+ at junit.framework.TestSuite.runTest(TestSuite.java:232)
+ at junit.framework.TestSuite.run(TestSuite.java:227)
+ at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
+ at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
+ at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
+ at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
+ at java.lang.reflect.Method.invoke(Method.java:597)
+ at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
+ at $Proxy0.invoke(Unknown Source)
+ at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
+ at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
+ at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.338 sec
+
+ Results :
+
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/decorators/pom.xml b/content/examples/decorators/pom.xml
new file mode 100755
index 0000000..d6f1686
--- /dev/null
+++ b/content/examples/decorators/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>decorators</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Decorators</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/AccessDeniedException.java b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/AccessDeniedException.java
new file mode 100755
index 0000000..af038e4
--- /dev/null
+++ b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/AccessDeniedException.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.decorators;
+
+import javax.ejb.ApplicationException;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@ApplicationException
+public class AccessDeniedException extends RuntimeException {
+
+ public AccessDeniedException(String s) {
+ super(s);
+ }
+}
diff --git a/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/Calculator.java b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/Calculator.java
new file mode 100755
index 0000000..55f368c
--- /dev/null
+++ b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/Calculator.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.decorators;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public interface Calculator {
+
+ public int add(int a, int b);
+
+ public int subtract(int a, int b);
+
+ public int multiply(int a, int b);
+
+ public int divide(int a, int b);
+
+ public int remainder(int a, int b);
+}
diff --git a/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorBean.java b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorBean.java
new file mode 100755
index 0000000..0941ffc
--- /dev/null
+++ b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorBean.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.decorators;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Produces;
+
+@Stateless
+public class CalculatorBean implements Calculator {
+
+ @Produces
+ @Resource
+ private SessionContext sessionContext;
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+
+}
diff --git a/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorLogging.java b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorLogging.java
new file mode 100755
index 0000000..5ed8890
--- /dev/null
+++ b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorLogging.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.decorators;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+import java.util.logging.Logger;
+
+@Decorator
+public class CalculatorLogging implements Calculator {
+
+ private Logger logger = Logger.getLogger("Calculator");
+
+ @Inject
+ @Delegate
+ private Calculator calculator;
+
+ @Override
+ public int add(int a, int b) {
+ logger.fine(String.format("add(%s, %s)", a, b));
+ return calculator.add(a, b);
+ }
+
+ @Override
+ public int subtract(int a, int b) {
+ return calculator.subtract(a, b);
+ }
+
+ @Override
+ public int multiply(int a, int b) {
+ logger.finest(String.format("multiply(%s, %s)", a, b));
+ return calculator.multiply(a, b);
+ }
+
+ @Override
+ public int divide(int a, int b) {
+ return calculator.divide(a, b);
+ }
+
+ @Override
+ public int remainder(int a, int b) {
+ logger.info(String.format("remainder(%s, %s)", a, b));
+ return calculator.remainder(a, b);
+ }
+}
diff --git a/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorSecurity.java b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorSecurity.java
new file mode 100755
index 0000000..65d45ed
--- /dev/null
+++ b/content/examples/decorators/src/main/java/org/superbiz/cdi/decorators/CalculatorSecurity.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.decorators;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.ejb.SessionContext;
+import javax.inject.Inject;
+
+@Decorator
+public class CalculatorSecurity implements Calculator {
+
+ @Inject
+ @Delegate
+ private Calculator calculator;
+
+ @Inject
+ private SessionContext sessionContext;
+
+ @Override
+ public int add(int a, int b) {
+ return calculator.add(a, b);
+ }
+
+ @Override
+ public int subtract(int a, int b) {
+ // Caller must pass a security check to call subtract
+ if (!sessionContext.isCallerInRole("Manager")) {
+ throw new AccessDeniedException(sessionContext.getCallerPrincipal().getName());
+ }
+
+ return calculator.subtract(a, b);
+ }
+
+ @Override
+ public int multiply(int a, int b) {
+ return calculator.multiply(a, b);
+ }
+
+ @Override
+ public int divide(int a, int b) {
+ return calculator.divide(a, b);
+ }
+
+ @Override
+ public int remainder(int a, int b) {
+ return calculator.remainder(a, b);
+ }
+
+}
diff --git a/content/examples/decorators/src/main/resources/META-INF/beans.xml b/content/examples/decorators/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..57fe3f3
--- /dev/null
+++ b/content/examples/decorators/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,10 @@
+<beans>
+ <!--
+ Explicitly declaring decorators is required by the CDI specification.
+ The order decorators are listed in the xml is the order in which they are invoked.
+ -->
+ <decorators>
+ <class>org.superbiz.cdi.decorators.CalculatorSecurity</class>
+ <class>org.superbiz.cdi.decorators.CalculatorLogging</class>
+ </decorators>
+</beans>
diff --git a/content/examples/decorators/src/test/java/org/superbiz/cdi/decorators/CalculatorTest.java b/content/examples/decorators/src/test/java/org/superbiz/cdi/decorators/CalculatorTest.java
new file mode 100755
index 0000000..01bdd2e
--- /dev/null
+++ b/content/examples/decorators/src/test/java/org/superbiz/cdi/decorators/CalculatorTest.java
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.decorators;
+
+import junit.framework.TestCase;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.concurrent.Callable;
+
+public class CalculatorTest extends TestCase {
+
+ @EJB
+ private Calculator calculator;
+
+ @EJB
+ private ManagerBean manager;
+
+ /**
+ * Bootstrap the Embedded EJB Container
+ *
+ * @throws Exception
+ */
+ protected void setUp() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+ }
+
+ /**
+ * Test Add method
+ */
+ public void testAdd() {
+
+ assertEquals(10, calculator.add(4, 6));
+
+ }
+
+ /**
+ * Test Subtract method
+ */
+ public void testSubtract() {
+
+ try {
+ calculator.subtract(4, 6);
+
+ fail("AccessDeniedException should have been thrown for unauthenticated access");
+ } catch (AccessDeniedException expected) {
+ // pass
+ }
+
+ final int result = manager.call(new Callable<Integer>() {
+ public Integer call() {
+ return calculator.subtract(4, 6);
+ }
+ });
+
+ assertEquals(-2, result);
+
+ }
+
+ /**
+ * Test Multiply method
+ */
+ public void testMultiply() {
+
+ assertEquals(24, calculator.multiply(4, 6));
+
+ }
+
+ /**
+ * Test Divide method
+ */
+ public void testDivide() {
+
+ assertEquals(2, calculator.divide(12, 6));
+
+ }
+
+ /**
+ * Test Remainder method
+ */
+ public void testRemainder() {
+
+ assertEquals(4, calculator.remainder(46, 6));
+
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ public static class ManagerBean {
+
+ public <V> V call(Callable<V> callable) {
+ try {
+ return callable.call();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ }
+}
diff --git a/content/examples/deltaspike-configproperty.html b/content/examples/deltaspike-configproperty.html
new file mode 100644
index 0000000..fa0df75
--- /dev/null
+++ b/content/examples/deltaspike-configproperty.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/deltaspike-configproperty.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>deltaspike-configproperty</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example deltaspike-configproperty can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/deltaspike-configproperty" class="bare">https://github.com/apache/tomee/tree/master/examples/deltaspike-configproperty</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/deltaspike-configproperty.pdf b/content/examples/deltaspike-configproperty.pdf
new file mode 100644
index 0000000..fdbc4f2
--- /dev/null
+++ b/content/examples/deltaspike-configproperty.pdf
Binary files differ
diff --git a/content/examples/deltaspike-configproperty/pom.xml b/content/examples/deltaspike-configproperty/pom.xml
new file mode 100755
index 0000000..5ec0625
--- /dev/null
+++ b/content/examples/deltaspike-configproperty/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>deltaspike-configproperty</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: DeltaSpike @ConfigProperty</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <version.deltaspike>1.0.0</version.deltaspike>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-impl</artifactId>
+ <version>${version.deltaspike}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-api</artifactId>
+ <version>${version.deltaspike}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- The <scope>test</scope> guarantees that none of your runtime code
+ is dependent on any OpenEJB classes. -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/Counter.java b/content/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/Counter.java
new file mode 100755
index 0000000..c6d71f2
--- /dev/null
+++ b/content/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/Counter.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.config;
+
+import org.apache.deltaspike.core.api.config.ConfigProperty;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+@ApplicationScoped
+public class Counter {
+
+ @Inject
+ @ConfigProperty(name = "loop.size")
+ private Integer iterations;
+
+ public int loop() {
+ for (int i = 0; i < iterations; i++) {
+ System.out.println("Iteration #" + i);
+ }
+ return iterations;
+ }
+}
diff --git a/content/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSource.java b/content/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSource.java
new file mode 100755
index 0000000..85a912b
--- /dev/null
+++ b/content/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSource.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.config;
+
+import org.apache.deltaspike.core.impl.config.BaseConfigSource;
+import org.apache.deltaspike.core.util.PropertyFileUtils;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+public class MyConfigSource extends BaseConfigSource {
+
+ private static final Logger LOGGER = Logger.getLogger(MyConfigSource.class.getName());
+ private static final String MY_CONF_FILE_NAME = "my-app-config.properties";
+
+ private final Properties properties;
+
+ public MyConfigSource() {
+ final Enumeration<URL> in;
+ try {
+ in = Thread.currentThread().getContextClassLoader().getResources(MY_CONF_FILE_NAME);
+ } catch (IOException e) {
+ throw new IllegalArgumentException("can't find " + MY_CONF_FILE_NAME, e);
+ }
+
+ properties = new Properties();
+
+ while (in.hasMoreElements()) {
+ final Properties currentProps = PropertyFileUtils.loadProperties(in.nextElement());
+ for (Map.Entry<Object, Object> key : currentProps.entrySet()) { // some check
+ if (properties.containsKey(key.getKey().toString())) {
+ LOGGER.warning("found " + key.getKey() + " multiple times, only one value will be available.");
+ }
+ }
+ properties.putAll(currentProps);
+ }
+
+ initOrdinal(401); // before other sources
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return Collections.emptyMap(); // not scannable
+ }
+
+ @Override
+ public String getPropertyValue(String key) {
+ return properties.getProperty(key);
+ }
+
+ @Override
+ public String getConfigName() {
+ return MY_CONF_FILE_NAME;
+ }
+
+ @Override
+ public boolean isScannable() {
+ return false;
+ }
+}
diff --git a/content/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSourceProvider.java b/content/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSourceProvider.java
new file mode 100755
index 0000000..e9f42bb
--- /dev/null
+++ b/content/examples/deltaspike-configproperty/src/main/java/org/superbiz/deltaspike/config/MyConfigSourceProvider.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.config;
+
+import org.apache.deltaspike.core.spi.config.ConfigSource;
+import org.apache.deltaspike.core.spi.config.ConfigSourceProvider;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class MyConfigSourceProvider implements ConfigSourceProvider {
+ @Override
+ public List<ConfigSource> getConfigSources() {
+ return Arrays.asList((ConfigSource) new MyConfigSource());
+ }
+}
diff --git a/content/examples/deltaspike-configproperty/src/main/resources/META-INF/beans.xml b/content/examples/deltaspike-configproperty/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/deltaspike-configproperty/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/deltaspike-configproperty/src/main/resources/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSourceProvider b/content/examples/deltaspike-configproperty/src/main/resources/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSourceProvider
new file mode 100755
index 0000000..351f726
--- /dev/null
+++ b/content/examples/deltaspike-configproperty/src/main/resources/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSourceProvider
@@ -0,0 +1 @@
+org.superbiz.deltaspike.config.MyConfigSourceProvider
diff --git a/content/examples/deltaspike-configproperty/src/main/resources/my-app-config.properties b/content/examples/deltaspike-configproperty/src/main/resources/my-app-config.properties
new file mode 100755
index 0000000..988b7b4
--- /dev/null
+++ b/content/examples/deltaspike-configproperty/src/main/resources/my-app-config.properties
@@ -0,0 +1,23 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+# this config file is hooked up through a custom ConfigSource
+# (see org.superbiz.deltaspike.config.MyConfigSource)
+loop.size = 10
diff --git a/content/examples/deltaspike-configproperty/src/test/java/org/superbiz/deltaspike/config/ConfigTest.java b/content/examples/deltaspike-configproperty/src/test/java/org/superbiz/deltaspike/config/ConfigTest.java
new file mode 100755
index 0000000..f6547d0
--- /dev/null
+++ b/content/examples/deltaspike-configproperty/src/test/java/org/superbiz/deltaspike/config/ConfigTest.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.config;
+
+import org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider;
+import org.apache.deltaspike.core.spi.config.ConfigSourceProvider;
+import org.apache.openjpa.lib.conf.MapConfigurationProvider;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class ConfigTest {
+
+ @Inject
+ private Counter counter;
+
+ @Deployment
+ public static WebArchive jar() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addClasses(Counter.class, MyConfigSource.class, MapConfigurationProvider.class)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
+ .addAsResource(new ClassLoaderAsset("my-app-config.properties"), "my-app-config.properties")
+ .addAsLibraries(JarLocation.jarLocation(ConfigSourceProvider.class))
+ .addAsLibraries(JarLocation.jarLocation(DefaultConfigSourceProvider.class))
+ .addAsServiceProvider(ConfigSourceProvider.class, MyConfigSourceProvider.class);
+ }
+
+ @Test
+ public void check() {
+ assertNotNull(counter);
+ counter.loop();
+ }
+}
diff --git a/content/examples/deltaspike-exception-handling.html b/content/examples/deltaspike-exception-handling.html
new file mode 100644
index 0000000..535eedb
--- /dev/null
+++ b/content/examples/deltaspike-exception-handling.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/deltaspike-exception-handling.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>deltaspike-exception-handling</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example deltaspike-exception-handling can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/deltaspike-exception-handling" class="bare">https://github.com/apache/tomee/tree/master/examples/deltaspike-exception-handling</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/deltaspike-exception-handling.pdf b/content/examples/deltaspike-exception-handling.pdf
new file mode 100644
index 0000000..55cc8a1
--- /dev/null
+++ b/content/examples/deltaspike-exception-handling.pdf
Binary files differ
diff --git a/content/examples/deltaspike-exception-handling/pom.xml b/content/examples/deltaspike-exception-handling/pom.xml
new file mode 100755
index 0000000..da6e90a
--- /dev/null
+++ b/content/examples/deltaspike-exception-handling/pom.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>deltaspike-exception-handling</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: DeltaSpike Exception Handling</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-impl</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- The <scope>test</scope> guarantees that none of your runtime code
+ is dependent on any OpenEJB classes. -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSExceptionHandler.java b/content/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSExceptionHandler.java
new file mode 100755
index 0000000..58b0027
--- /dev/null
+++ b/content/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSExceptionHandler.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.exceptionhandling;
+
+import org.apache.deltaspike.core.api.exception.control.ExceptionHandler;
+import org.apache.deltaspike.core.api.exception.control.Handles;
+import org.apache.deltaspike.core.api.exception.control.event.ExceptionEvent;
+
+import java.util.logging.Logger;
+
+@ExceptionHandler
+public class OSExceptionHandler {
+
+ private static final Logger LOGGER = Logger.getLogger(OSExceptionHandler.class.getName());
+
+ public void printExceptions(@Handles final ExceptionEvent<OSRuntimeException> evt) {
+ LOGGER.severe("==> a bad OS was mentionned");
+ evt.handled();
+ }
+}
diff --git a/content/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSRuntimeException.java b/content/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSRuntimeException.java
new file mode 100755
index 0000000..c457adb
--- /dev/null
+++ b/content/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSRuntimeException.java
@@ -0,0 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.exceptionhandling;
+
+public class OSRuntimeException extends RuntimeException {
+
+}
diff --git a/content/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSValidator.java b/content/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSValidator.java
new file mode 100755
index 0000000..0334c75
--- /dev/null
+++ b/content/examples/deltaspike-exception-handling/src/main/java/org/superbiz/deltaspike/exceptionhandling/OSValidator.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.exceptionhandling;
+
+import org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+public class OSValidator {
+
+ @Inject
+ private Event<ExceptionToCatchEvent> exceptionEvent;
+
+ public void validOS(final String os) {
+ if (os.toLowerCase().contains("win")) {
+ final Exception ex = new OSRuntimeException(); // can be a caugh exceptino
+ exceptionEvent.fire(new ExceptionToCatchEvent(ex));
+ }
+ }
+}
diff --git a/content/examples/deltaspike-exception-handling/src/main/resources/META-INF/beans.xml b/content/examples/deltaspike-exception-handling/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/deltaspike-exception-handling/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/deltaspike-exception-handling/src/test/java/org/superbiz/deltaspike/exceptionhandling/ExceptionHandlingDemoTest.java b/content/examples/deltaspike-exception-handling/src/test/java/org/superbiz/deltaspike/exceptionhandling/ExceptionHandlingDemoTest.java
new file mode 100755
index 0000000..7512a38
--- /dev/null
+++ b/content/examples/deltaspike-exception-handling/src/test/java/org/superbiz/deltaspike/exceptionhandling/ExceptionHandlingDemoTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.exceptionhandling;
+
+import org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider;
+import org.apache.deltaspike.core.spi.config.ConfigSourceProvider;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class ExceptionHandlingDemoTest {
+
+ @Inject
+ private OSValidator validator;
+
+ @Deployment
+ public static WebArchive jar() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addPackage(OSValidator.class.getPackage())
+ .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
+ // DeltaSpike libs (api and impl)
+ .addAsLibraries(JarLocation.jarLocation(ConfigSourceProvider.class))
+ .addAsLibraries(JarLocation.jarLocation(DefaultConfigSourceProvider.class));
+ }
+
+ @Test
+ public void check() {
+ assertNotNull(validator);
+ validator.validOS("Linux");
+ validator.validOS("windows"); // should throw a handled exception
+ validator.validOS("Mac OS");
+ }
+}
diff --git a/content/examples/deltaspike-fullstack.html b/content/examples/deltaspike-fullstack.html
new file mode 100644
index 0000000..55b6d88
--- /dev/null
+++ b/content/examples/deltaspike-fullstack.html
@@ -0,0 +1,273 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/deltaspike-fullstack.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Apache DeltaSpike Demo</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example deltaspike-fullstack can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/deltaspike-fullstack" class="bare">https://github.com/apache/tomee/tree/master/examples/deltaspike-fullstack</a></p>
+</div>
+<div class="paragraph">
+<p>Notice: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ .
+ <a href="http://www.apache.org/licenses/LICENSE-2.0" class="bare">http://www.apache.org/licenses/LICENSE-2.0</a>
+ .
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.</p>
+</div>
+<div class="paragraph">
+<p><h2>Steps to run the example</h2></p>
+</div>
+<div class="paragraph">
+<p>Build and start the demo:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>mvn clean package tomee:run</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Open:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>http://localhost:8080/</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This example shows how to improve JSF2/CDI/BV/JPA applications with features provided by Apache DeltaSpike and MyFaces ExtVal.</p>
+</div>
+<div class="paragraph">
+<p><h2>Intro of Apache DeltaSpike and MyFaces ExtVal</h2></p>
+</div>
+<div class="paragraph">
+<p>The Apache DeltaSpike project hosts portable extensions for Contexts and Dependency Injection (CDI - JSR 299). DeltaSpike is a toolbox for your CDI application. Like CDI itself DeltaSpike is focused on type-safety. It is a modularized and extensible framework. So it’s easy to choose the needed parts to facilitate the daily work in your project.</p>
+</div>
+<div class="paragraph">
+<p>MyFaces Extensions Validator (aka ExtVal) is a JSF centric validation framework which is compatible with JSF 1.x and JSF 2.x.
+This example shows how it improves the default integration of Bean-Validation (JSR-303) with JSF2 as well as meta-data based cross-field validation.</p>
+</div>
+<div class="paragraph">
+<p><h2>Illustrated Features</h2></p>
+</div>
+<div class="paragraph">
+<p><h3>Apache DeltaSpike</h3></p>
+</div>
+<div class="paragraph">
+<p><ul></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><li><a href="./src/main/java/org/superbiz/deltaspike/view/config/Pages.java" target="_blank">Type-safe view-config</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/view/InfoPage.java" target="_blank">Type-safe (custom) view-meta-data</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/view/MenuBean.java" target="_blank">Type-safe navigation</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/CustomProjectStage.java" target="_blank">Type-safe custom project-stage</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/view/UserHolder.java" target="_blank">@WindowScoped</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/view/MenuBean.java" target="_blank">Controlling DeltaSpike grouped-conversations with GroupedConversationManager</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/view/FeedbackPage.java" target="_blank">@GroupedConversationScoped</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/view/FeedbackPage.java" target="_blank">Manual conversation handling</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/view/security/LoginAccessDecisionVoter.java" target="_blank">Secured pages (AccessDecisionVoter)</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/repository/Repository.java" target="_blank">@Transactional</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/view/RegistrationPage.java" target="_blank">I18n (type-safe messages)</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserNameValidator.java" target="_blank">Dependency-Injection for JSR303 (BV) constraint-validators</a></li>
+<li><a href="./src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java" target="_blank">Dependency-Injection for JSF phase-listeners</a></li>
+</ul>
+
+<h3>Apache MyFaces ExtVal</h3>
+
+<ul>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Cross-Field validation (@Equals)</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Type-safe group-validation (@BeanValidation) for JSF action-methods</a></li>
+</ul></code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/deltaspike-fullstack.pdf b/content/examples/deltaspike-fullstack.pdf
new file mode 100644
index 0000000..8abe236
--- /dev/null
+++ b/content/examples/deltaspike-fullstack.pdf
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/README.md b/content/examples/deltaspike-fullstack/README.md
new file mode 100755
index 0000000..f81e7eb
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/README.md
@@ -0,0 +1,64 @@
+Title: Apache DeltaSpike Demo
+Notice: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+<h2>Steps to run the example</h2>
+
+Build and start the demo:
+
+ mvn clean package tomee:run
+
+Open:
+
+ http://localhost:8080/
+
+This example shows how to improve JSF2/CDI/BV/JPA applications with features provided by Apache DeltaSpike and MyFaces ExtVal.
+
+<h2>Intro of Apache DeltaSpike and MyFaces ExtVal</h2>
+
+The Apache DeltaSpike project hosts portable extensions for Contexts and Dependency Injection (CDI - JSR 299). DeltaSpike is a toolbox for your CDI application. Like CDI itself DeltaSpike is focused on type-safety. It is a modularized and extensible framework. So it's easy to choose the needed parts to facilitate the daily work in your project.
+
+MyFaces Extensions Validator (aka ExtVal) is a JSF centric validation framework which is compatible with JSF 1.x and JSF 2.x.
+This example shows how it improves the default integration of Bean-Validation (JSR-303) with JSF2 as well as meta-data based cross-field validation.
+
+
+<h2>Illustrated Features</h2>
+
+<h3>Apache DeltaSpike</h3>
+
+<ul>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/view/config/Pages.java" target="_blank">Type-safe view-config</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/view/InfoPage.java" target="_blank">Type-safe (custom) view-meta-data</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/view/MenuBean.java" target="_blank">Type-safe navigation</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/CustomProjectStage.java" target="_blank">Type-safe custom project-stage</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/view/UserHolder.java" target="_blank">@WindowScoped</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/view/MenuBean.java" target="_blank">Controlling DeltaSpike grouped-conversations with GroupedConversationManager</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/view/FeedbackPage.java" target="_blank">@GroupedConversationScoped</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/view/FeedbackPage.java" target="_blank">Manual conversation handling</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/view/security/LoginAccessDecisionVoter.java" target="_blank">Secured pages (AccessDecisionVoter)</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/repository/Repository.java" target="_blank">@Transactional</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/view/RegistrationPage.java" target="_blank">I18n (type-safe messages)</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserNameValidator.java" target="_blank">Dependency-Injection for JSR303 (BV) constraint-validators</a></li>
+ <li><a href="./src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java" target="_blank">Dependency-Injection for JSF phase-listeners</a></li>
+</ul>
+
+<h3>Apache MyFaces ExtVal</h3>
+
+<ul>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Cross-Field validation (@Equals)</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Type-safe group-validation (@BeanValidation) for JSF action-methods</a></li>
+</ul>
diff --git a/content/examples/deltaspike-fullstack/pom.xml b/content/examples/deltaspike-fullstack/pom.xml
new file mode 100755
index 0000000..08f9473
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/pom.xml
@@ -0,0 +1,333 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>deltaspike-fullstack</artifactId>
+ <name>OpenEJB :: Examples :: JSF2/CDI/BV/JPA/DeltaSpike</name>
+ <version>1.1.1-SNAPSHOT</version>
+
+ <packaging>war</packaging>
+
+ <properties>
+ <version.myfaces2>2.2.3</version.myfaces2>
+ <version.deltaspike>1.0.1</version.deltaspike>
+ <version.extval>2.0.8</version.extval>
+ <version.openejb>4.7.1</version.openejb>
+ <version.tomee>1.7.1</version.tomee>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>${version.tomee}</version>
+ <configuration>
+ <context>ROOT</context>
+ <simpleLog>true</simpleLog>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration> <!-- optional -->
+ <systemPropertyVariables>
+ <openejb.jul.forceReload>true</openejb.jul.forceReload>
+ <logging.level.OpenEJB.startup>FINEST</logging.level.OpenEJB.startup>
+ </systemPropertyVariables>
+ <reuseForks>false</reuseForks>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>prime-repo</id>
+ <name>Prime Technology Maven Repository</name>
+ <url>http://repository.primefaces.org/</url>
+ <layout>default</layout>
+ </repository>
+ <repository>
+ <id>apache-m2</id>
+ <name>Apache M2 Repository</name>
+ <url>https://repository.apache.org/content/repositories/releases/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>${version.openejb}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>slf4j-api</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xbean-asm5-shaded</artifactId>
+ <groupId>org.apache.xbean</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-collections</artifactId>
+ <groupId>commons-collections</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-lang3</artifactId>
+ <groupId>org.apache.commons</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-asm5-shaded</artifactId>
+ <version>3.18</version>
+ </dependency>
+ <dependency>
+ <artifactId>commons-lang3</artifactId>
+ <groupId>org.apache.commons</groupId>
+ <version>3.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-api</artifactId>
+ <version>${version.deltaspike}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-impl</artifactId>
+ <version>${version.deltaspike}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-jsf-module-api</artifactId>
+ <version>${version.deltaspike}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-jsf-module-impl</artifactId>
+ <version>${version.deltaspike}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-jpa-module-api</artifactId>
+ <version>${version.deltaspike}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-jpa-module-impl</artifactId>
+ <version>${version.deltaspike}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-security-module-api</artifactId>
+ <version>${version.deltaspike}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-security-module-impl</artifactId>
+ <version>${version.deltaspike}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-bean-validation-module-api</artifactId>
+ <version>${version.deltaspike}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-bean-validation-module-impl</artifactId>
+ <version>${version.deltaspike}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator</groupId>
+ <artifactId>myfaces-extval-core</artifactId>
+ <version>${version.extval}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
+ <artifactId>myfaces-extval-property-validation</artifactId>
+ <version>${version.extval}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
+ <artifactId>myfaces-extval-bean-validation</artifactId>
+ <version>${version.extval}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-test-control-module-api</artifactId>
+ <version>${version.deltaspike}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.modules</groupId>
+ <artifactId>deltaspike-test-control-module-impl</artifactId>
+ <version>${version.deltaspike}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.cdictrl</groupId>
+ <artifactId>deltaspike-cdictrl-api</artifactId>
+ <version>${version.deltaspike}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.cdictrl</groupId>
+ <artifactId>deltaspike-cdictrl-openejb</artifactId>
+ <version>${version.deltaspike}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- only needed for mocked cdi-beans -->
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- for full page-bean tests -->
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>${version.myfaces2}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <version>${version.myfaces2}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>commons-collections</artifactId>
+ <groupId>commons-collections</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-beanutils</artifactId>
+ <groupId>commons-beanutils</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl-test</artifactId>
+ <version>${version.myfaces2}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.test</groupId>
+ <artifactId>myfaces-test20</artifactId>
+ <version>1.0.6</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- 3rd party libs -->
+ <dependency>
+ <groupId>org.primefaces</groupId>
+ <artifactId>primefaces</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/CustomProjectStage.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/CustomProjectStage.java
new file mode 100755
index 0000000..042507e
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/CustomProjectStage.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike;
+
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.apache.deltaspike.core.api.projectstage.ProjectStageHolder;
+
+public class CustomProjectStage implements ProjectStageHolder
+{
+ public static final class Debugging extends ProjectStage
+ {
+ private static final long serialVersionUID = -8626602281649294170L;
+ }
+
+ public static final Debugging Debugging = new Debugging();
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java
new file mode 100755
index 0000000..d8c77c8
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike;
+
+import org.apache.deltaspike.core.api.exclude.Exclude;
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.apache.deltaspike.jsf.api.listener.phase.JsfPhaseListener;
+
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import java.util.logging.Logger;
+
+@Exclude(exceptIfProjectStage = {ProjectStage.Development.class, CustomProjectStage.Debugging.class})
+
+@JsfPhaseListener
+public class DebugPhaseListener implements PhaseListener
+{
+ private static final long serialVersionUID = 5899542118538949019L;
+
+ private Logger logger = Logger.getLogger(Logger.class.getName());
+
+ public void beforePhase(PhaseEvent phaseEvent)
+ {
+ this.logger.info("before " + phaseEvent.getPhaseId());
+ }
+
+ public void afterPhase(PhaseEvent phaseEvent)
+ {
+ this.logger.info("after " + phaseEvent.getPhaseId());
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/WebappMessageBundle.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/WebappMessageBundle.java
new file mode 100755
index 0000000..bbe7482
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/WebappMessageBundle.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike;
+
+import org.apache.deltaspike.core.api.message.MessageBundle;
+import org.apache.deltaspike.core.api.message.MessageContextConfig;
+
+@MessageBundle
+@MessageContextConfig(messageSource = "org.superbiz.deltaspike.i18n.messages")
+public interface WebappMessageBundle
+{
+ String msgAccessDenied();
+
+ String msgUserRegistered(String userName);
+
+ String msgLoginSuccessful();
+
+ String msgLoginFailed();
+
+ String msgError(String message);
+
+ String msgWelcome();
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/AbstractDomainObject.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/AbstractDomainObject.java
new file mode 100755
index 0000000..32ffdeb
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/AbstractDomainObject.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@MappedSuperclass
+public abstract class AbstractDomainObject implements Serializable
+{
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Version
+ private Long version;
+
+ public boolean isTransient()
+ {
+ return this.version == null;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Comment.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Comment.java
new file mode 100755
index 0000000..5d0f793
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Comment.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+
+@Entity
+public class Comment extends AbstractDomainObject
+{
+ private static final long serialVersionUID = -5718296682587279635L;
+
+ @Column(length = 2048)
+ private String description;
+
+ @ManyToOne(optional = false)
+ private Feedback feedback;
+
+ void setFeedback(Feedback feedback)
+ {
+ this.feedback = feedback;
+ }
+
+ /*
+ * generated
+ */
+
+ public Comment()
+ {
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Feedback.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Feedback.java
new file mode 100755
index 0000000..dde622a
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/Feedback.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+public class Feedback extends AbstractDomainObject
+{
+ private static final long serialVersionUID = -431924785266663236L;
+
+ @Column(nullable = false, length = 32)
+ private String topic;
+
+ @Column(length = 128)
+ private String description;
+
+ @OneToMany(mappedBy = "feedback", cascade = CascadeType.ALL)
+ private List<Comment> comments = new ArrayList<Comment>();
+
+ public void addComment(Comment comment)
+ {
+ comment.setFeedback(this);
+ this.comments.add(comment);
+ }
+
+ /*
+ * generated
+ */
+
+ public List<Comment> getComments()
+ {
+ return comments;
+ }
+
+ public String getTopic()
+ {
+ return topic;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setTopic(String topic)
+ {
+ this.topic = topic;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/User.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/User.java
new file mode 100755
index 0000000..fb44f89
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/User.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain;
+
+import org.superbiz.deltaspike.domain.validation.*;
+
+import javax.enterprise.inject.Typed;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Table(name = "T_User")
+@Entity
+@NamedQuery(name = "findUserByName", query = "select u from User u where u.userName = :currentUser")
+@DifferentName(groups = Partial.class)
+@Typed()
+public class User extends AbstractDomainObject
+{
+ private static final long serialVersionUID = 3810638653455000233L;
+
+ @UserName(groups = UniqueUserName.class)
+ @Column(nullable = false, length = 9, unique = true)
+ private String userName;
+
+ @Size(min = 2, max = 20, message = "invalid first name")
+ @NotNull
+ @Column
+ private String firstName;
+
+ @Column
+ @Name(message = "invalid last name")
+ private String lastName;
+
+ @Column
+ private String password;
+
+ /*
+ * generated
+ */
+
+ public User()
+ {
+ }
+
+ public User(String userName, String firstName, String lastName)
+ {
+ this.userName = userName;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ public void setUserName(String userName)
+ {
+ this.userName = userName;
+ }
+
+ public String getFirstName()
+ {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName)
+ {
+ this.firstName = firstName;
+ }
+
+ public String getLastName()
+ {
+ return lastName;
+ }
+
+ public void setLastName(String lastName)
+ {
+ this.lastName = lastName;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentName.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentName.java
new file mode 100755
index 0000000..ccdc1fa
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentName.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain.validation;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Constraint(validatedBy = DifferentNameValidator.class)
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface DifferentName
+{
+ String message() default "invalid name";
+
+ Class<?>[] groups() default {};
+
+ Class<? extends Payload>[] payload() default {};
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentNameValidator.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentNameValidator.java
new file mode 100755
index 0000000..f893f35
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/DifferentNameValidator.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain.validation;
+
+import org.superbiz.deltaspike.domain.User;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+public class DifferentNameValidator implements ConstraintValidator<DifferentName, User>
+{
+ public void initialize(DifferentName differentName)
+ {
+ }
+
+ public boolean isValid(User person, ConstraintValidatorContext constraintValidatorContext)
+ {
+ return person == null || !(person.getFirstName() != null && person.getFirstName().equals(person.getLastName()));
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Full.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Full.java
new file mode 100755
index 0000000..4fcb0cf
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Full.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain.validation;
+
+import javax.validation.GroupSequence;
+import javax.validation.groups.Default;
+
+@GroupSequence({Default.class, UniqueUserName.class})
+public interface Full
+{
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Name.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Name.java
new file mode 100755
index 0000000..037c224
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Name.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain.validation;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.ReportAsSingleViolation;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Size(min = 2, max = 20)
+@NotNull
+
+@Constraint(validatedBy = {})
+@ReportAsSingleViolation
+
+@Target({METHOD, FIELD, ANNOTATION_TYPE})
+@Retention(RUNTIME)
+public @interface Name
+{
+ public abstract String message() default "invalid name";
+
+ public abstract Class<?>[] groups() default {};
+
+ public abstract Class<? extends Payload>[] payload() default {};
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Partial.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Partial.java
new file mode 100755
index 0000000..68962b9
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/Partial.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain.validation;
+
+public interface Partial
+{
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserName.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserName.java
new file mode 100755
index 0000000..4416054
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserName.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain.validation;
+
+public interface UniqueUserName
+{
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserNameValidator.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserNameValidator.java
new file mode 100755
index 0000000..b5d2707
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserNameValidator.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain.validation;
+
+import org.superbiz.deltaspike.repository.UserRepository;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+@ApplicationScoped
+public class UniqueUserNameValidator implements ConstraintValidator<UserName, String>
+{
+ @Inject
+ private UserRepository userRepository;
+
+ public void initialize(UserName differentName)
+ {
+ }
+
+ public boolean isValid(String userName, ConstraintValidatorContext constraintValidatorContext)
+ {
+ return this.userRepository.loadUser(userName) == null;
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UserName.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UserName.java
new file mode 100755
index 0000000..3a85e2f
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/domain/validation/UserName.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.domain.validation;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.groups.Default;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@NotNull(groups = Default.class)
+@Size(min = 2, max = 9, message = "invalid name", groups = Default.class)
+
+@Constraint(validatedBy = UniqueUserNameValidator.class)
+@Target(FIELD)
+@Retention(RUNTIME)
+public @interface UserName
+{
+ String message() default "user-name exists already";
+
+ Class<?>[] groups() default {};
+
+ Class<? extends Payload>[] payload() default {};
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/FeedbackRepository.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/FeedbackRepository.java
new file mode 100755
index 0000000..3d68a0d
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/FeedbackRepository.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.repository;
+
+import org.superbiz.deltaspike.domain.Feedback;
+
+public interface FeedbackRepository extends GenericRepository<Feedback>
+{
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/GenericRepository.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/GenericRepository.java
new file mode 100755
index 0000000..37246bc
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/GenericRepository.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.repository;
+
+import org.superbiz.deltaspike.domain.AbstractDomainObject;
+
+import java.io.Serializable;
+import java.util.List;
+
+public interface GenericRepository<T extends AbstractDomainObject> extends Serializable
+{
+ void save(T entity);
+
+ void remove(T entity);
+
+ List<T> loadAll();
+
+ T loadById(Long id);
+
+ T createNewEntity();
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/Repository.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/Repository.java
new file mode 100755
index 0000000..808224e
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/Repository.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.repository;
+
+import org.apache.deltaspike.jpa.api.transaction.Transactional;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+
+@Target({TYPE})
+@Retention(RUNTIME)
+@Documented
+
+@RequestScoped
+public @interface Repository
+{
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/UserRepository.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/UserRepository.java
new file mode 100755
index 0000000..7d63fc5
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/UserRepository.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.repository;
+
+import org.superbiz.deltaspike.domain.User;
+
+public interface UserRepository extends GenericRepository<User>
+{
+ User loadUser(String userName);
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/AbstractGenericJpaRepository.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/AbstractGenericJpaRepository.java
new file mode 100755
index 0000000..0d0111a
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/AbstractGenericJpaRepository.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.repository.jpa;
+
+import org.superbiz.deltaspike.domain.AbstractDomainObject;
+import org.superbiz.deltaspike.repository.GenericRepository;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.List;
+
+/**
+ * Abstract repository class which provides default implementations for common repository methods.
+ */
+public abstract class AbstractGenericJpaRepository<T extends AbstractDomainObject> implements GenericRepository<T>
+{
+ protected final Class<? extends AbstractDomainObject> entityClass;
+
+ @Inject
+ protected EntityManager entityManager;
+
+ public AbstractGenericJpaRepository()
+ {
+ Class currentClass = getClass();
+
+ if (currentClass.getName().contains("$$"))
+ { //we are in a proxy
+ currentClass = currentClass.getSuperclass();
+ }
+
+ for (Type interfaceClass : currentClass.getGenericInterfaces())
+ {
+ for (Type genericInterfaceClass : ((Class) interfaceClass).getGenericInterfaces())
+ {
+ if (genericInterfaceClass instanceof ParameterizedType &&
+ GenericRepository.class.isAssignableFrom((Class) ((ParameterizedType) genericInterfaceClass).getRawType()))
+ {
+ for (Type parameterizedType : ((ParameterizedType) genericInterfaceClass).getActualTypeArguments())
+ {
+ if (AbstractDomainObject.class.isAssignableFrom((Class) parameterizedType))
+ {
+ this.entityClass = (Class<? extends AbstractDomainObject>) parameterizedType;
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ throw new IllegalStateException("Entity type of " + currentClass.getName() + " not detected!");
+ }
+
+ @Override
+ public T createNewEntity()
+ {
+ try
+ {
+ return (T)this.entityClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void save(T entity)
+ {
+ if (entity.isTransient())
+ {
+ this.entityManager.persist(entity);
+ }
+ else
+ {
+ this.entityManager.merge(entity);
+ }
+ }
+
+ public void remove(T entity)
+ {
+ if (entity.isTransient())
+ {
+ throw new IllegalStateException("entity is not persistent");
+ }
+
+ this.entityManager.remove(loadById(entity.getId()));
+ }
+
+ public List<T> loadAll()
+ {
+ return (List<T>) this.entityManager.createQuery("select entity from " + this.entityClass.getSimpleName() + " entity")
+ .getResultList();
+ }
+
+ public T loadById(Long id)
+ {
+ return (T) this.entityManager.find(this.entityClass, id);
+ }
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/EntityManagerProducer.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/EntityManagerProducer.java
new file mode 100755
index 0000000..b0e9b3a
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/EntityManagerProducer.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.repository.jpa;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+@ApplicationScoped
+public class EntityManagerProducer
+{
+ @PersistenceUnit(unitName = "demoApplicationPU")
+ private EntityManagerFactory entityManagerFactory;
+
+ @Produces
+ @Default
+ @RequestScoped
+ public EntityManager create()
+ {
+ return this.entityManagerFactory.createEntityManager();
+ }
+
+ public void dispose(@Disposes @Default EntityManager entityManager)
+ {
+ if (entityManager.isOpen())
+ {
+ entityManager.close();
+ }
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/JpaFeedbackRepository.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/JpaFeedbackRepository.java
new file mode 100755
index 0000000..448ccbf
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/JpaFeedbackRepository.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.repository.jpa;
+
+import org.apache.deltaspike.jpa.api.transaction.Transactional;
+import org.superbiz.deltaspike.domain.Feedback;
+import org.superbiz.deltaspike.repository.FeedbackRepository;
+import org.superbiz.deltaspike.repository.Repository;
+
+@Transactional
+@Repository
+public class JpaFeedbackRepository extends AbstractGenericJpaRepository<Feedback> implements FeedbackRepository
+{
+ private static final long serialVersionUID = -4140472572607337575L;
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/JpaUserRepository.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/JpaUserRepository.java
new file mode 100755
index 0000000..6c42652
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/repository/jpa/JpaUserRepository.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.repository.jpa;
+
+import org.superbiz.deltaspike.domain.User;
+import org.superbiz.deltaspike.repository.Repository;
+import org.superbiz.deltaspike.repository.UserRepository;
+
+import javax.persistence.Query;
+import java.util.List;
+
+@Repository
+public class JpaUserRepository extends AbstractGenericJpaRepository<User> implements UserRepository
+{
+ private static final long serialVersionUID = 672568789774892077L;
+
+ public User loadUser(String userName)
+ {
+ Query query = this.entityManager.createNamedQuery("findUserByName");
+ query.setParameter("currentUser", userName);
+
+ //just for the demo:
+ List result = query.getResultList();
+ if (result != null && result.size() == 1)
+ {
+ return (User) result.iterator().next();
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/service/DomainService.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/service/DomainService.java
new file mode 100755
index 0000000..5e4883d
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/service/DomainService.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.service;
+
+import org.apache.deltaspike.jpa.api.transaction.Transactional;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+
+@Target({TYPE})
+@Retention(RUNTIME)
+@Documented
+
+@RequestScoped
+@Transactional
+public @interface DomainService
+{
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/service/UserService.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/service/UserService.java
new file mode 100755
index 0000000..f9ac3f0
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/service/UserService.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.service;
+
+import org.superbiz.deltaspike.domain.User;
+import org.superbiz.deltaspike.repository.UserRepository;
+
+import javax.enterprise.inject.Typed;
+import javax.inject.Inject;
+import java.util.List;
+
+//usually services contain additional logic or delegate to multiple repositories.
+//here the service just delegates to one repository to allow tests which use a mocked user-repository.
+//currently it isn't supported to mock intercepted beans (see DELTASPIKE-605)
+//-> @Repository as well as JpaUserRepository can't use an interceptor like @Transactional
+@DomainService
+@Typed(UserService.class)
+public class UserService implements UserRepository
+{
+ @Inject
+ private UserRepository userRepository;
+
+ /*
+ * generated
+ */
+
+ @Override
+ public User loadUser(String userName)
+ {
+ return userRepository.loadUser(userName);
+ }
+
+ @Override
+ public void save(User entity)
+ {
+ userRepository.save(entity);
+ }
+
+ @Override
+ public void remove(User entity)
+ {
+ userRepository.remove(entity);
+ }
+
+ @Override
+ public List<User> loadAll()
+ {
+ return userRepository.loadAll();
+ }
+
+ @Override
+ public User loadById(Long id)
+ {
+ return userRepository.loadById(id);
+ }
+
+ @Override
+ public User createNewEntity()
+ {
+ return userRepository.createNewEntity();
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/startup/ModuleStartupObserver.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/startup/ModuleStartupObserver.java
new file mode 100755
index 0000000..a3636d7
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/startup/ModuleStartupObserver.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.startup;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+@Singleton
+@Startup
+public class ModuleStartupObserver
+{
+ private Logger logger = Logger.getLogger(ModuleStartupObserver.class.getName());
+
+ @PostConstruct
+ public void logStartup()
+ {
+ if (logger.isLoggable(Level.INFO))
+ {
+ logger.info("starting application module");
+ }
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/FeedbackPage.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/FeedbackPage.java
new file mode 100755
index 0000000..da610f4
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/FeedbackPage.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.view;
+
+import org.apache.deltaspike.core.api.config.view.controller.PreRenderView;
+import org.apache.deltaspike.core.api.scope.GroupedConversation;
+import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
+import org.superbiz.deltaspike.domain.Feedback;
+import org.superbiz.deltaspike.repository.FeedbackRepository;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.Serializable;
+import java.util.List;
+
+@Named
+@GroupedConversationScoped
+public class FeedbackPage implements Serializable
+{
+ private static final long serialVersionUID = 744025508253889974L;
+
+ private List<Feedback> feedbackList;
+
+ @Inject
+ private GroupedConversation conversation;
+
+ @Inject
+ private FeedbackRepository feedbackRepository;
+
+ private Feedback feedback;
+
+ @PostConstruct
+ protected void init()
+ {
+ this.feedback = this.feedbackRepository.createNewEntity();
+ }
+
+ @PreRenderView
+ public void reloadFeedbackList()
+ {
+ this.feedbackList = this.feedbackRepository.loadAll();
+ }
+
+ public void save()
+ {
+ this.feedbackRepository.save(this.feedback);
+ this.conversation.close();
+ }
+
+ /*
+ * generated
+ */
+
+ public List<Feedback> getFeedbackList()
+ {
+ return feedbackList;
+ }
+
+ public Feedback getFeedback()
+ {
+ return feedback;
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/InfoPage.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/InfoPage.java
new file mode 100755
index 0000000..5751e07
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/InfoPage.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.view;
+
+import org.apache.deltaspike.core.api.config.view.metadata.ViewMetaData;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target({TYPE})
+@Retention(RUNTIME)
+@Documented
+
+@ViewMetaData
+public @interface InfoPage
+{
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/MenuBean.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/MenuBean.java
new file mode 100755
index 0000000..01e36eb
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/MenuBean.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.view;
+
+import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationManager;
+import org.superbiz.deltaspike.view.config.Pages;
+
+import javax.enterprise.inject.Model;
+import javax.inject.Inject;
+
+@Model
+public class MenuBean
+{
+ @Inject
+ private GroupedConversationManager groupedConversationManager;
+
+ public Class<? extends Pages> home()
+ {
+ //close all conversations of the current window
+ this.groupedConversationManager.closeConversations();
+ return Pages.Index.class;
+ }
+
+ public Class<? extends Pages.Secure> feedback()
+ {
+ //close all conversations of the current window
+ this.groupedConversationManager.closeConversations();
+ return Pages.Secure.FeedbackList.class;
+ }
+
+ public Class<? extends Pages> about()
+ {
+ //close all conversations of the current window
+ this.groupedConversationManager.closeConversations();
+ return Pages.About.class;
+ }
+
+ public Class<? extends Pages> login()
+ {
+ //close all conversations of the current window
+ this.groupedConversationManager.closeConversations();
+ return Pages.Login.class;
+ }
+
+ public Class<? extends Pages> register()
+ {
+ //close all conversations of the current window
+ this.groupedConversationManager.closeConversations();
+ return Pages.Registration.class;
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/RegistrationPage.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/RegistrationPage.java
new file mode 100755
index 0000000..303cc4a
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/RegistrationPage.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.view;
+
+import org.apache.deltaspike.core.api.scope.GroupedConversation;
+import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
+import org.apache.deltaspike.jsf.api.message.JsfMessage;
+import org.apache.myfaces.extensions.validator.beanval.annotation.BeanValidation;
+import org.apache.myfaces.extensions.validator.crossval.annotation.Equals;
+import org.superbiz.deltaspike.WebappMessageBundle;
+import org.superbiz.deltaspike.domain.User;
+import org.superbiz.deltaspike.domain.validation.Full;
+import org.superbiz.deltaspike.service.UserService;
+import org.superbiz.deltaspike.view.config.Pages;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.Serializable;
+
+@Named
+@GroupedConversationScoped
+public class RegistrationPage implements Serializable
+{
+ private static final long serialVersionUID = 3844502441069448490L;
+
+ @Inject
+ private UserService userService;
+
+ @Inject
+ private GroupedConversation conversation;
+
+ @Inject
+ private JsfMessage<WebappMessageBundle> webappMessages;
+
+ private User user = new User();
+
+ @Inject
+ private UserHolder userHolder;
+
+ @Equals("user.password")
+ private String repeatedPassword;
+
+ @BeanValidation(useGroups = Full.class) //triggers UniqueUserNameValidator
+ public Class<? extends Pages> register()
+ {
+ this.userService.save(this.user);
+ this.webappMessages.addInfo().msgUserRegistered(this.user.getUserName());
+
+ //in order to re-use the page-bean for the login-page
+ this.conversation.close();
+
+ return Pages.Login.class;
+ }
+
+ public Class<? extends Pages> login()
+ {
+ User user = this.userService.loadUser(this.user.getUserName());
+ if (user != null && user.getPassword().equals(this.user.getPassword()))
+ {
+ this.webappMessages.addInfo().msgLoginSuccessful();
+ this.userHolder.setCurrentUser(user);
+ return Pages.About.class;
+ }
+
+ this.webappMessages.addError().msgLoginFailed();
+
+ return null;
+ }
+
+ public User getUser()
+ {
+ return user;
+ }
+
+ public String getRepeatedPassword()
+ {
+ return repeatedPassword;
+ }
+
+ public void setRepeatedPassword(String repeatedPassword)
+ {
+ this.repeatedPassword = repeatedPassword;
+ }
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/UserHolder.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/UserHolder.java
new file mode 100755
index 0000000..911ed6c
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/UserHolder.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.view;
+
+import org.apache.deltaspike.core.api.scope.WindowScoped;
+import org.superbiz.deltaspike.domain.User;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.Serializable;
+
+//due to the enhanced entities it isn't possible to use them directly (due to final methods)
+@WindowScoped
+public class UserHolder implements Serializable
+{
+ private static final long serialVersionUID = -7687528373042288584L;
+
+ @Inject
+ @New
+ private User user;
+
+ @Produces
+ @Dependent
+ @Named("currentUser")
+ protected User createCurrentUser()
+ {
+ return this.user;
+ }
+
+ public void setCurrentUser(User user)
+ {
+ this.user = user;
+ }
+
+ public boolean isLoggedIn()
+ {
+ return this.user.getId() != null;
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/config/Pages.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/config/Pages.java
new file mode 100755
index 0000000..650f72d
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/config/Pages.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.view.config;
+
+import org.apache.deltaspike.core.api.config.view.DefaultErrorView;
+import org.apache.deltaspike.core.api.config.view.ViewConfig;
+import org.apache.deltaspike.core.api.config.view.controller.ViewControllerRef;
+import org.apache.deltaspike.jsf.api.config.view.View;
+import org.apache.deltaspike.security.api.authorization.Secured;
+import org.superbiz.deltaspike.view.FeedbackPage;
+import org.superbiz.deltaspike.view.InfoPage;
+import org.superbiz.deltaspike.view.security.LoginAccessDecisionVoter;
+
+import static org.apache.deltaspike.jsf.api.config.view.View.NavigationMode.REDIRECT;
+
+@View(navigation = REDIRECT)
+public interface Pages extends ViewConfig
+{
+ class Index implements Pages {}
+
+ @InfoPage class About implements Pages {}
+
+ class Registration implements Pages {}
+
+ class Login extends DefaultErrorView implements Pages /*just to benefit from the config*/ {}
+
+ @Secured(LoginAccessDecisionVoter.class)
+ //@Secured(value = LoginAccessDecisionVoter.class, errorView = Login.class)
+ interface Secure extends Pages
+ {
+ @ViewControllerRef(FeedbackPage.class)
+ //optional: @View
+ class FeedbackList implements Secure {}
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/security/LoginAccessDecisionVoter.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/security/LoginAccessDecisionVoter.java
new file mode 100755
index 0000000..1bcc034
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/security/LoginAccessDecisionVoter.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.view.security;
+
+import org.apache.deltaspike.security.api.authorization.AbstractAccessDecisionVoter;
+import org.apache.deltaspike.security.api.authorization.AccessDecisionVoterContext;
+import org.apache.deltaspike.security.api.authorization.SecurityViolation;
+import org.superbiz.deltaspike.WebappMessageBundle;
+import org.superbiz.deltaspike.view.UserHolder;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import java.util.Set;
+
+@ApplicationScoped
+public class LoginAccessDecisionVoter extends AbstractAccessDecisionVoter
+{
+ private static final long serialVersionUID = -6332617547592896599L;
+
+ @Inject
+ private UserHolder userHolder;
+
+ @Inject
+ private WebappMessageBundle webappMessageBundle;
+
+ @Override
+ protected void checkPermission(AccessDecisionVoterContext accessDecisionVoterContext,
+ Set<SecurityViolation> violations)
+ {
+ if (!this.userHolder.isLoggedIn())
+ {
+ violations.add(newSecurityViolation(this.webappMessageBundle.msgAccessDenied()));
+ }
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/util/InfoBean.java b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/util/InfoBean.java
new file mode 100755
index 0000000..c84e4e0
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/java/org/superbiz/deltaspike/view/util/InfoBean.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.view.util;
+
+import org.apache.deltaspike.core.api.config.view.metadata.ViewConfigDescriptor;
+import org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver;
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.core.spi.scope.window.WindowContext;
+import org.apache.deltaspike.jsf.api.message.JsfMessage;
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+import org.superbiz.deltaspike.WebappMessageBundle;
+import org.superbiz.deltaspike.view.InfoPage;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.Persistence;
+import javax.validation.Validation;
+import java.io.Serializable;
+
+@SuppressWarnings("CdiUnproxyableBeanTypesInspection")
+@Named
+@SessionScoped
+public class InfoBean implements Serializable
+{
+ private static final long serialVersionUID = -1748909261695527800L;
+
+ @Inject
+ private WindowContext windowContext;
+
+ @Inject
+ private JsfMessage<WebappMessageBundle> webappMessages;
+
+ @Inject
+ private ProjectStage projectStage;
+
+ @Inject
+ private ViewConfigResolver viewConfigResolver;
+
+ private String applicationMessageVersionInfo;
+
+ private String beanValidationVersion;
+
+ private String jpaVersion;
+
+ @PostConstruct
+ protected void showWelcomeMessage()
+ {
+ String versionString = ClassUtils.getJarVersion(InfoBean.class);
+
+ if (versionString != null)
+ {
+ this.applicationMessageVersionInfo = " (v" + versionString + ")";
+ }
+
+ this.beanValidationVersion =
+ ClassUtils.getJarVersion(Validation.buildDefaultValidatorFactory().getValidator().getClass());
+
+ this.jpaVersion =
+ ClassUtils.getJarVersion(Persistence.createEntityManagerFactory("demoApplicationPU").getClass());
+
+ if (!ProjectStage.IntegrationTest.equals(this.projectStage))
+ {
+ this.webappMessages.addInfo().msgWelcome();
+ }
+ }
+
+ public boolean isInfoPage()
+ {
+ ViewConfigDescriptor viewConfigDescriptor =
+ this.viewConfigResolver.getViewConfigDescriptor(FacesContext.getCurrentInstance().getViewRoot().getViewId());
+
+ if (viewConfigDescriptor == null)
+ {
+ return false;
+ }
+
+ return !viewConfigDescriptor.getMetaData(InfoPage.class).isEmpty();
+ }
+
+ public String getProjectStage()
+ {
+ return this.projectStage.toString();
+ }
+
+ public String getApplicationVersion()
+ {
+ return this.applicationMessageVersionInfo;
+ }
+
+ public String getDeltaSpikeVersion()
+ {
+ return ClassUtils.getJarVersion(BeanManagerProvider.class);
+ }
+
+ public String getCdiVersion() {
+ try {
+ return ClassUtils.getJarVersion(BeanManagerProvider.getInstance().getBeanManager().getClass());
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "Failed to get CDI Version: " + e.getMessage();
+ }
+ }
+
+ public String getExtValVersion()
+ {
+ return ExtValInformation.VERSION;
+ }
+
+ public String getJsfVersion()
+ {
+ return ClassUtils.getJarVersion(FacesContext.class);
+ }
+
+ public String getBeanValidationVersion()
+ {
+ return this.beanValidationVersion;
+ }
+
+ public String getJpaVersion()
+ {
+ return this.jpaVersion;
+ }
+
+ public String getWindowId()
+ {
+ return this.windowContext.getCurrentWindowId();
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/main/resources/META-INF/beans.xml b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..6a4e0bd
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<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>
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/resources/META-INF/faces-config.xml b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/faces-config.xml
new file mode 100755
index 0000000..53c505b
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/faces-config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+</faces-config>
diff --git a/content/examples/deltaspike-fullstack/src/main/resources/META-INF/persistence.xml b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..d9dd26f
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+
+ <persistence-unit name="demoApplicationPU" transaction-type="RESOURCE_LOCAL">
+ <!-- needed by tomee 1.6.0+-->
+ <non-jta-data-source>demoDS</non-jta-data-source>
+
+ <!-- config of (non-)jta-data-source isn't needed if there is just one -->
+
+ <!-- @MappedSuperclass classes - see OPENJPA-1926 -->
+ <class>org.superbiz.deltaspike.domain.AbstractDomainObject</class>
+
+ <!-- entities -->
+ <class>org.superbiz.deltaspike.domain.User</class>
+ <class>org.superbiz.deltaspike.domain.Feedback</class>
+ <class>org.superbiz.deltaspike.domain.Comment</class>
+
+ <properties>
+ <property name="openjpa.DataCache" value="true"/>
+ <property name="openjpa.DynamicEnhancementAgent" value="true"/>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ <property name="openjpa.jdbc.QuerySQLCache" value="true(EnableStatistics=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/resources/META-INF/services/org.apache.deltaspike.core.api.projectstage.ProjectStageHolder b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/services/org.apache.deltaspike.core.api.projectstage.ProjectStageHolder
new file mode 100755
index 0000000..fd699a9
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/services/org.apache.deltaspike.core.api.projectstage.ProjectStageHolder
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.superbiz.deltaspike.CustomProjectStage
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/resources/META-INF/validation.xml b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/validation.xml
new file mode 100755
index 0000000..d5d1a62
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/resources/META-INF/validation.xml
@@ -0,0 +1,23 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration">
+ <constraint-validator-factory>org.apache.deltaspike.beanvalidation.impl.CDIAwareConstraintValidatorFactory</constraint-validator-factory>
+</validation-config>
diff --git a/content/examples/deltaspike-fullstack/src/main/resources/org/superbiz/deltaspike/i18n/messages.properties b/content/examples/deltaspike-fullstack/src/main/resources/org/superbiz/deltaspike/i18n/messages.properties
new file mode 100755
index 0000000..07b8422
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/resources/org/superbiz/deltaspike/i18n/messages.properties
@@ -0,0 +1,62 @@
+#Licensed to the Apache Software Foundation (ASF) under one
+#or more contributor license agreements. See the NOTICE file
+#distributed with this work for additional information
+#regarding copyright ownership. The ASF licenses this file
+#to you under the Apache License, Version 2.0 (the
+#"License"); you may not use this file except in compliance
+#with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing,
+#software distributed under the License is distributed on an
+#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#KIND, either express or implied. See the License for the
+#specific language governing permissions and limitations
+#under the License.
+
+
+
+#overrule the default format {1}: {0} to ignore the labels
+#javax.faces.validator.BeanValidator.MESSAGE={0}
+#javax.faces.validator.BeanValidator.MESSAGE_detail={0}
+
+btnRegisterAndRestart=save and restart
+btnLogin=login
+lnkLogin=Login
+btnRegister=register
+
+lblLoginName=Login-name
+lblFirstName=First-name
+lblLastName=Last-name
+lblPassword=Password
+lblRepeatedPassword=Repeated password
+lblFinish=finish
+
+lblLeftMenuTitle=Menu
+lblHome=Home
+lblFeedback=Feedback
+
+lblWiki=Wiki
+lblExternalExamples=External examples
+
+menuDocumentation=Documentation
+menuMisc=Misc
+menuAbout=About
+
+welcome=Welcome
+msgWelcome=Welcome to the Apache TomEE/DeltaSpike-Stack Demo
+
+msgUserRegistered=User %s registered successfully!
+msgUserNotRegistered=Failed to register user %s!
+
+msgLoginSuccessful=Login successful!
+msgLoginFailed=Login failed!
+msgAccessDenied=Access denied!
+tblFeedbackTopic=Topic
+tblFeedbackDescription=Description
+lblTopic=Topic
+lblDescription=Feedback Text
+btnSave=save
+
+msgError=Error %s
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/WEB-INF/beans.xml b/content/examples/deltaspike-fullstack/src/main/webapp/WEB-INF/beans.xml
new file mode 100755
index 0000000..6a4e0bd
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<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>
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/WEB-INF/faces-config.xml b/content/examples/deltaspike-fullstack/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100755
index 0000000..5e7fb5b
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <application>
+ <locale-config>
+ <default-locale>en</default-locale>
+ <supported-locale>en</supported-locale>
+ </locale-config>
+ <message-bundle>org.superbiz.deltaspike.i18n.messages</message-bundle>
+ <resource-bundle>
+ <base-name>org.superbiz.deltaspike.i18n.messages</base-name>
+ <var>i18n</var>
+ </resource-bundle>
+ </application>
+
+</faces-config>
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/WEB-INF/web.xml b/content/examples/deltaspike-fullstack/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..66a1bef
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<web-app 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/web-app_3_0.xsd"
+ version="3.0">
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.xhtml</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list>
+ <welcome-file>pages/index.xhtml</welcome-file>
+ </welcome-file-list>
+</web-app>
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/layout/main-template.xhtml b/content/examples/deltaspike-fullstack/src/main/webapp/layout/main-template.xhtml
new file mode 100755
index 0000000..609680a
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/layout/main-template.xhtml
@@ -0,0 +1,144 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:p="http://primefaces.prime.com.tr/ui"
+ >
+
+<f:view contentType="text/html">
+
+ <h:head>
+ <title>Apache TomEE/DeltaSpike-Stack Demo</title>
+ <h:outputStylesheet library="styles" name="base.css"/>
+ <h:outputStylesheet library="styles" name="theme.css"/>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ </h:head>
+ <h:body>
+ <div id="header">
+ <h:form id="topMenuForm" prependId="false">
+ <div id="top_menu">
+ <div id="top_menu_container">
+ <h:panelGroup rendered="#{infoBean.infoPage}">
+ <div class="date">Apache TomEE/DeltaSpike-Stack <b>Demo-App</b> #{infoBean.applicationVersion}</div>
+ </h:panelGroup>
+ <div id="projectStage" class="date">[#{infoBean.projectStage}]</div>
+ <ul>
+ <li>
+ <h:commandLink id="lnkLogin" value="#{i18n.lnkLogin}" action="#{menuBean.login}"/>
+ </li>
+ <li>
+ <a href="http://www.apache.org" target="_blank">Apache</a>
+ </li>
+ <li>
+ <a href="http://deltaspike.apache.org" target="_blank">DeltaSpike</a>
+ </li>
+ <li>
+ <a href="http://myfaces.apache.org" target="_blank">MyFaces</a>
+ </li>
+ </ul>
+ <div class="clear"></div>
+ </div>
+ </div>
+ </h:form>
+ <div id="header_bottom">
+ <div id="logo_banner_container">
+ <div id="logo">
+ <h1>
+ <a href="http://deltaspike.apache.org/">Apache DS</a>
+ </h1>
+ </div>
+ <div id="banner">
+ <!-- TODO add logo -->
+ </div>
+ <div class="clear"></div>
+ </div>
+ </div>
+ </div>
+
+ <div id="main_container">
+ <div id="left_column">
+ <h:form id="menuForm" prependId="false">
+ <div class="left_menu_top">
+ <div class="left_menu_bottom">
+ <h5>#{i18n.lblLeftMenuTitle}</h5>
+
+ <div class="content">
+ <ul class="left_menu">
+ <ui:include src="menu.xhtml"/>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </h:form>
+
+ <div class="clear"></div>
+
+ <h:form id="leftMenuForm" prependId="false">
+
+ <div class="left_menu_top">
+ <div class="left_menu_bottom">
+ <h5>#{i18n.menuMisc}</h5>
+
+ <div class="content">
+ <ul class="left_menu">
+ <li class="none">
+ <h:commandLink id="menuAbout" value="#{i18n.menuAbout}" action="#{menuBean.about}"/>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </h:form>
+ <div class="clear"></div>
+ </div>
+ <div id="body_column">
+ <div>
+ <div class="section">
+
+ <ui:insert name="header"><h2>Apache TomEE/DeltaSpike-Stack Demo-App</h2></ui:insert>
+
+ <div class="main_content">
+ <h:form id="mainForm" prependId="false">
+ <ui:insert name="content"><p>No content available.</p></ui:insert>
+ </h:form>
+ </div>
+
+ </div>
+ </div>
+ </div>
+ <div class="clear"></div>
+ </div>
+ <p:growl sticky="false" showSummary="true" showDetail="false"/>
+ <div id="footer">
+ <div class="copyright">
+ <p>© The Apache Software Foundation
+ </p>
+ </div>
+ </div>
+ </h:body>
+</f:view>
+</html>
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/layout/menu.xhtml b/content/examples/deltaspike-fullstack/src/main/webapp/layout/menu.xhtml
new file mode 100755
index 0000000..7529684
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/layout/menu.xhtml
@@ -0,0 +1,32 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<div id="menu"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ >
+
+ <li class="none">
+ <h:commandLink id="menuHome" value="#{i18n.lblHome}" action="#{menuBean.home}"/>
+ </li>
+
+ <li class="none">
+ <h:commandLink id="menuFeedback" value="#{i18n.lblFeedback}" action="#{menuBean.feedback}"/>
+ </li>
+
+</div>
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/pages/about.xhtml b/content/examples/deltaspike-fullstack/src/main/webapp/pages/about.xhtml
new file mode 100755
index 0000000..813732f
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/pages/about.xhtml
@@ -0,0 +1,56 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h:panelGrid columns="2">
+ <h:outputLabel value="Current Window-ID:" for="wid"/>
+ <h:outputText id="wid" value="#{infoBean.windowId}"/>
+
+ <h:outputLabel value="Apache MyFaces-Core:" for="jsfVersion"/>
+ <h:outputText id="jsfVersion" value="#{infoBean.jsfVersion}"/>
+
+ <h:outputLabel value="Apache OpenWebBeans:" for="cdiVersion"/>
+ <h:outputText id="cdiVersion" value="#{infoBean.cdiVersion}"/>
+
+ <h:outputLabel value="Apache DeltaSpike:" for="dsVersion"/>
+ <h:outputText id="dsVersion" value="#{infoBean.deltaSpikeVersion}"/>
+
+ <h:outputLabel value="Apache MyFaces ExtVal:" for="extValVersion"/>
+ <h:outputText id="extValVersion" value="#{infoBean.extValVersion}"/>
+
+ <h:outputLabel value="Apache BVal:" for="bValVersion"/>
+ <h:outputText id="bValVersion" value="#{infoBean.beanValidationVersion}"/>
+
+ <h:outputLabel value="Apache OpenJPA:" for="jpaVersion"/>
+ <h:outputText id="jpaVersion" value="#{infoBean.jpaVersion}"/>
+ </h:panelGrid>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/pages/index.xhtml b/content/examples/deltaspike-fullstack/src/main/webapp/pages/index.xhtml
new file mode 100755
index 0000000..9aae2e0
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/pages/index.xhtml
@@ -0,0 +1,65 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h2>Illustrated Features</h2>
+ <h3>Apache DeltaSpike</h3>
+ <ul>
+ <li>Type-safe view-config</li>
+ <li>Type-safe (custom) view-meta-data</li>
+ <li>Type-safe navigation</li>
+ <li>Type-safe custom project-stage</li>
+ <li>@WindowScoped</li>
+ <li>@GroupedConversationScoped</li>
+ <li>Manual conversation handling</li>
+ <li>Secured pages (AccessDecisionVoter)</li>
+ <li>@Transactional</li>
+ <li>I18n (type-safe messages)</li>
+ <li>Dependency-Injection for JSR303 (BV) constraint-validators</li>
+ <li>Dependency-Injection for JSF phase-listeners</li>
+ </ul>
+
+ <h3>Apache MyFaces ExtVal</h3>
+ <ul>
+ <li>Cross-Field validation (@Equals)</li>
+ <li>Type-safe group-validation (@BeanValidation) for JSF action-methods</li>
+ </ul>
+
+ <h2>Hints</h2>
+ <ul>
+ <li>
+ This application doesn't show the/a best practise. It's only a small application which shows a bunch of features.
+ </li>
+ <li>
+ To sync the project-stage of DeltaSpike and JSF use e.g. faces.PROJECT_STAGE=Development in [tomee dir]/conf/system.properties
+ </li>
+ </ul>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/pages/login.xhtml b/content/examples/deltaspike-fullstack/src/main/webapp/pages/login.xhtml
new file mode 100755
index 0000000..0a9ff89
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/pages/login.xhtml
@@ -0,0 +1,48 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="loginName" value="#{i18n.lblLoginName}: "/>
+ <h:inputText id="loginName" label="#{i18n.lblLoginName}" value="#{registrationPage.user.userName}" required="true"/>
+ <h:message for="loginName" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="password" value="#{i18n.lblPassword}: "/>
+ <h:inputSecret id="password" label="#{i18n.lblPassword}" value="#{registrationPage.user.password}"/>
+ <h:message for="password" showSummary="true" showDetail="false"/>
+ </h:panelGrid>
+ <p/>
+ <h:panelGrid columns="2">
+ <h:commandButton id="login" value="#{i18n.btnLogin}" action="#{registrationPage.login}"/>
+ <h:commandLink id="register" value="#{i18n.btnRegister}" action="#{menuBean.register}" immediate="true"/>
+ </h:panelGrid>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/pages/registration.xhtml b/content/examples/deltaspike-fullstack/src/main/webapp/pages/registration.xhtml
new file mode 100755
index 0000000..74aa1b1
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/pages/registration.xhtml
@@ -0,0 +1,57 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="firstName" value="#{i18n.lblFirstName}: "/>
+ <h:inputText id="firstName" label="#{i18n.lblFirstName}" value="#{registrationPage.user.firstName}"/>
+ <h:message for="firstName" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="lastName" value="#{i18n.lblLastName}: "/>
+ <h:inputText id="lastName" label="#{i18n.lblLastName}" value="#{registrationPage.user.lastName}"/>
+ <h:message for="lastName" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="loginName" value="#{i18n.lblLoginName}: "/>
+ <h:inputText id="loginName" label="#{i18n.lblLoginName}" value="#{registrationPage.user.userName}" required="true"/>
+ <h:message for="loginName" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="password" value="#{i18n.lblPassword}: "/>
+ <h:inputSecret id="password" label="#{i18n.lblPassword}" value="#{registrationPage.user.password}"/>
+ <h:message for="password" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="repeatedPassword" value="#{i18n.lblRepeatedPassword}: "/>
+ <h:inputSecret id="repeatedPassword" label="#{i18n.lblRepeatedPassword}" value="#{registrationPage.repeatedPassword}"/>
+ <h:message for="repeatedPassword" showSummary="true" showDetail="false"/>
+ </h:panelGrid>
+ <p/>
+ <h:commandButton id="register" value="#{i18n.btnRegister}" action="#{registrationPage.register}"/>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/pages/secure/feedbackList.xhtml b/content/examples/deltaspike-fullstack/src/main/webapp/pages/secure/feedbackList.xhtml
new file mode 100755
index 0000000..5dc873e
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/pages/secure/feedbackList.xhtml
@@ -0,0 +1,61 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:p="http://primefaces.prime.com.tr/ui"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="topic" value="#{i18n.lblTopic}: "/>
+ <h:inputText id="topic" label="#{i18n.lblTopic}" value="#{feedbackPage.feedback.topic}" required="true"/>
+ <h:message for="topic" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="description" value="#{i18n.lblDescription}: "/>
+ <h:inputTextarea id="description" cols="80" rows="10" label="#{i18n.lblDescription}" value="#{feedbackPage.feedback.description}"/>
+ <h:message for="description" showSummary="true" showDetail="false"/>
+ </h:panelGrid>
+
+ <h:commandButton id="save" value="#{i18n.btnSave}" action="#{feedbackPage.save}"/>
+
+ <p/>
+
+ <p:dataTable var="entry" value="#{feedbackPage.feedbackList}" paginator="true" paginatorPosition="bottom"
+ rows="10">
+ <p:column>
+ <f:facet name="header"><h:outputText value="#{i18n.tblFeedbackTopic}"/></f:facet>
+ #{entry.topic}
+ </p:column>
+ <p:column>
+ <f:facet name="header"><h:outputText value="#{i18n.tblFeedbackDescription}"/></f:facet>
+ #{entry.description}
+ </p:column>
+ </p:dataTable>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/codi_logo.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/codi_logo.png
new file mode 100755
index 0000000..11b45ca
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/codi_logo.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/myfaces_logo.jpg b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/myfaces_logo.jpg
new file mode 100755
index 0000000..5c76195
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/myfaces_logo.jpg
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/code_section.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/code_section.png
new file mode 100755
index 0000000..e9d793d
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/code_section.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/footer.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/footer.png
new file mode 100755
index 0000000..7ac05e8
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/footer.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/h2.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/h2.png
new file mode 100755
index 0000000..3effe10
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/h2.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_bottom.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_bottom.png
new file mode 100755
index 0000000..34b412a
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_bottom.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_expand.gif b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_expand.gif
new file mode 100755
index 0000000..b964caf
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_expand.gif
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_expand_hover.gif b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_expand_hover.gif
new file mode 100755
index 0000000..aeff8a4
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_expand_hover.gif
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_expand_selected.gif b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_expand_selected.gif
new file mode 100755
index 0000000..3f18875
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_expand_selected.gif
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_option.gif b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_option.gif
new file mode 100755
index 0000000..a4357cb
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_option.gif
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_option_hover.gif b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_option_hover.gif
new file mode 100755
index 0000000..6e20b6f
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_option_hover.gif
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_top.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_top.png
new file mode 100755
index 0000000..6cde4b5
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/left_menu_top.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/logo_banner_container.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/logo_banner_container.png
new file mode 100755
index 0000000..cb82ada
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/logo_banner_container.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/main_space_list.gif b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/main_space_list.gif
new file mode 100755
index 0000000..a23c02b
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/main_space_list.gif
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/table_head.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/table_head.png
new file mode 100755
index 0000000..bdfa5c0
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/table_head.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/table_head_dark.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/table_head_dark.png
new file mode 100755
index 0000000..df5fa55
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/table_head_dark.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/top_menu.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/top_menu.png
new file mode 100755
index 0000000..7b41b40
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/top_menu.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/top_menu_hover.png b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/top_menu_hover.png
new file mode 100755
index 0000000..b0aaf44
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/top_menu_hover.png
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/transparent.gif b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/transparent.gif
new file mode 100755
index 0000000..fc25609
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/images/slices/transparent.gif
Binary files differ
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/styles/base.css b/content/examples/deltaspike-fullstack/src/main/webapp/resources/styles/base.css
new file mode 100755
index 0000000..83051d7
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/styles/base.css
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+body {
+ margin: 0;
+ padding: 0;
+}
+
+img {
+ border: none;
+}
+
+table {
+ padding: 0;
+ width: 50%;
+ margin-left: -2px;
+ margin-right: -2px;
+}
+
+acronym {
+ cursor: help;
+ border-bottom: 1px dotted #feb;
+}
+
+table.bodyTable th,table.bodyTable td {
+ padding: 2px 4px 2px 4px;
+ vertical-align: top;
+}
+
+div.clear {
+ clear: both;
+ visibility: hidden;
+}
+
+div.clear hr {
+ display: none;
+}
+
+#bannerLeft,#bannerRight {
+ font-size: xx-large;
+ font-weight: bold;
+}
+
+#bannerLeft img,#bannerRight img {
+ margin: 0;
+}
+
+.xleft,#bannerLeft img {
+ float: left;
+ text-shadow: #7CFC00 1px 1px 1px;
+}
+
+.xright,#bannerRight {
+ float: right;
+ text-shadow: #7CFC00 1px 1px 1px;
+}
+
+#banner {
+ padding: 0;
+}
+
+#banner img {
+ border: none;
+}
+
+#breadcrumbs {
+ padding: 3px 10px 3px 10px;
+}
+
+#leftColumn {
+ width: 170px;
+ float: left;
+ overflow: auto;
+}
+
+#bodyColumn {
+ margin-right: 1.5em;
+ margin-left: 197px;
+}
+
+#legend {
+ padding: 8px 0 8px 0;
+}
+
+#navcolumn {
+ padding: 8px 4px 0 8px;
+}
+
+#navcolumn h5 {
+ margin: 0;
+ padding: 0;
+ font-size: small;
+}
+
+#navcolumn ul {
+ margin: 0;
+ padding: 0;
+ font-size: small;
+}
+
+#navcolumn li {
+ list-style-type: none;
+ background-image: none;
+ background-repeat: no-repeat;
+ background-position: 0 0.4em;
+ padding-left: 16px;
+ list-style-position: outside;
+ line-height: 1.2em;
+ font-size: smaller;
+}
+
+#poweredBy {
+ text-align: center;
+}
+
+#navcolumn img {
+ margin-top: 10px;
+ margin-bottom: 3px;
+}
+
+#poweredBy img {
+ display: block;
+ margin: 20px 0 20px 17px;
+}
+
+#search img {
+ margin: 0;
+ display: block;
+}
+
+#search #q,#search #btnG {
+ border: 1px solid #999;
+ margin-bottom: 10px;
+}
+
+#search form {
+ margin: 0;
+}
+
+#lastPublished {
+ font-size: x-small;
+}
+
+.navSection {
+ margin-bottom: 2px;
+ padding: 8px;
+}
+
+.navSectionHead {
+ font-weight: bold;
+ font-size: x-small;
+}
+
+.section {
+ padding: 4px;
+}
+
+#footer {
+ padding: 3px 10px 3px 10px;
+ font-size: x-small;
+}
+
+#breadcrumbs {
+ font-size: x-small;
+ margin: 0;
+}
+
+.source {
+ padding: 12px;
+ margin: 1em 7px 1em 7px;
+}
+
+.source pre {
+ margin: 0;
+ padding: 0;
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/main/webapp/resources/styles/theme.css b/content/examples/deltaspike-fullstack/src/main/webapp/resources/styles/theme.css
new file mode 100755
index 0000000..a45d71a
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/main/webapp/resources/styles/theme.css
@@ -0,0 +1,480 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Init --------------------------------------------------------------------- */
+* {
+ margin: 0px;
+ padding: 0px;
+}
+
+body {
+ text-align: center; /*font-size: 75%;*/
+/*=12pixels*/
+ font-size: 12px;
+ font-family: verdana, tahoma, sans-serif;
+ font-weight: normal;
+ line-height: 1.4em;
+ color: #666666;
+ background-color: white;
+}
+
+div {
+ text-align: left;
+}
+
+span {
+ display: inline;
+}
+
+img {
+ display: block;
+}
+
+h1, h2, h3 {
+ font-family: arial, geneva, helvetica, sans-serif;
+ font-weight: bold;
+ margin-top: 10px;
+ color: #669900;
+}
+
+h1 {
+ font-size: 1.6em;
+}
+
+h2 {
+ font-size: 1.2em;
+}
+
+h3 {
+ font-size: 1.1em;
+}
+
+ul {
+ list-style-type: none;
+}
+
+a {
+ text-decoration: none;
+ color: #669900;
+}
+
+a:hover {
+ color: #FF9900;
+}
+
+/*
+ * Clear float positions.
+ */
+.clear {
+ clear: both;
+}
+
+/* IE fixes ------------------------------------------------ */
+/* Solve the IE 3px gap bug */
+/* Hides from IE5-mac \*/
+* html .section, p {
+ height: 1%;
+}
+
+/* End hide from IE5-mac */
+/* Add the min and max width in IE */
+* #main_container, * #top_menu_container, * #logo_banner_container, * .copyright {
+ width: expression(document . body . clientWidth > 1210 ? "1200px" : (
+ document . body . clientWidth < 960 ? "950px" : "auto") );
+}
+
+/* PNG transparency fix */
+img {
+ behavior: url(css/png-fix.htc);
+}
+
+/* IE fixes ----------------------------------------------------------------- */
+/* Fluid layout constraints ----------------------------------------- */
+#main_container, #top_menu_container, #logo_banner_container, .copyright {
+ max-width: 1200px;
+ min-width: 950px;
+}
+
+#footer, #top_menu, #header_bottom {
+ width: 100%;
+ min-width: 950px;
+}
+
+/* Main layout -------------------------------------------------------------- */
+#main_container {
+ margin: 0px auto 0px auto;
+}
+
+#footer {
+ margin: 0px;
+ border: 0px;
+ padding: 0px;
+ height: 90px;
+ margin-top: 50px;
+ text-align: center;
+ color: white;
+ background: #52842D url("#{resource['images:slices/footer.png']}") repeat-x;
+}
+
+/* Header layout ------------------------------------------------------------ */
+#top_menu {
+ width: auto;
+ height: 45px;
+ text-align: center;
+ background: #52842D url("#{resource['images:slices/top_menu.png']}") repeat-x;
+}
+
+#top_menu_container {
+ margin: 0px auto 0px auto;
+ padding-top: 4px;
+}
+
+#header_bottom {
+ height: auto;
+ text-align: center;
+ background: url("#{resource['images:slices/logo_banner_container.png']}") repeat-x;
+}
+
+#logo_banner_container {
+ margin: 0px auto 0px auto;
+}
+
+/* body layout -------------------------------------------------------------- */
+#left_column {
+ float: left;
+ width: 210px;
+ height: auto;
+}
+
+#body_column {
+ padding: 1px 0px 0px 230px;
+ width: auto;
+}
+
+/* footer layout ------------------------------------------------------------ */
+.copyright {
+ margin: 0px auto 0px auto;
+ padding-top: 15px;
+}
+
+/* logo_banner_container layout --------------------------------------------- */
+#logo {
+ float: left;
+ width: 210px;
+ height: 100px;
+ margin-top: 10px;
+}
+
+#banner {
+ float: right;
+ width: 210px;
+ height: 85px;
+ margin-top: 10px;
+}
+
+/* leftColumn layout ------------------------------------------------------ */
+.left_menu_container {
+ width: 210px;
+}
+
+#powered_by {
+/*float: right;*/
+ text-align: center;
+}
+
+#powered_by img {
+ margin: 10px auto 10px auto;
+}
+
+/* left_menu layout --------------------------------------------------------- */
+.left_menu_top {
+ width: 210px;
+ background: url("#{resource['images:slices/left_menu_top.png']}") no-repeat top;
+}
+
+.left_menu_bottom {
+ width: 210px;
+ background: url("#{resource['images:slices/left_menu_bottom.png']}") no-repeat bottom;
+}
+
+/* top menu ----------------------------------------------------------------- */
+#top_menu div.date, #top_menu div.version {
+ margin: 9px 0px 0px 10px;
+ float: left;
+ color: white;
+}
+
+#top_menu ul {
+ float: right;
+ height: 37px;
+ border-right: 1px solid #80AA66;
+}
+
+#top_menu li {
+ display: inline;
+ height: 37px;
+ margin-left: -4px;
+}
+
+#top_menu a {
+ position: relative;
+ top: 9px;
+ border-left: 1px solid #80AA66;
+ padding: 10px 10px 13px 10px;
+ font-size: 12px;
+ color: white;
+}
+
+#top_menu a:hover {
+ text-decoration: underline;
+ background: url("#{resource['images:slices/top_menu_hover.png']}") repeat-x top;
+}
+
+/* left menu - first level menu --------------------------------------------- */
+.left_menu_top h5 {
+ padding: 26px 20px 0px 25px;
+ font-size: 1em;
+ color: #84683E;
+}
+
+ul.left_menu {
+ padding: 22px 20px 22px 25px;
+}
+
+ul.left_menu a {
+ font-size: 0.9em;
+ color: #705F38;
+ margin-left: 2px;
+ padding-left: 15px;
+}
+
+ul.left_menu a:hover {
+ color: #FF9900;
+}
+
+ul.left_menu li.none a {
+ background: url("#{resource['images:slices/left_menu_option.gif']}") no-repeat left;
+}
+
+ul.left_menu li.none a:hover {
+ background: url("#{resource['images:slices/left_menu_option_hover.gif']}") no-repeat left;
+}
+
+ul.left_menu li.none a.selected {
+ font-weight: bold;
+ background: none;
+}
+
+ul.left_menu li.expanded a {
+ font-weight: bold;
+ margin-left: 0px;
+ background: url("#{resource['images:slices/left_menu_expand_selected.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded a:hover {
+ background: url("#{resource['images:slices/left_menu_expand_hover.gif']}") no-repeat left;
+}
+
+ul.left_menu li.collapsed a {
+ margin-left: 0px;
+ background: url("#{resource['images:slices/left_menu_expand.gif']}") no-repeat left;
+}
+
+ul.left_menu li.collapsed a:hover {
+ background: url("#{resource['images:slices/left_menu_expand_hover.gif']}") no-repeat left;
+}
+
+/* left menu - second level menu ------------------------------------------- */
+ul.left_menu ul {
+ list-style-type: none;
+ padding: 0px 0px 10px 10px;
+}
+
+ul.left_menu li.expanded ul {
+ display: block;
+}
+
+ul.left_menu li.expanded ul a {
+ font-weight: normal;
+ background: none;
+}
+
+ul.left_menu li.expanded ul li.expanded a {
+ font-weight: bold;
+ background: url("#{resource['images:slices/left_menu_expand_selected.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded ul li.expanded a:hover {
+ background: url("#{resource['images:slices/left_menu_expand_hover.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded ul li.collapsed a {
+ font-weight: normal;
+ background: url("#{resource['images:slices/left_menu_expand.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded ul li.collapsed a:hover {
+ background: url("#{resource['images:slices/left_menu_expand_hover.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded ul a.selected {
+ font-weight: bold;
+}
+
+ul.left_menu li.collapsed ul {
+ display: none;
+}
+
+ul.left_menu ul li.none a,
+ul.left_menu ul li.none a:hover,
+ul.left_menu ul li.none a.selected {
+ background: none;
+}
+
+/* left menu - third level menu --------------------------------------------- */
+ul.left_menu ul ul {
+ padding: 0px 0px 10px 10px;
+}
+
+ul.left_menu ul li.expanded ul {
+ display: block;
+}
+
+ul.left_menu ul li.expanded ul li.none a {
+ font-weight: normal;
+}
+
+ul.left_menu ul li.expanded ul li.none a.selected {
+ font-weight: bold;
+}
+
+ul.left_menu ul li.expanded ul li.none a,
+ul.left_menu ul li.expanded ul li.none a:hover,
+ul.left_menu ul li.expanded ul li.none a.selected {
+ background: none;
+}
+
+/* body_column -------------------------------------------------------------- */
+#body_column p {
+ margin: 15px 15px 0px 0px;
+}
+
+#body_column .section, #body_column dl {
+ margin: 25px 0px 0px 0px;
+ padding: 0px 10px;
+}
+
+#body_column .section {
+}
+
+#body_column .section .section {
+ margin: 0px;
+ border: 0px;
+ padding: 0px;
+ overflow: auto;
+}
+
+/* Overflow fix for IE */
+* #body_column .section .section {
+ position: relative;
+ width: 100%;
+ overflow: hidden;
+ overflow-x: auto;
+}
+
+#body_column ul {
+ margin: 0px 15px 10px 15px;
+}
+
+#body_column ul li {
+ padding: 0px 0px 0px 15px;
+ background: url("#{resource['images:slices/main_space_list.gif']}") no-repeat left 5px;
+}
+
+#body_column ol {
+ padding: 15px 0px 15px 20px;
+}
+
+#body_column ol ol {
+ padding: 0px 0px 0px 15px;
+}
+
+/* tables ------------------------------------------------------------------- */
+#body_column table.bodyTable {
+ margin: 0px 0px 10px 0px;
+ border-collapse: collapse;
+ padding: 2px;
+ font-family: Tahoma, Arial, sans-serif;
+ font-size: 0.9em;
+ color: #333333;
+ background: white;
+}
+
+#body_column table.bodyTable th, table.bodyTable tr, table.bodyTable td {
+ margin: 0px;
+ border: 1px solid white;
+ padding: 0px 7px 0px 7px;
+}
+
+#body_column table.bodyTable tr.a {
+ background: #F7F9F4;
+}
+
+#body_column table.bodyTable tr.b {
+ background: #F2F5ED;
+}
+
+#body_column table a.externalLink {
+ background: none;
+ padding-right: 0px;
+}
+
+#body_column table.bodyTable th {
+ padding: 7px 7px 5px 7px;
+ background: #CDDCB8 url("#{resource['images:slices/table_head_dark.png']}") repeat-x;
+}
+
+/* source sections ---------------------------------------------------------- */
+#body_column .source, code {
+ margin: 14px 0px 14px 0px;
+ border: 1px solid #E6E9DA;
+ font-size: 1.1em;
+ font-family: "Courier new", Courier, monospace;
+ color: #333333;
+ background: #F9FAF5 url("#{resource['images:slices/code_section.png']}") repeat-x top;
+}
+
+#body_column b {
+ padding-top: 10px;
+}
+
+#body_column h2 {
+ padding: 5px 10px 5px 10px;
+ border: 1px solid #D8E4C7;
+ background: white url("#{resource['images:slices/h2.png']}") repeat-x top;
+}
+
+.main_content {
+ padding: 30px;
+}
+
+/* copyright ---------------------------------------------------------------- */
+.copyright p {
+ font-size: 0.9em;
+}
\ No newline at end of file
diff --git a/content/examples/deltaspike-fullstack/src/test/java/org/superbiz/deltaspike/test/MockedPageBeanTest.java b/content/examples/deltaspike-fullstack/src/test/java/org/superbiz/deltaspike/test/MockedPageBeanTest.java
new file mode 100755
index 0000000..6b9bb74
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/test/java/org/superbiz/deltaspike/test/MockedPageBeanTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.test;
+
+import junit.framework.Assert;
+import org.apache.deltaspike.core.spi.scope.window.WindowContext;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.apache.deltaspike.testcontrol.api.mock.DynamicMockManager;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.superbiz.deltaspike.WebappMessageBundle;
+import org.superbiz.deltaspike.domain.User;
+import org.superbiz.deltaspike.repository.UserRepository;
+import org.superbiz.deltaspike.repository.jpa.JpaUserRepository;
+import org.superbiz.deltaspike.view.RegistrationPage;
+import org.superbiz.deltaspike.view.config.Pages;
+
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+
+import static org.mockito.Mockito.*;
+
+@Ignore
+@RunWith(CdiTestRunner.class)
+public class MockedPageBeanTest
+{
+ @Inject
+ private RegistrationPage registrationPage; //will use a the mocked UserRepository
+
+ @Inject
+ private WindowContext windowContext;
+
+ @Inject
+ private WebappMessageBundle webappMessageBundle;
+
+ @Inject
+ private DynamicMockManager mockManager;
+
+ @Inject
+ private UserRepository userRepository; //will inject the mocked instance
+
+ @Test
+ public void saveUserWithMockedBean()
+ {
+ final String userName = "gp";
+ final String firstName = "Gerhard";
+ final String lastName = "Petracek";
+
+ UserRepository mockedUserRepository = mock(JpaUserRepository.class); //don't use the interface here to avoid issues with mockito and cdi proxies
+ when(mockedUserRepository.loadUser(userName)).thenReturn(new User(userName, firstName, lastName.toUpperCase() /*just to illustrate that the mock-instance is used*/));
+ mockManager.addMock(mockedUserRepository);
+
+
+ this.windowContext.activateWindow("testWindow");
+
+ this.registrationPage.getUser().setUserName(userName);
+ this.registrationPage.getUser().setFirstName(firstName);
+ this.registrationPage.getUser().setLastName(lastName);
+ this.registrationPage.getUser().setPassword("123");
+
+ Class<? extends Pages> targetPage = this.registrationPage.register();
+
+ Assert.assertEquals(Pages.Login.class, targetPage);
+ Assert.assertFalse(FacesContext.getCurrentInstance().getMessageList().isEmpty());
+ Assert.assertEquals(webappMessageBundle.msgUserRegistered(userName), FacesContext.getCurrentInstance().getMessageList().iterator().next().getSummary());
+
+ User user = this.userRepository.loadUser(userName);
+ Assert.assertNotNull(user);
+ Assert.assertEquals(firstName, user.getFirstName());
+ Assert.assertEquals(lastName.toUpperCase(), user.getLastName());
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/test/java/org/superbiz/deltaspike/test/PageBeanTest.java b/content/examples/deltaspike-fullstack/src/test/java/org/superbiz/deltaspike/test/PageBeanTest.java
new file mode 100755
index 0000000..c3a8935
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/test/java/org/superbiz/deltaspike/test/PageBeanTest.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.deltaspike.test;
+
+import junit.framework.Assert;
+import org.apache.deltaspike.cdise.api.ContextControl;
+import org.apache.deltaspike.core.spi.scope.window.WindowContext;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.superbiz.deltaspike.WebappMessageBundle;
+import org.superbiz.deltaspike.domain.User;
+import org.superbiz.deltaspike.repository.UserRepository;
+import org.superbiz.deltaspike.view.RegistrationPage;
+import org.superbiz.deltaspike.view.config.Pages;
+
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+
+@Ignore
+@RunWith(CdiTestRunner.class)
+public class PageBeanTest
+{
+ @Inject
+ private RegistrationPage registrationPage;
+
+ @Inject
+ private WindowContext windowContext;
+
+ @Inject
+ private WebappMessageBundle webappMessageBundle;
+
+ @Inject
+ private UserRepository userRepository;
+
+ @Inject
+ private ContextControl contextControl;
+
+ @Test
+ public void saveUser()
+ {
+ final String userName = "gp";
+ final String firstName = "Gerhard";
+ final String lastName = "Petracek";
+ this.windowContext.activateWindow("testWindow");
+
+ this.registrationPage.getUser().setUserName(userName);
+ this.registrationPage.getUser().setFirstName(firstName);
+ this.registrationPage.getUser().setLastName(lastName);
+ this.registrationPage.getUser().setPassword("123");
+
+ Class<? extends Pages> targetPage = this.registrationPage.register();
+
+ Assert.assertEquals(Pages.Login.class, targetPage);
+ Assert.assertFalse(FacesContext.getCurrentInstance().getMessageList().isEmpty());
+ Assert.assertEquals(webappMessageBundle.msgUserRegistered(userName), FacesContext.getCurrentInstance().getMessageList().iterator().next().getSummary());
+
+ User user = this.userRepository.loadUser(userName);
+ Assert.assertNotNull(user);
+ Assert.assertEquals(firstName, user.getFirstName());
+ Assert.assertEquals(lastName, user.getLastName());
+ }
+
+ @Test
+ public void saveUserAndLogin()
+ {
+ final String userName = "tt";
+ final String firstName = "Tom";
+ final String lastName = "Tester";
+ this.windowContext.activateWindow("testWindow");
+
+ Assert.assertTrue(FacesContext.getCurrentInstance().getMessageList().isEmpty());
+
+ this.registrationPage.getUser().setUserName(userName);
+ this.registrationPage.getUser().setFirstName(firstName);
+ this.registrationPage.getUser().setLastName(lastName);
+ this.registrationPage.getUser().setPassword("123");
+
+ Class<? extends Pages> targetPage = this.registrationPage.register();
+
+ Assert.assertEquals(Pages.Login.class, targetPage);
+ Assert.assertFalse(FacesContext.getCurrentInstance().getMessageList().isEmpty());
+ Assert.assertEquals(webappMessageBundle.msgUserRegistered(userName), FacesContext.getCurrentInstance().getMessageList().iterator().next().getSummary());
+
+ User user = this.userRepository.loadUser(userName);
+ Assert.assertNotNull(user);
+ Assert.assertEquals(firstName, user.getFirstName());
+ Assert.assertEquals(lastName, user.getLastName());
+
+ this.contextControl.stopContexts();
+ this.contextControl.startContexts();
+ this.windowContext.activateWindow("testWindow");
+
+ Assert.assertTrue(FacesContext.getCurrentInstance().getMessageList().isEmpty());
+
+ this.registrationPage.getUser().setUserName(userName);
+ this.registrationPage.getUser().setFirstName(firstName);
+ this.registrationPage.getUser().setLastName(lastName);
+ this.registrationPage.getUser().setPassword("123");
+
+ targetPage = this.registrationPage.login();
+ Assert.assertEquals(Pages.About.class, targetPage);
+ }
+}
diff --git a/content/examples/deltaspike-fullstack/src/test/resources/META-INF/beans.xml b/content/examples/deltaspike-fullstack/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..4070730
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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>
diff --git a/content/examples/deltaspike-fullstack/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer b/content/examples/deltaspike-fullstack/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer
new file mode 100755
index 0000000..3b2a2c4
--- /dev/null
+++ b/content/examples/deltaspike-fullstack/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerAdapter
diff --git a/content/examples/deltaspike-i18n.html b/content/examples/deltaspike-i18n.html
new file mode 100644
index 0000000..c07a52b
--- /dev/null
+++ b/content/examples/deltaspike-i18n.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/deltaspike-i18n.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>deltaspike-i18n</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example deltaspike-i18n can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/deltaspike-i18n" class="bare">https://github.com/apache/tomee/tree/master/examples/deltaspike-i18n</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/deltaspike-i18n.pdf b/content/examples/deltaspike-i18n.pdf
new file mode 100644
index 0000000..2791161
--- /dev/null
+++ b/content/examples/deltaspike-i18n.pdf
Binary files differ
diff --git a/content/examples/deltaspike-i18n/pom.xml b/content/examples/deltaspike-i18n/pom.xml
new file mode 100755
index 0000000..10d7b40
--- /dev/null
+++ b/content/examples/deltaspike-i18n/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>deltaspike-i18n</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: DeltaSpike I18n</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <version.deltaspike>1.0.0</version.deltaspike>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-impl</artifactId>
+ <version>${version.deltaspike}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-api</artifactId>
+ <version>${version.deltaspike}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- The <scope>test</scope> guarantees that none of your runtime code
+ is dependent on any OpenEJB classes. -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/deltaspike-i18n/src/main/java/org/superbiz/deltaspike/i18n/MessageHelper.java b/content/examples/deltaspike-i18n/src/main/java/org/superbiz/deltaspike/i18n/MessageHelper.java
new file mode 100755
index 0000000..72911dd
--- /dev/null
+++ b/content/examples/deltaspike-i18n/src/main/java/org/superbiz/deltaspike/i18n/MessageHelper.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.i18n;
+
+import org.apache.deltaspike.core.api.message.MessageBundle;
+import org.apache.deltaspike.core.api.message.MessageTemplate;
+
+@MessageBundle
+public interface MessageHelper {
+
+ @MessageTemplate("{openejb.and.deltaspike}")
+ String openejbAndDeltaspike();
+}
diff --git a/content/examples/deltaspike-i18n/src/main/resources/META-INF/beans.xml b/content/examples/deltaspike-i18n/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/deltaspike-i18n/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/deltaspike-i18n/src/main/resources/org/superbiz/deltaspike/i18n/MessageHelper.properties b/content/examples/deltaspike-i18n/src/main/resources/org/superbiz/deltaspike/i18n/MessageHelper.properties
new file mode 100755
index 0000000..42cd78c
--- /dev/null
+++ b/content/examples/deltaspike-i18n/src/main/resources/org/superbiz/deltaspike/i18n/MessageHelper.properties
@@ -0,0 +1,20 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+openejb.and.deltaspike = OpenEJB and DeltaSpike are cool products!
diff --git a/content/examples/deltaspike-i18n/src/test/java/org/superbiz/deltaspike/i18n/MessageHelperTest.java b/content/examples/deltaspike-i18n/src/test/java/org/superbiz/deltaspike/i18n/MessageHelperTest.java
new file mode 100755
index 0000000..72d07ab
--- /dev/null
+++ b/content/examples/deltaspike-i18n/src/test/java/org/superbiz/deltaspike/i18n/MessageHelperTest.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.deltaspike.i18n;
+
+import org.apache.deltaspike.core.impl.config.DefaultConfigSourceProvider;
+import org.apache.deltaspike.core.spi.config.ConfigSourceProvider;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class MessageHelperTest {
+
+ @Inject
+ private MessageHelper msg;
+
+ @Deployment
+ public static WebArchive jar() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addClasses(MessageHelper.class)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
+ .addAsLibraries(JarLocation.jarLocation(ConfigSourceProvider.class))
+ .addAsLibraries(JarLocation.jarLocation(DefaultConfigSourceProvider.class));
+ }
+
+ @Test
+ public void check() {
+ assertNotNull(msg);
+ assertEquals("OpenEJB and DeltaSpike are cool products!", msg.openejbAndDeltaspike());
+ }
+}
diff --git a/content/examples/dynamic-dao-implementation.html b/content/examples/dynamic-dao-implementation.html
new file mode 100644
index 0000000..b34f776
--- /dev/null
+++ b/content/examples/dynamic-dao-implementation.html
@@ -0,0 +1,589 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/dynamic-dao-implementation.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Dynamic DAO Implementation</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example dynamic-dao-implementation can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/dynamic-dao-implementation" class="bare">https://github.com/apache/tomee/tree/master/examples/dynamic-dao-implementation</a></p>
+</div>
+<div class="paragraph">
+<p>Many aspects of Data Access Objects (DAOs) are very repetitive and boiler plate. As a fun and experimental feature, TomEE supports dynamically implementing an interface
+that is seen to have standard DAO-style methods.</p>
+</div>
+<div class="paragraph">
+<p>The interface has to be annotated with @PersistenceContext to define which EntityManager to use.</p>
+</div>
+<div class="paragraph">
+<p>Methods should respect these conventions:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>void save(Foo foo): persist foo</p>
+</li>
+<li>
+<p>Foo update(Foo foo): merge foo</p>
+</li>
+<li>
+<p>void delete(Foo foo): remove foo, if foo is detached it tries to attach it</p>
+</li>
+<li>
+<p>Collection<Foo>|Foo namedQuery(String name[, Map<String, ?> params, int first, int max]): run the named query called name, params contains bindings, first and max are used for magination. Last three parameters are optionnals</p>
+</li>
+<li>
+<p>Collection<Foo>|Foo nativeQuery(String name[, Map<String, ?> params, int first, int max]): run the native query called name, params contains bindings, first and max are used for magination. Last three parameters are optionnals</p>
+</li>
+<li>
+<p>Collection<Foo>|Foo query(String value [, Map<String, ?> params, int first, int max]): run the query put as first parameter, params contains bindings, first and max are used for magination. Last three parameters are optionnals</p>
+</li>
+<li>
+<p>Collection<Foo> findAll([int first, int max]): find all Foo, parameters are used for pagination</p>
+</li>
+<li>
+<p>Collection<Foo> findByBar1AndBar2AndBar3(<bar 1 type> bar1, <bar 2 type> bar2, <bar3 type> bar3 [, int first, int max]): find all Foo with specified field values for bar1, bar2, bar3.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Dynamic finder can have as much as you want field constraints. For String like is used and for other type equals is used.</p>
+</div>
+</div>
+</div>
+<h1 id="_example" class="sect0">Example</h1>
+<div class="sect1">
+<h2 id="_user">User</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "dynamic-ejb-impl-test.query", query = "SELECT u FROM User AS u WHERE u.name LIKE :name"),
+ @NamedQuery(name = "dynamic-ejb-impl-test.all", query = "SELECT u FROM User AS u")
+})
+public class User {
+ @Id
+ @GeneratedValue
+ private long id;
+ private String name;
+ private int age;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_userdao">UserDao</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic;
+
+
+import javax.ejb.Stateless;
+import javax.persistence.PersistenceContext;
+import java.util.Collection;
+import java.util.Map;
+
+@Stateless
+@PersistenceContext(name = "dynamic")
+public interface UserDao {
+ User findById(long id);
+
+ Collection<User> findByName(String name);
+
+ Collection<User> findByNameAndAge(String name, int age);
+
+ Collection<User> findAll();
+
+ Collection<User> findAll(int first, int max);
+
+ Collection<User> namedQuery(String name, Map<String, ?> params, int first, int max);
+
+ Collection<User> namedQuery(String name, int first, int max, Map<String, ?> params);
+
+ Collection<User> namedQuery(String name, Map<String, ?> params);
+
+ Collection<User> namedQuery(String name);
+
+ Collection<User> query(String value, Map<String, ?> params);
+
+ void save(User u);
+
+ void delete(User u);
+
+ User update(User u);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="dynamic" transaction-type="JTA">
+ <jta-data-source>jdbc/dynamicDB</jta-data-source>
+ <class>org.superbiz.dynamic.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_dynamicuserdaotest">DynamicUserDaoTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic;
+
+import junit.framework.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.PersistenceContext;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+public class DynamicUserDaoTest {
+ private static UserDao dao;
+ private static Util util;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ final Properties p = new Properties();
+ p.put("jdbc/dynamicDB", "new://Resource?type=DataSource");
+ p.put("jdbc/dynamicDB.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("jdbc/dynamicDB.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.put("jdbc/dynamicDB.UserName", "sa");
+ p.put("jdbc/dynamicDB.Password", "");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+ dao = (UserDao) context.lookup("java:global/dynamic-dao-implementation/UserDao");
+ util = (Util) context.lookup("java:global/dynamic-dao-implementation/Util");
+
+ util.init(); // init database
+ }
+
+ @Test
+ public void simple() {
+ User user = dao.findById(1);
+ assertNotNull(user);
+ assertEquals(1, user.getId());
+ }
+
+ @Test
+ public void findAll() {
+ Collection<User> users = dao.findAll();
+ assertEquals(10, users.size());
+ }
+
+ @Test
+ public void pagination() {
+ Collection<User> users = dao.findAll(0, 5);
+ assertEquals(5, users.size());
+
+ users = dao.findAll(6, 1);
+ assertEquals(1, users.size());
+ assertEquals(7, users.iterator().next().getId());
+ }
+
+ @Test
+ public void persist() {
+ User u = new User();
+ dao.save(u);
+ assertNotNull(u.getId());
+ util.remove(u);
+ }
+
+ @Test
+ public void remove() {
+ User u = new User();
+ dao.save(u);
+ assertNotNull(u.getId());
+ dao.delete(u);
+ try {
+ dao.findById(u.getId());
+ Assert.fail();
+ } catch (EJBException ee) {
+ assertTrue(ee.getCause() instanceof NoResultException);
+ }
+ }
+
+ @Test
+ public void merge() {
+ User u = new User();
+ u.setAge(1);
+ dao.save(u);
+ assertEquals(1, u.getAge());
+ assertNotNull(u.getId());
+
+ u.setAge(2);
+ dao.update(u);
+ assertEquals(2, u.getAge());
+
+ dao.delete(u);
+ }
+
+ @Test
+ public void oneCriteria() {
+ Collection<User> users = dao.findByName("foo");
+ assertEquals(4, users.size());
+ for (User user : users) {
+ assertEquals("foo", user.getName());
+ }
+ }
+
+ @Test
+ public void twoCriteria() {
+ Collection<User> users = dao.findByNameAndAge("bar-1", 1);
+ assertEquals(1, users.size());
+
+ User user = users.iterator().next();
+ assertEquals("bar-1", user.getName());
+ assertEquals(1, user.getAge());
+ }
+
+ @Test
+ public void query() {
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put("name", "foo");
+
+ Collection<User> users = dao.namedQuery("dynamic-ejb-impl-test.query", params, 0, 100);
+ assertEquals(4, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.query", params);
+ assertEquals(4, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.query", params, 0, 2);
+ assertEquals(2, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.query", 0, 2, params);
+ assertEquals(2, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.all");
+ assertEquals(10, users.size());
+
+ params.remove("name");
+ params.put("age", 1);
+ users = dao.query("SELECT u FROM User AS u WHERE u.age = :age", params);
+ assertEquals(3, users.size());
+ }
+
+ @Stateless
+ public static class Util {
+ @PersistenceContext
+ private EntityManager em;
+
+ public void remove(User o) {
+ em.remove(em.find(User.class, o.getId()));
+ }
+
+ public void init() {
+ for (int i = 0; i < 10; i++) {
+ User u = new User();
+ u.setAge(i % 4);
+ if (i % 3 == 0) {
+ u.setName("foo");
+ } else {
+ u.setName("bar-" + i);
+ }
+ em.persist(u);
+ }
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.dynamic.DynamicUserDaoTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/dynamic-dao-implementation
+INFO - openejb.base = /Users/dblevins/examples/dynamic-dao-implementation
+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 - Configuring Service(id=jdbc/dynamicDB, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/dynamic-dao-implementation/target/classes
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/dynamic-dao-implementation/target/test-classes
+INFO - Beginning load: /Users/dblevins/examples/dynamic-dao-implementation/target/classes
+INFO - Beginning load: /Users/dblevins/examples/dynamic-dao-implementation/target/test-classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/dynamic-dao-implementation
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean UserDao: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.dynamic.DynamicUserDaoTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=dynamic)
+INFO - Auto-creating a Resource with id 'jdbc/dynamicDBNonJta' of type 'DataSource for 'dynamic'.
+INFO - Configuring Service(id=jdbc/dynamicDBNonJta, type=Resource, provider-id=jdbc/dynamicDB)
+INFO - Adjusting PersistenceUnit dynamic <non-jta-data-source> to Resource ID 'jdbc/dynamicDBNonJta' from 'null'
+INFO - Enterprise application "/Users/dblevins/examples/dynamic-dao-implementation" loaded.
+INFO - Assembling app: /Users/dblevins/examples/dynamic-dao-implementation
+INFO - PersistenceUnit(name=dynamic, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 417ms
+INFO - Jndi(name="java:global/dynamic-dao-implementation/UserDao!org.superbiz.dynamic.UserDao")
+INFO - Jndi(name="java:global/dynamic-dao-implementation/UserDao")
+INFO - Jndi(name="java:global/dynamic-dao-implementation/Util!org.superbiz.dynamic.DynamicUserDaoTest$Util")
+INFO - Jndi(name="java:global/dynamic-dao-implementation/Util")
+INFO - Jndi(name="java:global/EjbModule346613126/org.superbiz.dynamic.DynamicUserDaoTest!org.superbiz.dynamic.DynamicUserDaoTest")
+INFO - Jndi(name="java:global/EjbModule346613126/org.superbiz.dynamic.DynamicUserDaoTest")
+INFO - Created Ejb(deployment-id=UserDao, ejb-name=UserDao, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=Util, ejb-name=Util, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.dynamic.DynamicUserDaoTest, ejb-name=org.superbiz.dynamic.DynamicUserDaoTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=UserDao, ejb-name=UserDao, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=Util, ejb-name=Util, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.dynamic.DynamicUserDaoTest, ejb-name=org.superbiz.dynamic.DynamicUserDaoTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/dynamic-dao-implementation)
+WARN - Meta class "org.superbiz.dynamic.User_" for entity class org.superbiz.dynamic.User can not be registered with following exception "java.security.PrivilegedActionException: java.lang.ClassNotFoundException: org.superbiz.dynamic.User_"
+WARN - Query "SELECT u FROM User AS u WHERE u.name LIKE :name" is removed from cache excluded permanently. Query "SELECT u FROM User AS u WHERE u.name LIKE :name" is not cached because it uses pagination..
+Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.471 sec
+
+Results :
+
+Tests run: 9, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/dynamic-dao-implementation.pdf b/content/examples/dynamic-dao-implementation.pdf
new file mode 100644
index 0000000..227da77
--- /dev/null
+++ b/content/examples/dynamic-dao-implementation.pdf
Binary files differ
diff --git a/content/examples/dynamic-dao-implementation/README.md b/content/examples/dynamic-dao-implementation/README.md
new file mode 100755
index 0000000..2c71e56
--- /dev/null
+++ b/content/examples/dynamic-dao-implementation/README.md
@@ -0,0 +1,352 @@
+Title: Dynamic DAO Implementation
+
+Many aspects of Data Access Objects (DAOs) are very repetitive and boiler plate. As a fun and experimental feature, TomEE supports dynamically implementing an interface
+that is seen to have standard DAO-style methods.
+
+The interface has to be annotated with @PersistenceContext to define which EntityManager to use.
+
+Methods should respect these conventions:
+
+ * void save(Foo foo): persist foo
+ * Foo update(Foo foo): merge foo
+ * void delete(Foo foo): remove foo, if foo is detached it tries to attach it
+ * Collection<Foo>|Foo namedQuery(String name[, Map<String, ?> params, int first, int max]): run the named query called name, params contains bindings, first and max are used for magination. Last three parameters are optionnals
+ * Collection<Foo>|Foo nativeQuery(String name[, Map<String, ?> params, int first, int max]): run the native query called name, params contains bindings, first and max are used for magination. Last three parameters are optionnals
+ * Collection<Foo>|Foo query(String value [, Map<String, ?> params, int first, int max]): run the query put as first parameter, params contains bindings, first and max are used for magination. Last three parameters are optionnals
+ * Collection<Foo> findAll([int first, int max]): find all Foo, parameters are used for pagination
+ * Collection<Foo> findByBar1AndBar2AndBar3(<bar 1 type> bar1, <bar 2 type> bar2, <bar3 type> bar3 [, int first, int max]): find all Foo with specified field values for bar1, bar2, bar3.
+
+Dynamic finder can have as much as you want field constraints. For String like is used and for other type equals is used.
+
+# Example
+
+## User
+
+ package org.superbiz.dynamic;
+
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.Id;
+ import javax.persistence.NamedQueries;
+ import javax.persistence.NamedQuery;
+
+ @Entity
+ @NamedQueries({
+ @NamedQuery(name = "dynamic-ejb-impl-test.query", query = "SELECT u FROM User AS u WHERE u.name LIKE :name"),
+ @NamedQuery(name = "dynamic-ejb-impl-test.all", query = "SELECT u FROM User AS u")
+ })
+ public class User {
+ @Id
+ @GeneratedValue
+ private long id;
+ private String name;
+ private int age;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+ }
+
+## UserDao
+
+ package org.superbiz.dynamic;
+
+
+ import javax.ejb.Stateless;
+ import javax.persistence.PersistenceContext;
+ import java.util.Collection;
+ import java.util.Map;
+
+ @Stateless
+ @PersistenceContext(name = "dynamic")
+ public interface UserDao {
+ User findById(long id);
+
+ Collection<User> findByName(String name);
+
+ Collection<User> findByNameAndAge(String name, int age);
+
+ Collection<User> findAll();
+
+ Collection<User> findAll(int first, int max);
+
+ Collection<User> namedQuery(String name, Map<String, ?> params, int first, int max);
+
+ Collection<User> namedQuery(String name, int first, int max, Map<String, ?> params);
+
+ Collection<User> namedQuery(String name, Map<String, ?> params);
+
+ Collection<User> namedQuery(String name);
+
+ Collection<User> query(String value, Map<String, ?> params);
+
+ void save(User u);
+
+ void delete(User u);
+
+ User update(User u);
+ }
+
+## persistence.xml
+
+ <persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="dynamic" transaction-type="JTA">
+ <jta-data-source>jdbc/dynamicDB</jta-data-source>
+ <class>org.superbiz.dynamic.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+
+## DynamicUserDaoTest
+
+ package org.superbiz.dynamic;
+
+ import junit.framework.Assert;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+
+ import javax.ejb.EJBException;
+ import javax.ejb.Stateless;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import javax.persistence.EntityManager;
+ import javax.persistence.NoResultException;
+ import javax.persistence.PersistenceContext;
+ import java.util.Collection;
+ import java.util.HashMap;
+ import java.util.Map;
+ import java.util.Properties;
+
+ import static junit.framework.Assert.assertEquals;
+ import static junit.framework.Assert.assertNotNull;
+ import static junit.framework.Assert.assertTrue;
+
+ public class DynamicUserDaoTest {
+ private static UserDao dao;
+ private static Util util;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ final Properties p = new Properties();
+ p.put("jdbc/dynamicDB", "new://Resource?type=DataSource");
+ p.put("jdbc/dynamicDB.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("jdbc/dynamicDB.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.put("jdbc/dynamicDB.UserName", "sa");
+ p.put("jdbc/dynamicDB.Password", "");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+ dao = (UserDao) context.lookup("java:global/dynamic-dao-implementation/UserDao");
+ util = (Util) context.lookup("java:global/dynamic-dao-implementation/Util");
+
+ util.init(); // init database
+ }
+
+ @Test
+ public void simple() {
+ User user = dao.findById(1);
+ assertNotNull(user);
+ assertEquals(1, user.getId());
+ }
+
+ @Test
+ public void findAll() {
+ Collection<User> users = dao.findAll();
+ assertEquals(10, users.size());
+ }
+
+ @Test
+ public void pagination() {
+ Collection<User> users = dao.findAll(0, 5);
+ assertEquals(5, users.size());
+
+ users = dao.findAll(6, 1);
+ assertEquals(1, users.size());
+ assertEquals(7, users.iterator().next().getId());
+ }
+
+ @Test
+ public void persist() {
+ User u = new User();
+ dao.save(u);
+ assertNotNull(u.getId());
+ util.remove(u);
+ }
+
+ @Test
+ public void remove() {
+ User u = new User();
+ dao.save(u);
+ assertNotNull(u.getId());
+ dao.delete(u);
+ try {
+ dao.findById(u.getId());
+ Assert.fail();
+ } catch (EJBException ee) {
+ assertTrue(ee.getCause() instanceof NoResultException);
+ }
+ }
+
+ @Test
+ public void merge() {
+ User u = new User();
+ u.setAge(1);
+ dao.save(u);
+ assertEquals(1, u.getAge());
+ assertNotNull(u.getId());
+
+ u.setAge(2);
+ dao.update(u);
+ assertEquals(2, u.getAge());
+
+ dao.delete(u);
+ }
+
+ @Test
+ public void oneCriteria() {
+ Collection<User> users = dao.findByName("foo");
+ assertEquals(4, users.size());
+ for (User user : users) {
+ assertEquals("foo", user.getName());
+ }
+ }
+
+ @Test
+ public void twoCriteria() {
+ Collection<User> users = dao.findByNameAndAge("bar-1", 1);
+ assertEquals(1, users.size());
+
+ User user = users.iterator().next();
+ assertEquals("bar-1", user.getName());
+ assertEquals(1, user.getAge());
+ }
+
+ @Test
+ public void query() {
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put("name", "foo");
+
+ Collection<User> users = dao.namedQuery("dynamic-ejb-impl-test.query", params, 0, 100);
+ assertEquals(4, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.query", params);
+ assertEquals(4, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.query", params, 0, 2);
+ assertEquals(2, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.query", 0, 2, params);
+ assertEquals(2, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.all");
+ assertEquals(10, users.size());
+
+ params.remove("name");
+ params.put("age", 1);
+ users = dao.query("SELECT u FROM User AS u WHERE u.age = :age", params);
+ assertEquals(3, users.size());
+ }
+
+ @Stateless
+ public static class Util {
+ @PersistenceContext
+ private EntityManager em;
+
+ public void remove(User o) {
+ em.remove(em.find(User.class, o.getId()));
+ }
+
+ public void init() {
+ for (int i = 0; i < 10; i++) {
+ User u = new User();
+ u.setAge(i % 4);
+ if (i % 3 == 0) {
+ u.setName("foo");
+ } else {
+ u.setName("bar-" + i);
+ }
+ em.persist(u);
+ }
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.dynamic.DynamicUserDaoTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/dynamic-dao-implementation
+ INFO - openejb.base = /Users/dblevins/examples/dynamic-dao-implementation
+ 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 - Configuring Service(id=jdbc/dynamicDB, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/dynamic-dao-implementation/target/classes
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/dynamic-dao-implementation/target/test-classes
+ INFO - Beginning load: /Users/dblevins/examples/dynamic-dao-implementation/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/dynamic-dao-implementation/target/test-classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/dynamic-dao-implementation
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean UserDao: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.dynamic.DynamicUserDaoTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=dynamic)
+ INFO - Auto-creating a Resource with id 'jdbc/dynamicDBNonJta' of type 'DataSource for 'dynamic'.
+ INFO - Configuring Service(id=jdbc/dynamicDBNonJta, type=Resource, provider-id=jdbc/dynamicDB)
+ INFO - Adjusting PersistenceUnit dynamic <non-jta-data-source> to Resource ID 'jdbc/dynamicDBNonJta' from 'null'
+ INFO - Enterprise application "/Users/dblevins/examples/dynamic-dao-implementation" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/dynamic-dao-implementation
+ INFO - PersistenceUnit(name=dynamic, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 417ms
+ INFO - Jndi(name="java:global/dynamic-dao-implementation/UserDao!org.superbiz.dynamic.UserDao")
+ INFO - Jndi(name="java:global/dynamic-dao-implementation/UserDao")
+ INFO - Jndi(name="java:global/dynamic-dao-implementation/Util!org.superbiz.dynamic.DynamicUserDaoTest$Util")
+ INFO - Jndi(name="java:global/dynamic-dao-implementation/Util")
+ INFO - Jndi(name="java:global/EjbModule346613126/org.superbiz.dynamic.DynamicUserDaoTest!org.superbiz.dynamic.DynamicUserDaoTest")
+ INFO - Jndi(name="java:global/EjbModule346613126/org.superbiz.dynamic.DynamicUserDaoTest")
+ INFO - Created Ejb(deployment-id=UserDao, ejb-name=UserDao, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=Util, ejb-name=Util, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.dynamic.DynamicUserDaoTest, ejb-name=org.superbiz.dynamic.DynamicUserDaoTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=UserDao, ejb-name=UserDao, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=Util, ejb-name=Util, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.dynamic.DynamicUserDaoTest, ejb-name=org.superbiz.dynamic.DynamicUserDaoTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/dynamic-dao-implementation)
+ WARN - Meta class "org.superbiz.dynamic.User_" for entity class org.superbiz.dynamic.User can not be registered with following exception "java.security.PrivilegedActionException: java.lang.ClassNotFoundException: org.superbiz.dynamic.User_"
+ WARN - Query "SELECT u FROM User AS u WHERE u.name LIKE :name" is removed from cache excluded permanently. Query "SELECT u FROM User AS u WHERE u.name LIKE :name" is not cached because it uses pagination..
+ Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.471 sec
+
+ Results :
+
+ Tests run: 9, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/dynamic-dao-implementation/pom.xml b/content/examples/dynamic-dao-implementation/pom.xml
new file mode 100755
index 0000000..3b650ca
--- /dev/null
+++ b/content/examples/dynamic-dao-implementation/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>dynamic-dao-implementation</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Dynamic DAO Implementation</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/dynamic-dao-implementation/src/main/java/org/superbiz/dynamic/User.java b/content/examples/dynamic-dao-implementation/src/main/java/org/superbiz/dynamic/User.java
new file mode 100755
index 0000000..c5d51f7
--- /dev/null
+++ b/content/examples/dynamic-dao-implementation/src/main/java/org/superbiz/dynamic/User.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "dynamic-ejb-impl-test.query", query = "SELECT u FROM User AS u WHERE u.name LIKE :name"),
+ @NamedQuery(name = "dynamic-ejb-impl-test.all", query = "SELECT u FROM User AS u")
+ })
+public class User {
+
+ @Id
+ @GeneratedValue
+ private long id;
+ private String name;
+ private int age;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
diff --git a/content/examples/dynamic-dao-implementation/src/main/java/org/superbiz/dynamic/UserDao.java b/content/examples/dynamic-dao-implementation/src/main/java/org/superbiz/dynamic/UserDao.java
new file mode 100755
index 0000000..ebe37ae
--- /dev/null
+++ b/content/examples/dynamic-dao-implementation/src/main/java/org/superbiz/dynamic/UserDao.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import javax.ejb.Stateless;
+import javax.persistence.PersistenceContext;
+import java.util.Collection;
+import java.util.Map;
+
+@Stateless
+@PersistenceContext(name = "dynamic")
+public interface UserDao {
+
+ User findById(long id);
+
+ Collection<User> findByName(String name);
+
+ Collection<User> findByNameAndAge(String name, int age);
+
+ Collection<User> findAll();
+
+ Collection<User> findAll(int first, int max);
+
+ Collection<User> namedQuery(String name, Map<String, ?> params, int first, int max);
+
+ Collection<User> namedQuery(String name, int first, int max, Map<String, ?> params);
+
+ Collection<User> namedQuery(String name, Map<String, ?> params);
+
+ Collection<User> namedQuery(String name);
+
+ Collection<User> query(String value, Map<String, ?> params);
+
+ void save(User u);
+
+ void delete(User u);
+
+ User update(User u);
+}
diff --git a/content/examples/dynamic-dao-implementation/src/main/resources/META-INF/persistence.xml b/content/examples/dynamic-dao-implementation/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..97d2ba5
--- /dev/null
+++ b/content/examples/dynamic-dao-implementation/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="dynamic" transaction-type="JTA">
+ <jta-data-source>jdbc/dynamicDB</jta-data-source>
+ <class>org.superbiz.dynamic.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/dynamic-dao-implementation/src/test/java/org/superbiz/dynamic/DynamicUserDaoTest.java b/content/examples/dynamic-dao-implementation/src/test/java/org/superbiz/dynamic/DynamicUserDaoTest.java
new file mode 100755
index 0000000..45eee6b
--- /dev/null
+++ b/content/examples/dynamic-dao-implementation/src/test/java/org/superbiz/dynamic/DynamicUserDaoTest.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.PersistenceContext;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class DynamicUserDaoTest {
+
+ private static UserDao dao;
+ private static Util util;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ final Properties p = new Properties();
+ p.put("jdbc/dynamicDB", "new://Resource?type=DataSource");
+ p.put("jdbc/dynamicDB.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("jdbc/dynamicDB.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.put("jdbc/dynamicDB.UserName", "sa");
+ p.put("jdbc/dynamicDB.Password", "");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+ dao = (UserDao) context.lookup("java:global/dynamic-dao-implementation/UserDao");
+ util = (Util) context.lookup("java:global/dynamic-dao-implementation/Util");
+
+ util.init(); // init database
+ }
+
+ @Test
+ public void simple() {
+ User user = dao.findById(1);
+ assertNotNull(user);
+ assertEquals(1, user.getId());
+ }
+
+ @Test
+ public void findAll() {
+ Collection<User> users = dao.findAll();
+ assertEquals(10, users.size());
+ }
+
+ @Test
+ public void pagination() {
+ Collection<User> users = dao.findAll(0, 5);
+ assertEquals(5, users.size());
+
+ users = dao.findAll(6, 1);
+ assertEquals(1, users.size());
+ assertEquals(7, users.iterator().next().getId());
+ }
+
+ @Test
+ public void persist() {
+ User u = new User();
+ dao.save(u);
+ assertNotNull(u.getId());
+ util.remove(u);
+ }
+
+ @Test
+ public void remove() {
+ User u = new User();
+ dao.save(u);
+ assertNotNull(u.getId());
+ dao.delete(u);
+ try {
+ dao.findById(u.getId());
+ Assert.fail();
+ } catch (EJBException ee) {
+ assertTrue(ee.getCause() instanceof NoResultException);
+ }
+ }
+
+ @Test
+ public void merge() {
+ User u = new User();
+ u.setAge(1);
+ dao.save(u);
+ assertEquals(1, u.getAge());
+ assertNotNull(u.getId());
+
+ u.setAge(2);
+ dao.update(u);
+ assertEquals(2, u.getAge());
+
+ dao.delete(u);
+ }
+
+ @Test
+ public void oneCriteria() {
+ Collection<User> users = dao.findByName("foo");
+ assertEquals(4, users.size());
+ for (User user : users) {
+ assertEquals("foo", user.getName());
+ }
+ }
+
+ @Test
+ public void twoCriteria() {
+ Collection<User> users = dao.findByNameAndAge("bar-1", 1);
+ assertEquals(1, users.size());
+
+ User user = users.iterator().next();
+ assertEquals("bar-1", user.getName());
+ assertEquals(1, user.getAge());
+ }
+
+ @Test
+ public void query() {
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put("name", "foo");
+
+ Collection<User> users = dao.namedQuery("dynamic-ejb-impl-test.query", params, 0, 100);
+ assertEquals(4, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.query", params);
+ assertEquals(4, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.query", params, 0, 2);
+ assertEquals(2, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.query", 0, 2, params);
+ assertEquals(2, users.size());
+
+ users = dao.namedQuery("dynamic-ejb-impl-test.all");
+ assertEquals(10, users.size());
+
+ params.remove("name");
+ params.put("age", 1);
+ users = dao.query("SELECT u FROM User AS u WHERE u.age = :age", params);
+ assertEquals(3, users.size());
+ }
+
+ @Stateless
+ public static class Util {
+
+ @PersistenceContext
+ private EntityManager em;
+
+ public void remove(User o) {
+ em.remove(em.find(User.class, o.getId()));
+ }
+
+ public void init() {
+ for (int i = 0; i < 10; i++) {
+ User u = new User();
+ u.setAge(i % 4);
+ if (i % 3 == 0) {
+ u.setName("foo");
+ } else {
+ u.setName("bar-" + i);
+ }
+ em.persist(u);
+ }
+ }
+
+ }
+}
diff --git a/content/examples/dynamic-datasource-routing.html b/content/examples/dynamic-datasource-routing.html
new file mode 100644
index 0000000..49ff727
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing.html
@@ -0,0 +1,651 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/dynamic-datasource-routing.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Dynamic Datasource Routing</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example dynamic-datasource-routing can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/dynamic-datasource-routing" class="bare">https://github.com/apache/tomee/tree/master/examples/dynamic-datasource-routing</a></p>
+</div>
+<div class="paragraph">
+<p>The TomEE dynamic datasource api aims to allow to use multiple data sources as one from an application point of view.</p>
+</div>
+<div class="paragraph">
+<p>It can be useful for technical reasons (load balancing for example) or more generally
+functionnal reasons (filtering, aggregation, enriching…​). However please note you can choose
+only one datasource by transaction. It means the goal of this feature is not to switch more than
+once of datasource in a transaction. The following code will not work:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stateless
+public class MyEJB {
+ @Resource private MyRouter router;
+ @PersistenceContext private EntityManager em;
+
+ public void workWithDataSources() {
+ router.setDataSource("ds1");
+ em.persist(new MyEntity());
+
+ router.setDataSource("ds2"); // same transaction -> this invocation doesn't work
+ em.persist(new MyEntity());
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In this example the implementation simply use a datasource from its name and needs to be set before using any JPA
+operation in the transaction (to keep the logic simple in the example).</p>
+</div>
+</div>
+</div>
+<h1 id="_the_implementation_of_the_router" class="sect0">The implementation of the Router</h1>
+<div class="paragraph">
+<p>Our router has two configuration parameters:
+* a list of jndi names representing datasources to use
+* a default datasource to use</p>
+</div>
+<div class="sect1">
+<h2 id="_router_implementation">Router implementation</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The interface Router (<code>org.apache.openejb.resource.jdbc.Router</code>) has only one method to implement, <code>public DataSource getDataSource()</code></p>
+</div>
+<div class="paragraph">
+<p>Our <code>DeterminedRouter</code> implementation uses a ThreadLocal to manage the currently used datasource. Keep in mind JPA used more than once the getDatasource() method
+for one operation. To change the datasource in one transaction is dangerous and should be avoid.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamicdatasourcerouting;
+
+import org.apache.openejb.resource.jdbc.AbstractRouter;
+
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class DeterminedRouter extends AbstractRouter {
+ private String dataSourceNames;
+ private String defaultDataSourceName;
+ private Map<String, DataSource> dataSources = null;
+ private ThreadLocal<DataSource> currentDataSource = new ThreadLocal<DataSource>();
+
+ /**
+ * @param datasourceList datasource resource name, separator is a space
+ */
+ public void setDataSourceNames(String datasourceList) {
+ dataSourceNames = datasourceList;
+ }
+
+ /**
+ * lookup datasource in openejb resources
+ */
+ private void init() {
+ dataSources = new ConcurrentHashMap<String, DataSource>();
+ for (String ds : dataSourceNames.split(" ")) {
+ try {
+ Object o = getOpenEJBResource(ds);
+ if (o instanceof DataSource) {
+ dataSources.put(ds, DataSource.class.cast(o));
+ }
+ } catch (NamingException e) {
+ // ignored
+ }
+ }
+ }
+
+ /**
+ * @return the user selected data source if it is set
+ * or the default one
+ * @throws IllegalArgumentException if the data source is not found
+ */
+ @Override
+ public DataSource getDataSource() {
+ // lazy init of routed datasources
+ if (dataSources == null) {
+ init();
+ }
+
+ // if no datasource is selected use the default one
+ if (currentDataSource.get() == null) {
+ if (dataSources.containsKey(defaultDataSourceName)) {
+ return dataSources.get(defaultDataSourceName);
+
+ } else {
+ throw new IllegalArgumentException("you have to specify at least one datasource");
+ }
+ }
+
+ // the developper set the datasource to use
+ return currentDataSource.get();
+ }
+
+ /**
+ *
+ * @param datasourceName data source name
+ */
+ public void setDataSource(String datasourceName) {
+ if (dataSources == null) {
+ init();
+ }
+ if (!dataSources.containsKey(datasourceName)) {
+ throw new IllegalArgumentException("data source called " + datasourceName + " can't be found.");
+ }
+ DataSource ds = dataSources.get(datasourceName);
+ currentDataSource.set(ds);
+ }
+
+ /**
+ * reset the data source
+ */
+ public void clear() {
+ currentDataSource.remove();
+ }
+
+ public void setDefaultDataSourceName(String name) {
+ this.defaultDataSourceName = name;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_declaring_the_implementation">Declaring the implementation</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>To be able to use your router as a resource you need to provide a service configuration. It is done in a file
+you can find in META-INF/org.router/ and called service-jar.xml
+(for your implementation you can of course change the package name).</p>
+</div>
+<div class="paragraph">
+<p>It contains the following code:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ServiceJar>
+ <ServiceProvider id="DeterminedRouter" <!-- the name you want to use -->
+ service="Resource"
+ type="org.apache.openejb.resource.jdbc.Router"
+ class-name="org.superbiz.dynamicdatasourcerouting.DeterminedRouter"> <!-- implementation class -->
+
+ # the parameters
+
+ DataSourceNames
+ DefaultDataSourceName
+ </ServiceProvider>
+</ServiceJar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_using_the_router" class="sect0">Using the Router</h1>
+<div class="paragraph">
+<p>Here we have a <code>RoutedPersister</code> stateless bean which uses our <code>DeterminedRouter</code></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamicdatasourcerouting;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Stateless
+public class RoutedPersister {
+ @PersistenceContext(unitName = "router")
+ private EntityManager em;
+
+ @Resource(name = "My Router", type = DeterminedRouter.class)
+ private DeterminedRouter router;
+
+ public void persist(int id, String name, String ds) {
+ router.setDataSource(ds);
+ em.persist(new Person(id, name));
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_the_test" class="sect0">The test</h1>
+<div class="paragraph">
+<p>In test mode and using property style configuration the foolowing configuration is used:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class DynamicDataSourceTest {
+ @Test
+ public void route() throws Exception {
+ String[] databases = new String[]{"database1", "database2", "database3"};
+
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
+
+ // resources
+ // datasources
+ for (int i = 1; i <= databases.length; i++) {
+ String dbName = databases[i - 1];
+ properties.setProperty(dbName, "new://Resource?type=DataSource");
+ dbName += ".";
+ properties.setProperty(dbName + "JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty(dbName + "JdbcUrl", "jdbc:hsqldb:mem:db" + i);
+ properties.setProperty(dbName + "UserName", "sa");
+ properties.setProperty(dbName + "Password", "");
+ properties.setProperty(dbName + "JtaManaged", "true");
+ }
+
+ // router
+ properties.setProperty("My Router", "new://Resource?provider=org.router:DeterminedRouter&type=" + DeterminedRouter.class.getName());
+ properties.setProperty("My Router.DatasourceNames", "database1 database2 database3");
+ properties.setProperty("My Router.DefaultDataSourceName", "database1");
+
+ // routed datasource
+ properties.setProperty("Routed Datasource", "new://Resource?provider=RoutedDataSource&type=" + Router.class.getName());
+ properties.setProperty("Routed Datasource.Router", "My Router");
+
+ Context ctx = EJBContainer.createEJBContainer(properties).getContext();
+ RoutedPersister ejb = (RoutedPersister) ctx.lookup("java:global/dynamic-datasource-routing/RoutedPersister");
+ for (int i = 0; i < 18; i++) {
+ // persisting a person on database db -> kind of manual round robin
+ String name = "record " + i;
+ String db = databases[i % 3];
+ ejb.persist(i, name, db);
+ }
+
+ // assert database records number using jdbc
+ for (int i = 1; i <= databases.length; i++) {
+ Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:db" + i, "sa", "");
+ Statement st = connection.createStatement();
+ ResultSet rs = st.executeQuery("select count(*) from PERSON");
+ rs.next();
+ assertEquals(6, rs.getInt(1));
+ st.close();
+ connection.close();
+ }
+
+ ctx.close();
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_configuration_via_openejb_xml" class="sect0">Configuration via openejb.xml</h1>
+<div class="paragraph">
+<p>The testcase above uses properties for configuration. The identical way to do it via the <code>conf/openejb.xml</code> is as follows:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><!-- Router and datasource -->
+<Resource id="My Router" type="org.apache.openejb.router.test.DynamicDataSourceTest$DeterminedRouter" provider="org.routertest:DeterminedRouter">
+ DatasourceNames = database1 database2 database3
+ DefaultDataSourceName = database1
+</Resource></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><Resource id="Routed Datasource" type="org.apache.openejb.resource.jdbc.Router" provider="RoutedDataSource">
+ Router = My Router
+</Resource></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><!-- real datasources -->
+<Resource id="database1" type="DataSource">
+ JdbcDriver = org.hsqldb.jdbcDriver
+ JdbcUrl = jdbc:hsqldb:mem:db1
+ UserName = sa
+ Password
+ JtaManaged = true
+</Resource></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><Resource id="database2" type="DataSource">
+ JdbcDriver = org.hsqldb.jdbcDriver
+ JdbcUrl = jdbc:hsqldb:mem:db2
+ UserName = sa
+ Password
+ JtaManaged = true
+</Resource></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><Resource id="database3" type="DataSource">
+ JdbcDriver = org.hsqldb.jdbcDriver
+ JdbcUrl = jdbc:hsqldb:mem:db3
+ UserName = sa
+ Password
+ JtaManaged = true
+</Resource></code></pre>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_some_hack_for_openjpa">Some hack for OpenJPA</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Using more than one datasource behind one EntityManager means the databases are already created. If it is not the case,
+the JPA provider has to create the datasource at boot time.</p>
+</div>
+<div class="paragraph">
+<p>Hibernate do it so if you declare your databases it will work. However with OpenJPA
+(the default JPA provider for OpenEJB), the creation is lazy and it happens only once so when you’ll switch of database
+it will no more work.</p>
+</div>
+<div class="paragraph">
+<p>Of course OpenEJB provides @Singleton and @Startup features of Java EE 6 and we can do a bean just making a simple find,
+even on none existing entities, just to force the database creation:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Startup
+@Singleton
+public class BoostrapUtility {
+ // inject all real databases
+
+ @PersistenceContext(unitName = "db1")
+ private EntityManager em1;
+
+ @PersistenceContext(unitName = "db2")
+ private EntityManager em2;
+
+ @PersistenceContext(unitName = "db3")
+ private EntityManager em3;
+
+ // force database creation
+
+ @PostConstruct
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void initDatabase() {
+ em1.find(Person.class, 0);
+ em2.find(Person.class, 0);
+ em3.find(Person.class, 0);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_using_the_routed_datasource">Using the routed datasource</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Now you configured the way you want to route your JPA operation, you registered the resources and you initialized
+your databases you can use it and see how it is simple:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stateless
+public class RoutedPersister {
+ // injection of the "proxied" datasource
+ @PersistenceContext(unitName = "router")
+ private EntityManager em;
+
+ // injection of the router you need it to configured the database
+ @Resource(name = "My Router", type = DeterminedRouter.class)
+ private DeterminedRouter router;
+
+ public void persist(int id, String name, String ds) {
+ router.setDataSource(ds); // configuring the database for the current transaction
+ em.persist(new Person(id, name)); // will use ds database automatically
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/dynamic-datasource-routing
+INFO - openejb.base = /Users/dblevins/examples/dynamic-datasource-routing
+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 - Configuring Service(id=My Router, type=Resource, provider-id=DeterminedRouter)
+INFO - Configuring Service(id=database3, type=Resource, provider-id=Default JDBC Database)
+INFO - Configuring Service(id=database2, type=Resource, provider-id=Default JDBC Database)
+INFO - Configuring Service(id=Routed Datasource, type=Resource, provider-id=RoutedDataSource)
+INFO - Configuring Service(id=database1, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/dynamic-datasource-routing/target/classes
+INFO - Beginning load: /Users/dblevins/examples/dynamic-datasource-routing/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/dynamic-datasource-routing
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean BoostrapUtility: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean RoutedPersister: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Auto-linking resource-ref 'java:comp/env/My Router' in bean RoutedPersister to Resource(id=My Router)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=router)
+INFO - Configuring PersistenceUnit(name=db1)
+INFO - Auto-creating a Resource with id 'database1NonJta' of type 'DataSource for 'db1'.
+INFO - Configuring Service(id=database1NonJta, type=Resource, provider-id=database1)
+INFO - Adjusting PersistenceUnit db1 <non-jta-data-source> to Resource ID 'database1NonJta' from 'null'
+INFO - Configuring PersistenceUnit(name=db2)
+INFO - Auto-creating a Resource with id 'database2NonJta' of type 'DataSource for 'db2'.
+INFO - Configuring Service(id=database2NonJta, type=Resource, provider-id=database2)
+INFO - Adjusting PersistenceUnit db2 <non-jta-data-source> to Resource ID 'database2NonJta' from 'null'
+INFO - Configuring PersistenceUnit(name=db3)
+INFO - Auto-creating a Resource with id 'database3NonJta' of type 'DataSource for 'db3'.
+INFO - Configuring Service(id=database3NonJta, type=Resource, provider-id=database3)
+INFO - Adjusting PersistenceUnit db3 <non-jta-data-source> to Resource ID 'database3NonJta' from 'null'
+INFO - Enterprise application "/Users/dblevins/examples/dynamic-datasource-routing" loaded.
+INFO - Assembling app: /Users/dblevins/examples/dynamic-datasource-routing
+INFO - PersistenceUnit(name=router, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 504ms
+INFO - PersistenceUnit(name=db1, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 11ms
+INFO - PersistenceUnit(name=db2, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 7ms
+INFO - PersistenceUnit(name=db3, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 6ms
+INFO - Jndi(name="java:global/dynamic-datasource-routing/BoostrapUtility!org.superbiz.dynamicdatasourcerouting.BoostrapUtility")
+INFO - Jndi(name="java:global/dynamic-datasource-routing/BoostrapUtility")
+INFO - Jndi(name="java:global/dynamic-datasource-routing/RoutedPersister!org.superbiz.dynamicdatasourcerouting.RoutedPersister")
+INFO - Jndi(name="java:global/dynamic-datasource-routing/RoutedPersister")
+INFO - Jndi(name="java:global/EjbModule1519652738/org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest!org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest")
+INFO - Jndi(name="java:global/EjbModule1519652738/org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest")
+INFO - Created Ejb(deployment-id=RoutedPersister, ejb-name=RoutedPersister, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest, ejb-name=org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=BoostrapUtility, ejb-name=BoostrapUtility, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=RoutedPersister, ejb-name=RoutedPersister, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest, ejb-name=org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=BoostrapUtility, ejb-name=BoostrapUtility, container=Default Singleton Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/dynamic-datasource-routing)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.504 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/dynamic-datasource-routing.pdf b/content/examples/dynamic-datasource-routing.pdf
new file mode 100644
index 0000000..a236a52
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing.pdf
Binary files differ
diff --git a/content/examples/dynamic-datasource-routing/README.md b/content/examples/dynamic-datasource-routing/README.md
new file mode 100755
index 0000000..0ce34a5
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing/README.md
@@ -0,0 +1,401 @@
+Title: Dynamic Datasource Routing
+
+The TomEE dynamic datasource api aims to allow to use multiple data sources as one from an application point of view.
+
+It can be useful for technical reasons (load balancing for example) or more generally
+functionnal reasons (filtering, aggregation, enriching...). However please note you can choose
+only one datasource by transaction. It means the goal of this feature is not to switch more than
+once of datasource in a transaction. The following code will not work:
+
+ @Stateless
+ public class MyEJB {
+ @Resource private MyRouter router;
+ @PersistenceContext private EntityManager em;
+
+ public void workWithDataSources() {
+ router.setDataSource("ds1");
+ em.persist(new MyEntity());
+
+ router.setDataSource("ds2"); // same transaction -> this invocation doesn't work
+ em.persist(new MyEntity());
+ }
+ }
+
+In this example the implementation simply use a datasource from its name and needs to be set before using any JPA
+operation in the transaction (to keep the logic simple in the example).
+
+# The implementation of the Router
+
+Our router has two configuration parameters:
+* a list of jndi names representing datasources to use
+* a default datasource to use
+
+## Router implementation
+
+The interface Router (`org.apache.openejb.resource.jdbc.Router`) has only one method to implement, `public DataSource getDataSource()`
+
+Our `DeterminedRouter` implementation uses a ThreadLocal to manage the currently used datasource. Keep in mind JPA used more than once the getDatasource() method
+for one operation. To change the datasource in one transaction is dangerous and should be avoid.
+
+ package org.superbiz.dynamicdatasourcerouting;
+
+ import org.apache.openejb.resource.jdbc.AbstractRouter;
+
+ import javax.naming.NamingException;
+ import javax.sql.DataSource;
+ import java.util.Map;
+ import java.util.concurrent.ConcurrentHashMap;
+
+ public class DeterminedRouter extends AbstractRouter {
+ private String dataSourceNames;
+ private String defaultDataSourceName;
+ private Map<String, DataSource> dataSources = null;
+ private ThreadLocal<DataSource> currentDataSource = new ThreadLocal<DataSource>();
+
+ /**
+ * @param datasourceList datasource resource name, separator is a space
+ */
+ public void setDataSourceNames(String datasourceList) {
+ dataSourceNames = datasourceList;
+ }
+
+ /**
+ * lookup datasource in openejb resources
+ */
+ private void init() {
+ dataSources = new ConcurrentHashMap<String, DataSource>();
+ for (String ds : dataSourceNames.split(" ")) {
+ try {
+ Object o = getOpenEJBResource(ds);
+ if (o instanceof DataSource) {
+ dataSources.put(ds, DataSource.class.cast(o));
+ }
+ } catch (NamingException e) {
+ // ignored
+ }
+ }
+ }
+
+ /**
+ * @return the user selected data source if it is set
+ * or the default one
+ * @throws IllegalArgumentException if the data source is not found
+ */
+ @Override
+ public DataSource getDataSource() {
+ // lazy init of routed datasources
+ if (dataSources == null) {
+ init();
+ }
+
+ // if no datasource is selected use the default one
+ if (currentDataSource.get() == null) {
+ if (dataSources.containsKey(defaultDataSourceName)) {
+ return dataSources.get(defaultDataSourceName);
+
+ } else {
+ throw new IllegalArgumentException("you have to specify at least one datasource");
+ }
+ }
+
+ // the developper set the datasource to use
+ return currentDataSource.get();
+ }
+
+ /**
+ *
+ * @param datasourceName data source name
+ */
+ public void setDataSource(String datasourceName) {
+ if (dataSources == null) {
+ init();
+ }
+ if (!dataSources.containsKey(datasourceName)) {
+ throw new IllegalArgumentException("data source called " + datasourceName + " can't be found.");
+ }
+ DataSource ds = dataSources.get(datasourceName);
+ currentDataSource.set(ds);
+ }
+
+ /**
+ * reset the data source
+ */
+ public void clear() {
+ currentDataSource.remove();
+ }
+
+ public void setDefaultDataSourceName(String name) {
+ this.defaultDataSourceName = name;
+ }
+ }
+
+## Declaring the implementation
+
+To be able to use your router as a resource you need to provide a service configuration. It is done in a file
+you can find in META-INF/org.router/ and called service-jar.xml
+(for your implementation you can of course change the package name).
+
+It contains the following code:
+
+ <ServiceJar>
+ <ServiceProvider id="DeterminedRouter" <!-- the name you want to use -->
+ service="Resource"
+ type="org.apache.openejb.resource.jdbc.Router"
+ class-name="org.superbiz.dynamicdatasourcerouting.DeterminedRouter"> <!-- implementation class -->
+
+ # the parameters
+
+ DataSourceNames
+ DefaultDataSourceName
+ </ServiceProvider>
+ </ServiceJar>
+
+
+# Using the Router
+
+Here we have a `RoutedPersister` stateless bean which uses our `DeterminedRouter`
+
+ package org.superbiz.dynamicdatasourcerouting;
+
+ import javax.annotation.Resource;
+ import javax.ejb.Stateless;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+
+ @Stateless
+ public class RoutedPersister {
+ @PersistenceContext(unitName = "router")
+ private EntityManager em;
+
+ @Resource(name = "My Router", type = DeterminedRouter.class)
+ private DeterminedRouter router;
+
+ public void persist(int id, String name, String ds) {
+ router.setDataSource(ds);
+ em.persist(new Person(id, name));
+ }
+ }
+
+# The test
+
+In test mode and using property style configuration the foolowing configuration is used:
+
+ public class DynamicDataSourceTest {
+ @Test
+ public void route() throws Exception {
+ String[] databases = new String[]{"database1", "database2", "database3"};
+
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
+
+ // resources
+ // datasources
+ for (int i = 1; i <= databases.length; i++) {
+ String dbName = databases[i - 1];
+ properties.setProperty(dbName, "new://Resource?type=DataSource");
+ dbName += ".";
+ properties.setProperty(dbName + "JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty(dbName + "JdbcUrl", "jdbc:hsqldb:mem:db" + i);
+ properties.setProperty(dbName + "UserName", "sa");
+ properties.setProperty(dbName + "Password", "");
+ properties.setProperty(dbName + "JtaManaged", "true");
+ }
+
+ // router
+ properties.setProperty("My Router", "new://Resource?provider=org.router:DeterminedRouter&type=" + DeterminedRouter.class.getName());
+ properties.setProperty("My Router.DatasourceNames", "database1 database2 database3");
+ properties.setProperty("My Router.DefaultDataSourceName", "database1");
+
+ // routed datasource
+ properties.setProperty("Routed Datasource", "new://Resource?provider=RoutedDataSource&type=" + Router.class.getName());
+ properties.setProperty("Routed Datasource.Router", "My Router");
+
+ Context ctx = EJBContainer.createEJBContainer(properties).getContext();
+ RoutedPersister ejb = (RoutedPersister) ctx.lookup("java:global/dynamic-datasource-routing/RoutedPersister");
+ for (int i = 0; i < 18; i++) {
+ // persisting a person on database db -> kind of manual round robin
+ String name = "record " + i;
+ String db = databases[i % 3];
+ ejb.persist(i, name, db);
+ }
+
+ // assert database records number using jdbc
+ for (int i = 1; i <= databases.length; i++) {
+ Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:db" + i, "sa", "");
+ Statement st = connection.createStatement();
+ ResultSet rs = st.executeQuery("select count(*) from PERSON");
+ rs.next();
+ assertEquals(6, rs.getInt(1));
+ st.close();
+ connection.close();
+ }
+
+ ctx.close();
+ }
+ }
+
+# Configuration via openejb.xml
+
+The testcase above uses properties for configuration. The identical way to do it via the `conf/openejb.xml` is as follows:
+
+ <!-- Router and datasource -->
+ <Resource id="My Router" type="org.apache.openejb.router.test.DynamicDataSourceTest$DeterminedRouter" provider="org.routertest:DeterminedRouter">
+ DatasourceNames = database1 database2 database3
+ DefaultDataSourceName = database1
+ </Resource>
+ <Resource id="Routed Datasource" type="org.apache.openejb.resource.jdbc.Router" provider="RoutedDataSource">
+ Router = My Router
+ </Resource>
+
+ <!-- real datasources -->
+ <Resource id="database1" type="DataSource">
+ JdbcDriver = org.hsqldb.jdbcDriver
+ JdbcUrl = jdbc:hsqldb:mem:db1
+ UserName = sa
+ Password
+ JtaManaged = true
+ </Resource>
+ <Resource id="database2" type="DataSource">
+ JdbcDriver = org.hsqldb.jdbcDriver
+ JdbcUrl = jdbc:hsqldb:mem:db2
+ UserName = sa
+ Password
+ JtaManaged = true
+ </Resource>
+ <Resource id="database3" type="DataSource">
+ JdbcDriver = org.hsqldb.jdbcDriver
+ JdbcUrl = jdbc:hsqldb:mem:db3
+ UserName = sa
+ Password
+ JtaManaged = true
+ </Resource>
+
+
+
+
+## Some hack for OpenJPA
+
+Using more than one datasource behind one EntityManager means the databases are already created. If it is not the case,
+the JPA provider has to create the datasource at boot time.
+
+Hibernate do it so if you declare your databases it will work. However with OpenJPA
+(the default JPA provider for OpenEJB), the creation is lazy and it happens only once so when you'll switch of database
+it will no more work.
+
+Of course OpenEJB provides @Singleton and @Startup features of Java EE 6 and we can do a bean just making a simple find,
+even on none existing entities, just to force the database creation:
+
+ @Startup
+ @Singleton
+ public class BoostrapUtility {
+ // inject all real databases
+
+ @PersistenceContext(unitName = "db1")
+ private EntityManager em1;
+
+ @PersistenceContext(unitName = "db2")
+ private EntityManager em2;
+
+ @PersistenceContext(unitName = "db3")
+ private EntityManager em3;
+
+ // force database creation
+
+ @PostConstruct
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void initDatabase() {
+ em1.find(Person.class, 0);
+ em2.find(Person.class, 0);
+ em3.find(Person.class, 0);
+ }
+ }
+
+## Using the routed datasource
+
+Now you configured the way you want to route your JPA operation, you registered the resources and you initialized
+your databases you can use it and see how it is simple:
+
+ @Stateless
+ public class RoutedPersister {
+ // injection of the "proxied" datasource
+ @PersistenceContext(unitName = "router")
+ private EntityManager em;
+
+ // injection of the router you need it to configured the database
+ @Resource(name = "My Router", type = DeterminedRouter.class)
+ private DeterminedRouter router;
+
+ public void persist(int id, String name, String ds) {
+ router.setDataSource(ds); // configuring the database for the current transaction
+ em.persist(new Person(id, name)); // will use ds database automatically
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/dynamic-datasource-routing
+ INFO - openejb.base = /Users/dblevins/examples/dynamic-datasource-routing
+ 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 - Configuring Service(id=My Router, type=Resource, provider-id=DeterminedRouter)
+ INFO - Configuring Service(id=database3, type=Resource, provider-id=Default JDBC Database)
+ INFO - Configuring Service(id=database2, type=Resource, provider-id=Default JDBC Database)
+ INFO - Configuring Service(id=Routed Datasource, type=Resource, provider-id=RoutedDataSource)
+ INFO - Configuring Service(id=database1, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/dynamic-datasource-routing/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/dynamic-datasource-routing/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/dynamic-datasource-routing
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean BoostrapUtility: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean RoutedPersister: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Auto-linking resource-ref 'java:comp/env/My Router' in bean RoutedPersister to Resource(id=My Router)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=router)
+ INFO - Configuring PersistenceUnit(name=db1)
+ INFO - Auto-creating a Resource with id 'database1NonJta' of type 'DataSource for 'db1'.
+ INFO - Configuring Service(id=database1NonJta, type=Resource, provider-id=database1)
+ INFO - Adjusting PersistenceUnit db1 <non-jta-data-source> to Resource ID 'database1NonJta' from 'null'
+ INFO - Configuring PersistenceUnit(name=db2)
+ INFO - Auto-creating a Resource with id 'database2NonJta' of type 'DataSource for 'db2'.
+ INFO - Configuring Service(id=database2NonJta, type=Resource, provider-id=database2)
+ INFO - Adjusting PersistenceUnit db2 <non-jta-data-source> to Resource ID 'database2NonJta' from 'null'
+ INFO - Configuring PersistenceUnit(name=db3)
+ INFO - Auto-creating a Resource with id 'database3NonJta' of type 'DataSource for 'db3'.
+ INFO - Configuring Service(id=database3NonJta, type=Resource, provider-id=database3)
+ INFO - Adjusting PersistenceUnit db3 <non-jta-data-source> to Resource ID 'database3NonJta' from 'null'
+ INFO - Enterprise application "/Users/dblevins/examples/dynamic-datasource-routing" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/dynamic-datasource-routing
+ INFO - PersistenceUnit(name=router, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 504ms
+ INFO - PersistenceUnit(name=db1, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 11ms
+ INFO - PersistenceUnit(name=db2, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 7ms
+ INFO - PersistenceUnit(name=db3, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 6ms
+ INFO - Jndi(name="java:global/dynamic-datasource-routing/BoostrapUtility!org.superbiz.dynamicdatasourcerouting.BoostrapUtility")
+ INFO - Jndi(name="java:global/dynamic-datasource-routing/BoostrapUtility")
+ INFO - Jndi(name="java:global/dynamic-datasource-routing/RoutedPersister!org.superbiz.dynamicdatasourcerouting.RoutedPersister")
+ INFO - Jndi(name="java:global/dynamic-datasource-routing/RoutedPersister")
+ INFO - Jndi(name="java:global/EjbModule1519652738/org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest!org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest")
+ INFO - Jndi(name="java:global/EjbModule1519652738/org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest")
+ INFO - Created Ejb(deployment-id=RoutedPersister, ejb-name=RoutedPersister, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest, ejb-name=org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=BoostrapUtility, ejb-name=BoostrapUtility, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=RoutedPersister, ejb-name=RoutedPersister, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest, ejb-name=org.superbiz.dynamicdatasourcerouting.DynamicDataSourceTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=BoostrapUtility, ejb-name=BoostrapUtility, container=Default Singleton Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/dynamic-datasource-routing)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.504 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/dynamic-datasource-routing/pom.xml b/content/examples/dynamic-datasource-routing/pom.xml
new file mode 100755
index 0000000..2ce10dd
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>dynamic-datasource-routing</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Dynamic Datasource Routing</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The router is dependent of openejb so it needs openejb core with compile scope.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/BoostrapUtility.java b/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/BoostrapUtility.java
new file mode 100755
index 0000000..8ee973c
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/BoostrapUtility.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamicdatasourcerouting;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+/**
+ * OpenJPA create the table at the first query.
+ * To avoid to have to create the table manunally this singleton will do it for us.
+ */
+@Startup
+@Singleton
+public class BoostrapUtility {
+
+ @PersistenceContext(unitName = "db1")
+ private EntityManager em1;
+
+ @PersistenceContext(unitName = "db2")
+ private EntityManager em2;
+
+ @PersistenceContext(unitName = "db3")
+ private EntityManager em3;
+
+ @PostConstruct
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void initDatabase() {
+ em1.find(Person.class, 0);
+ em2.find(Person.class, 0);
+ em3.find(Person.class, 0);
+ }
+}
diff --git a/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/DeterminedRouter.java b/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/DeterminedRouter.java
new file mode 100755
index 0000000..e2b1caa
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/DeterminedRouter.java
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamicdatasourcerouting;
+
+import org.apache.openejb.resource.jdbc.router.AbstractRouter;
+
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class DeterminedRouter extends AbstractRouter {
+
+ private String dataSourceNames;
+ private String defaultDataSourceName;
+ private Map<String, DataSource> dataSources = null;
+ private ThreadLocal<DataSource> currentDataSource = new ThreadLocal<DataSource>();
+
+ /**
+ * @param datasourceList datasource resource name, separator is a space
+ */
+ public void setDataSourceNames(String datasourceList) {
+ dataSourceNames = datasourceList;
+ }
+
+ /**
+ * lookup datasource in openejb resources
+ */
+ private void init() {
+ dataSources = new ConcurrentHashMap<String, DataSource>();
+ for (String ds : dataSourceNames.split(" ")) {
+ try {
+ Object o = getOpenEJBResource(ds);
+ if (o instanceof DataSource) {
+ dataSources.put(ds, DataSource.class.cast(o));
+ }
+ } catch (NamingException e) {
+ // ignored
+ }
+ }
+ }
+
+ /**
+ * @return the user selected data source if it is set
+ * or the default one
+ * @throws IllegalArgumentException if the data source is not found
+ */
+ @Override
+ public DataSource getDataSource() {
+ // lazy init of routed datasources
+ if (dataSources == null) {
+ init();
+ }
+
+ // if no datasource is selected use the default one
+ if (currentDataSource.get() == null) {
+ if (dataSources.containsKey(defaultDataSourceName)) {
+ return dataSources.get(defaultDataSourceName);
+
+ } else {
+ throw new IllegalArgumentException("you have to specify at least one datasource");
+ }
+ }
+
+ // the developper set the datasource to use
+ return currentDataSource.get();
+ }
+
+ /**
+ * @param datasourceName data source name
+ */
+ public void setDataSource(String datasourceName) {
+ if (dataSources == null) {
+ init();
+ }
+ if (!dataSources.containsKey(datasourceName)) {
+ throw new IllegalArgumentException("data source called " + datasourceName + " can't be found.");
+ }
+ DataSource ds = dataSources.get(datasourceName);
+ currentDataSource.set(ds);
+ }
+
+ /**
+ * reset the data source
+ */
+ public void clear() {
+ currentDataSource.remove();
+ }
+
+ public void setDefaultDataSourceName(String name) {
+ this.defaultDataSourceName = name;
+ }
+}
diff --git a/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/Person.java b/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/Person.java
new file mode 100755
index 0000000..cefa256
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/Person.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamicdatasourcerouting;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Person {
+
+ @Id
+ private long id;
+ private String name;
+
+ public Person() {
+ // no-op
+ }
+
+ public Person(int i, String n) {
+ id = i;
+ name = n;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/RoutedPersister.java b/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/RoutedPersister.java
new file mode 100755
index 0000000..462bb2f
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing/src/main/java/org/superbiz/dynamicdatasourcerouting/RoutedPersister.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamicdatasourcerouting;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Stateless
+public class RoutedPersister {
+
+ @PersistenceContext(unitName = "router")
+ private EntityManager em;
+
+ @Resource(name = "My Router", type = DeterminedRouter.class)
+ private DeterminedRouter router;
+
+ public void persist(int id, String name, String ds) {
+ router.setDataSource(ds);
+ em.persist(new Person(id, name));
+ }
+}
diff --git a/content/examples/dynamic-datasource-routing/src/main/resources/META-INF/org.router/service-jar.xml b/content/examples/dynamic-datasource-routing/src/main/resources/META-INF/org.router/service-jar.xml
new file mode 100755
index 0000000..8b4c2dd
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing/src/main/resources/META-INF/org.router/service-jar.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ServiceJar>
+ <ServiceProvider id="DeterminedRouter" service="Resource"
+ type="org.apache.openejb.resource.jdbc.Router"
+ class-name="org.superbiz.dynamicdatasourcerouting.DeterminedRouter">
+ DataSourceNames
+ DefaultDataSourceName
+ </ServiceProvider>
+</ServiceJar>
+
diff --git a/content/examples/dynamic-datasource-routing/src/main/resources/META-INF/persistence.xml b/content/examples/dynamic-datasource-routing/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..4aeeb24
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="router" transaction-type="JTA">
+ <jta-data-source>Routed Datasource</jta-data-source>
+ <class>org.superbiz.dynamicdatasourcerouting.Person</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+
+ <persistence-unit name="db1" transaction-type="JTA">
+ <jta-data-source>database1</jta-data-source>
+ <class>org.superbiz.dynamicdatasourcerouting.Person</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ <persistence-unit name="db2" transaction-type="JTA">
+ <jta-data-source>database2</jta-data-source>
+ <class>org.superbiz.dynamicdatasourcerouting.Person</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ <persistence-unit name="db3" transaction-type="JTA">
+ <jta-data-source>database3</jta-data-source>
+ <class>org.superbiz.dynamicdatasourcerouting.Person</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/dynamic-datasource-routing/src/test/java/org/superbiz/dynamicdatasourcerouting/DynamicDataSourceTest.java b/content/examples/dynamic-datasource-routing/src/test/java/org/superbiz/dynamicdatasourcerouting/DynamicDataSourceTest.java
new file mode 100755
index 0000000..e3b3020
--- /dev/null
+++ b/content/examples/dynamic-datasource-routing/src/test/java/org/superbiz/dynamicdatasourcerouting/DynamicDataSourceTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamicdatasourcerouting;
+
+import org.apache.openejb.core.LocalInitialContextFactory;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * If you are using openejb.xml the test properties are:
+ * <p/>
+ * <p/>
+ * <!-- Router and datasource -->
+ * <Resource id="My Router" type="org.apache.openejb.router.test.DynamicDataSourceTest$DeterminedRouter" provider="org.routertest:DeterminedRouter">
+ * DatasourceNames = database1 database2 database3
+ * DefaultDataSourceName = database1
+ * </Resource>
+ * <Resource id="Routed Datasource" type="org.apache.openejb.resource.jdbc.Router" provider="org.router:RoutedDataSource">
+ * Router = My Router
+ * </Resource>
+ * <p/>
+ * <!-- real datasources -->
+ * <Resource id="database1" type="DataSource">
+ * JdbcDriver = org.hsqldb.jdbcDriver
+ * JdbcUrl = jdbc:hsqldb:mem:db1
+ * UserName = sa
+ * Password
+ * JtaManaged = true
+ * </Resource>
+ * <Resource id="database2" type="DataSource">
+ * JdbcDriver = org.hsqldb.jdbcDriver
+ * JdbcUrl = jdbc:hsqldb:mem:db2
+ * UserName = sa
+ * Password
+ * JtaManaged = true
+ * </Resource>
+ * <Resource id="database3" type="DataSource">
+ * JdbcDriver = org.hsqldb.jdbcDriver
+ * JdbcUrl = jdbc:hsqldb:mem:db3
+ * UserName = sa
+ * Password
+ * JtaManaged = true
+ * </Resource>
+ */
+public class DynamicDataSourceTest {
+
+ @Test
+ public void route() throws Exception {
+ String[] databases = new String[]{"database1", "database2", "database3"};
+
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
+
+ // resources
+ // datasources
+ for (int i = 1; i <= databases.length; i++) {
+ String dbName = databases[i - 1];
+ properties.setProperty(dbName, "new://Resource?type=DataSource");
+ dbName += ".";
+ properties.setProperty(dbName + "JdbcDriver", "org.hsqldb.jdbcDriver");
+ properties.setProperty(dbName + "JdbcUrl", "jdbc:hsqldb:mem:db" + i);
+ properties.setProperty(dbName + "UserName", "sa");
+ properties.setProperty(dbName + "Password", "");
+ properties.setProperty(dbName + "JtaManaged", "true");
+ }
+
+ // router
+ properties.setProperty("My Router", "new://Resource?provider=org.router:DeterminedRouter&type=" + DeterminedRouter.class.getName());
+ properties.setProperty("My Router.DatasourceNames", "database1 database2 database3");
+ properties.setProperty("My Router.DefaultDataSourceName", "database1");
+
+ // routed datasource
+ properties.setProperty("Routed Datasource", "new://Resource?provider=RoutedDataSource&type=" + DataSource.class.getName());
+ properties.setProperty("Routed Datasource.Router", "My Router");
+
+ Context ctx = EJBContainer.createEJBContainer(properties).getContext();
+ RoutedPersister ejb = (RoutedPersister) ctx.lookup("java:global/dynamic-datasource-routing/RoutedPersister");
+ for (int i = 0; i < 18; i++) {
+ // persisting a person on database db -> kind of manual round robin
+ String name = "record " + i;
+ String db = databases[i % 3];
+ ejb.persist(i, name, db);
+ }
+
+ // assert database records number using jdbc
+ for (int i = 1; i <= databases.length; i++) {
+ Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:db" + i, "sa", "");
+ Statement st = connection.createStatement();
+ ResultSet rs = st.executeQuery("select count(*) from PERSON");
+ rs.next();
+ assertEquals(6, rs.getInt(1));
+ st.close();
+ connection.close();
+ }
+
+ ctx.close();
+ }
+}
+
diff --git a/content/examples/dynamic-implementation.html b/content/examples/dynamic-implementation.html
new file mode 100644
index 0000000..90e168c
--- /dev/null
+++ b/content/examples/dynamic-implementation.html
@@ -0,0 +1,340 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/dynamic-implementation.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Dynamic Implementation</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example dynamic-implementation can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/dynamic-implementation" class="bare">https://github.com/apache/tomee/tree/master/examples/dynamic-implementation</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_socialbean">SocialBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic;
+
+import org.apache.openejb.api.Proxy;
+
+import javax.ejb.Singleton;
+import javax.interceptor.Interceptors;
+
+@Singleton
+@Proxy(SocialHandler.class)
+@Interceptors(SocialInterceptor.class)
+public interface SocialBean {
+ public String facebookStatus();
+
+ public String twitterStatus();
+
+ public String status();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_socialhandler">SocialHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+public class SocialHandler implements InvocationHandler {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String mtd = method.getName();
+ if (mtd.toLowerCase().contains("facebook")) {
+ return "You think you have a life!";
+ } else if (mtd.toLowerCase().contains("twitter")) {
+ return "Wow, you eat pop corn!";
+ }
+ return "Hey, you have no virtual friend!";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_socialinterceptor">SocialInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">packagenull
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_socialtest">SocialTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+
+import static junit.framework.Assert.assertTrue;
+
+public class SocialTest {
+ private static SocialBean social;
+ private static EJBContainer container;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ container = EJBContainer.createEJBContainer();
+ social = (SocialBean) container.getContext().lookup("java:global/dynamic-implementation/SocialBean");
+ }
+
+ @AfterClass
+ public static void close() {
+ container.close();
+ }
+
+ @Test
+ public void simple() {
+ assertTrue(social.facebookStatus().contains("think"));
+ assertTrue(social.twitterStatus().contains("eat"));
+ assertTrue(social.status().contains("virtual"));
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.dynamic.SocialTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/dynamic-implementation
+INFO - openejb.base = /Users/dblevins/examples/dynamic-implementation
+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/dynamic-implementation/target/classes
+INFO - Beginning load: /Users/dblevins/examples/dynamic-implementation/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/dynamic-implementation
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean SocialBean: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.dynamic.SocialTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/dynamic-implementation" loaded.
+INFO - Assembling app: /Users/dblevins/examples/dynamic-implementation
+INFO - Jndi(name="java:global/dynamic-implementation/SocialBean!org.superbiz.dynamic.SocialBean")
+INFO - Jndi(name="java:global/dynamic-implementation/SocialBean")
+INFO - Jndi(name="java:global/EjbModule236706648/org.superbiz.dynamic.SocialTest!org.superbiz.dynamic.SocialTest")
+INFO - Jndi(name="java:global/EjbModule236706648/org.superbiz.dynamic.SocialTest")
+INFO - Created Ejb(deployment-id=org.superbiz.dynamic.SocialTest, ejb-name=org.superbiz.dynamic.SocialTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=SocialBean, ejb-name=SocialBean, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=org.superbiz.dynamic.SocialTest, ejb-name=org.superbiz.dynamic.SocialTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=SocialBean, ejb-name=SocialBean, container=Default Singleton Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/dynamic-implementation)
+INFO - Undeploying app: /Users/dblevins/examples/dynamic-implementation
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.107 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/dynamic-implementation.pdf b/content/examples/dynamic-implementation.pdf
new file mode 100644
index 0000000..805af7a
--- /dev/null
+++ b/content/examples/dynamic-implementation.pdf
Binary files differ
diff --git a/content/examples/dynamic-implementation/README.md b/content/examples/dynamic-implementation/README.md
new file mode 100755
index 0000000..19d1de3
--- /dev/null
+++ b/content/examples/dynamic-implementation/README.md
@@ -0,0 +1,123 @@
+Title: Dynamic Implementation
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## SocialBean
+
+ package org.superbiz.dynamic;
+
+ import org.apache.openejb.api.Proxy;
+
+ import javax.ejb.Singleton;
+ import javax.interceptor.Interceptors;
+
+ @Singleton
+ @Proxy(SocialHandler.class)
+ @Interceptors(SocialInterceptor.class)
+ public interface SocialBean {
+ public String facebookStatus();
+
+ public String twitterStatus();
+
+ public String status();
+ }
+
+## SocialHandler
+
+ package org.superbiz.dynamic;
+
+ import java.lang.reflect.InvocationHandler;
+ import java.lang.reflect.Method;
+
+ public class SocialHandler implements InvocationHandler {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String mtd = method.getName();
+ if (mtd.toLowerCase().contains("facebook")) {
+ return "You think you have a life!";
+ } else if (mtd.toLowerCase().contains("twitter")) {
+ return "Wow, you eat pop corn!";
+ }
+ return "Hey, you have no virtual friend!";
+ }
+ }
+
+## SocialInterceptor
+
+ packagenull
+ }
+
+## SocialTest
+
+ package org.superbiz.dynamic;
+
+ import org.junit.AfterClass;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+
+ import static junit.framework.Assert.assertTrue;
+
+ public class SocialTest {
+ private static SocialBean social;
+ private static EJBContainer container;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ container = EJBContainer.createEJBContainer();
+ social = (SocialBean) container.getContext().lookup("java:global/dynamic-implementation/SocialBean");
+ }
+
+ @AfterClass
+ public static void close() {
+ container.close();
+ }
+
+ @Test
+ public void simple() {
+ assertTrue(social.facebookStatus().contains("think"));
+ assertTrue(social.twitterStatus().contains("eat"));
+ assertTrue(social.status().contains("virtual"));
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.dynamic.SocialTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/dynamic-implementation
+ INFO - openejb.base = /Users/dblevins/examples/dynamic-implementation
+ 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/dynamic-implementation/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/dynamic-implementation/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/dynamic-implementation
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean SocialBean: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.dynamic.SocialTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/dynamic-implementation" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/dynamic-implementation
+ INFO - Jndi(name="java:global/dynamic-implementation/SocialBean!org.superbiz.dynamic.SocialBean")
+ INFO - Jndi(name="java:global/dynamic-implementation/SocialBean")
+ INFO - Jndi(name="java:global/EjbModule236706648/org.superbiz.dynamic.SocialTest!org.superbiz.dynamic.SocialTest")
+ INFO - Jndi(name="java:global/EjbModule236706648/org.superbiz.dynamic.SocialTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.dynamic.SocialTest, ejb-name=org.superbiz.dynamic.SocialTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=SocialBean, ejb-name=SocialBean, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.dynamic.SocialTest, ejb-name=org.superbiz.dynamic.SocialTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=SocialBean, ejb-name=SocialBean, container=Default Singleton Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/dynamic-implementation)
+ INFO - Undeploying app: /Users/dblevins/examples/dynamic-implementation
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.107 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/dynamic-implementation/pom.xml b/content/examples/dynamic-implementation/pom.xml
new file mode 100755
index 0000000..3b9a0ae
--- /dev/null
+++ b/content/examples/dynamic-implementation/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>dynamic-implementation</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Dynamic Implementation</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-api</artifactId>
+ <version>4.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialBean.java b/content/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialBean.java
new file mode 100755
index 0000000..d82c67c
--- /dev/null
+++ b/content/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialBean.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.apache.openejb.api.Proxy;
+
+import javax.ejb.Singleton;
+import javax.interceptor.Interceptors;
+
+@Singleton
+@Proxy(SocialHandler.class)
+@Interceptors(SocialInterceptor.class)
+public interface SocialBean {
+
+ public String facebookStatus();
+
+ public String twitterStatus();
+
+ public String status();
+}
diff --git a/content/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialHandler.java b/content/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialHandler.java
new file mode 100755
index 0000000..58d7c12
--- /dev/null
+++ b/content/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialHandler.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+public class SocialHandler implements InvocationHandler {
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String mtd = method.getName();
+ if (mtd.toLowerCase().contains("facebook")) {
+ return "You think you have a life!";
+ } else if (mtd.toLowerCase().contains("twitter")) {
+ return "Wow, you eat pop corn!";
+ }
+ return "Hey, you have no virtual friend!";
+ }
+}
diff --git a/content/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialInterceptor.java b/content/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialInterceptor.java
new file mode 100755
index 0000000..762e04a
--- /dev/null
+++ b/content/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialInterceptor.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.dynamic;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+public class SocialInterceptor {
+
+ @AroundInvoke
+ public Object around(InvocationContext context) throws Exception {
+ String mtd = context.getMethod().getName();
+ String address;
+ if (mtd.toLowerCase().contains("facebook")) {
+ address = "http://www.facebook.com";
+ } else if (mtd.toLowerCase().contains("twitter")) {
+ address = "http://twitter.com";
+ } else {
+ address = "no website for you";
+ }
+
+ System.out.println("go on " + address);
+ return context.proceed();
+ }
+}
diff --git a/content/examples/dynamic-implementation/src/test/java/org/superbiz/dynamic/SocialTest.java b/content/examples/dynamic-implementation/src/test/java/org/superbiz/dynamic/SocialTest.java
new file mode 100755
index 0000000..0069d4a
--- /dev/null
+++ b/content/examples/dynamic-implementation/src/test/java/org/superbiz/dynamic/SocialTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+
+import static org.junit.Assert.assertTrue;
+
+public class SocialTest {
+
+ private static SocialBean social;
+ private static EJBContainer container;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ container = EJBContainer.createEJBContainer();
+ social = (SocialBean) container.getContext().lookup("java:global/dynamic-implementation/SocialBean");
+ }
+
+ @AfterClass
+ public static void close() {
+ container.close();
+ }
+
+ @Test
+ public void simple() {
+ assertTrue(social.facebookStatus().contains("think"));
+ assertTrue(social.twitterStatus().contains("eat"));
+ assertTrue(social.status().contains("virtual"));
+ }
+}
diff --git a/content/examples/dynamic-proxy-to-access-mbean.html b/content/examples/dynamic-proxy-to-access-mbean.html
new file mode 100644
index 0000000..e760e6b
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean.html
@@ -0,0 +1,706 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/dynamic-proxy-to-access-mbean.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>dynamic-proxy-to-access-mbean</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example dynamic-proxy-to-access-mbean can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/dynamic-proxy-to-access-mbean" class="bare">https://github.com/apache/tomee/tree/master/examples/dynamic-proxy-to-access-mbean</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_example">Example</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Acessing MBean is something simple through the JMX API but it is often technical and not very interesting.</p>
+</div>
+<div class="paragraph">
+<p>This example simplify this work simply doing it generically in a proxy.</p>
+</div>
+<div class="paragraph">
+<p>So from an user side you simple declare an interface to access your MBeans.</p>
+</div>
+<div class="paragraph">
+<p>Note: the example implementation uses a local MBeanServer but enhancing the example API
+it is easy to imagine a remote connection with user/password if needed.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_objectname_api_annotation">ObjectName API (annotation)</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Simply an annotation to get the object</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic.mbean;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+public @interface ObjectName {
+ String value();
+
+ // for remote usage only
+ String url() default "";
+ String user() default "";
+ String password() default "";
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_dynamicmbeanhandler_thr_proxy_implementation">DynamicMBeanHandler (thr proxy implementation)</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic.mbean;
+
+import javax.annotation.PreDestroy;
+import javax.management.Attribute;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Need a @PreDestroy method to disconnect the remote host when used in remote mode.
+ */
+public class DynamicMBeanHandler implements InvocationHandler {
+ private final Map<Method, ConnectionInfo> infos = new ConcurrentHashMap<Method, ConnectionInfo>();
+
+ @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ final String methodName = method.getName();
+ if (method.getDeclaringClass().equals(Object.class) && "toString".equals(methodName)) {
+ return getClass().getSimpleName() + " Proxy";
+ }
+ if (method.getAnnotation(PreDestroy.class) != null) {
+ return destroy();
+ }
+
+ final ConnectionInfo info = getConnectionInfo(method);
+ final MBeanInfo infos = info.getMBeanInfo();
+ if (methodName.startsWith("set") && methodName.length() > 3 && args != null && args.length == 1
+ && (Void.TYPE.equals(method.getReturnType()) || Void.class.equals(method.getReturnType()))) {
+ final String attributeName = attributeName(infos, methodName, method.getParameterTypes()[0]);
+ info.setAttribute(new Attribute(attributeName, args[0]));
+ return null;
+ } else if (methodName.startsWith("get") && (args == null || args.length == 0) && methodName.length() > 3) {
+ final String attributeName = attributeName(infos, methodName, method.getReturnType());
+ return info.getAttribute(attributeName);
+ }
+ // operation
+ return info.invoke(methodName, args, getSignature(method));
+ }
+
+ public Object destroy() {
+ for (ConnectionInfo info : infos.values()) {
+ info.clean();
+ }
+ infos.clear();
+ return null;
+ }
+
+ private String[] getSignature(Method method) {
+ String[] args = new String[method.getParameterTypes().length];
+ for (int i = 0; i < method.getParameterTypes().length; i++) {
+ args[i] = method.getParameterTypes()[i].getName();
+ }
+ return args; // note: null should often work...
+ }
+
+ private String attributeName(MBeanInfo infos, String methodName, Class<?> type) {
+ String found = null;
+ String foundBackUp = null; // without checking the type
+ final String attributeName = methodName.substring(3, methodName.length());
+ final String lowerName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4, methodName.length());
+
+ for (MBeanAttributeInfo attribute : infos.getAttributes()) {
+ final String name = attribute.getName();
+ if (attributeName.equals(name)) {
+ foundBackUp = attributeName;
+ if (attribute.getType().equals(type.getName())) {
+ found = name;
+ }
+ } else if (found == null && ((lowerName.equals(name) && !attributeName.equals(name))
+ || lowerName.equalsIgnoreCase(name))) {
+ foundBackUp = name;
+ if (attribute.getType().equals(type.getName())) {
+ found = name;
+ }
+ }
+ }
+
+ if (found == null && foundBackUp == null) {
+ throw new UnsupportedOperationException("cannot find attribute " + attributeName);
+ }
+
+ if (found != null) {
+ return found;
+ }
+ return foundBackUp;
+ }
+
+ private synchronized ConnectionInfo getConnectionInfo(Method method) throws Exception {
+ if (!infos.containsKey(method)) {
+ synchronized (infos) {
+ if (!infos.containsKey(method)) { // double check for synchro
+ org.superbiz.dynamic.mbean.ObjectName on = method.getAnnotation(org.superbiz.dynamic.mbean.ObjectName.class);
+ if (on == null) {
+ Class<?> current = method.getDeclaringClass();
+ do {
+ on = method.getDeclaringClass().getAnnotation(org.superbiz.dynamic.mbean.ObjectName.class);
+ current = current.getSuperclass();
+ } while (on == null && current != null);
+ if (on == null) {
+ throw new UnsupportedOperationException("class or method should define the objectName to use for invocation: " + method.toGenericString());
+ }
+ }
+ final ConnectionInfo info;
+ if (on.url().isEmpty()) {
+ info = new LocalConnectionInfo();
+ ((LocalConnectionInfo) info).server = ManagementFactory.getPlatformMBeanServer(); // could use an id...
+ } else {
+ info = new RemoteConnectionInfo();
+ final Map<String, String[]> environment = new HashMap<String, String[]>();
+ if (!on.user().isEmpty()) {
+ environment.put(JMXConnector.CREDENTIALS, new String[]{ on.user(), on.password() });
+ }
+ // ((RemoteConnectionInfo) info).connector = JMXConnectorFactory.newJMXConnector(new JMXServiceURL(on.url()), environment);
+ ((RemoteConnectionInfo) info).connector = JMXConnectorFactory.connect(new JMXServiceURL(on.url()), environment);
+
+ }
+ info.objectName = new ObjectName(on.value());
+
+ infos.put(method, info);
+ }
+ }
+ }
+ return infos.get(method);
+ }
+
+ private abstract static class ConnectionInfo {
+ protected ObjectName objectName;
+
+ public abstract void setAttribute(Attribute attribute) throws Exception;
+ public abstract Object getAttribute(String attribute) throws Exception;
+ public abstract Object invoke(String operationName, Object params[], String signature[]) throws Exception;
+ public abstract MBeanInfo getMBeanInfo() throws Exception;
+ public abstract void clean();
+ }
+
+ private static class LocalConnectionInfo extends ConnectionInfo {
+ private MBeanServer server;
+
+ @Override public void setAttribute(Attribute attribute) throws Exception {
+ server.setAttribute(objectName, attribute);
+ }
+
+ @Override public Object getAttribute(String attribute) throws Exception {
+ return server.getAttribute(objectName, attribute);
+ }
+
+ @Override
+ public Object invoke(String operationName, Object[] params, String[] signature) throws Exception {
+ return server.invoke(objectName, operationName, params, signature);
+ }
+
+ @Override public MBeanInfo getMBeanInfo() throws Exception {
+ return server.getMBeanInfo(objectName);
+ }
+
+ @Override public void clean() {
+ // no-op
+ }
+ }
+
+ private static class RemoteConnectionInfo extends ConnectionInfo {
+ private JMXConnector connector;
+ private MBeanServerConnection connection;
+
+ private void before() throws IOException {
+ connection = connector.getMBeanServerConnection();
+ }
+
+ private void after() throws IOException {
+ // no-op
+ }
+
+ @Override public void setAttribute(Attribute attribute) throws Exception {
+ before();
+ connection.setAttribute(objectName, attribute);
+ after();
+ }
+
+ @Override public Object getAttribute(String attribute) throws Exception {
+ before();
+ try {
+ return connection.getAttribute(objectName, attribute);
+ } finally {
+ after();
+ }
+ }
+
+ @Override
+ public Object invoke(String operationName, Object[] params, String[] signature) throws Exception {
+ before();
+ try {
+ return connection.invoke(objectName, operationName, params, signature);
+ } finally {
+ after();
+ }
+ }
+
+ @Override public MBeanInfo getMBeanInfo() throws Exception {
+ before();
+ try {
+ return connection.getMBeanInfo(objectName);
+ } finally {
+ after();
+ }
+ }
+
+ @Override public void clean() {
+ try {
+ connector.close();
+ } catch (IOException e) {
+ // no-op
+ }
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_dynamic_proxies">Dynamic Proxies</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_dynamicmbeanclient_the_dynamic_jmx_client">DynamicMBeanClient (the dynamic JMX client)</h3>
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.dynamic.mbean;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>import org.apache.openejb.api.Proxy;
+import org.superbiz.dynamic.mbean.DynamicMBeanHandler;
+import org.superbiz.dynamic.mbean.ObjectName;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>import javax.ejb.Singleton;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>/**
+ * @author rmannibucau
+ */
+@Singleton
+@Proxy(DynamicMBeanHandler.class)
+@ObjectName(DynamicMBeanClient.OBJECT_NAME)
+public interface DynamicMBeanClient {
+ static final String OBJECT_NAME = "test:group=DynamicMBeanClientTest";</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> int getCounter();
+ void setCounter(int i);
+ int length(String aString);
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_dynamicmbeanclient_the_dynamic_jmx_client_2">DynamicMBeanClient (the dynamic JMX client)</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic.mbean;
+
+import org.apache.openejb.api.Proxy;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.Singleton;
+
+
+@Singleton
+@Proxy(DynamicMBeanHandler.class)
+@ObjectName(value = DynamicRemoteMBeanClient.OBJECT_NAME, url = "service:jmx:rmi:///jndi/rmi://localhost:8243/jmxrmi")
+public interface DynamicRemoteMBeanClient {
+ static final String OBJECT_NAME = "test:group=DynamicMBeanClientTest";
+
+ int getCounter();
+ void setCounter(int i);
+ int length(String aString);
+
+ @PreDestroy void clean();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_mbean_used_for_the_test">The MBean used for the test</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_simplembean">SimpleMBean</h3>
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.dynamic.mbean.simple;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public interface SimpleMBean {
+ int length(String s);</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> int getCounter();
+ void setCounter(int c);
+}</pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_simple">Simple</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.dynamic.mbean.simple;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public class Simple implements SimpleMBean {
+ private int counter = 0;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Override public int length(String s) {
+ if (s == null) {
+ return 0;
+ }
+ return s.length();
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Override public int getCounter() {
+ return counter;
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> @Override public void setCounter(int c) {
+ counter = c;
+ }
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_dynamicmbeanclienttest_the_test">DynamicMBeanClientTest (The test)</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.dynamic.mbean;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.superbiz.dynamic.mbean.simple.Simple;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.management.Attribute;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+
+import static junit.framework.Assert.assertEquals;
+
+public class DynamicMBeanClientTest {
+ private static ObjectName objectName;
+ private static EJBContainer container;
+
+ @EJB private DynamicMBeanClient localClient;
+ @EJB private DynamicRemoteMBeanClient remoteClient;
+
+ @BeforeClass public static void start() {
+ container = EJBContainer.createEJBContainer();
+ }
+
+ @Before public void injectAndRegisterMBean() throws Exception {
+ container.getContext().bind("inject", this);
+ objectName = new ObjectName(DynamicMBeanClient.OBJECT_NAME);
+ ManagementFactory.getPlatformMBeanServer().registerMBean(new Simple(), objectName);
+ }
+
+ @After public void unregisterMBean() throws Exception {
+ if (objectName != null) {
+ ManagementFactory.getPlatformMBeanServer().unregisterMBean(objectName);
+ }
+ }
+
+ @Test public void localGet() throws Exception {
+ assertEquals(0, localClient.getCounter());
+ ManagementFactory.getPlatformMBeanServer().setAttribute(objectName, new Attribute("Counter", 5));
+ assertEquals(5, localClient.getCounter());
+ }
+
+ @Test public void localSet() throws Exception {
+ assertEquals(0, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ localClient.setCounter(8);
+ assertEquals(8, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ }
+
+ @Test public void localOperation() {
+ assertEquals(7, localClient.length("openejb"));
+ }
+
+ @Test public void remoteGet() throws Exception {
+ assertEquals(0, remoteClient.getCounter());
+ ManagementFactory.getPlatformMBeanServer().setAttribute(objectName, new Attribute("Counter", 5));
+ assertEquals(5, remoteClient.getCounter());
+ }
+
+ @Test public void remoteSet() throws Exception {
+ assertEquals(0, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ remoteClient.setCounter(8);
+ assertEquals(8, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ }
+
+ @Test public void remoteOperation() {
+ assertEquals(7, remoteClient.length("openejb"));
+ }
+
+ @AfterClass public static void close() {
+ if (container != null) {
+ container.close();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/dynamic-proxy-to-access-mbean.pdf b/content/examples/dynamic-proxy-to-access-mbean.pdf
new file mode 100644
index 0000000..75fd640
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean.pdf
Binary files differ
diff --git a/content/examples/dynamic-proxy-to-access-mbean/README.md b/content/examples/dynamic-proxy-to-access-mbean/README.md
new file mode 100755
index 0000000..0851976
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean/README.md
@@ -0,0 +1,433 @@
+Title: dynamic-proxy-to-access-mbean
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Example
+
+Acessing MBean is something simple through the JMX API but it is often technical and not very interesting.
+
+This example simplify this work simply doing it generically in a proxy.
+
+So from an user side you simple declare an interface to access your MBeans.
+
+Note: the example implementation uses a local MBeanServer but enhancing the example API
+it is easy to imagine a remote connection with user/password if needed.
+
+## ObjectName API (annotation)
+
+Simply an annotation to get the object
+
+ package org.superbiz.dynamic.mbean;
+
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.Target;
+
+ import static java.lang.annotation.ElementType.TYPE;
+ import static java.lang.annotation.ElementType.METHOD;
+ import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+ @Target({TYPE, METHOD})
+ @Retention(RUNTIME)
+ public @interface ObjectName {
+ String value();
+
+ // for remote usage only
+ String url() default "";
+ String user() default "";
+ String password() default "";
+ }
+
+## DynamicMBeanHandler (thr proxy implementation)
+
+ package org.superbiz.dynamic.mbean;
+
+ import javax.annotation.PreDestroy;
+ import javax.management.Attribute;
+ import javax.management.MBeanAttributeInfo;
+ import javax.management.MBeanInfo;
+ import javax.management.MBeanServer;
+ import javax.management.MBeanServerConnection;
+ import javax.management.ObjectName;
+ import javax.management.remote.JMXConnector;
+ import javax.management.remote.JMXConnectorFactory;
+ import javax.management.remote.JMXServiceURL;
+ import java.io.IOException;
+ import java.lang.management.ManagementFactory;
+ import java.lang.reflect.InvocationHandler;
+ import java.lang.reflect.Method;
+ import java.util.HashMap;
+ import java.util.Map;
+ import java.util.concurrent.ConcurrentHashMap;
+
+ /**
+ * Need a @PreDestroy method to disconnect the remote host when used in remote mode.
+ */
+ public class DynamicMBeanHandler implements InvocationHandler {
+ private final Map<Method, ConnectionInfo> infos = new ConcurrentHashMap<Method, ConnectionInfo>();
+
+ @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ final String methodName = method.getName();
+ if (method.getDeclaringClass().equals(Object.class) && "toString".equals(methodName)) {
+ return getClass().getSimpleName() + " Proxy";
+ }
+ if (method.getAnnotation(PreDestroy.class) != null) {
+ return destroy();
+ }
+
+ final ConnectionInfo info = getConnectionInfo(method);
+ final MBeanInfo infos = info.getMBeanInfo();
+ if (methodName.startsWith("set") && methodName.length() > 3 && args != null && args.length == 1
+ && (Void.TYPE.equals(method.getReturnType()) || Void.class.equals(method.getReturnType()))) {
+ final String attributeName = attributeName(infos, methodName, method.getParameterTypes()[0]);
+ info.setAttribute(new Attribute(attributeName, args[0]));
+ return null;
+ } else if (methodName.startsWith("get") && (args == null || args.length == 0) && methodName.length() > 3) {
+ final String attributeName = attributeName(infos, methodName, method.getReturnType());
+ return info.getAttribute(attributeName);
+ }
+ // operation
+ return info.invoke(methodName, args, getSignature(method));
+ }
+
+ public Object destroy() {
+ for (ConnectionInfo info : infos.values()) {
+ info.clean();
+ }
+ infos.clear();
+ return null;
+ }
+
+ private String[] getSignature(Method method) {
+ String[] args = new String[method.getParameterTypes().length];
+ for (int i = 0; i < method.getParameterTypes().length; i++) {
+ args[i] = method.getParameterTypes()[i].getName();
+ }
+ return args; // note: null should often work...
+ }
+
+ private String attributeName(MBeanInfo infos, String methodName, Class<?> type) {
+ String found = null;
+ String foundBackUp = null; // without checking the type
+ final String attributeName = methodName.substring(3, methodName.length());
+ final String lowerName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4, methodName.length());
+
+ for (MBeanAttributeInfo attribute : infos.getAttributes()) {
+ final String name = attribute.getName();
+ if (attributeName.equals(name)) {
+ foundBackUp = attributeName;
+ if (attribute.getType().equals(type.getName())) {
+ found = name;
+ }
+ } else if (found == null && ((lowerName.equals(name) && !attributeName.equals(name))
+ || lowerName.equalsIgnoreCase(name))) {
+ foundBackUp = name;
+ if (attribute.getType().equals(type.getName())) {
+ found = name;
+ }
+ }
+ }
+
+ if (found == null && foundBackUp == null) {
+ throw new UnsupportedOperationException("cannot find attribute " + attributeName);
+ }
+
+ if (found != null) {
+ return found;
+ }
+ return foundBackUp;
+ }
+
+ private synchronized ConnectionInfo getConnectionInfo(Method method) throws Exception {
+ if (!infos.containsKey(method)) {
+ synchronized (infos) {
+ if (!infos.containsKey(method)) { // double check for synchro
+ org.superbiz.dynamic.mbean.ObjectName on = method.getAnnotation(org.superbiz.dynamic.mbean.ObjectName.class);
+ if (on == null) {
+ Class<?> current = method.getDeclaringClass();
+ do {
+ on = method.getDeclaringClass().getAnnotation(org.superbiz.dynamic.mbean.ObjectName.class);
+ current = current.getSuperclass();
+ } while (on == null && current != null);
+ if (on == null) {
+ throw new UnsupportedOperationException("class or method should define the objectName to use for invocation: " + method.toGenericString());
+ }
+ }
+ final ConnectionInfo info;
+ if (on.url().isEmpty()) {
+ info = new LocalConnectionInfo();
+ ((LocalConnectionInfo) info).server = ManagementFactory.getPlatformMBeanServer(); // could use an id...
+ } else {
+ info = new RemoteConnectionInfo();
+ final Map<String, String[]> environment = new HashMap<String, String[]>();
+ if (!on.user().isEmpty()) {
+ environment.put(JMXConnector.CREDENTIALS, new String[]{ on.user(), on.password() });
+ }
+ // ((RemoteConnectionInfo) info).connector = JMXConnectorFactory.newJMXConnector(new JMXServiceURL(on.url()), environment);
+ ((RemoteConnectionInfo) info).connector = JMXConnectorFactory.connect(new JMXServiceURL(on.url()), environment);
+
+ }
+ info.objectName = new ObjectName(on.value());
+
+ infos.put(method, info);
+ }
+ }
+ }
+ return infos.get(method);
+ }
+
+ private abstract static class ConnectionInfo {
+ protected ObjectName objectName;
+
+ public abstract void setAttribute(Attribute attribute) throws Exception;
+ public abstract Object getAttribute(String attribute) throws Exception;
+ public abstract Object invoke(String operationName, Object params[], String signature[]) throws Exception;
+ public abstract MBeanInfo getMBeanInfo() throws Exception;
+ public abstract void clean();
+ }
+
+ private static class LocalConnectionInfo extends ConnectionInfo {
+ private MBeanServer server;
+
+ @Override public void setAttribute(Attribute attribute) throws Exception {
+ server.setAttribute(objectName, attribute);
+ }
+
+ @Override public Object getAttribute(String attribute) throws Exception {
+ return server.getAttribute(objectName, attribute);
+ }
+
+ @Override
+ public Object invoke(String operationName, Object[] params, String[] signature) throws Exception {
+ return server.invoke(objectName, operationName, params, signature);
+ }
+
+ @Override public MBeanInfo getMBeanInfo() throws Exception {
+ return server.getMBeanInfo(objectName);
+ }
+
+ @Override public void clean() {
+ // no-op
+ }
+ }
+
+ private static class RemoteConnectionInfo extends ConnectionInfo {
+ private JMXConnector connector;
+ private MBeanServerConnection connection;
+
+ private void before() throws IOException {
+ connection = connector.getMBeanServerConnection();
+ }
+
+ private void after() throws IOException {
+ // no-op
+ }
+
+ @Override public void setAttribute(Attribute attribute) throws Exception {
+ before();
+ connection.setAttribute(objectName, attribute);
+ after();
+ }
+
+ @Override public Object getAttribute(String attribute) throws Exception {
+ before();
+ try {
+ return connection.getAttribute(objectName, attribute);
+ } finally {
+ after();
+ }
+ }
+
+ @Override
+ public Object invoke(String operationName, Object[] params, String[] signature) throws Exception {
+ before();
+ try {
+ return connection.invoke(objectName, operationName, params, signature);
+ } finally {
+ after();
+ }
+ }
+
+ @Override public MBeanInfo getMBeanInfo() throws Exception {
+ before();
+ try {
+ return connection.getMBeanInfo(objectName);
+ } finally {
+ after();
+ }
+ }
+
+ @Override public void clean() {
+ try {
+ connector.close();
+ } catch (IOException e) {
+ // no-op
+ }
+ }
+ }
+ }
+
+## Dynamic Proxies
+
+### DynamicMBeanClient (the dynamic JMX client)
+
+ package org.superbiz.dynamic.mbean;
+
+ import org.apache.openejb.api.Proxy;
+ import org.superbiz.dynamic.mbean.DynamicMBeanHandler;
+ import org.superbiz.dynamic.mbean.ObjectName;
+
+ import javax.ejb.Singleton;
+
+ /**
+ * @author rmannibucau
+ */
+ @Singleton
+ @Proxy(DynamicMBeanHandler.class)
+ @ObjectName(DynamicMBeanClient.OBJECT_NAME)
+ public interface DynamicMBeanClient {
+ static final String OBJECT_NAME = "test:group=DynamicMBeanClientTest";
+
+ int getCounter();
+ void setCounter(int i);
+ int length(String aString);
+ }
+
+### DynamicMBeanClient (the dynamic JMX client)
+ package org.superbiz.dynamic.mbean;
+
+ import org.apache.openejb.api.Proxy;
+
+ import javax.annotation.PreDestroy;
+ import javax.ejb.Singleton;
+
+
+ @Singleton
+ @Proxy(DynamicMBeanHandler.class)
+ @ObjectName(value = DynamicRemoteMBeanClient.OBJECT_NAME, url = "service:jmx:rmi:///jndi/rmi://localhost:8243/jmxrmi")
+ public interface DynamicRemoteMBeanClient {
+ static final String OBJECT_NAME = "test:group=DynamicMBeanClientTest";
+
+ int getCounter();
+ void setCounter(int i);
+ int length(String aString);
+
+ @PreDestroy void clean();
+ }
+
+## The MBean used for the test
+
+### SimpleMBean
+
+ package org.superbiz.dynamic.mbean.simple;
+
+ public interface SimpleMBean {
+ int length(String s);
+
+ int getCounter();
+ void setCounter(int c);
+ }
+
+## Simple
+
+ package org.superbiz.dynamic.mbean.simple;
+
+ public class Simple implements SimpleMBean {
+ private int counter = 0;
+
+ @Override public int length(String s) {
+ if (s == null) {
+ return 0;
+ }
+ return s.length();
+ }
+
+ @Override public int getCounter() {
+ return counter;
+ }
+
+ @Override public void setCounter(int c) {
+ counter = c;
+ }
+ }
+
+## DynamicMBeanClientTest (The test)
+
+ package org.superbiz.dynamic.mbean;
+
+ import org.junit.After;
+ import org.junit.AfterClass;
+ import org.junit.Before;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+ import org.superbiz.dynamic.mbean.simple.Simple;
+
+ import javax.ejb.EJB;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.management.Attribute;
+ import javax.management.ObjectName;
+ import java.lang.management.ManagementFactory;
+
+ import static junit.framework.Assert.assertEquals;
+
+ public class DynamicMBeanClientTest {
+ private static ObjectName objectName;
+ private static EJBContainer container;
+
+ @EJB private DynamicMBeanClient localClient;
+ @EJB private DynamicRemoteMBeanClient remoteClient;
+
+ @BeforeClass public static void start() {
+ container = EJBContainer.createEJBContainer();
+ }
+
+ @Before public void injectAndRegisterMBean() throws Exception {
+ container.getContext().bind("inject", this);
+ objectName = new ObjectName(DynamicMBeanClient.OBJECT_NAME);
+ ManagementFactory.getPlatformMBeanServer().registerMBean(new Simple(), objectName);
+ }
+
+ @After public void unregisterMBean() throws Exception {
+ if (objectName != null) {
+ ManagementFactory.getPlatformMBeanServer().unregisterMBean(objectName);
+ }
+ }
+
+ @Test public void localGet() throws Exception {
+ assertEquals(0, localClient.getCounter());
+ ManagementFactory.getPlatformMBeanServer().setAttribute(objectName, new Attribute("Counter", 5));
+ assertEquals(5, localClient.getCounter());
+ }
+
+ @Test public void localSet() throws Exception {
+ assertEquals(0, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ localClient.setCounter(8);
+ assertEquals(8, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ }
+
+ @Test public void localOperation() {
+ assertEquals(7, localClient.length("openejb"));
+ }
+
+ @Test public void remoteGet() throws Exception {
+ assertEquals(0, remoteClient.getCounter());
+ ManagementFactory.getPlatformMBeanServer().setAttribute(objectName, new Attribute("Counter", 5));
+ assertEquals(5, remoteClient.getCounter());
+ }
+
+ @Test public void remoteSet() throws Exception {
+ assertEquals(0, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ remoteClient.setCounter(8);
+ assertEquals(8, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ }
+
+ @Test public void remoteOperation() {
+ assertEquals(7, remoteClient.length("openejb"));
+ }
+
+ @AfterClass public static void close() {
+ if (container != null) {
+ container.close();
+ }
+ }
+ }
+
diff --git a/content/examples/dynamic-proxy-to-access-mbean/pom.xml b/content/examples/dynamic-proxy-to-access-mbean/pom.xml
new file mode 100755
index 0000000..dbf02a6
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean/pom.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>dynamic-proxy-to-access-mbean</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Dynamic MBean Proxy</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <argLine>-Dcom.sun.management.jmxremote.port=8243 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-api</artifactId>
+ <version>4.7.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/dynamic-proxy-to-access-mbean/src/main/java/org/superbiz/dynamic/mbean/DynamicMBeanHandler.java b/content/examples/dynamic-proxy-to-access-mbean/src/main/java/org/superbiz/dynamic/mbean/DynamicMBeanHandler.java
new file mode 100755
index 0000000..5f86374
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean/src/main/java/org/superbiz/dynamic/mbean/DynamicMBeanHandler.java
@@ -0,0 +1,260 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.dynamic.mbean;
+
+import javax.annotation.PreDestroy;
+import javax.management.Attribute;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Need a @PreDestroy method to disconnect the remote host when used in remote mode.
+ */
+public class DynamicMBeanHandler implements InvocationHandler {
+
+ private final Map<Method, ConnectionInfo> infos = new ConcurrentHashMap<Method, ConnectionInfo>();
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ final String methodName = method.getName();
+ if (method.getDeclaringClass().equals(Object.class) && "toString".equals(methodName)) {
+ return getClass().getSimpleName() + " Proxy";
+ }
+ if (method.getAnnotation(PreDestroy.class) != null) {
+ return destroy();
+ }
+
+ final ConnectionInfo info = getConnectionInfo(method);
+ final MBeanInfo infos = info.getMBeanInfo();
+ if (methodName.startsWith("set") && methodName.length() > 3 && args != null && args.length == 1
+ && (Void.TYPE.equals(method.getReturnType()) || Void.class.equals(method.getReturnType()))) {
+ final String attributeName = attributeName(infos, methodName, method.getParameterTypes()[0]);
+ info.setAttribute(new Attribute(attributeName, args[0]));
+ return null;
+ } else if (methodName.startsWith("get") && (args == null || args.length == 0) && methodName.length() > 3) {
+ final String attributeName = attributeName(infos, methodName, method.getReturnType());
+ return info.getAttribute(attributeName);
+ }
+ // operation
+ return info.invoke(methodName, args, getSignature(method));
+ }
+
+ public Object destroy() {
+ for (ConnectionInfo info : infos.values()) {
+ info.clean();
+ }
+ infos.clear();
+ return null;
+ }
+
+ private String[] getSignature(Method method) {
+ String[] args = new String[method.getParameterTypes().length];
+ for (int i = 0; i < method.getParameterTypes().length; i++) {
+ args[i] = method.getParameterTypes()[i].getName();
+ }
+ return args; // note: null should often work...
+ }
+
+ private String attributeName(MBeanInfo infos, String methodName, Class<?> type) {
+ String found = null;
+ String foundBackUp = null; // without checking the type
+ final String attributeName = methodName.substring(3, methodName.length());
+ final String lowerName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4, methodName.length());
+
+ for (MBeanAttributeInfo attribute : infos.getAttributes()) {
+ final String name = attribute.getName();
+ if (attributeName.equals(name)) {
+ foundBackUp = attributeName;
+ if (attribute.getType().equals(type.getName())) {
+ found = name;
+ }
+ } else if (found == null && ((lowerName.equals(name) && !attributeName.equals(name))
+ || lowerName.equalsIgnoreCase(name))) {
+ foundBackUp = name;
+ if (attribute.getType().equals(type.getName())) {
+ found = name;
+ }
+ }
+ }
+
+ if (found == null && foundBackUp == null) {
+ throw new UnsupportedOperationException("cannot find attribute " + attributeName);
+ }
+
+ if (found != null) {
+ return found;
+ }
+ return foundBackUp;
+ }
+
+ private synchronized ConnectionInfo getConnectionInfo(Method method) throws Exception {
+ if (!infos.containsKey(method)) {
+ synchronized (infos) {
+ if (!infos.containsKey(method)) { // double check for synchro
+ org.superbiz.dynamic.mbean.ObjectName on = method.getAnnotation(org.superbiz.dynamic.mbean.ObjectName.class);
+ if (on == null) {
+ Class<?> current = method.getDeclaringClass();
+ do {
+ on = method.getDeclaringClass().getAnnotation(org.superbiz.dynamic.mbean.ObjectName.class);
+ current = current.getSuperclass();
+ } while (on == null && current != null);
+ if (on == null) {
+ throw new UnsupportedOperationException("class or method should define the objectName to use for invocation: " + method.toGenericString());
+ }
+ }
+ final ConnectionInfo info;
+ if (on.url().isEmpty()) {
+ info = new LocalConnectionInfo();
+ ((LocalConnectionInfo) info).server = ManagementFactory.getPlatformMBeanServer(); // could use an id...
+ } else {
+ info = new RemoteConnectionInfo();
+ final Map<String, String[]> environment = new HashMap<String, String[]>();
+ if (!on.user().isEmpty()) {
+ environment.put(JMXConnector.CREDENTIALS, new String[]{on.user(), on.password()});
+ }
+ // ((RemoteConnectionInfo) info).connector = JMXConnectorFactory.newJMXConnector(new JMXServiceURL(on.url()), environment);
+ ((RemoteConnectionInfo) info).connector = JMXConnectorFactory.connect(new JMXServiceURL(on.url()), environment);
+
+ }
+ info.objectName = new ObjectName(on.value());
+
+ infos.put(method, info);
+ }
+ }
+ }
+ return infos.get(method);
+ }
+
+ private abstract static class ConnectionInfo {
+
+ protected ObjectName objectName;
+
+ public abstract void setAttribute(Attribute attribute) throws Exception;
+
+ public abstract Object getAttribute(String attribute) throws Exception;
+
+ public abstract Object invoke(String operationName, Object params[], String signature[]) throws Exception;
+
+ public abstract MBeanInfo getMBeanInfo() throws Exception;
+
+ public abstract void clean();
+ }
+
+ private static class LocalConnectionInfo extends ConnectionInfo {
+
+ private MBeanServer server;
+
+ @Override
+ public void setAttribute(Attribute attribute) throws Exception {
+ server.setAttribute(objectName, attribute);
+ }
+
+ @Override
+ public Object getAttribute(String attribute) throws Exception {
+ return server.getAttribute(objectName, attribute);
+ }
+
+ @Override
+ public Object invoke(String operationName, Object[] params, String[] signature) throws Exception {
+ return server.invoke(objectName, operationName, params, signature);
+ }
+
+ @Override
+ public MBeanInfo getMBeanInfo() throws Exception {
+ return server.getMBeanInfo(objectName);
+ }
+
+ @Override
+ public void clean() {
+ // no-op
+ }
+ }
+
+ private static class RemoteConnectionInfo extends ConnectionInfo {
+
+ private JMXConnector connector;
+ private MBeanServerConnection connection;
+
+ private void before() throws IOException {
+ connection = connector.getMBeanServerConnection();
+ }
+
+ private void after() throws IOException {
+ // no-op
+ }
+
+ @Override
+ public void setAttribute(Attribute attribute) throws Exception {
+ before();
+ connection.setAttribute(objectName, attribute);
+ after();
+ }
+
+ @Override
+ public Object getAttribute(String attribute) throws Exception {
+ before();
+ try {
+ return connection.getAttribute(objectName, attribute);
+ } finally {
+ after();
+ }
+ }
+
+ @Override
+ public Object invoke(String operationName, Object[] params, String[] signature) throws Exception {
+ before();
+ try {
+ return connection.invoke(objectName, operationName, params, signature);
+ } finally {
+ after();
+ }
+ }
+
+ @Override
+ public MBeanInfo getMBeanInfo() throws Exception {
+ before();
+ try {
+ return connection.getMBeanInfo(objectName);
+ } finally {
+ after();
+ }
+ }
+
+ @Override
+ public void clean() {
+ try {
+ connector.close();
+ } catch (IOException e) {
+ // no-op
+ }
+ }
+ }
+}
diff --git a/content/examples/dynamic-proxy-to-access-mbean/src/main/java/org/superbiz/dynamic/mbean/ObjectName.java b/content/examples/dynamic-proxy-to-access-mbean/src/main/java/org/superbiz/dynamic/mbean/ObjectName.java
new file mode 100755
index 0000000..21b9a77
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean/src/main/java/org/superbiz/dynamic/mbean/ObjectName.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.dynamic.mbean;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+public @interface ObjectName {
+
+ String value();
+
+ // for remote usage only
+ String url() default "";
+
+ String user() default "";
+
+ String password() default "";
+}
diff --git a/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/DynamicMBeanClient.java b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/DynamicMBeanClient.java
new file mode 100755
index 0000000..8ecee58
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/DynamicMBeanClient.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.dynamic.mbean;
+
+import org.apache.openejb.api.Proxy;
+
+import javax.ejb.Singleton;
+
+@Singleton
+@Proxy(DynamicMBeanHandler.class)
+@ObjectName(DynamicMBeanClient.OBJECT_NAME)
+public interface DynamicMBeanClient {
+
+ static final String OBJECT_NAME = "test:group=DynamicMBeanClientTest";
+
+ int getCounter();
+
+ void setCounter(int i);
+
+ int length(String aString);
+}
diff --git a/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/DynamicMBeanClientTest.java b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/DynamicMBeanClientTest.java
new file mode 100755
index 0000000..dfd24f7
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/DynamicMBeanClientTest.java
@@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.dynamic.mbean;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.superbiz.dynamic.mbean.simple.Simple;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.management.Attribute;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+
+import static org.junit.Assert.assertEquals;
+
+public class DynamicMBeanClientTest {
+
+ private static ObjectName objectName;
+ private static EJBContainer container;
+
+ @EJB
+ private DynamicMBeanClient localClient;
+ @EJB
+ private DynamicRemoteMBeanClient remoteClient;
+
+ @BeforeClass
+ public static void start() {
+ container = EJBContainer.createEJBContainer();
+ }
+
+ @Before
+ public void injectAndRegisterMBean() throws Exception {
+ container.getContext().bind("inject", this);
+ objectName = new ObjectName(DynamicMBeanClient.OBJECT_NAME);
+ ManagementFactory.getPlatformMBeanServer().registerMBean(new Simple(), objectName);
+ }
+
+ @After
+ public void unregisterMBean() throws Exception {
+ if (objectName != null) {
+ ManagementFactory.getPlatformMBeanServer().unregisterMBean(objectName);
+ }
+ }
+
+ @Test
+ public void localGet() throws Exception {
+ assertEquals(0, localClient.getCounter());
+ ManagementFactory.getPlatformMBeanServer().setAttribute(objectName, new Attribute("Counter", 5));
+ assertEquals(5, localClient.getCounter());
+ }
+
+ @Test
+ public void localSet() throws Exception {
+ assertEquals(0, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ localClient.setCounter(8);
+ assertEquals(8, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ }
+
+ @Test
+ public void localOperation() {
+ assertEquals(7, localClient.length("openejb"));
+ }
+
+ @Test
+ public void remoteGet() throws Exception {
+ assertEquals(0, remoteClient.getCounter());
+ ManagementFactory.getPlatformMBeanServer().setAttribute(objectName, new Attribute("Counter", 5));
+ assertEquals(5, remoteClient.getCounter());
+ }
+
+ @Test
+ public void remoteSet() throws Exception {
+ assertEquals(0, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ remoteClient.setCounter(8);
+ assertEquals(8, ((Integer) ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "Counter")).intValue());
+ }
+
+ @Test
+ public void remoteOperation() {
+ assertEquals(7, remoteClient.length("openejb"));
+ }
+
+ @AfterClass
+ public static void close() {
+ if (container != null) {
+ container.close();
+ }
+ }
+}
diff --git a/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/DynamicRemoteMBeanClient.java b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/DynamicRemoteMBeanClient.java
new file mode 100755
index 0000000..2051c99
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/DynamicRemoteMBeanClient.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.dynamic.mbean;
+
+import org.apache.openejb.api.Proxy;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.Singleton;
+
+@Singleton
+@Proxy(DynamicMBeanHandler.class)
+@ObjectName(value = DynamicRemoteMBeanClient.OBJECT_NAME, url = "service:jmx:rmi:///jndi/rmi://localhost:8243/jmxrmi")
+public interface DynamicRemoteMBeanClient {
+
+ static final String OBJECT_NAME = "test:group=DynamicMBeanClientTest";
+
+ int getCounter();
+
+ void setCounter(int i);
+
+ int length(String aString);
+
+ @PreDestroy
+ void clean();
+}
diff --git a/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/simple/Simple.java b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/simple/Simple.java
new file mode 100755
index 0000000..de5fec6
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/simple/Simple.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.dynamic.mbean.simple;
+
+public class Simple implements SimpleMBean {
+
+ private int counter = 0;
+
+ @Override
+ public int length(String s) {
+ if (s == null) {
+ return 0;
+ }
+ return s.length();
+ }
+
+ @Override
+ public int getCounter() {
+ return counter;
+ }
+
+ @Override
+ public void setCounter(int c) {
+ counter = c;
+ }
+}
diff --git a/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/simple/SimpleMBean.java b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/simple/SimpleMBean.java
new file mode 100755
index 0000000..1b176bd
--- /dev/null
+++ b/content/examples/dynamic-proxy-to-access-mbean/src/test/java/org/superbiz/dynamic/mbean/simple/SimpleMBean.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.dynamic.mbean.simple;
+
+public interface SimpleMBean {
+
+ int length(String s);
+
+ int getCounter();
+
+ void setCounter(int c);
+}
diff --git a/content/examples/ear-testing.html b/content/examples/ear-testing.html
new file mode 100644
index 0000000..45b3e52
--- /dev/null
+++ b/content/examples/ear-testing.html
@@ -0,0 +1,431 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/ear-testing.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>EAR Testing</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example ear-testing can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/ear-testing" class="bare">https://github.com/apache/tomee/tree/master/examples/ear-testing</a></p>
+</div>
+<div class="paragraph">
+<p>The goal of this example is to demonstrate how maven projects might be organized in a more real world style and how testing with OpenEJB can fit into that structure.</p>
+</div>
+<div class="paragraph">
+<p>This example takes the basic moviefun code we us in many of examples and splits it into two modules:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><code>business-logic</code></p>
+</li>
+<li>
+<p><code>business-model</code></p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>As the names imply, we keep our <code>@Entity</code> beans in the <code>business-model</code> module and our session beans in the <code>business-logic</code> model. The tests located and run from the business logic module.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>ear-testing
+ear-testing/business-logic
+ear-testing/business-logic/pom.xml
+ear-testing/business-logic/src/main/java/org/superbiz/logic/Movies.java
+ear-testing/business-logic/src/main/java/org/superbiz/logic/MoviesImpl.java
+ear-testing/business-logic/src/main/resources
+ear-testing/business-logic/src/main/resources/META-INF
+ear-testing/business-logic/src/main/resources/META-INF/ejb-jar.xml
+ear-testing/business-logic/src/test/java/org/superbiz/logic/MoviesTest.java
+ear-testing/business-model
+ear-testing/business-model/pom.xml
+ear-testing/business-model/src/main/java/org/superbiz/model/Movie.java
+ear-testing/business-model/src/main/resources/META-INF/persistence.xml
+ear-testing/pom.xml</pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_project_configuration" class="sect0">Project configuration</h1>
+<div class="paragraph">
+<p>The parent pom, trimmed to the minimum, looks like so:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myear</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>business-model</module>
+ <module>business-logic</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The <code>business-model/pom.xml</code> as follows:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myear</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>business-model</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>And finally, the <code>business-logic/pom.xml</code> which is setup to support embedded testing with OpenEJB:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myear</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>business-logic</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.superbiz</groupId>
+ <artifactId>business-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>7.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project></code></pre>
+</div>
+</div>
+<h1 id="_testcode" class="sect0">TestCode</h1>
+<div class="paragraph">
+<p>The test code is the same as always:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ p.put("openejb.deployments.classpath.ear", "true");
+
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ p.put("movieDatabaseUnmanaged", "new://Resource?type=DataSource");
+ p.put("movieDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.put("movieDatabaseUnmanaged.JtaManaged", "false");
+
+ Context context = new InitialContext(p);
+
+ Movies movies = (Movies) context.lookup("MoviesLocal");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.logic.MoviesTest
+Apache OpenEJB 7.0.0-SNAPSHOT build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/ear-testing/business-logic
+INFO - openejb.base = /Users/dblevins/examples/ear-testing/business-logic
+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 - Configuring Service(id=movieDatabaseUnmanaged, type=Resource, provider-id=Default JDBC Database)
+INFO - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found PersistenceModule in classpath: /Users/dblevins/examples/ear-testing/business-model/target/business-model-1.0.jar
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/ear-testing/business-logic/target/classes
+INFO - Using 'openejb.deployments.classpath.ear=true'
+INFO - Beginning load: /Users/dblevins/examples/ear-testing/business-model/target/business-model-1.0.jar
+INFO - Beginning load: /Users/dblevins/examples/ear-testing/business-logic/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/ear-testing/business-logic/classpath.ear
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Enterprise application "/Users/dblevins/examples/ear-testing/business-logic/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/ear-testing/business-logic/classpath.ear
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 415ms
+INFO - Jndi(name=MoviesLocal) --> Ejb(deployment-id=Movies)
+INFO - Jndi(name=global/classpath.ear/business-logic/Movies!org.superbiz.logic.Movies) --> Ejb(deployment-id=Movies)
+INFO - Jndi(name=global/classpath.ear/business-logic/Movies) --> Ejb(deployment-id=Movies)
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/ear-testing/business-logic/classpath.ear)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.393 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/ear-testing.pdf b/content/examples/ear-testing.pdf
new file mode 100644
index 0000000..85eba6a
--- /dev/null
+++ b/content/examples/ear-testing.pdf
Binary files differ
diff --git a/content/examples/ear-testing/README.md b/content/examples/ear-testing/README.md
new file mode 100755
index 0000000..cf20430
--- /dev/null
+++ b/content/examples/ear-testing/README.md
@@ -0,0 +1,212 @@
+Title: EAR Testing
+
+The goal of this example is to demonstrate how maven projects might be organized in a more real world style and how testing with OpenEJB can fit into that structure.
+
+This example takes the basic moviefun code we us in many of examples and splits it into two modules:
+
+ - `business-logic`
+ - `business-model`
+
+As the names imply, we keep our `@Entity` beans in the `business-model` module and our session beans in the `business-logic` model. The tests located and run from the business logic module.
+
+ ear-testing
+ ear-testing/business-logic
+ ear-testing/business-logic/pom.xml
+ ear-testing/business-logic/src/main/java/org/superbiz/logic/Movies.java
+ ear-testing/business-logic/src/main/java/org/superbiz/logic/MoviesImpl.java
+ ear-testing/business-logic/src/main/resources
+ ear-testing/business-logic/src/main/resources/META-INF
+ ear-testing/business-logic/src/main/resources/META-INF/ejb-jar.xml
+ ear-testing/business-logic/src/test/java/org/superbiz/logic/MoviesTest.java
+ ear-testing/business-model
+ ear-testing/business-model/pom.xml
+ ear-testing/business-model/src/main/java/org/superbiz/model/Movie.java
+ ear-testing/business-model/src/main/resources/META-INF/persistence.xml
+ ear-testing/pom.xml
+
+# Project configuration
+
+The parent pom, trimmed to the minimum, looks like so:
+
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myear</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>business-model</module>
+ <module>business-logic</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ </project>
+
+The `business-model/pom.xml` as follows:
+
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myear</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>business-model</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ </project>
+
+And finally, the `business-logic/pom.xml` which is setup to support embedded testing with OpenEJB:
+
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myear</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>business-logic</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.superbiz</groupId>
+ <artifactId>business-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.0.0-beta-1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </project>
+
+# TestCode
+
+The test code is the same as always:
+
+ public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ p.put("openejb.deployments.classpath.ear", "true");
+
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ p.put("movieDatabaseUnmanaged", "new://Resource?type=DataSource");
+ p.put("movieDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.put("movieDatabaseUnmanaged.JtaManaged", "false");
+
+ Context context = new InitialContext(p);
+
+ Movies movies = (Movies) context.lookup("MoviesLocal");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+ }
+
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.logic.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/ear-testing/business-logic
+ INFO - openejb.base = /Users/dblevins/examples/ear-testing/business-logic
+ 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 - Configuring Service(id=movieDatabaseUnmanaged, type=Resource, provider-id=Default JDBC Database)
+ INFO - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found PersistenceModule in classpath: /Users/dblevins/examples/ear-testing/business-model/target/business-model-1.0.jar
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/ear-testing/business-logic/target/classes
+ INFO - Using 'openejb.deployments.classpath.ear=true'
+ INFO - Beginning load: /Users/dblevins/examples/ear-testing/business-model/target/business-model-1.0.jar
+ INFO - Beginning load: /Users/dblevins/examples/ear-testing/business-logic/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/ear-testing/business-logic/classpath.ear
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Enterprise application "/Users/dblevins/examples/ear-testing/business-logic/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/ear-testing/business-logic/classpath.ear
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 415ms
+ INFO - Jndi(name=MoviesLocal) --> Ejb(deployment-id=Movies)
+ INFO - Jndi(name=global/classpath.ear/business-logic/Movies!org.superbiz.logic.Movies) --> Ejb(deployment-id=Movies)
+ INFO - Jndi(name=global/classpath.ear/business-logic/Movies) --> Ejb(deployment-id=Movies)
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/ear-testing/business-logic/classpath.ear)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.393 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
diff --git a/content/examples/ear-testing/business-logic/pom.xml b/content/examples/ear-testing/business-logic/pom.xml
new file mode 100755
index 0000000..8f142dc
--- /dev/null
+++ b/content/examples/ear-testing/business-logic/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 638272 $ $Date: 2008-03-18 01:59:59 -0700 (Tue, 18 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myear</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>business-logic</artifactId>
+ <packaging>jar</packaging>
+ <name>OpenEJB :: Examples :: Ear Testing :: Business Logic</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots/</url>
+ </repository>
+ </repositories>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.superbiz</groupId>
+ <artifactId>business-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/content/examples/ear-testing/business-logic/src/main/java/org/superbiz/logic/Movies.java b/content/examples/ear-testing/business-logic/src/main/java/org/superbiz/logic/Movies.java
new file mode 100755
index 0000000..02e09e2
--- /dev/null
+++ b/content/examples/ear-testing/business-logic/src/main/java/org/superbiz/logic/Movies.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.logic;
+
+import org.superbiz.model.Movie;
+
+import java.util.List;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public interface Movies {
+
+ void addMovie(Movie movie) throws Exception;
+
+ void deleteMovie(Movie movie) throws Exception;
+
+ List<Movie> getMovies() throws Exception;
+}
diff --git a/content/examples/ear-testing/business-logic/src/main/java/org/superbiz/logic/MoviesImpl.java b/content/examples/ear-testing/business-logic/src/main/java/org/superbiz/logic/MoviesImpl.java
new file mode 100755
index 0000000..a78c761
--- /dev/null
+++ b/content/examples/ear-testing/business-logic/src/main/java/org/superbiz/logic/MoviesImpl.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.logic;
+
+//START SNIPPET: code
+
+import org.superbiz.model.Movie;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful(name = "Movies")
+public class MoviesImpl implements Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/ear-testing/business-logic/src/main/resources/META-INF/ejb-jar.xml b/content/examples/ear-testing/business-logic/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..91be4f8
--- /dev/null
+++ b/content/examples/ear-testing/business-logic/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
diff --git a/content/examples/ear-testing/business-logic/src/test/java/org/superbiz/logic/MoviesTest.java b/content/examples/ear-testing/business-logic/src/test/java/org/superbiz/logic/MoviesTest.java
new file mode 100755
index 0000000..b589ff4
--- /dev/null
+++ b/content/examples/ear-testing/business-logic/src/test/java/org/superbiz/logic/MoviesTest.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.logic;
+
+import junit.framework.TestCase;
+import org.superbiz.model.Movie;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ p.put("openejb.deployments.classpath.ear", "true");
+
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ p.put("movieDatabaseUnmanaged", "new://Resource?type=DataSource");
+ p.put("movieDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.put("movieDatabaseUnmanaged.JtaManaged", "false");
+
+ Context context = new InitialContext(p);
+
+ Movies movies = (Movies) context.lookup("MoviesLocal");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/ear-testing/business-model/pom.xml b/content/examples/ear-testing/business-model/pom.xml
new file mode 100755
index 0000000..e435c0c
--- /dev/null
+++ b/content/examples/ear-testing/business-model/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 638272 $ $Date: 2008-03-18 01:59:59 -0700 (Tue, 18 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myear</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>business-model</artifactId>
+ <packaging>jar</packaging>
+ <name>OpenEJB :: Examples :: Ear Testing :: Business Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/content/examples/ear-testing/business-model/src/main/java/org/superbiz/model/Movie.java b/content/examples/ear-testing/business-model/src/main/java/org/superbiz/model/Movie.java
new file mode 100755
index 0000000..f348166
--- /dev/null
+++ b/content/examples/ear-testing/business-model/src/main/java/org/superbiz/model/Movie.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.model;
+//START SNIPPET: code
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/ear-testing/business-model/src/main/resources/META-INF/persistence.xml b/content/examples/ear-testing/business-model/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..a92d490
--- /dev/null
+++ b/content/examples/ear-testing/business-model/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- START SNIPPET: code -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.model.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
+ <!-- END SNIPPET: code -->
diff --git a/content/examples/ear-testing/pom.xml b/content/examples/ear-testing/pom.xml
new file mode 100755
index 0000000..2bd0e00
--- /dev/null
+++ b/content/examples/ear-testing/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 661532 $ $Date: 2008-05-29 16:46:42 -0700 (Thu, 29 May 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myear</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>OpenEJB :: Examples :: Ear Testing</name>
+ <modules>
+ <module>business-model</module>
+ <module>business-logic</module>
+ </modules>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots/</url>
+ </repository>
+ </repositories>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/ejb-examples.html b/content/examples/ejb-examples.html
new file mode 100644
index 0000000..2f2afb1
--- /dev/null
+++ b/content/examples/ejb-examples.html
@@ -0,0 +1,1395 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/ejb-examples.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>EJB Examples</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example ejb-examples can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/ejb-examples" class="bare">https://github.com/apache/tomee/tree/master/examples/ejb-examples</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_annotatedejb">AnnotatedEJB</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.annotation.Resource;
+import javax.ejb.LocalBean;
+import javax.ejb.Stateless;
+import javax.sql.DataSource;
+
+@Stateless
+@LocalBean
+public class AnnotatedEJB implements AnnotatedEJBLocal, AnnotatedEJBRemote {
+ @Resource
+ private DataSource ds;
+
+ private String name = "foo";
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public DataSource getDs() {
+ return ds;
+ }
+
+ public void setDs(DataSource ds) {
+ this.ds = ds;
+ }
+
+ public String toString() {
+ return "AnnotatedEJB[name=" + name + "]";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_annotatedejblocal">AnnotatedEJBLocal</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.ejb.Local;
+import javax.sql.DataSource;
+
+@Local
+public interface AnnotatedEJBLocal {
+ String getName();
+
+ void setName(String name);
+
+ DataSource getDs();
+
+ void setDs(DataSource ds);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_annotatedejbremote">AnnotatedEJBRemote</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface AnnotatedEJBRemote {
+ String getName();
+
+ void setName(String name);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_annotatedservlet">AnnotatedServlet</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.sql.DataSource;
+import java.io.IOException;
+
+public class AnnotatedServlet extends HttpServlet {
+ @EJB
+ private AnnotatedEJBLocal localEJB;
+
+ @EJB
+ private AnnotatedEJBRemote remoteEJB;
+
+ @EJB
+ private AnnotatedEJB localbeanEJB;
+
+ @Resource
+ private DataSource ds;
+
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("LocalBean EJB");
+ out.println("@EJB=" + localbeanEJB);
+ if (localbeanEJB != null) {
+ out.println("@EJB.getName()=" + localbeanEJB.getName());
+ out.println("@EJB.getDs()=" + localbeanEJB.getDs());
+ }
+ out.println("JNDI=" + lookupField("localbeanEJB"));
+ out.println();
+
+ out.println("Local EJB");
+ out.println("@EJB=" + localEJB);
+ if (localEJB != null) {
+ out.println("@EJB.getName()=" + localEJB.getName());
+ out.println("@EJB.getDs()=" + localEJB.getDs());
+ }
+ out.println("JNDI=" + lookupField("localEJB"));
+ out.println();
+
+ out.println("Remote EJB");
+ out.println("@EJB=" + remoteEJB);
+ if (localEJB != null) {
+ out.println("@EJB.getName()=" + remoteEJB.getName());
+ }
+ out.println("JNDI=" + lookupField("remoteEJB"));
+ out.println();
+
+
+ out.println("DataSource");
+ out.println("@Resource=" + ds);
+ out.println("JNDI=" + lookupField("ds"));
+ }
+
+ private Object lookupField(String name) {
+ try {
+ return new InitialContext().lookup("java:comp/env/" + getClass().getName() + "/" + name);
+ } catch (NamingException e) {
+ return null;
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_clienthandler">ClientHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+
+public class ClientHandler implements Handler {
+ public boolean handleMessage(MessageContext messageContext) {
+ WebserviceServlet.write(" ClientHandler handleMessage");
+ return true;
+ }
+
+ public void close(MessageContext messageContext) {
+ WebserviceServlet.write(" ClientHandler close");
+ }
+
+ public boolean handleFault(MessageContext messageContext) {
+ WebserviceServlet.write(" ClientHandler handleFault");
+ return true;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_helloejb">HelloEjb</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://examples.org/wsdl")
+public interface HelloEjb {
+ String hello(String name);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_helloejbservice">HelloEjbService</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.ejb.Stateless;
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+@WebService(
+ portName = "HelloEjbPort",
+ serviceName = "HelloEjbService",
+ targetNamespace = "http://examples.org/wsdl",
+ endpointInterface = "org.superbiz.servlet.HelloEjb"
+)
+@HandlerChain(file = "server-handlers.xml")
+@Stateless
+public class HelloEjbService implements HelloEjb {
+ public String hello(String name) {
+ WebserviceServlet.write(" HelloEjbService hello(" + name + ")");
+ if (name == null) name = "World";
+ return "Hello " + name + " from EJB Webservice!";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_hellopojo">HelloPojo</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://examples.org/wsdl")
+public interface HelloPojo {
+ String hello(String name);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_hellopojoservice">HelloPojoService</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+@WebService(
+ portName = "HelloPojoPort",
+ serviceName = "HelloPojoService",
+ targetNamespace = "http://examples.org/wsdl",
+ endpointInterface = "org.superbiz.servlet.HelloPojo"
+)
+@HandlerChain(file = "server-handlers.xml")
+public class HelloPojoService implements HelloPojo {
+ public String hello(String name) {
+ WebserviceServlet.write(" HelloPojoService hello(" + name + ")");
+ if (name == null) name = "World";
+ return "Hello " + name + " from Pojo Webservice!";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_jndiservlet">JndiServlet</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
+import javax.naming.NamingException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class JndiServlet extends HttpServlet {
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ Map<String, Object> bindings = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
+ try {
+ Context context = (Context) new InitialContext().lookup("java:comp/");
+ addBindings("", bindings, context);
+ } catch (NamingException e) {
+ throw new ServletException(e);
+ }
+
+ out.println("JNDI Context:");
+ for (Map.Entry<String, Object> entry : bindings.entrySet()) {
+ if (entry.getValue() != null) {
+ out.println(" " + entry.getKey() + "=" + entry.getValue());
+ } else {
+ out.println(" " + entry.getKey());
+ }
+ }
+ }
+
+ private void addBindings(String path, Map<String, Object> bindings, Context context) {
+ try {
+ for (NameClassPair pair : Collections.list(context.list(""))) {
+ String name = pair.getName();
+ String className = pair.getClassName();
+ if ("org.apache.naming.resources.FileDirContext$FileResource".equals(className)) {
+ bindings.put(path + name, "<file>");
+ } else {
+ try {
+ Object value = context.lookup(name);
+ if (value instanceof Context) {
+ Context nextedContext = (Context) value;
+ bindings.put(path + name, "");
+ addBindings(path + name + "/", bindings, nextedContext);
+ } else {
+ bindings.put(path + name, value);
+ }
+ } catch (NamingException e) {
+ // lookup failed
+ bindings.put(path + name, "ERROR: " + e.getMessage());
+ }
+ }
+ }
+ } catch (NamingException e) {
+ bindings.put(path, "ERROR: list bindings threw an exception: " + e.getMessage());
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_jpabean">JpaBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class JpaBean {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private int id;
+
+ @Column(name = "name")
+ private String name;
+
+ public int getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ public String toString() {
+ return "[JpaBean id=" + id + ", name=" + name + "]";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_jpaservlet">JpaServlet</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.PersistenceUnit;
+import javax.persistence.Query;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class JpaServlet extends HttpServlet {
+ @PersistenceUnit(name = "jpa-example")
+ private EntityManagerFactory emf;
+
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("@PersistenceUnit=" + emf);
+
+ EntityManager em = emf.createEntityManager();
+ EntityTransaction transaction = em.getTransaction();
+ transaction.begin();
+
+ JpaBean jpaBean = new JpaBean();
+ jpaBean.setName("JpaBean");
+ em.persist(jpaBean);
+
+ transaction.commit();
+ transaction.begin();
+
+ Query query = em.createQuery("SELECT j FROM JpaBean j WHERE j.name='JpaBean'");
+ jpaBean = (JpaBean) query.getSingleResult();
+ out.println("Loaded " + jpaBean);
+
+ em.remove(jpaBean);
+
+ transaction.commit();
+ transaction.begin();
+
+ query = em.createQuery("SELECT count(j) FROM JpaBean j WHERE j.name='JpaBean'");
+ int count = ((Number) query.getSingleResult()).intValue();
+ if (count == 0) {
+ out.println("Removed " + jpaBean);
+ } else {
+ out.println("ERROR: unable to remove" + jpaBean);
+ }
+
+ transaction.commit();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_resourcebean">ResourceBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+public class ResourceBean {
+ private String value;
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return "[ResourceBean " + value + "]";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_runasservlet">RunAsServlet</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.security.Principal;
+
+public class RunAsServlet extends HttpServlet {
+ @EJB
+ private SecureEJBLocal secureEJBLocal;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("Servlet");
+ Principal principal = request.getUserPrincipal();
+ if (principal != null) {
+ out.println("Servlet.getUserPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("Servlet.getUserPrincipal()=<null>");
+ }
+ out.println("Servlet.isCallerInRole(\"user\")=" + request.isUserInRole("user"));
+ out.println("Servlet.isCallerInRole(\"manager\")=" + request.isUserInRole("manager"));
+ out.println("Servlet.isCallerInRole(\"fake\")=" + request.isUserInRole("fake"));
+ out.println();
+
+ out.println("@EJB=" + secureEJBLocal);
+ if (secureEJBLocal != null) {
+ principal = secureEJBLocal.getCallerPrincipal();
+ if (principal != null) {
+ out.println("@EJB.getCallerPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("@EJB.getCallerPrincipal()=<null>");
+ }
+ out.println("@EJB.isCallerInRole(\"user\")=" + secureEJBLocal.isCallerInRole("user"));
+ out.println("@EJB.isCallerInRole(\"manager\")=" + secureEJBLocal.isCallerInRole("manager"));
+ out.println("@EJB.isCallerInRole(\"fake\")=" + secureEJBLocal.isCallerInRole("fake"));
+
+ try {
+ secureEJBLocal.allowUserMethod();
+ out.println("@EJB.allowUserMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowUserMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowManagerMethod();
+ out.println("@EJB.allowManagerMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowManagerMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowFakeMethod();
+ out.println("@EJB.allowFakeMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowFakeMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.denyAllMethod();
+ out.println("@EJB.denyAllMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.denyAllMethod() DENIED");
+ }
+ }
+ out.println();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_secureejb">SecureEJB</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.annotation.Resource;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.DenyAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import java.security.Principal;
+
+@Stateless
+@DeclareRoles({"user", "manager", "fake"})
+public class SecureEJB implements SecureEJBLocal {
+ @Resource
+ private SessionContext context;
+
+ public Principal getCallerPrincipal() {
+ return context.getCallerPrincipal();
+ }
+
+ public boolean isCallerInRole(String role) {
+ return context.isCallerInRole(role);
+ }
+
+ @RolesAllowed("user")
+ public void allowUserMethod() {
+ }
+
+ @RolesAllowed("manager")
+ public void allowManagerMethod() {
+ }
+
+ @RolesAllowed("fake")
+ public void allowFakeMethod() {
+ }
+
+ @DenyAll
+ public void denyAllMethod() {
+ }
+
+ public String toString() {
+ return "SecureEJB[userName=" + getCallerPrincipal() + "]";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_secureejblocal">SecureEJBLocal</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.ejb.Local;
+import java.security.Principal;
+
+@Local
+public interface SecureEJBLocal {
+ Principal getCallerPrincipal();
+
+ boolean isCallerInRole(String role);
+
+ void allowUserMethod();
+
+ void allowManagerMethod();
+
+ void allowFakeMethod();
+
+ void denyAllMethod();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_secureservlet">SecureServlet</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.security.Principal;
+
+public class SecureServlet extends HttpServlet {
+ @EJB
+ private SecureEJBLocal secureEJBLocal;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("Servlet");
+ Principal principal = request.getUserPrincipal();
+ if (principal != null) {
+ out.println("Servlet.getUserPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("Servlet.getUserPrincipal()=<null>");
+ }
+ out.println("Servlet.isCallerInRole(\"user\")=" + request.isUserInRole("user"));
+ out.println("Servlet.isCallerInRole(\"manager\")=" + request.isUserInRole("manager"));
+ out.println("Servlet.isCallerInRole(\"fake\")=" + request.isUserInRole("fake"));
+ out.println();
+
+ out.println("@EJB=" + secureEJBLocal);
+ if (secureEJBLocal != null) {
+ principal = secureEJBLocal.getCallerPrincipal();
+ if (principal != null) {
+ out.println("@EJB.getCallerPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("@EJB.getCallerPrincipal()=<null>");
+ }
+ out.println("@EJB.isCallerInRole(\"user\")=" + secureEJBLocal.isCallerInRole("user"));
+ out.println("@EJB.isCallerInRole(\"manager\")=" + secureEJBLocal.isCallerInRole("manager"));
+ out.println("@EJB.isCallerInRole(\"fake\")=" + secureEJBLocal.isCallerInRole("fake"));
+
+ try {
+ secureEJBLocal.allowUserMethod();
+ out.println("@EJB.allowUserMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowUserMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowManagerMethod();
+ out.println("@EJB.allowManagerMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowManagerMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowFakeMethod();
+ out.println("@EJB.allowFakeMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowFakeMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.denyAllMethod();
+ out.println("@EJB.denyAllMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.denyAllMethod() DENIED");
+ }
+ }
+ out.println();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_serverhandler">ServerHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+
+public class ServerHandler implements Handler {
+ public boolean handleMessage(MessageContext messageContext) {
+ WebserviceServlet.write(" ServerHandler handleMessage");
+ return true;
+ }
+
+ public void close(MessageContext messageContext) {
+ WebserviceServlet.write(" ServerHandler close");
+ }
+
+ public boolean handleFault(MessageContext messageContext) {
+ WebserviceServlet.write(" ServerHandler handleFault");
+ return true;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_webserviceclient">WebserviceClient</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.xml.ws.Service;
+import java.io.PrintStream;
+import java.net.URL;
+
+public class WebserviceClient {
+ /**
+ * Unfortunately, to run this example with CXF you need to have a HUGE class path. This
+ * is just what is required to run CXF:
+ * <p/>
+ * jaxb-api-2.0.jar
+ * jaxb-impl-2.0.3.jar
+ * <p/>
+ * saaj-api-1.3.jar
+ * saaj-impl-1.3.jar
+ * <p/>
+ * <p/>
+ * cxf-api-2.0.2-incubator.jar
+ * cxf-common-utilities-2.0.2-incubator.jar
+ * cxf-rt-bindings-soap-2.0.2-incubator.jar
+ * cxf-rt-core-2.0.2-incubator.jar
+ * cxf-rt-databinding-jaxb-2.0.2-incubator.jar
+ * cxf-rt-frontend-jaxws-2.0.2-incubator.jar
+ * cxf-rt-frontend-simple-2.0.2-incubator.jar
+ * cxf-rt-transports-http-jetty-2.0.2-incubator.jar
+ * cxf-rt-transports-http-2.0.2-incubator.jar
+ * cxf-tools-common-2.0.2-incubator.jar
+ * <p/>
+ * geronimo-activation_1.1_spec-1.0.jar
+ * geronimo-annotation_1.0_spec-1.1.jar
+ * geronimo-ejb_3.0_spec-1.0.jar
+ * geronimo-jpa_3.0_spec-1.1.jar
+ * geronimo-servlet_2.5_spec-1.1.jar
+ * geronimo-stax-api_1.0_spec-1.0.jar
+ * jaxws-api-2.0.jar
+ * axis2-jws-api-1.3.jar
+ * <p/>
+ * wsdl4j-1.6.1.jar
+ * xml-resolver-1.2.jar
+ * XmlSchema-1.3.1.jar
+ */
+ public static void main(String[] args) throws Exception {
+ PrintStream out = System.out;
+
+ Service helloPojoService = Service.create(new URL("http://localhost:8080/ejb-examples/hello?wsdl"), null);
+ HelloPojo helloPojo = helloPojoService.getPort(HelloPojo.class);
+ out.println();
+ out.println("Pojo Webservice");
+ out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob"));
+ out.println(" helloPojo.hello(null)=" + helloPojo.hello(null));
+ out.println();
+
+ Service helloEjbService = Service.create(new URL("http://localhost:8080/HelloEjbService?wsdl"), null);
+ HelloEjb helloEjb = helloEjbService.getPort(HelloEjb.class);
+ out.println();
+ out.println("EJB Webservice");
+ out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob"));
+ out.println(" helloEjb.hello(null)=" + helloEjb.hello(null));
+ out.println();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_webserviceservlet">WebserviceServlet</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import javax.jws.HandlerChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.ws.WebServiceRef;
+import java.io.IOException;
+
+public class WebserviceServlet extends HttpServlet {
+
+ @WebServiceRef
+ @HandlerChain(file = "client-handlers.xml")
+ private HelloPojo helloPojo;
+
+ @WebServiceRef
+ @HandlerChain(file = "client-handlers.xml")
+ private HelloEjb helloEjb;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ OUT = out;
+ try {
+ out.println("Pojo Webservice");
+ out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob"));
+ out.println();
+ out.println(" helloPojo.hello(null)=" + helloPojo.hello(null));
+ out.println();
+ out.println("EJB Webservice");
+ out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob"));
+ out.println();
+ out.println(" helloEjb.hello(null)=" + helloEjb.hello(null));
+ out.println();
+ } finally {
+ OUT = out;
+ }
+ }
+
+ private static ServletOutputStream OUT;
+
+ public static void write(String message) {
+ try {
+ ServletOutputStream out = OUT;
+ out.println(message);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit transaction-type="RESOURCE_LOCAL" name="jpa-example">
+ <jta-data-source>java:openejb/Connector/Default JDBC Database</jta-data-source>
+ <non-jta-data-source>java:openejb/Connector/Default Unmanaged JDBC Database</non-jta-data-source>
+ <class>org.superbiz.servlet.JpaBean</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_client_handlers_xml">client-handlers.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+ <jws:handler-chain>
+ <jws:handler>
+ <jws:handler-name>ClientHandler</jws:handler-name>
+ <jws:handler-class>org.superbiz.servlet.ClientHandler</jws:handler-class>
+ </jws:handler>
+ </jws:handler-chain>
+</jws:handler-chains></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_server_handlers_xml">server-handlers.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+ <jws:handler-chain>
+ <jws:handler>
+ <jws:handler-name>ServerHandler</jws:handler-name>
+ <jws:handler-class>org.superbiz.servlet.ServerHandler</jws:handler-class>
+ </jws:handler>
+ </jws:handler-chain>
+</jws:handler-chains></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_context_xml">context.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><Context>
+ <!-- This only works if the context is installed under the correct name -->
+ <Realm className="org.apache.catalina.realm.MemoryRealm"
+ pathname="webapps/ejb-examples-1.0-SNAPSHOT/WEB-INF/tomcat-users.xml"/>
+
+ <Environment
+ name="context.xml/environment"
+ value="ContextString"
+ type="java.lang.String"/>
+ <Resource
+ name="context.xml/resource"
+ auth="Container"
+ type="org.superbiz.servlet.ResourceBean"
+ factory="org.apache.naming.factory.BeanFactory"
+ value="ContextResource"/>
+ <ResourceLink
+ name="context.xml/resource-link"
+ global="server.xml/environment"
+ type="java.lang.String"/>
+
+ <!-- web.xml resources -->
+ <Resource
+ name="web.xml/resource-env-ref"
+ auth="Container"
+ type="org.superbiz.servlet.ResourceBean"
+ factory="org.apache.naming.factory.BeanFactory"
+ value="ContextResourceEnvRef"/>
+ <Resource
+ name="web.xml/resource-ref"
+ auth="Container"
+ type="org.superbiz.servlet.ResourceBean"
+ factory="org.apache.naming.factory.BeanFactory"
+ value="ContextResourceRef"/>
+ <ResourceLink
+ name="web.xml/resource-link"
+ global="server.xml/environment"
+ type="java.lang.String"/>
+</Context></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_jetty_web_xml">jetty-web.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><Configure class="org.eclipse.jetty.webapp.WebAppContext">
+ <Get name="securityHandler">
+ <Set name="loginService">
+ <New class="org.eclipse.jetty.security.HashLoginService">
+ <Set name="name">Test Realm</Set>
+ <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties
+ </Set>
+ </New>
+ </Set>
+ </Get>
+</Configure></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_tomcat_users_xml">tomcat-users.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><tomcat-users>
+ <user name="manager" password="manager" roles="manager,user"/>
+ <user name="user" password="user" roles="user"/>
+</tomcat-users></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_web_xml">web.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB Servlet Examples</display-name>
+
+ <servlet>
+ <servlet-name>AnnotatedServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.AnnotatedServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>AnnotatedServlet</servlet-name>
+ <url-pattern>/annotated/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>JpaServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.JpaServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JpaServlet</servlet-name>
+ <url-pattern>/jpa/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>JndiServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.JndiServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JndiServlet</servlet-name>
+ <url-pattern>/jndi/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>RunAsServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.RunAsServlet</servlet-class>
+ <run-as>
+ <role-name>fake</role-name>
+ </run-as>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>RunAsServlet</servlet-name>
+ <url-pattern>/runas/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>SecureServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.SecureServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>SecureServlet</servlet-name>
+ <url-pattern>/secure/*</url-pattern>
+ </servlet-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Secure Area</web-resource-name>
+ <url-pattern>/secure/*</url-pattern>
+ <url-pattern>/runas/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>user</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <servlet>
+ <servlet-name>WebserviceServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.WebserviceServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>WebserviceServlet</servlet-name>
+ <url-pattern>/webservice/*</url-pattern>
+ </servlet-mapping>
+
+
+ <servlet>
+ <servlet-name>HelloPojoService</servlet-name>
+ <servlet-class>org.superbiz.servlet.HelloPojoService</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>HelloPojoService</servlet-name>
+ <url-pattern>/hello</url-pattern>
+ </servlet-mapping>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+
+ <security-role>
+ <role-name>manager</role-name>
+ </security-role>
+
+ <security-role>
+ <role-name>user</role-name>
+ </security-role>
+
+ <env-entry>
+ <env-entry-name>web.xml/env-entry</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>WebValue</env-entry-value>
+ </env-entry>
+
+ <resource-ref>
+ <res-ref-name>web.xml/Data Source</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ <resource-env-ref>
+ <resource-env-ref-name>web.xml/Queue</resource-env-ref-name>
+ <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
+ </resource-env-ref>
+
+ <ejb-ref>
+ <ejb-ref-name>web.xml/EjbRemote</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <remote>org.superbiz.servlet.AnnotatedEJBRemote</remote>
+ </ejb-ref>
+
+ <ejb-local-ref>
+ <ejb-ref-name>web.xml/EjLocal</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <local>org.superbiz.servlet.AnnotatedEJBLocal</local>
+ </ejb-local-ref>
+
+ <persistence-unit-ref>
+ <persistence-unit-ref-name>web.xml/PersistenceUnit</persistence-unit-ref-name>
+ <persistence-unit-name>jpa-example</persistence-unit-name>
+ </persistence-unit-ref>
+
+ <persistence-context-ref>
+ <persistence-context-ref-name>web.xml/PersistenceContext</persistence-context-ref-name>
+ <persistence-unit-name>jpa-example</persistence-unit-name>
+ <persistence-context-type>Transactional</persistence-context-type>
+ </persistence-context-ref>
+</web-app></code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/ejb-examples.pdf b/content/examples/ejb-examples.pdf
new file mode 100644
index 0000000..1101b6e
--- /dev/null
+++ b/content/examples/ejb-examples.pdf
Binary files differ
diff --git a/content/examples/ejb-examples/README.md b/content/examples/ejb-examples/README.md
new file mode 100755
index 0000000..b67ae55
--- /dev/null
+++ b/content/examples/ejb-examples/README.md
@@ -0,0 +1,1046 @@
+Title: EJB Examples
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## AnnotatedEJB
+
+ package org.superbiz.servlet;
+
+ import javax.annotation.Resource;
+ import javax.ejb.LocalBean;
+ import javax.ejb.Stateless;
+ import javax.sql.DataSource;
+
+ @Stateless
+ @LocalBean
+ public class AnnotatedEJB implements AnnotatedEJBLocal, AnnotatedEJBRemote {
+ @Resource
+ private DataSource ds;
+
+ private String name = "foo";
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public DataSource getDs() {
+ return ds;
+ }
+
+ public void setDs(DataSource ds) {
+ this.ds = ds;
+ }
+
+ public String toString() {
+ return "AnnotatedEJB[name=" + name + "]";
+ }
+ }
+
+## AnnotatedEJBLocal
+
+ package org.superbiz.servlet;
+
+ import javax.ejb.Local;
+ import javax.sql.DataSource;
+
+ @Local
+ public interface AnnotatedEJBLocal {
+ String getName();
+
+ void setName(String name);
+
+ DataSource getDs();
+
+ void setDs(DataSource ds);
+ }
+
+## AnnotatedEJBRemote
+
+ package org.superbiz.servlet;
+
+ import javax.ejb.Remote;
+
+ @Remote
+ public interface AnnotatedEJBRemote {
+ String getName();
+
+ void setName(String name);
+ }
+
+## AnnotatedServlet
+
+ package org.superbiz.servlet;
+
+ import javax.annotation.Resource;
+ import javax.ejb.EJB;
+ import javax.naming.InitialContext;
+ import javax.naming.NamingException;
+ import javax.servlet.ServletException;
+ import javax.servlet.ServletOutputStream;
+ import javax.servlet.http.HttpServlet;
+ import javax.servlet.http.HttpServletRequest;
+ import javax.servlet.http.HttpServletResponse;
+ import javax.sql.DataSource;
+ import java.io.IOException;
+
+ public class AnnotatedServlet extends HttpServlet {
+ @EJB
+ private AnnotatedEJBLocal localEJB;
+
+ @EJB
+ private AnnotatedEJBRemote remoteEJB;
+
+ @EJB
+ private AnnotatedEJB localbeanEJB;
+
+ @Resource
+ private DataSource ds;
+
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("LocalBean EJB");
+ out.println("@EJB=" + localbeanEJB);
+ if (localbeanEJB != null) {
+ out.println("@EJB.getName()=" + localbeanEJB.getName());
+ out.println("@EJB.getDs()=" + localbeanEJB.getDs());
+ }
+ out.println("JNDI=" + lookupField("localbeanEJB"));
+ out.println();
+
+ out.println("Local EJB");
+ out.println("@EJB=" + localEJB);
+ if (localEJB != null) {
+ out.println("@EJB.getName()=" + localEJB.getName());
+ out.println("@EJB.getDs()=" + localEJB.getDs());
+ }
+ out.println("JNDI=" + lookupField("localEJB"));
+ out.println();
+
+ out.println("Remote EJB");
+ out.println("@EJB=" + remoteEJB);
+ if (localEJB != null) {
+ out.println("@EJB.getName()=" + remoteEJB.getName());
+ }
+ out.println("JNDI=" + lookupField("remoteEJB"));
+ out.println();
+
+
+ out.println("DataSource");
+ out.println("@Resource=" + ds);
+ out.println("JNDI=" + lookupField("ds"));
+ }
+
+ private Object lookupField(String name) {
+ try {
+ return new InitialContext().lookup("java:comp/env/" + getClass().getName() + "/" + name);
+ } catch (NamingException e) {
+ return null;
+ }
+ }
+ }
+
+## ClientHandler
+
+ package org.superbiz.servlet;
+
+ import javax.xml.ws.handler.Handler;
+ import javax.xml.ws.handler.MessageContext;
+
+ public class ClientHandler implements Handler {
+ public boolean handleMessage(MessageContext messageContext) {
+ WebserviceServlet.write(" ClientHandler handleMessage");
+ return true;
+ }
+
+ public void close(MessageContext messageContext) {
+ WebserviceServlet.write(" ClientHandler close");
+ }
+
+ public boolean handleFault(MessageContext messageContext) {
+ WebserviceServlet.write(" ClientHandler handleFault");
+ return true;
+ }
+ }
+
+## HelloEjb
+
+ package org.superbiz.servlet;
+
+ import javax.jws.WebService;
+
+ @WebService(targetNamespace = "http://examples.org/wsdl")
+ public interface HelloEjb {
+ String hello(String name);
+ }
+
+## HelloEjbService
+
+ package org.superbiz.servlet;
+
+ import javax.ejb.Stateless;
+ import javax.jws.HandlerChain;
+ import javax.jws.WebService;
+
+ @WebService(
+ portName = "HelloEjbPort",
+ serviceName = "HelloEjbService",
+ targetNamespace = "http://examples.org/wsdl",
+ endpointInterface = "org.superbiz.servlet.HelloEjb"
+ )
+ @HandlerChain(file = "server-handlers.xml")
+ @Stateless
+ public class HelloEjbService implements HelloEjb {
+ public String hello(String name) {
+ WebserviceServlet.write(" HelloEjbService hello(" + name + ")");
+ if (name == null) name = "World";
+ return "Hello " + name + " from EJB Webservice!";
+ }
+ }
+
+## HelloPojo
+
+ package org.superbiz.servlet;
+
+ import javax.jws.WebService;
+
+ @WebService(targetNamespace = "http://examples.org/wsdl")
+ public interface HelloPojo {
+ String hello(String name);
+ }
+
+## HelloPojoService
+
+ package org.superbiz.servlet;
+
+ import javax.jws.HandlerChain;
+ import javax.jws.WebService;
+
+ @WebService(
+ portName = "HelloPojoPort",
+ serviceName = "HelloPojoService",
+ targetNamespace = "http://examples.org/wsdl",
+ endpointInterface = "org.superbiz.servlet.HelloPojo"
+ )
+ @HandlerChain(file = "server-handlers.xml")
+ public class HelloPojoService implements HelloPojo {
+ public String hello(String name) {
+ WebserviceServlet.write(" HelloPojoService hello(" + name + ")");
+ if (name == null) name = "World";
+ return "Hello " + name + " from Pojo Webservice!";
+ }
+ }
+
+## JndiServlet
+
+ package org.superbiz.servlet;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.naming.NameClassPair;
+ import javax.naming.NamingException;
+ import javax.servlet.ServletException;
+ import javax.servlet.ServletOutputStream;
+ import javax.servlet.http.HttpServlet;
+ import javax.servlet.http.HttpServletRequest;
+ import javax.servlet.http.HttpServletResponse;
+ import java.io.IOException;
+ import java.util.Collections;
+ import java.util.Map;
+ import java.util.TreeMap;
+
+ public class JndiServlet extends HttpServlet {
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ Map<String, Object> bindings = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
+ try {
+ Context context = (Context) new InitialContext().lookup("java:comp/");
+ addBindings("", bindings, context);
+ } catch (NamingException e) {
+ throw new ServletException(e);
+ }
+
+ out.println("JNDI Context:");
+ for (Map.Entry<String, Object> entry : bindings.entrySet()) {
+ if (entry.getValue() != null) {
+ out.println(" " + entry.getKey() + "=" + entry.getValue());
+ } else {
+ out.println(" " + entry.getKey());
+ }
+ }
+ }
+
+ private void addBindings(String path, Map<String, Object> bindings, Context context) {
+ try {
+ for (NameClassPair pair : Collections.list(context.list(""))) {
+ String name = pair.getName();
+ String className = pair.getClassName();
+ if ("org.apache.naming.resources.FileDirContext$FileResource".equals(className)) {
+ bindings.put(path + name, "<file>");
+ } else {
+ try {
+ Object value = context.lookup(name);
+ if (value instanceof Context) {
+ Context nextedContext = (Context) value;
+ bindings.put(path + name, "");
+ addBindings(path + name + "/", bindings, nextedContext);
+ } else {
+ bindings.put(path + name, value);
+ }
+ } catch (NamingException e) {
+ // lookup failed
+ bindings.put(path + name, "ERROR: " + e.getMessage());
+ }
+ }
+ }
+ } catch (NamingException e) {
+ bindings.put(path, "ERROR: list bindings threw an exception: " + e.getMessage());
+ }
+ }
+ }
+
+## JpaBean
+
+ package org.superbiz.servlet;
+
+ import javax.persistence.Column;
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.GenerationType;
+ import javax.persistence.Id;
+
+ @Entity
+ public class JpaBean {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private int id;
+
+ @Column(name = "name")
+ private String name;
+
+ public int getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ public String toString() {
+ return "[JpaBean id=" + id + ", name=" + name + "]";
+ }
+ }
+
+## JpaServlet
+
+ package org.superbiz.servlet;
+
+ import javax.persistence.EntityManager;
+ import javax.persistence.EntityManagerFactory;
+ import javax.persistence.EntityTransaction;
+ import javax.persistence.PersistenceUnit;
+ import javax.persistence.Query;
+ import javax.servlet.ServletException;
+ import javax.servlet.ServletOutputStream;
+ import javax.servlet.http.HttpServlet;
+ import javax.servlet.http.HttpServletRequest;
+ import javax.servlet.http.HttpServletResponse;
+ import java.io.IOException;
+
+ public class JpaServlet extends HttpServlet {
+ @PersistenceUnit(name = "jpa-example")
+ private EntityManagerFactory emf;
+
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("@PersistenceUnit=" + emf);
+
+ EntityManager em = emf.createEntityManager();
+ EntityTransaction transaction = em.getTransaction();
+ transaction.begin();
+
+ JpaBean jpaBean = new JpaBean();
+ jpaBean.setName("JpaBean");
+ em.persist(jpaBean);
+
+ transaction.commit();
+ transaction.begin();
+
+ Query query = em.createQuery("SELECT j FROM JpaBean j WHERE j.name='JpaBean'");
+ jpaBean = (JpaBean) query.getSingleResult();
+ out.println("Loaded " + jpaBean);
+
+ em.remove(jpaBean);
+
+ transaction.commit();
+ transaction.begin();
+
+ query = em.createQuery("SELECT count(j) FROM JpaBean j WHERE j.name='JpaBean'");
+ int count = ((Number) query.getSingleResult()).intValue();
+ if (count == 0) {
+ out.println("Removed " + jpaBean);
+ } else {
+ out.println("ERROR: unable to remove" + jpaBean);
+ }
+
+ transaction.commit();
+ }
+ }
+
+## ResourceBean
+
+ package org.superbiz.servlet;
+
+ public class ResourceBean {
+ private String value;
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return "[ResourceBean " + value + "]";
+ }
+ }
+
+## RunAsServlet
+
+ package org.superbiz.servlet;
+
+ import javax.ejb.EJB;
+ import javax.ejb.EJBAccessException;
+ import javax.servlet.ServletException;
+ import javax.servlet.ServletOutputStream;
+ import javax.servlet.http.HttpServlet;
+ import javax.servlet.http.HttpServletRequest;
+ import javax.servlet.http.HttpServletResponse;
+ import java.io.IOException;
+ import java.security.Principal;
+
+ public class RunAsServlet extends HttpServlet {
+ @EJB
+ private SecureEJBLocal secureEJBLocal;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("Servlet");
+ Principal principal = request.getUserPrincipal();
+ if (principal != null) {
+ out.println("Servlet.getUserPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("Servlet.getUserPrincipal()=<null>");
+ }
+ out.println("Servlet.isCallerInRole(\"user\")=" + request.isUserInRole("user"));
+ out.println("Servlet.isCallerInRole(\"manager\")=" + request.isUserInRole("manager"));
+ out.println("Servlet.isCallerInRole(\"fake\")=" + request.isUserInRole("fake"));
+ out.println();
+
+ out.println("@EJB=" + secureEJBLocal);
+ if (secureEJBLocal != null) {
+ principal = secureEJBLocal.getCallerPrincipal();
+ if (principal != null) {
+ out.println("@EJB.getCallerPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("@EJB.getCallerPrincipal()=<null>");
+ }
+ out.println("@EJB.isCallerInRole(\"user\")=" + secureEJBLocal.isCallerInRole("user"));
+ out.println("@EJB.isCallerInRole(\"manager\")=" + secureEJBLocal.isCallerInRole("manager"));
+ out.println("@EJB.isCallerInRole(\"fake\")=" + secureEJBLocal.isCallerInRole("fake"));
+
+ try {
+ secureEJBLocal.allowUserMethod();
+ out.println("@EJB.allowUserMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowUserMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowManagerMethod();
+ out.println("@EJB.allowManagerMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowManagerMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowFakeMethod();
+ out.println("@EJB.allowFakeMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowFakeMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.denyAllMethod();
+ out.println("@EJB.denyAllMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.denyAllMethod() DENIED");
+ }
+ }
+ out.println();
+ }
+ }
+
+## SecureEJB
+
+ package org.superbiz.servlet;
+
+ import javax.annotation.Resource;
+ import javax.annotation.security.DeclareRoles;
+ import javax.annotation.security.DenyAll;
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.SessionContext;
+ import javax.ejb.Stateless;
+ import java.security.Principal;
+
+ @Stateless
+ @DeclareRoles({"user", "manager", "fake"})
+ public class SecureEJB implements SecureEJBLocal {
+ @Resource
+ private SessionContext context;
+
+ public Principal getCallerPrincipal() {
+ return context.getCallerPrincipal();
+ }
+
+ public boolean isCallerInRole(String role) {
+ return context.isCallerInRole(role);
+ }
+
+ @RolesAllowed("user")
+ public void allowUserMethod() {
+ }
+
+ @RolesAllowed("manager")
+ public void allowManagerMethod() {
+ }
+
+ @RolesAllowed("fake")
+ public void allowFakeMethod() {
+ }
+
+ @DenyAll
+ public void denyAllMethod() {
+ }
+
+ public String toString() {
+ return "SecureEJB[userName=" + getCallerPrincipal() + "]";
+ }
+ }
+
+## SecureEJBLocal
+
+ package org.superbiz.servlet;
+
+ import javax.ejb.Local;
+ import java.security.Principal;
+
+ @Local
+ public interface SecureEJBLocal {
+ Principal getCallerPrincipal();
+
+ boolean isCallerInRole(String role);
+
+ void allowUserMethod();
+
+ void allowManagerMethod();
+
+ void allowFakeMethod();
+
+ void denyAllMethod();
+ }
+
+## SecureServlet
+
+ package org.superbiz.servlet;
+
+ import javax.ejb.EJB;
+ import javax.ejb.EJBAccessException;
+ import javax.servlet.ServletException;
+ import javax.servlet.ServletOutputStream;
+ import javax.servlet.http.HttpServlet;
+ import javax.servlet.http.HttpServletRequest;
+ import javax.servlet.http.HttpServletResponse;
+ import java.io.IOException;
+ import java.security.Principal;
+
+ public class SecureServlet extends HttpServlet {
+ @EJB
+ private SecureEJBLocal secureEJBLocal;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("Servlet");
+ Principal principal = request.getUserPrincipal();
+ if (principal != null) {
+ out.println("Servlet.getUserPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("Servlet.getUserPrincipal()=<null>");
+ }
+ out.println("Servlet.isCallerInRole(\"user\")=" + request.isUserInRole("user"));
+ out.println("Servlet.isCallerInRole(\"manager\")=" + request.isUserInRole("manager"));
+ out.println("Servlet.isCallerInRole(\"fake\")=" + request.isUserInRole("fake"));
+ out.println();
+
+ out.println("@EJB=" + secureEJBLocal);
+ if (secureEJBLocal != null) {
+ principal = secureEJBLocal.getCallerPrincipal();
+ if (principal != null) {
+ out.println("@EJB.getCallerPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("@EJB.getCallerPrincipal()=<null>");
+ }
+ out.println("@EJB.isCallerInRole(\"user\")=" + secureEJBLocal.isCallerInRole("user"));
+ out.println("@EJB.isCallerInRole(\"manager\")=" + secureEJBLocal.isCallerInRole("manager"));
+ out.println("@EJB.isCallerInRole(\"fake\")=" + secureEJBLocal.isCallerInRole("fake"));
+
+ try {
+ secureEJBLocal.allowUserMethod();
+ out.println("@EJB.allowUserMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowUserMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowManagerMethod();
+ out.println("@EJB.allowManagerMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowManagerMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowFakeMethod();
+ out.println("@EJB.allowFakeMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowFakeMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.denyAllMethod();
+ out.println("@EJB.denyAllMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.denyAllMethod() DENIED");
+ }
+ }
+ out.println();
+ }
+ }
+
+## ServerHandler
+
+ package org.superbiz.servlet;
+
+ import javax.xml.ws.handler.Handler;
+ import javax.xml.ws.handler.MessageContext;
+
+ public class ServerHandler implements Handler {
+ public boolean handleMessage(MessageContext messageContext) {
+ WebserviceServlet.write(" ServerHandler handleMessage");
+ return true;
+ }
+
+ public void close(MessageContext messageContext) {
+ WebserviceServlet.write(" ServerHandler close");
+ }
+
+ public boolean handleFault(MessageContext messageContext) {
+ WebserviceServlet.write(" ServerHandler handleFault");
+ return true;
+ }
+ }
+
+## WebserviceClient
+
+ package org.superbiz.servlet;
+
+ import javax.xml.ws.Service;
+ import java.io.PrintStream;
+ import java.net.URL;
+
+ public class WebserviceClient {
+ /**
+ * Unfortunately, to run this example with CXF you need to have a HUGE class path. This
+ * is just what is required to run CXF:
+ * <p/>
+ * jaxb-api-2.0.jar
+ * jaxb-impl-2.0.3.jar
+ * <p/>
+ * saaj-api-1.3.jar
+ * saaj-impl-1.3.jar
+ * <p/>
+ * <p/>
+ * cxf-api-2.0.2-incubator.jar
+ * cxf-common-utilities-2.0.2-incubator.jar
+ * cxf-rt-bindings-soap-2.0.2-incubator.jar
+ * cxf-rt-core-2.0.2-incubator.jar
+ * cxf-rt-databinding-jaxb-2.0.2-incubator.jar
+ * cxf-rt-frontend-jaxws-2.0.2-incubator.jar
+ * cxf-rt-frontend-simple-2.0.2-incubator.jar
+ * cxf-rt-transports-http-jetty-2.0.2-incubator.jar
+ * cxf-rt-transports-http-2.0.2-incubator.jar
+ * cxf-tools-common-2.0.2-incubator.jar
+ * <p/>
+ * geronimo-activation_1.1_spec-1.0.jar
+ * geronimo-annotation_1.0_spec-1.1.jar
+ * geronimo-ejb_3.0_spec-1.0.jar
+ * geronimo-jpa_3.0_spec-1.1.jar
+ * geronimo-servlet_2.5_spec-1.1.jar
+ * geronimo-stax-api_1.0_spec-1.0.jar
+ * jaxws-api-2.0.jar
+ * axis2-jws-api-1.3.jar
+ * <p/>
+ * wsdl4j-1.6.1.jar
+ * xml-resolver-1.2.jar
+ * XmlSchema-1.3.1.jar
+ */
+ public static void main(String[] args) throws Exception {
+ PrintStream out = System.out;
+
+ Service helloPojoService = Service.create(new URL("http://localhost:8080/ejb-examples/hello?wsdl"), null);
+ HelloPojo helloPojo = helloPojoService.getPort(HelloPojo.class);
+ out.println();
+ out.println("Pojo Webservice");
+ out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob"));
+ out.println(" helloPojo.hello(null)=" + helloPojo.hello(null));
+ out.println();
+
+ Service helloEjbService = Service.create(new URL("http://localhost:8080/HelloEjbService?wsdl"), null);
+ HelloEjb helloEjb = helloEjbService.getPort(HelloEjb.class);
+ out.println();
+ out.println("EJB Webservice");
+ out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob"));
+ out.println(" helloEjb.hello(null)=" + helloEjb.hello(null));
+ out.println();
+ }
+ }
+
+## WebserviceServlet
+
+ package org.superbiz.servlet;
+
+ import javax.jws.HandlerChain;
+ import javax.servlet.ServletException;
+ import javax.servlet.ServletOutputStream;
+ import javax.servlet.http.HttpServlet;
+ import javax.servlet.http.HttpServletRequest;
+ import javax.servlet.http.HttpServletResponse;
+ import javax.xml.ws.WebServiceRef;
+ import java.io.IOException;
+
+ public class WebserviceServlet extends HttpServlet {
+
+ @WebServiceRef
+ @HandlerChain(file = "client-handlers.xml")
+ private HelloPojo helloPojo;
+
+ @WebServiceRef
+ @HandlerChain(file = "client-handlers.xml")
+ private HelloEjb helloEjb;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ OUT = out;
+ try {
+ out.println("Pojo Webservice");
+ out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob"));
+ out.println();
+ out.println(" helloPojo.hello(null)=" + helloPojo.hello(null));
+ out.println();
+ out.println("EJB Webservice");
+ out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob"));
+ out.println();
+ out.println(" helloEjb.hello(null)=" + helloEjb.hello(null));
+ out.println();
+ } finally {
+ OUT = out;
+ }
+ }
+
+ private static ServletOutputStream OUT;
+
+ public static void write(String message) {
+ try {
+ ServletOutputStream out = OUT;
+ out.println(message);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit transaction-type="RESOURCE_LOCAL" name="jpa-example">
+ <jta-data-source>java:openejb/Connector/Default JDBC Database</jta-data-source>
+ <non-jta-data-source>java:openejb/Connector/Default Unmanaged JDBC Database</non-jta-data-source>
+ <class>org.superbiz.servlet.JpaBean</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## client-handlers.xml
+
+ <jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+ <jws:handler-chain>
+ <jws:handler>
+ <jws:handler-name>ClientHandler</jws:handler-name>
+ <jws:handler-class>org.superbiz.servlet.ClientHandler</jws:handler-class>
+ </jws:handler>
+ </jws:handler-chain>
+ </jws:handler-chains>
+
+
+## server-handlers.xml
+
+ <jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+ <jws:handler-chain>
+ <jws:handler>
+ <jws:handler-name>ServerHandler</jws:handler-name>
+ <jws:handler-class>org.superbiz.servlet.ServerHandler</jws:handler-class>
+ </jws:handler>
+ </jws:handler-chain>
+ </jws:handler-chains>
+
+
+## context.xml
+
+ <Context>
+ <!-- This only works if the context is installed under the correct name -->
+ <Realm className="org.apache.catalina.realm.MemoryRealm"
+ pathname="webapps/ejb-examples-1.1.1-SNAPSHOT/WEB-INF/tomcat-users.xml"/>
+
+ <Environment
+ name="context.xml/environment"
+ value="ContextString"
+ type="java.lang.String"/>
+ <Resource
+ name="context.xml/resource"
+ auth="Container"
+ type="org.superbiz.servlet.ResourceBean"
+ factory="org.apache.naming.factory.BeanFactory"
+ value="ContextResource"/>
+ <ResourceLink
+ name="context.xml/resource-link"
+ global="server.xml/environment"
+ type="java.lang.String"/>
+
+ <!-- web.xml resources -->
+ <Resource
+ name="web.xml/resource-env-ref"
+ auth="Container"
+ type="org.superbiz.servlet.ResourceBean"
+ factory="org.apache.naming.factory.BeanFactory"
+ value="ContextResourceEnvRef"/>
+ <Resource
+ name="web.xml/resource-ref"
+ auth="Container"
+ type="org.superbiz.servlet.ResourceBean"
+ factory="org.apache.naming.factory.BeanFactory"
+ value="ContextResourceRef"/>
+ <ResourceLink
+ name="web.xml/resource-link"
+ global="server.xml/environment"
+ type="java.lang.String"/>
+ </Context>
+
+
+## jetty-web.xml
+
+ <Configure class="org.eclipse.jetty.webapp.WebAppContext">
+ <Get name="securityHandler">
+ <Set name="loginService">
+ <New class="org.eclipse.jetty.security.HashLoginService">
+ <Set name="name">Test Realm</Set>
+ <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties
+ </Set>
+ </New>
+ </Set>
+ </Get>
+ </Configure>
+
+## tomcat-users.xml
+
+ <tomcat-users>
+ <user name="manager" password="manager" roles="manager,user"/>
+ <user name="user" password="user" roles="user"/>
+ </tomcat-users>
+
+
+## web.xml
+
+ <web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB Servlet Examples</display-name>
+
+ <servlet>
+ <servlet-name>AnnotatedServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.AnnotatedServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>AnnotatedServlet</servlet-name>
+ <url-pattern>/annotated/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>JpaServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.JpaServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JpaServlet</servlet-name>
+ <url-pattern>/jpa/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>JndiServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.JndiServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JndiServlet</servlet-name>
+ <url-pattern>/jndi/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>RunAsServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.RunAsServlet</servlet-class>
+ <run-as>
+ <role-name>fake</role-name>
+ </run-as>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>RunAsServlet</servlet-name>
+ <url-pattern>/runas/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>SecureServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.SecureServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>SecureServlet</servlet-name>
+ <url-pattern>/secure/*</url-pattern>
+ </servlet-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Secure Area</web-resource-name>
+ <url-pattern>/secure/*</url-pattern>
+ <url-pattern>/runas/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>user</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <servlet>
+ <servlet-name>WebserviceServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.WebserviceServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>WebserviceServlet</servlet-name>
+ <url-pattern>/webservice/*</url-pattern>
+ </servlet-mapping>
+
+
+ <servlet>
+ <servlet-name>HelloPojoService</servlet-name>
+ <servlet-class>org.superbiz.servlet.HelloPojoService</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>HelloPojoService</servlet-name>
+ <url-pattern>/hello</url-pattern>
+ </servlet-mapping>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+
+ <security-role>
+ <role-name>manager</role-name>
+ </security-role>
+
+ <security-role>
+ <role-name>user</role-name>
+ </security-role>
+
+ <env-entry>
+ <env-entry-name>web.xml/env-entry</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>WebValue</env-entry-value>
+ </env-entry>
+
+ <resource-ref>
+ <res-ref-name>web.xml/Data Source</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ <resource-env-ref>
+ <resource-env-ref-name>web.xml/Queue</resource-env-ref-name>
+ <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
+ </resource-env-ref>
+
+ <ejb-ref>
+ <ejb-ref-name>web.xml/EjbRemote</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <remote>org.superbiz.servlet.AnnotatedEJBRemote</remote>
+ </ejb-ref>
+
+ <ejb-local-ref>
+ <ejb-ref-name>web.xml/EjLocal</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <local>org.superbiz.servlet.AnnotatedEJBLocal</local>
+ </ejb-local-ref>
+
+ <persistence-unit-ref>
+ <persistence-unit-ref-name>web.xml/PersistenceUnit</persistence-unit-ref-name>
+ <persistence-unit-name>jpa-example</persistence-unit-name>
+ </persistence-unit-ref>
+
+ <persistence-context-ref>
+ <persistence-context-ref-name>web.xml/PersistenceContext</persistence-context-ref-name>
+ <persistence-unit-name>jpa-example</persistence-unit-name>
+ <persistence-context-type>Transactional</persistence-context-type>
+ </persistence-context-ref>
+ </web-app>
+
diff --git a/content/examples/ejb-examples/pom.xml b/content/examples/ejb-examples/pom.xml
new file mode 100755
index 0000000..77c53ec
--- /dev/null
+++ b/content/examples/ejb-examples/pom.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>ejb-examples</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: EJB Examples War</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.googlecode.t7mp</groupId>
+ <artifactId>maven-t7-plugin</artifactId>
+ <version>0.9.6</version>
+ <configuration>
+ <tomcatHttpPort>9999</tomcatHttpPort>
+ <tomcatShutdownPort>9998</tomcatShutdownPort>
+ <tomcatVersion>7.0.27</tomcatVersion>
+ <webapps>
+ <webappArtifact>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-tomcat-webapp</artifactId>
+ <version>4.7.1</version>
+ <contextPath>openejb</contextPath>
+ </webappArtifact>
+ </webapps>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedEJB.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedEJB.java
new file mode 100755
index 0000000..fc7015b
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedEJB.java
@@ -0,0 +1,53 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.annotation.Resource;
+import javax.ejb.LocalBean;
+import javax.ejb.Stateless;
+import javax.sql.DataSource;
+
+@Stateless
+@LocalBean
+public class AnnotatedEJB implements AnnotatedEJBLocal, AnnotatedEJBRemote {
+
+ @Resource
+ private DataSource ds;
+
+ private String name = "foo";
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public DataSource getDs() {
+ return ds;
+ }
+
+ public void setDs(DataSource ds) {
+ this.ds = ds;
+ }
+
+ public String toString() {
+ return "AnnotatedEJB[name=" + name + "]";
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedEJBLocal.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedEJBLocal.java
new file mode 100755
index 0000000..5027461
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedEJBLocal.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.ejb.Local;
+import javax.sql.DataSource;
+
+@Local
+public interface AnnotatedEJBLocal {
+
+ String getName();
+
+ void setName(String name);
+
+ DataSource getDs();
+
+ void setDs(DataSource ds);
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedEJBRemote.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedEJBRemote.java
new file mode 100755
index 0000000..9ad7ae4
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedEJBRemote.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface AnnotatedEJBRemote {
+
+ String getName();
+
+ void setName(String name);
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedServlet.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedServlet.java
new file mode 100755
index 0000000..e26ff11
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/AnnotatedServlet.java
@@ -0,0 +1,88 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.sql.DataSource;
+import java.io.IOException;
+
+public class AnnotatedServlet extends HttpServlet {
+
+ @EJB
+ private AnnotatedEJBLocal localEJB;
+
+ @EJB
+ private AnnotatedEJBRemote remoteEJB;
+
+ @EJB
+ private AnnotatedEJB localbeanEJB;
+
+ @Resource
+ private DataSource ds;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("LocalBean EJB");
+ out.println("@EJB=" + localbeanEJB);
+ if (localbeanEJB != null) {
+ out.println("@EJB.getName()=" + localbeanEJB.getName());
+ out.println("@EJB.getDs()=" + localbeanEJB.getDs());
+ }
+ out.println("JNDI=" + lookupField("localbeanEJB"));
+ out.println();
+
+ out.println("Local EJB");
+ out.println("@EJB=" + localEJB);
+ if (localEJB != null) {
+ out.println("@EJB.getName()=" + localEJB.getName());
+ out.println("@EJB.getDs()=" + localEJB.getDs());
+ }
+ out.println("JNDI=" + lookupField("localEJB"));
+ out.println();
+
+ out.println("Remote EJB");
+ out.println("@EJB=" + remoteEJB);
+ if (localEJB != null) {
+ out.println("@EJB.getName()=" + remoteEJB.getName());
+ }
+ out.println("JNDI=" + lookupField("remoteEJB"));
+ out.println();
+
+ out.println("DataSource");
+ out.println("@Resource=" + ds);
+ out.println("JNDI=" + lookupField("ds"));
+ }
+
+ private Object lookupField(String name) {
+ try {
+ return new InitialContext().lookup("java:comp/env/" + getClass().getName() + "/" + name);
+ } catch (NamingException e) {
+ return null;
+ }
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/ClientHandler.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/ClientHandler.java
new file mode 100755
index 0000000..16cacc3
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/ClientHandler.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+
+public class ClientHandler implements Handler {
+
+ public boolean handleMessage(MessageContext messageContext) {
+ WebserviceServlet.write(" ClientHandler handleMessage");
+ return true;
+ }
+
+ public void close(MessageContext messageContext) {
+ WebserviceServlet.write(" ClientHandler close");
+ }
+
+ public boolean handleFault(MessageContext messageContext) {
+ WebserviceServlet.write(" ClientHandler handleFault");
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloEjb.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloEjb.java
new file mode 100755
index 0000000..27598d9
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloEjb.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://examples.org/wsdl")
+public interface HelloEjb {
+
+ String hello(String name);
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloEjbService.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloEjbService.java
new file mode 100755
index 0000000..d616ae8
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloEjbService.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.ejb.Stateless;
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+@WebService(
+ portName = "HelloEjbPort",
+ serviceName = "HelloEjbService",
+ targetNamespace = "http://examples.org/wsdl",
+ endpointInterface = "org.superbiz.servlet.HelloEjb"
+)
+@HandlerChain(file = "server-handlers.xml")
+@Stateless
+public class HelloEjbService implements HelloEjb {
+
+ public String hello(String name) {
+ WebserviceServlet.write(" HelloEjbService hello(" + name + ")");
+ if (name == null) {
+ name = "World";
+ }
+ return "Hello " + name + " from EJB Webservice!";
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloPojo.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloPojo.java
new file mode 100755
index 0000000..574c280
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloPojo.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://examples.org/wsdl")
+public interface HelloPojo {
+
+ String hello(String name);
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloPojoService.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloPojoService.java
new file mode 100755
index 0000000..10d891f
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/HelloPojoService.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+@WebService(
+ portName = "HelloPojoPort",
+ serviceName = "HelloPojoService",
+ targetNamespace = "http://examples.org/wsdl",
+ endpointInterface = "org.superbiz.servlet.HelloPojo"
+)
+@HandlerChain(file = "server-handlers.xml")
+public class HelloPojoService implements HelloPojo {
+
+ public String hello(String name) {
+ WebserviceServlet.write(" HelloPojoService hello(" + name + ")");
+ if (name == null) {
+ name = "World";
+ }
+ return "Hello " + name + " from Pojo Webservice!";
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/JndiServlet.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/JndiServlet.java
new file mode 100755
index 0000000..1e9cbba
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/JndiServlet.java
@@ -0,0 +1,85 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
+import javax.naming.NamingException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class JndiServlet extends HttpServlet {
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ Map<String, Object> bindings = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
+ try {
+ Context context = (Context) new InitialContext().lookup("java:comp/");
+ addBindings("", bindings, context);
+ } catch (NamingException e) {
+ throw new ServletException(e);
+ }
+
+ out.println("JNDI Context:");
+ for (Map.Entry<String, Object> entry : bindings.entrySet()) {
+ if (entry.getValue() != null) {
+ out.println(" " + entry.getKey() + "=" + entry.getValue());
+ } else {
+ out.println(" " + entry.getKey());
+ }
+ }
+ }
+
+ private void addBindings(String path, Map<String, Object> bindings, Context context) {
+ try {
+ for (NameClassPair pair : Collections.list(context.list(""))) {
+ String name = pair.getName();
+ String className = pair.getClassName();
+ if ("org.apache.naming.resources.FileDirContext$FileResource".equals(className)) {
+ bindings.put(path + name, "<file>");
+ } else {
+ try {
+ Object value = context.lookup(name);
+ if (value instanceof Context) {
+ Context nextedContext = (Context) value;
+ bindings.put(path + name, "");
+ addBindings(path + name + "/", bindings, nextedContext);
+ } else {
+ bindings.put(path + name, value);
+ }
+ } catch (NamingException e) {
+ // lookup failed
+ bindings.put(path + name, "ERROR: " + e.getMessage());
+ }
+ }
+ }
+ } catch (NamingException e) {
+ bindings.put(path, "ERROR: list bindings threw an exception: " + e.getMessage());
+ }
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/JpaBean.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/JpaBean.java
new file mode 100755
index 0000000..7ba61a9
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/JpaBean.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class JpaBean {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private int id;
+
+ @Column(name = "name")
+ private String name;
+
+ public int getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return "[JpaBean id=" + id + ", name=" + name + "]";
+ }
+}
\ No newline at end of file
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/JpaServlet.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/JpaServlet.java
new file mode 100755
index 0000000..d2d7525
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/JpaServlet.java
@@ -0,0 +1,73 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.PersistenceUnit;
+import javax.persistence.Query;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class JpaServlet extends HttpServlet {
+
+ @PersistenceUnit(name = "jpa-example")
+ private EntityManagerFactory emf;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("@PersistenceUnit=" + emf);
+
+ EntityManager em = emf.createEntityManager();
+ EntityTransaction transaction = em.getTransaction();
+ transaction.begin();
+
+ JpaBean jpaBean = new JpaBean();
+ jpaBean.setName("JpaBean");
+ em.persist(jpaBean);
+
+ transaction.commit();
+ transaction.begin();
+
+ Query query = em.createQuery("SELECT j FROM JpaBean j WHERE j.name='JpaBean'");
+ jpaBean = (JpaBean) query.getSingleResult();
+ out.println("Loaded " + jpaBean);
+
+ em.remove(jpaBean);
+
+ transaction.commit();
+ transaction.begin();
+
+ query = em.createQuery("SELECT count(j) FROM JpaBean j WHERE j.name='JpaBean'");
+ int count = ((Number) query.getSingleResult()).intValue();
+ if (count == 0) {
+ out.println("Removed " + jpaBean);
+ } else {
+ out.println("ERROR: unable to remove" + jpaBean);
+ }
+
+ transaction.commit();
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/ResourceBean.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/ResourceBean.java
new file mode 100755
index 0000000..81b2d7d
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/ResourceBean.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+public class ResourceBean {
+
+ private String value;
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return "[ResourceBean " + value + "]";
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/RunAsServlet.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/RunAsServlet.java
new file mode 100755
index 0000000..64e6e21
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/RunAsServlet.java
@@ -0,0 +1,93 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.security.Principal;
+
+public class RunAsServlet extends HttpServlet {
+
+ @EJB
+ private SecureEJBLocal secureEJBLocal;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("Servlet");
+ Principal principal = request.getUserPrincipal();
+ if (principal != null) {
+ out.println("Servlet.getUserPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("Servlet.getUserPrincipal()=<null>");
+ }
+ out.println("Servlet.isCallerInRole(\"user\")=" + request.isUserInRole("user"));
+ out.println("Servlet.isCallerInRole(\"manager\")=" + request.isUserInRole("manager"));
+ out.println("Servlet.isCallerInRole(\"fake\")=" + request.isUserInRole("fake"));
+ out.println();
+
+ out.println("@EJB=" + secureEJBLocal);
+ if (secureEJBLocal != null) {
+ principal = secureEJBLocal.getCallerPrincipal();
+ if (principal != null) {
+ out.println("@EJB.getCallerPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("@EJB.getCallerPrincipal()=<null>");
+ }
+ out.println("@EJB.isCallerInRole(\"user\")=" + secureEJBLocal.isCallerInRole("user"));
+ out.println("@EJB.isCallerInRole(\"manager\")=" + secureEJBLocal.isCallerInRole("manager"));
+ out.println("@EJB.isCallerInRole(\"fake\")=" + secureEJBLocal.isCallerInRole("fake"));
+
+ try {
+ secureEJBLocal.allowUserMethod();
+ out.println("@EJB.allowUserMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowUserMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowManagerMethod();
+ out.println("@EJB.allowManagerMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowManagerMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowFakeMethod();
+ out.println("@EJB.allowFakeMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowFakeMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.denyAllMethod();
+ out.println("@EJB.denyAllMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.denyAllMethod() DENIED");
+ }
+ }
+ out.println();
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureEJB.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureEJB.java
new file mode 100755
index 0000000..d4d6b7d
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureEJB.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.annotation.Resource;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.DenyAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import java.security.Principal;
+
+@Stateless
+@DeclareRoles({"user", "manager", "fake"})
+public class SecureEJB implements SecureEJBLocal {
+
+ @Resource
+ private SessionContext context;
+
+ public Principal getCallerPrincipal() {
+ return context.getCallerPrincipal();
+ }
+
+ public boolean isCallerInRole(String role) {
+ return context.isCallerInRole(role);
+ }
+
+ @RolesAllowed("user")
+ public void allowUserMethod() {
+ }
+
+ @RolesAllowed("manager")
+ public void allowManagerMethod() {
+ }
+
+ @RolesAllowed("fake")
+ public void allowFakeMethod() {
+ }
+
+ @DenyAll
+ public void denyAllMethod() {
+ }
+
+ public String toString() {
+ return "SecureEJB[userName=" + getCallerPrincipal() + "]";
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureEJBLocal.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureEJBLocal.java
new file mode 100755
index 0000000..41c968d
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureEJBLocal.java
@@ -0,0 +1,37 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.ejb.Local;
+import java.security.Principal;
+
+@Local
+public interface SecureEJBLocal {
+
+ Principal getCallerPrincipal();
+
+ boolean isCallerInRole(String role);
+
+ void allowUserMethod();
+
+ void allowManagerMethod();
+
+ void allowFakeMethod();
+
+ void denyAllMethod();
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureServlet.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureServlet.java
new file mode 100755
index 0000000..53c217d
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/SecureServlet.java
@@ -0,0 +1,93 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.security.Principal;
+
+public class SecureServlet extends HttpServlet {
+
+ @EJB
+ private SecureEJBLocal secureEJBLocal;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ out.println("Servlet");
+ Principal principal = request.getUserPrincipal();
+ if (principal != null) {
+ out.println("Servlet.getUserPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("Servlet.getUserPrincipal()=<null>");
+ }
+ out.println("Servlet.isCallerInRole(\"user\")=" + request.isUserInRole("user"));
+ out.println("Servlet.isCallerInRole(\"manager\")=" + request.isUserInRole("manager"));
+ out.println("Servlet.isCallerInRole(\"fake\")=" + request.isUserInRole("fake"));
+ out.println();
+
+ out.println("@EJB=" + secureEJBLocal);
+ if (secureEJBLocal != null) {
+ principal = secureEJBLocal.getCallerPrincipal();
+ if (principal != null) {
+ out.println("@EJB.getCallerPrincipal()=" + principal + " [" + principal.getName() + "]");
+ } else {
+ out.println("@EJB.getCallerPrincipal()=<null>");
+ }
+ out.println("@EJB.isCallerInRole(\"user\")=" + secureEJBLocal.isCallerInRole("user"));
+ out.println("@EJB.isCallerInRole(\"manager\")=" + secureEJBLocal.isCallerInRole("manager"));
+ out.println("@EJB.isCallerInRole(\"fake\")=" + secureEJBLocal.isCallerInRole("fake"));
+
+ try {
+ secureEJBLocal.allowUserMethod();
+ out.println("@EJB.allowUserMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowUserMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowManagerMethod();
+ out.println("@EJB.allowManagerMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowManagerMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.allowFakeMethod();
+ out.println("@EJB.allowFakeMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.allowFakeMethod() DENIED");
+ }
+
+ try {
+ secureEJBLocal.denyAllMethod();
+ out.println("@EJB.denyAllMethod() ALLOWED");
+ } catch (EJBAccessException e) {
+ out.println("@EJB.denyAllMethod() DENIED");
+ }
+ }
+ out.println();
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/ServerHandler.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/ServerHandler.java
new file mode 100755
index 0000000..55ce0b7
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/ServerHandler.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+
+public class ServerHandler implements Handler {
+
+ public boolean handleMessage(MessageContext messageContext) {
+ WebserviceServlet.write(" ServerHandler handleMessage");
+ return true;
+ }
+
+ public void close(MessageContext messageContext) {
+ WebserviceServlet.write(" ServerHandler close");
+ }
+
+ public boolean handleFault(MessageContext messageContext) {
+ WebserviceServlet.write(" ServerHandler handleFault");
+ return true;
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceClient.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceClient.java
new file mode 100755
index 0000000..1c49f79
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceClient.java
@@ -0,0 +1,80 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.xml.ws.Service;
+import java.io.PrintStream;
+import java.net.URL;
+
+public class WebserviceClient {
+
+ /**
+ * Unfortunately, to run this example with CXF you need to have a HUGE class path. This
+ * is just what is required to run CXF:
+ * <p/>
+ * jaxb-api-2.0.jar
+ * jaxb-impl-2.0.3.jar
+ * <p/>
+ * saaj-api-1.3.jar
+ * saaj-impl-1.3.jar
+ * <p/>
+ * <p/>
+ * cxf-api-2.0.2-incubator.jar
+ * cxf-common-utilities-2.0.2-incubator.jar
+ * cxf-rt-bindings-soap-2.0.2-incubator.jar
+ * cxf-rt-core-2.0.2-incubator.jar
+ * cxf-rt-databinding-jaxb-2.0.2-incubator.jar
+ * cxf-rt-frontend-jaxws-2.0.2-incubator.jar
+ * cxf-rt-frontend-simple-2.0.2-incubator.jar
+ * cxf-rt-transports-http-jetty-2.0.2-incubator.jar
+ * cxf-rt-transports-http-2.0.2-incubator.jar
+ * cxf-tools-common-2.0.2-incubator.jar
+ * <p/>
+ * geronimo-activation_1.1_spec-1.0.jar
+ * geronimo-annotation_1.0_spec-1.1.jar
+ * geronimo-ejb_3.0_spec-1.0.jar
+ * geronimo-jpa_3.0_spec-1.1.jar
+ * geronimo-servlet_2.5_spec-1.1.jar
+ * geronimo-stax-api_1.0_spec-1.0.jar
+ * jaxws-api-2.0.jar
+ * axis2-jws-api-1.3.jar
+ * <p/>
+ * wsdl4j-1.6.1.jar
+ * xml-resolver-1.2.jar
+ * XmlSchema-1.3.1.jar
+ */
+ public static void main(String[] args) throws Exception {
+ PrintStream out = System.out;
+
+ Service helloPojoService = Service.create(new URL("http://localhost:8080/ejb-examples/hello?wsdl"), null);
+ HelloPojo helloPojo = helloPojoService.getPort(HelloPojo.class);
+ out.println();
+ out.println("Pojo Webservice");
+ out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob"));
+ out.println(" helloPojo.hello(null)=" + helloPojo.hello(null));
+ out.println();
+
+ Service helloEjbService = Service.create(new URL("http://localhost:8080/HelloEjbService?wsdl"), null);
+ HelloEjb helloEjb = helloEjbService.getPort(HelloEjb.class);
+ out.println();
+ out.println("EJB Webservice");
+ out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob"));
+ out.println(" helloEjb.hello(null)=" + helloEjb.hello(null));
+ out.println();
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceServlet.java b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceServlet.java
new file mode 100755
index 0000000..256ef90
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/java/org/superbiz/servlet/WebserviceServlet.java
@@ -0,0 +1,70 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import javax.jws.HandlerChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.ws.WebServiceRef;
+import java.io.IOException;
+
+public class WebserviceServlet extends HttpServlet {
+
+ @WebServiceRef
+ @HandlerChain(file = "client-handlers.xml")
+ private HelloPojo helloPojo;
+
+ @WebServiceRef
+ @HandlerChain(file = "client-handlers.xml")
+ private HelloEjb helloEjb;
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/plain");
+ ServletOutputStream out = response.getOutputStream();
+
+ OUT = out;
+ try {
+ out.println("Pojo Webservice");
+ out.println(" helloPojo.hello(\"Bob\")=" + helloPojo.hello("Bob"));
+ out.println();
+ out.println(" helloPojo.hello(null)=" + helloPojo.hello(null));
+ out.println();
+ out.println("EJB Webservice");
+ out.println(" helloEjb.hello(\"Bob\")=" + helloEjb.hello("Bob"));
+ out.println();
+ out.println(" helloEjb.hello(null)=" + helloEjb.hello(null));
+ out.println();
+ } finally {
+ OUT = out;
+ }
+ }
+
+ private static ServletOutputStream OUT;
+
+ public static void write(String message) {
+ try {
+ ServletOutputStream out = OUT;
+ out.println(message);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/content/examples/ejb-examples/src/main/resources/META-INF/persistence.xml b/content/examples/ejb-examples/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..008bce3
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit transaction-type="RESOURCE_LOCAL" name="jpa-example">
+ <jta-data-source>java:openejb/Connector/Default JDBC Database</jta-data-source>
+ <non-jta-data-source>java:openejb/Connector/Default Unmanaged JDBC Database</non-jta-data-source>
+ <class>org.superbiz.servlet.JpaBean</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/ejb-examples/src/main/resources/org/superbiz/servlet/client-handlers.xml b/content/examples/ejb-examples/src/main/resources/org/superbiz/servlet/client-handlers.xml
new file mode 100755
index 0000000..2bb2a76
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/resources/org/superbiz/servlet/client-handlers.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 16:49:26 +0200 (Sun, 10 Apr 2011) $ -->
+
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+ <jws:handler-chain>
+ <jws:handler>
+ <jws:handler-name>ClientHandler</jws:handler-name>
+ <jws:handler-class>org.superbiz.servlet.ClientHandler</jws:handler-class>
+ </jws:handler>
+ </jws:handler-chain>
+</jws:handler-chains>
diff --git a/content/examples/ejb-examples/src/main/resources/org/superbiz/servlet/server-handlers.xml b/content/examples/ejb-examples/src/main/resources/org/superbiz/servlet/server-handlers.xml
new file mode 100755
index 0000000..bf80d3c
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/resources/org/superbiz/servlet/server-handlers.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 16:49:26 +0200 (Sun, 10 Apr 2011) $ -->
+
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+ <jws:handler-chain>
+ <jws:handler>
+ <jws:handler-name>ServerHandler</jws:handler-name>
+ <jws:handler-class>org.superbiz.servlet.ServerHandler</jws:handler-class>
+ </jws:handler>
+ </jws:handler-chain>
+</jws:handler-chains>
diff --git a/content/examples/ejb-examples/src/main/webapp/META-INF/context.xml b/content/examples/ejb-examples/src/main/webapp/META-INF/context.xml
new file mode 100755
index 0000000..f6ef3f9
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/webapp/META-INF/context.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1613398 $ $Date: 2014-07-25 13:56:24 +0200 (Fri, 25 Jul 2014) $ -->
+
+<Context>
+ <!-- This only works if the context is installed under the correct name -->
+ <Realm className="org.apache.catalina.realm.MemoryRealm"
+ pathname="webapps/ejb-examples-1.1.1-SNAPSHOT/WEB-INF/tomcat-users.xml"/>
+
+ <Environment
+ name="context.xml/environment"
+ value="ContextString"
+ type="java.lang.String"/>
+ <Resource
+ name="context.xml/resource"
+ auth="Container"
+ type="org.superbiz.servlet.ResourceBean"
+ factory="org.apache.naming.factory.BeanFactory"
+ value="ContextResource"/>
+ <ResourceLink
+ name="context.xml/resource-link"
+ global="server.xml/environment"
+ type="java.lang.String"/>
+
+ <!-- web.xml resources -->
+ <Resource
+ name="web.xml/resource-env-ref"
+ auth="Container"
+ type="org.superbiz.servlet.ResourceBean"
+ factory="org.apache.naming.factory.BeanFactory"
+ value="ContextResourceEnvRef"/>
+ <Resource
+ name="web.xml/resource-ref"
+ auth="Container"
+ type="org.superbiz.servlet.ResourceBean"
+ factory="org.apache.naming.factory.BeanFactory"
+ value="ContextResourceRef"/>
+ <ResourceLink
+ name="web.xml/resource-link"
+ global="server.xml/environment"
+ type="java.lang.String"/>
+</Context>
diff --git a/content/examples/ejb-examples/src/main/webapp/WEB-INF/jetty-web.xml b/content/examples/ejb-examples/src/main/webapp/WEB-INF/jetty-web.xml
new file mode 100755
index 0000000..a72823f
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/webapp/WEB-INF/jetty-web.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<Configure class="org.eclipse.jetty.webapp.WebAppContext">
+ <Get name="securityHandler">
+ <Set name="loginService">
+ <New class="org.eclipse.jetty.security.HashLoginService">
+ <Set name="name">Test Realm</Set>
+ <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties
+ </Set>
+ </New>
+ </Set>
+ </Get>
+</Configure>
\ No newline at end of file
diff --git a/content/examples/ejb-examples/src/main/webapp/WEB-INF/tomcat-users.xml b/content/examples/ejb-examples/src/main/webapp/WEB-INF/tomcat-users.xml
new file mode 100755
index 0000000..45e967e
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/webapp/WEB-INF/tomcat-users.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<!-- $Rev: 597221 $ $Date: 2007-11-21 22:51:05 +0100 (Wed, 21 Nov 2007) $ -->
+
+<tomcat-users>
+ <user name="manager" password="manager" roles="manager,user"/>
+ <user name="user" password="user" roles="user"/>
+</tomcat-users>
diff --git a/content/examples/ejb-examples/src/main/webapp/WEB-INF/web.xml b/content/examples/ejb-examples/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..a1606cb
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 16:49:26 +0200 (Sun, 10 Apr 2011) $ -->
+
+<web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB Servlet Examples</display-name>
+
+ <servlet>
+ <servlet-name>AnnotatedServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.AnnotatedServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>AnnotatedServlet</servlet-name>
+ <url-pattern>/annotated/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>JpaServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.JpaServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JpaServlet</servlet-name>
+ <url-pattern>/jpa/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>JndiServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.JndiServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JndiServlet</servlet-name>
+ <url-pattern>/jndi/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>RunAsServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.RunAsServlet</servlet-class>
+ <run-as>
+ <role-name>fake</role-name>
+ </run-as>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>RunAsServlet</servlet-name>
+ <url-pattern>/runas/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet>
+ <servlet-name>SecureServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.SecureServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>SecureServlet</servlet-name>
+ <url-pattern>/secure/*</url-pattern>
+ </servlet-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Secure Area</web-resource-name>
+ <url-pattern>/secure/*</url-pattern>
+ <url-pattern>/runas/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>user</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <servlet>
+ <servlet-name>WebserviceServlet</servlet-name>
+ <servlet-class>org.superbiz.servlet.WebserviceServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>WebserviceServlet</servlet-name>
+ <url-pattern>/webservice/*</url-pattern>
+ </servlet-mapping>
+
+
+ <servlet>
+ <servlet-name>HelloPojoService</servlet-name>
+ <servlet-class>org.superbiz.servlet.HelloPojoService</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>HelloPojoService</servlet-name>
+ <url-pattern>/hello</url-pattern>
+ </servlet-mapping>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+
+ <security-role>
+ <role-name>manager</role-name>
+ </security-role>
+
+ <security-role>
+ <role-name>user</role-name>
+ </security-role>
+
+ <env-entry>
+ <env-entry-name>web.xml/env-entry</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>WebValue</env-entry-value>
+ </env-entry>
+
+ <resource-ref>
+ <res-ref-name>web.xml/Data Source</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ <resource-env-ref>
+ <resource-env-ref-name>web.xml/Queue</resource-env-ref-name>
+ <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
+ </resource-env-ref>
+
+ <ejb-ref>
+ <ejb-ref-name>web.xml/EjbRemote</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <remote>org.superbiz.servlet.AnnotatedEJBRemote</remote>
+ </ejb-ref>
+
+ <ejb-local-ref>
+ <ejb-ref-name>web.xml/EjLocal</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <local>org.superbiz.servlet.AnnotatedEJBLocal</local>
+ </ejb-local-ref>
+
+ <persistence-unit-ref>
+ <persistence-unit-ref-name>web.xml/PersistenceUnit</persistence-unit-ref-name>
+ <persistence-unit-name>jpa-example</persistence-unit-name>
+ </persistence-unit-ref>
+
+ <persistence-context-ref>
+ <persistence-context-ref-name>web.xml/PersistenceContext</persistence-context-ref-name>
+ <persistence-unit-name>jpa-example</persistence-unit-name>
+ <persistence-context-type>Transactional</persistence-context-type>
+ </persistence-context-ref>
+</web-app>
diff --git a/content/examples/ejb-examples/src/main/webapp/index.jsp b/content/examples/ejb-examples/src/main/webapp/index.jsp
new file mode 100755
index 0000000..a8760e5
--- /dev/null
+++ b/content/examples/ejb-examples/src/main/webapp/index.jsp
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 16:49:26 +0200 (Sun, 10 Apr 2011) $ -->
+
+<html>
+<body>
+<h2>Examples</h2>
+<a href="annotated">Annotated Servlet</a> <br>
+<a href="jpa">JPA Example</a> <br>
+<a href="jndi">JNDI Dump</a> <br>
+<a href="webservice">Webservice</a> <br>
+
+<h2>Security Examples</h2>
+<a href="secure">Secure</a> <br>
+<a href="runas">RunAs</a> <br>
+</body>
+</html>
diff --git a/content/examples/ejb-webservice.html b/content/examples/ejb-webservice.html
new file mode 100644
index 0000000..43b59f2
--- /dev/null
+++ b/content/examples/ejb-webservice.html
@@ -0,0 +1,239 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/ejb-webservice.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>EJB Webservice</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example ejb-webservice can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/ejb-webservice" class="bare">https://github.com/apache/tomee/tree/master/examples/ejb-webservice</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculator">Calculator</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.ws;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+@Stateless
+@WebService(portName = "CalculatorPort",
+ serviceName = "CalculatorWebService",
+ targetNamespace = "http://superbiz.org/wsdl")
+public class Calculator {
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_web_xml">web.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+</web-app></code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/ejb-webservice.pdf b/content/examples/ejb-webservice.pdf
new file mode 100644
index 0000000..7b4f3f4
--- /dev/null
+++ b/content/examples/ejb-webservice.pdf
Binary files differ
diff --git a/content/examples/ejb-webservice/README.md b/content/examples/ejb-webservice/README.md
new file mode 100755
index 0000000..9c6897f
--- /dev/null
+++ b/content/examples/ejb-webservice/README.md
@@ -0,0 +1,35 @@
+Title: EJB Webservice
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Calculator
+
+ package org.superbiz.ws;
+
+ import javax.ejb.Stateless;
+ import javax.jws.WebService;
+
+ @Stateless
+ @WebService(portName = "CalculatorPort",
+ serviceName = "CalculatorWebService",
+ targetNamespace = "http://superbiz.org/wsdl")
+ public class Calculator {
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+ }
+
+## web.xml
+
+ <web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ </web-app>
+
diff --git a/content/examples/ejb-webservice/client.pl b/content/examples/ejb-webservice/client.pl
new file mode 100755
index 0000000..be0a632
--- /dev/null
+++ b/content/examples/ejb-webservice/client.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/env perl -w
+#============================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#============================================================
+
+use SOAP::Lite;
+
+my $namespace = 'http://superbiz.org/wsdl';
+
+my $service = SOAP::Lite-> uri($namespace)
+ ->proxy('http://localhost:8080/Calculator')
+ ->on_action (sub { return '' } );
+
+my $method = SOAP::Data->name("ns1:multiply")
+ ->attr({'xmlns:ns1' => $namespace});
+
+my @params = (
+ SOAP::Data->name('arg0'=>3),
+ SOAP::Data->name('arg1'=>4));
+
+print $service->call($method=>@params)->result;
diff --git a/content/examples/ejb-webservice/pom.xml b/content/examples/ejb-webservice/pom.xml
new file mode 100755
index 0000000..98edf3d
--- /dev/null
+++ b/content/examples/ejb-webservice/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 684173 $ $Date: 2008-08-08 20:13:24 -0700 (Fri, 08 Aug 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>ejb-webservice</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: EJB WebService</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/ejb-webservice/src/main/java/org/superbiz/ws/Calculator.java b/content/examples/ejb-webservice/src/main/java/org/superbiz/ws/Calculator.java
new file mode 100755
index 0000000..cba1a79
--- /dev/null
+++ b/content/examples/ejb-webservice/src/main/java/org/superbiz/ws/Calculator.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+@Stateless
+@WebService(portName = "CalculatorPort",
+ serviceName = "CalculatorWebService",
+ targetNamespace = "http://superbiz.org/wsdl")
+public class Calculator {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+
+}
+
diff --git a/content/examples/ejb-webservice/src/main/webapp/WEB-INF/web.xml b/content/examples/ejb-webservice/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..76ce686
--- /dev/null
+++ b/content/examples/ejb-webservice/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 634170 $ $Date: 2008-03-05 21:30:10 -0800 (Wed, 05 Mar 2008) $ -->
+
+<web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+</web-app>
diff --git a/content/examples/groovy-cdi.html b/content/examples/groovy-cdi.html
new file mode 100644
index 0000000..613d81e
--- /dev/null
+++ b/content/examples/groovy-cdi.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/groovy-cdi.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>groovy-cdi</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example groovy-cdi can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/groovy-cdi" class="bare">https://github.com/apache/tomee/tree/master/examples/groovy-cdi</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/groovy-cdi.pdf b/content/examples/groovy-cdi.pdf
new file mode 100644
index 0000000..614ca1a
--- /dev/null
+++ b/content/examples/groovy-cdi.pdf
Binary files differ
diff --git a/content/examples/groovy-cdi/pom.xml b/content/examples/groovy-cdi/pom.xml
new file mode 100755
index 0000000..0d2daad
--- /dev/null
+++ b/content/examples/groovy-cdi/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>groovy-cdi</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Groovy CDI</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <version.arquillian.container>1.0.3.Final</version.arquillian.container>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <compilerId>groovy-eclipse-compiler</compilerId>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-compiler</artifactId>
+ <version>2.8.0-01</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-batch</artifactId>
+ <version>2.1.8-01</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.contenttype</artifactId>
+ <version>3.4.100.v20100505-1235</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/groovy-cdi/src/main/java/org/superbiz/groovy/Hello.groovy b/content/examples/groovy-cdi/src/main/java/org/superbiz/groovy/Hello.groovy
new file mode 100755
index 0000000..75b9569
--- /dev/null
+++ b/content/examples/groovy-cdi/src/main/java/org/superbiz/groovy/Hello.groovy
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.groovy
+
+class Hello {
+
+ def hi() {
+ "hi"
+ }
+}
diff --git a/content/examples/groovy-cdi/src/main/resources/META-INF/beans.xml b/content/examples/groovy-cdi/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..6668db4
--- /dev/null
+++ b/content/examples/groovy-cdi/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,19 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans>
+</beans>
\ No newline at end of file
diff --git a/content/examples/groovy-cdi/src/test/java/org/superbiz/groovy/HelloTest.groovy b/content/examples/groovy-cdi/src/test/java/org/superbiz/groovy/HelloTest.groovy
new file mode 100755
index 0000000..f2b259d
--- /dev/null
+++ b/content/examples/groovy-cdi/src/test/java/org/superbiz/groovy/HelloTest.groovy
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.groovy
+
+import org.apache.ziplock.JarLocation
+import org.jboss.arquillian.container.test.api.Deployment
+import org.jboss.arquillian.junit.Arquillian
+import org.jboss.shrinkwrap.api.ArchivePaths
+import org.jboss.shrinkwrap.api.ShrinkWrap
+import org.jboss.shrinkwrap.api.asset.EmptyAsset
+import org.jboss.shrinkwrap.api.spec.WebArchive
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import javax.inject.Inject
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+
+@RunWith(Arquillian.class)
+class HelloTest {
+
+ @Inject
+ private Hello hello
+
+ @Deployment
+ static WebArchive war() {
+ ShrinkWrap.create(WebArchive.class)
+ .addAsLibraries(JarLocation.jarLocation(GroovyObject.class))
+ .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
+ .addClasses(Hello.class)
+ }
+
+ @Test
+ void hello() {
+ assertNotNull hello
+ assertEquals "hi", hello.hi()
+ }
+}
diff --git a/content/examples/groovy-jpa.html b/content/examples/groovy-jpa.html
new file mode 100644
index 0000000..304cc43
--- /dev/null
+++ b/content/examples/groovy-jpa.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/groovy-jpa.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>groovy-jpa</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example groovy-jpa can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/groovy-jpa" class="bare">https://github.com/apache/tomee/tree/master/examples/groovy-jpa</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/groovy-jpa.pdf b/content/examples/groovy-jpa.pdf
new file mode 100644
index 0000000..cac846d
--- /dev/null
+++ b/content/examples/groovy-jpa.pdf
Binary files differ
diff --git a/content/examples/groovy-jpa/pom.xml b/content/examples/groovy-jpa/pom.xml
new file mode 100755
index 0000000..d83913e
--- /dev/null
+++ b/content/examples/groovy-jpa/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>groovy-jpa</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Groovy JPA</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <sourceDirectory>src/main/groovy</sourceDirectory>
+ <testSourceDirectory>src/test/groovy</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <compilerId>groovy-eclipse-compiler</compilerId>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-compiler</artifactId>
+ <version>2.8.0-01</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-batch</artifactId>
+ <version>2.1.8-01</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.contenttype</artifactId>
+ <version>3.4.100.v20100505-1235</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/groovy-jpa/src/main/groovy/org/superbiz/groovy/Person.groovy b/content/examples/groovy-jpa/src/main/groovy/org/superbiz/groovy/Person.groovy
new file mode 100755
index 0000000..8eb4ba8
--- /dev/null
+++ b/content/examples/groovy-jpa/src/main/groovy/org/superbiz/groovy/Person.groovy
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.groovy
+
+import javax.persistence.Entity
+import javax.persistence.GeneratedValue
+import javax.persistence.Id
+
+@Entity
+class Person {
+
+ @Id
+ @GeneratedValue long id
+ String name
+}
diff --git a/content/examples/groovy-jpa/src/main/resources/META-INF/persistence.xml b/content/examples/groovy-jpa/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..87bbe26
--- /dev/null
+++ b/content/examples/groovy-jpa/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="groovy" transaction-type="RESOURCE_LOCAL">
+ <non-jta-data-source>jdbc/groovy</non-jta-data-source>
+ <class>org.superbiz.groovy.Person</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ <property name="javax.persistence.jdbc.password" value=""/>
+ <property name="javax.persistence.jdbc.user" value="sa"/>
+ <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:groovy"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/groovy-jpa/src/test/groovy/org/superbiz/groovy/GroovyJPATest.groovy b/content/examples/groovy-jpa/src/test/groovy/org/superbiz/groovy/GroovyJPATest.groovy
new file mode 100755
index 0000000..7fb8ebf
--- /dev/null
+++ b/content/examples/groovy-jpa/src/test/groovy/org/superbiz/groovy/GroovyJPATest.groovy
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.groovy
+
+import org.apache.ziplock.JarLocation
+import org.jboss.arquillian.container.test.api.Deployment
+import org.jboss.arquillian.junit.Arquillian
+import org.jboss.shrinkwrap.api.ArchivePaths
+import org.jboss.shrinkwrap.api.ShrinkWrap
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset
+import org.jboss.shrinkwrap.api.spec.WebArchive
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import javax.persistence.EntityManager
+import javax.persistence.EntityManagerFactory
+import javax.persistence.PersistenceUnit
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+
+@RunWith(Arquillian.class)
+class GroovyJPATest {
+
+ @PersistenceUnit
+ private EntityManagerFactory emf
+
+ @Deployment
+ static WebArchive war() {
+ ShrinkWrap.create(WebArchive.class)
+ .addAsLibraries(JarLocation.jarLocation(GroovyObject.class))
+ .addAsWebInfResource(new ClassLoaderAsset("META-INF/persistence.xml"), ArchivePaths.create("persistence.xml"))
+ .addClasses(Person.class)
+ }
+
+ @Test
+ void persist() {
+ assertNotNull emf
+ final EntityManager em = emf.createEntityManager()
+
+ em.transaction.begin()
+ em.persist(new Person(name: 'openejb'))
+ em.transaction.commit()
+
+ def list = em.createQuery("select p from Person p").resultList
+ assertNotNull list
+ assertEquals 1, list.size()
+ assertEquals 'openejb', list.first().name
+ }
+}
diff --git a/content/examples/groovy-spock.html b/content/examples/groovy-spock.html
new file mode 100644
index 0000000..489afe9
--- /dev/null
+++ b/content/examples/groovy-spock.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/groovy-spock.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>groovy-spock</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example groovy-spock can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/groovy-spock" class="bare">https://github.com/apache/tomee/tree/master/examples/groovy-spock</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/groovy-spock.pdf b/content/examples/groovy-spock.pdf
new file mode 100644
index 0000000..0db85d2
--- /dev/null
+++ b/content/examples/groovy-spock.pdf
Binary files differ
diff --git a/content/examples/groovy-spock/pom.xml b/content/examples/groovy-spock/pom.xml
new file mode 100755
index 0000000..6f99cc1
--- /dev/null
+++ b/content/examples/groovy-spock/pom.xml
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>groovy-spock</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Groovy Spock</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <compilerId>groovy-eclipse-compiler</compilerId>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-compiler</artifactId>
+ <version>2.8.0-01</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-eclipse-batch</artifactId>
+ <version>2.1.8-01</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>org.eclipse.core.contenttype</artifactId>
+ <version>3.4.100.v20100505-1235</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <includes> <!-- we could have used *Test.java as by default but it is more consistent -->
+ <include>**/*Specification.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ <snapshots/>
+ </repository>
+ <repository>
+ <id>sonatype-snapshot</id>
+ <name>Sonatype Snapshot Repository</name>
+ <url>http://oss.sonatype.org/content/repositories/snapshots</url>
+ <snapshots/>
+ </repository>
+ <repository>
+ <id>codehaus-snapshot</id>
+ <name>Codehaus Snapshot Repository</name>
+ <url>http://nexus.codehaus.org/snapshots</url>
+ <snapshots/>
+ </repository>
+ <repository>
+ <id>codehaus</id>
+ <name>Codehaus Repository</name>
+ <url>https://nexus.codehaus.org/content/groups/public</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>1.1.5.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.spock</groupId>
+ <artifactId>arquillian-spock-container</artifactId>
+ <version>1.0.0.Beta3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.spockframework</groupId>
+ <artifactId>spock-core</artifactId>
+ <version>0.7-groovy-2.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/groovy-spock/src/main/java/org/superbiz/groovy/Hello.groovy b/content/examples/groovy-spock/src/main/java/org/superbiz/groovy/Hello.groovy
new file mode 100755
index 0000000..5141fcc
--- /dev/null
+++ b/content/examples/groovy-spock/src/main/java/org/superbiz/groovy/Hello.groovy
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.groovy
+
+class Hello {
+
+ def hi() {
+ "hi"
+ }
+
+ @Override
+ String toString() {
+ "This is the Hello instance";
+ }
+}
diff --git a/content/examples/groovy-spock/src/main/resources/META-INF/beans.xml b/content/examples/groovy-spock/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..6668db4
--- /dev/null
+++ b/content/examples/groovy-spock/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,19 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans>
+</beans>
\ No newline at end of file
diff --git a/content/examples/groovy-spock/src/test/java/org/superbiz/groovy/HelloSpecification.groovy b/content/examples/groovy-spock/src/test/java/org/superbiz/groovy/HelloSpecification.groovy
new file mode 100755
index 0000000..08b0c15
--- /dev/null
+++ b/content/examples/groovy-spock/src/test/java/org/superbiz/groovy/HelloSpecification.groovy
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.groovy
+
+import org.apache.ziplock.JarLocation
+import org.jboss.arquillian.container.test.api.Deployment
+import org.jboss.arquillian.spock.ArquillianSputnik
+import org.jboss.shrinkwrap.api.ArchivePaths
+import org.jboss.shrinkwrap.api.ShrinkWrap
+import org.jboss.shrinkwrap.api.asset.EmptyAsset
+import org.jboss.shrinkwrap.api.spec.WebArchive
+import org.junit.runner.RunWith
+
+import javax.inject.Inject
+
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertNotNull
+
+@RunWith(ArquillianSputnik.class)
+class HelloSpecification extends spock.lang.Specification {
+
+ @Inject
+ private org.superbiz.groovy.Hello hello
+
+ @Deployment
+ def static WebArchive "create archive"() {
+ ShrinkWrap.create(WebArchive.class)
+ .addAsLibraries(JarLocation.jarLocation(GroovyObject.class))
+ .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
+ .addClasses(Hello.class)
+ }
+
+ def "Hello.hi() method should return 'hi'"() {
+ when:
+ println("Checking hello instance: " + hello)
+ assertNotNull hello
+
+ then:
+ println("Comparing 'hi' to '" + hello.hi() + "'")
+ assertEquals "hi", hello.hi()
+ }
+}
diff --git a/content/examples/helloworld-weblogic.html b/content/examples/helloworld-weblogic.html
new file mode 100644
index 0000000..1167c79
--- /dev/null
+++ b/content/examples/helloworld-weblogic.html
@@ -0,0 +1,354 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/helloworld-weblogic.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Helloworld Weblogic</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example helloworld-weblogic can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/helloworld-weblogic" class="bare">https://github.com/apache/tomee/tree/master/examples/helloworld-weblogic</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_hellobean">HelloBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.hello;
+
+import javax.ejb.LocalHome;
+import javax.ejb.Stateless;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+@Stateless
+@LocalHome(HelloEjbLocalHome.class)
+public class HelloBean {
+
+ public String sayHello() {
+ return "Hello, World!";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_helloejblocal">HelloEjbLocal</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.hello;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public interface HelloEjbLocal extends EJBLocalObject {
+
+ String sayHello();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_helloejblocalhome">HelloEjbLocalHome</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.hello;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+
+/**
+ * @version $Revision: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+public interface HelloEjbLocalHome extends EJBLocalHome {
+ HelloEjbLocal create() throws CreateException;
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar/></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_weblogic_ejb_jar_xml">weblogic-ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><weblogic-ejb-jar>
+ <weblogic-enterprise-bean>
+ <ejb-name>HelloBean</ejb-name>
+ <local-jndi-name>MyHello</local-jndi-name>
+ </weblogic-enterprise-bean>
+</weblogic-ejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_hellotest">HelloTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.hello;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+/**
+ * @version $Revision: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+public class HelloTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ InitialContext initialContext = new InitialContext(properties);
+
+ HelloEjbLocalHome localHome = (HelloEjbLocalHome) initialContext.lookup("MyHello");
+ HelloEjbLocal helloEjb = localHome.create();
+
+ String message = helloEjb.sayHello();
+
+ assertEquals(message, "Hello, World!");
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.hello.HelloTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/helloworld-weblogic
+INFO - openejb.base = /Users/dblevins/examples/helloworld-weblogic
+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/helloworld-weblogic/target/classes
+INFO - Beginning load: /Users/dblevins/examples/helloworld-weblogic/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/helloworld-weblogic/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean HelloBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "/Users/dblevins/examples/helloworld-weblogic/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/helloworld-weblogic/classpath.ear
+INFO - Jndi(name=MyHello) --> Ejb(deployment-id=HelloBean)
+INFO - Jndi(name=global/classpath.ear/helloworld-weblogic/HelloBean!org.superbiz.hello.HelloEjbLocalHome) --> Ejb(deployment-id=HelloBean)
+INFO - Jndi(name=global/classpath.ear/helloworld-weblogic/HelloBean) --> Ejb(deployment-id=HelloBean)
+INFO - Created Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/helloworld-weblogic/classpath.ear)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.414 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/helloworld-weblogic.pdf b/content/examples/helloworld-weblogic.pdf
new file mode 100644
index 0000000..174a43e
--- /dev/null
+++ b/content/examples/helloworld-weblogic.pdf
Binary files differ
diff --git a/content/examples/helloworld-weblogic/README.md b/content/examples/helloworld-weblogic/README.md
new file mode 100755
index 0000000..be7b078
--- /dev/null
+++ b/content/examples/helloworld-weblogic/README.md
@@ -0,0 +1,127 @@
+Title: Helloworld Weblogic
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## HelloBean
+
+ package org.superbiz.hello;
+
+ import javax.ejb.LocalHome;
+ import javax.ejb.Stateless;
+
+ /**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ @Stateless
+ @LocalHome(HelloEjbLocalHome.class)
+ public class HelloBean {
+
+ public String sayHello() {
+ return "Hello, World!";
+ }
+ }
+
+## HelloEjbLocal
+
+ package org.superbiz.hello;
+
+ import javax.ejb.EJBLocalObject;
+
+ /**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public interface HelloEjbLocal extends EJBLocalObject {
+
+ String sayHello();
+ }
+
+## HelloEjbLocalHome
+
+ package org.superbiz.hello;
+
+ import javax.ejb.CreateException;
+ import javax.ejb.EJBLocalHome;
+
+ /**
+ * @version $Revision: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+ public interface HelloEjbLocalHome extends EJBLocalHome {
+ HelloEjbLocal create() throws CreateException;
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar/>
+
+## weblogic-ejb-jar.xml
+
+ <weblogic-ejb-jar>
+ <weblogic-enterprise-bean>
+ <ejb-name>HelloBean</ejb-name>
+ <local-jndi-name>MyHello</local-jndi-name>
+ </weblogic-enterprise-bean>
+ </weblogic-ejb-jar>
+
+
+
+## HelloTest
+
+ package org.superbiz.hello;
+
+ import junit.framework.TestCase;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.Properties;
+
+ /**
+ * @version $Revision: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+ public class HelloTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ InitialContext initialContext = new InitialContext(properties);
+
+ HelloEjbLocalHome localHome = (HelloEjbLocalHome) initialContext.lookup("MyHello");
+ HelloEjbLocal helloEjb = localHome.create();
+
+ String message = helloEjb.sayHello();
+
+ assertEquals(message, "Hello, World!");
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.hello.HelloTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/helloworld-weblogic
+ INFO - openejb.base = /Users/dblevins/examples/helloworld-weblogic
+ 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/helloworld-weblogic/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/helloworld-weblogic/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/helloworld-weblogic/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean HelloBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "/Users/dblevins/examples/helloworld-weblogic/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/helloworld-weblogic/classpath.ear
+ INFO - Jndi(name=MyHello) --> Ejb(deployment-id=HelloBean)
+ INFO - Jndi(name=global/classpath.ear/helloworld-weblogic/HelloBean!org.superbiz.hello.HelloEjbLocalHome) --> Ejb(deployment-id=HelloBean)
+ INFO - Jndi(name=global/classpath.ear/helloworld-weblogic/HelloBean) --> Ejb(deployment-id=HelloBean)
+ INFO - Created Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/helloworld-weblogic/classpath.ear)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.414 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/helloworld-weblogic/build.xml b/content/examples/helloworld-weblogic/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/helloworld-weblogic/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/helloworld-weblogic/pom.xml b/content/examples/helloworld-weblogic/pom.xml
new file mode 100755
index 0000000..dce47b3
--- /dev/null
+++ b/content/examples/helloworld-weblogic/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>helloworld-weblogic</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Hello World - Weblogic</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloBean.java b/content/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloBean.java
new file mode 100755
index 0000000..9692d20
--- /dev/null
+++ b/content/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloBean.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.hello;
+
+import javax.ejb.LocalHome;
+import javax.ejb.Stateless;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+@Stateless
+@LocalHome(HelloEjbLocalHome.class)
+public class HelloBean {
+
+ public String sayHello() {
+ return "Hello, World!";
+ }
+
+}
diff --git a/content/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocal.java b/content/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocal.java
new file mode 100755
index 0000000..0952e8e
--- /dev/null
+++ b/content/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocal.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.hello;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public interface HelloEjbLocal extends EJBLocalObject {
+
+ String sayHello();
+
+}
diff --git a/content/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocalHome.java b/content/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocalHome.java
new file mode 100755
index 0000000..957987e
--- /dev/null
+++ b/content/examples/helloworld-weblogic/src/main/java/org/superbiz/hello/HelloEjbLocalHome.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.hello;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBLocalHome;
+
+/**
+ * @version $Revision: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+public interface HelloEjbLocalHome extends EJBLocalHome {
+
+ HelloEjbLocal create() throws CreateException;
+}
diff --git a/content/examples/helloworld-weblogic/src/main/resources/META-INF/ejb-jar.xml b/content/examples/helloworld-weblogic/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..433757b
--- /dev/null
+++ b/content/examples/helloworld-weblogic/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
\ No newline at end of file
diff --git a/content/examples/helloworld-weblogic/src/main/resources/META-INF/weblogic-ejb-jar.xml b/content/examples/helloworld-weblogic/src/main/resources/META-INF/weblogic-ejb-jar.xml
new file mode 100755
index 0000000..f69ce99
--- /dev/null
+++ b/content/examples/helloworld-weblogic/src/main/resources/META-INF/weblogic-ejb-jar.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 16:49:26 +0200 (Sun, 10 Apr 2011) $ -->
+
+<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 7.0.0 EJB//EN"
+ "http://www.bea.com/servers/wls700/dtd/weblogic-ejb-jar.dtd">
+<weblogic-ejb-jar>
+ <weblogic-enterprise-bean>
+ <ejb-name>HelloBean</ejb-name>
+ <local-jndi-name>MyHello</local-jndi-name>
+ </weblogic-enterprise-bean>
+</weblogic-ejb-jar>
+
diff --git a/content/examples/helloworld-weblogic/src/test/java/org/superbiz/hello/HelloTest.java b/content/examples/helloworld-weblogic/src/test/java/org/superbiz/hello/HelloTest.java
new file mode 100755
index 0000000..ffce07d
--- /dev/null
+++ b/content/examples/helloworld-weblogic/src/test/java/org/superbiz/hello/HelloTest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.hello;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+/**
+ * @version $Revision: 1227481 $ $Date: 2012-01-05 05:39:55 +0100 (Thu, 05 Jan 2012) $
+ */
+public class HelloTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ InitialContext initialContext = new InitialContext(properties);
+
+ HelloEjbLocalHome localHome = (HelloEjbLocalHome) initialContext.lookup("MyHello");
+ HelloEjbLocal helloEjb = localHome.create();
+
+ String message = helloEjb.sayHello();
+
+ assertEquals(message, "Hello, World!");
+ }
+}
diff --git a/content/examples/index-ng.html b/content/examples/index-ng.html
new file mode 100644
index 0000000..4055848
--- /dev/null
+++ b/content/examples/index-ng.html
@@ -0,0 +1,1829 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+<div id="main-block" class="container section-padded">
+<div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right'>
+ <div class='btn-group'>
+ <a class="btn" href="../examples/index-ng.pdf">
+ <i class="fa fa-file-pdf-o"></i> Download as PDF
+ </a>
+ </div>
+ </div>
+
+ <h2>Examples</h2>
+ </div>
+</div>
+<div class="row">
+ <div class="col-md-12">
+ <input id="example-search" placeholder="Search an example and click on it to browse it..." class="typeahead"/>
+ </div>
+ <div class="vspace"> </div>
+ <div class="col-md-12 examples text-center">
+
+ <div class="col-sm-6">
+ <h3>adapters</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="multiple-arquillian-adapters.html">multiple-arquillian-adapters</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>alternate</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="alternate-descriptors.html">alternate-descriptors</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>alternative</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applet</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applet.html">applet</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applicationcomposer</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="rest-applicationcomposer.html">rest-applicationcomposer</a></li>
+
+ <li><a href="application-composer.html">application-composer</a></li>
+
+ <li><a href="rest-applicationcomposer-mockito.html">rest-applicationcomposer-mockito</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applicationexception</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationexception.html">applicationexception</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>arquillian</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="arquillian-jpa.html">arquillian-jpa</a></li>
+
+ <li><a href="multiple-tomee-arquillian.html">multiple-tomee-arquillian</a></li>
+
+ <li><a href="multiple-arquillian-adapters.html">multiple-arquillian-adapters</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>async</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="async-postconstruct.html">async-postconstruct</a></li>
+
+ <li><a href="async-methods.html">async-methods</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>attachments</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-attachments.html">webservice-attachments</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>bmt</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="testing-transactions-bmt.html">testing-transactions-bmt</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>bval</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>callbacks</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-stateful-callbacks.html">simple-stateful-callbacks</a></li>
+
+ <li><a href="simple-stateless-callbacks.html">simple-stateless-callbacks</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cdi</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="cdi-basic.html">cdi-basic</a></li>
+
+ <li><a href="simple-mdb-and-cdi.html">simple-mdb-and-cdi</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ <li><a href="groovy-cdi.html">groovy-cdi</a></li>
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ <li><a href="cdi-produces-disposes.html">cdi-produces-disposes</a></li>
+
+ <li><a href="cdi-interceptors.html">cdi-interceptors</a></li>
+
+ <li><a href="cdi-application-scope.html">cdi-application-scope</a></li>
+
+ <li><a href="cdi-request-scope.html">cdi-request-scope</a></li>
+
+ <li><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li>
+
+ <li><a href="cdi-produces-field.html">cdi-produces-field</a></li>
+
+ <li><a href="simple-cdi-interceptor.html">simple-cdi-interceptor</a></li>
+
+ <li><a href="cdi-events.html">cdi-events</a></li>
+
+ <li><a href="cdi-realm.html">cdi-realm</a></li>
+
+ <li><a href="rest-cdi.html">rest-cdi</a></li>
+
+ <li><a href="cdi-session-scope.html">cdi-session-scope</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ciphered</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="datasource-ciphered-password.html">datasource-ciphered-password</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>client</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="client-resource-lookup-preview.html">client-resource-lookup-preview</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cmp2</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-cmp2.html">simple-cmp2</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>codi</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="myfaces-codi-demo.html">myfaces-codi-demo</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>component</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="component-interfaces.html">component-interfaces</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>config</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-configproperty.html">deltaspike-configproperty</a></li>
+
+ <li><a href="webservice-ws-with-resources-config.html">webservice-ws-with-resources-config</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>connectionfactory</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-connectionfactory.html">injection-of-connectionfactory</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>contract</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bean-validation-design-by-contract.html">bean-validation-design-by-contract</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cucumber</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cucumber-jvm.html">cucumber-jvm</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>dao</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>data</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="spring-data-proxy.html">spring-data-proxy</a></li>
+
+ <li><a href="spring-data-proxy-meta.html">spring-data-proxy-meta</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>datasource</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-datasource-routing.html">dynamic-datasource-routing</a></li>
+
+ <li><a href="injection-of-datasource.html">injection-of-datasource</a></li>
+
+ <li><a href="datasource-definition.html">datasource-definition</a></li>
+
+ <li><a href="datasource-versioning.html">datasource-versioning</a></li>
+
+ <li><a href="datasource-ciphered-password.html">datasource-ciphered-password</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>decorators</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="decorators.html">decorators</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>definition</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="datasource-definition.html">datasource-definition</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>deltaspike</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-fullstack.html">deltaspike-fullstack</a></li>
+
+ <li><a href="deltaspike-exception-handling.html">deltaspike-exception-handling</a></li>
+
+ <li><a href="deltaspike-i18n.html">deltaspike-i18n</a></li>
+
+ <li><a href="deltaspike-configproperty.html">deltaspike-configproperty</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>descriptor</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-stateless-with-descriptor.html">simple-stateless-with-descriptor</a></li>
+
+ <li><a href="simple-mdb-with-descriptor.html">simple-mdb-with-descriptor</a></li>
+
+ <li><a href="alternate-descriptors.html">alternate-descriptors</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>design</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bean-validation-design-by-contract.html">bean-validation-design-by-contract</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>disposes</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-produces-disposes.html">cdi-produces-disposes</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>dynamic</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-implementation.html">dynamic-implementation</a></li>
+
+ <li><a href="dynamic-datasource-routing.html">dynamic-datasource-routing</a></li>
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ <li><a href="dynamic-proxy-to-access-mbean.html">dynamic-proxy-to-access-mbean</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ear</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="ear-testing.html">ear-testing</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>eclipselink</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-eclipselink.html">jpa-eclipselink</a></li>
+
+ <li><a href="tomee-jersey-eclipselink.html">tomee-jersey-eclipselink</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ejb</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="rest-on-ejb.html">rest-on-ejb</a></li>
+
+ <li><a href="jsf-managedBean-and-ejb.html">jsf-managedBean-and-ejb</a></li>
+
+ <li><a href="ejb-examples.html">ejb-examples</a></li>
+
+ <li><a href="injection-of-ejbs.html">injection-of-ejbs</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ <li><a href="ejb-webservice.html">ejb-webservice</a></li>
+
+ <li><a href="lookup-of-ejbs.html">lookup-of-ejbs</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ejbcontext</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>entitymanager</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-entitymanager.html">injection-of-entitymanager</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>enumerated</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-enumerated.html">jpa-enumerated</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>enventry</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-env-entry.html">injection-of-env-entry</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>evaluation</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>event</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="server-events.html">server-events</a></li>
+
+ <li><a href="cdi-events.html">cdi-events</a></li>
+
+ <li><a href="schedule-events.html">schedule-events</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>examples</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="ejb-examples.html">ejb-examples</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>exception</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-exception-handling.html">deltaspike-exception-handling</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>expression</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="schedule-expression.html">schedule-expression</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>field</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-produces-field.html">cdi-produces-field</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>fragment</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="persistence-fragment.html">persistence-fragment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>fullstack</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-fullstack.html">deltaspike-fullstack</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>groovy</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="groovy-jpa.html">groovy-jpa</a></li>
+
+ <li><a href="groovy-spock.html">groovy-spock</a></li>
+
+ <li><a href="groovy-cdi.html">groovy-cdi</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>handlerchain</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-handlerchain.html">webservice-handlerchain</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>helloworld</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="helloworld-weblogic.html">helloworld-weblogic</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>hibernate</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-hibernate.html">jpa-hibernate</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>holder</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-holder.html">webservice-holder</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>i18n</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-i18n.html">deltaspike-i18n</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>implementation</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-implementation.html">dynamic-implementation</a></li>
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>inheritance</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-inheritance.html">webservice-inheritance</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>injection</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-connectionfactory.html">injection-of-connectionfactory</a></li>
+
+ <li><a href="testcase-injection.html">testcase-injection</a></li>
+
+ <li><a href="injection-of-env-entry.html">injection-of-env-entry</a></li>
+
+ <li><a href="injection-of-entitymanager.html">injection-of-entitymanager</a></li>
+
+ <li><a href="injection-of-datasource.html">injection-of-datasource</a></li>
+
+ <li><a href="injection-of-ejbs.html">injection-of-ejbs</a></li>
+
+ <li><a href="custom-injection.html">custom-injection</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>interceptor</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="interceptors.html">interceptors</a></li>
+
+ <li><a href="cdi-interceptors.html">cdi-interceptors</a></li>
+
+ <li><a href="simple-cdi-interceptor.html">simple-cdi-interceptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>interfaces</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="component-interfaces.html">component-interfaces</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jaas</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ <li><a href="rest-jaas.html">rest-jaas</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>javamail</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="javamail.html">javamail</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jaxws</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="change-jaxws-url.html">change-jaxws-url</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jersey</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="tomee-jersey-eclipselink.html">tomee-jersey-eclipselink</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jmx</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="resources-jmx-example.html">resources-jmx-example</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jpa</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-eclipselink.html">jpa-eclipselink</a></li>
+
+ <li><a href="groovy-jpa.html">groovy-jpa</a></li>
+
+ <li><a href="jpa-enumerated.html">jpa-enumerated</a></li>
+
+ <li><a href="jpa-hibernate.html">jpa-hibernate</a></li>
+
+ <li><a href="arquillian-jpa.html">arquillian-jpa</a></li>
+
+ <li><a href="multi-jpa-provider-testing.html">multi-jpa-provider-testing</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jsf</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jsf-managedBean-and-ejb.html">jsf-managedBean-and-ejb</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>json</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="rest-xml-json.html">rest-xml-json</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>lookup</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="lookup-of-ejbs.html">lookup-of-ejbs</a></li>
+
+ <li><a href="client-resource-lookup-preview.html">client-resource-lookup-preview</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>adapters</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="multiple-arquillian-adapters.html">multiple-arquillian-adapters</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>alternate</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="alternate-descriptors.html">alternate-descriptors</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>alternative</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applet</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applet.html">applet</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applicationcomposer</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="rest-applicationcomposer.html">rest-applicationcomposer</a></li>
+
+ <li><a href="application-composer.html">application-composer</a></li>
+
+ <li><a href="rest-applicationcomposer-mockito.html">rest-applicationcomposer-mockito</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applicationexception</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationexception.html">applicationexception</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>arquillian</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="arquillian-jpa.html">arquillian-jpa</a></li>
+
+ <li><a href="multiple-tomee-arquillian.html">multiple-tomee-arquillian</a></li>
+
+ <li><a href="multiple-arquillian-adapters.html">multiple-arquillian-adapters</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>async</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="async-postconstruct.html">async-postconstruct</a></li>
+
+ <li><a href="async-methods.html">async-methods</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>attachments</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-attachments.html">webservice-attachments</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>bmt</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="testing-transactions-bmt.html">testing-transactions-bmt</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>bval</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>callbacks</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-stateful-callbacks.html">simple-stateful-callbacks</a></li>
+
+ <li><a href="simple-stateless-callbacks.html">simple-stateless-callbacks</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cdi</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="cdi-basic.html">cdi-basic</a></li>
+
+ <li><a href="simple-mdb-and-cdi.html">simple-mdb-and-cdi</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ <li><a href="groovy-cdi.html">groovy-cdi</a></li>
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ <li><a href="cdi-produces-disposes.html">cdi-produces-disposes</a></li>
+
+ <li><a href="cdi-interceptors.html">cdi-interceptors</a></li>
+
+ <li><a href="cdi-application-scope.html">cdi-application-scope</a></li>
+
+ <li><a href="cdi-request-scope.html">cdi-request-scope</a></li>
+
+ <li><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li>
+
+ <li><a href="cdi-produces-field.html">cdi-produces-field</a></li>
+
+ <li><a href="simple-cdi-interceptor.html">simple-cdi-interceptor</a></li>
+
+ <li><a href="cdi-events.html">cdi-events</a></li>
+
+ <li><a href="cdi-realm.html">cdi-realm</a></li>
+
+ <li><a href="rest-cdi.html">rest-cdi</a></li>
+
+ <li><a href="cdi-session-scope.html">cdi-session-scope</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ciphered</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="datasource-ciphered-password.html">datasource-ciphered-password</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>client</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="client-resource-lookup-preview.html">client-resource-lookup-preview</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cmp2</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-cmp2.html">simple-cmp2</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>codi</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="myfaces-codi-demo.html">myfaces-codi-demo</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>component</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="component-interfaces.html">component-interfaces</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>config</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-configproperty.html">deltaspike-configproperty</a></li>
+
+ <li><a href="webservice-ws-with-resources-config.html">webservice-ws-with-resources-config</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>connectionfactory</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-connectionfactory.html">injection-of-connectionfactory</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>contract</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bean-validation-design-by-contract.html">bean-validation-design-by-contract</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cucumber</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cucumber-jvm.html">cucumber-jvm</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>dao</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>data</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="spring-data-proxy.html">spring-data-proxy</a></li>
+
+ <li><a href="spring-data-proxy-meta.html">spring-data-proxy-meta</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>datasource</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-datasource-routing.html">dynamic-datasource-routing</a></li>
+
+ <li><a href="injection-of-datasource.html">injection-of-datasource</a></li>
+
+ <li><a href="datasource-definition.html">datasource-definition</a></li>
+
+ <li><a href="datasource-versioning.html">datasource-versioning</a></li>
+
+ <li><a href="datasource-ciphered-password.html">datasource-ciphered-password</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>decorators</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="decorators.html">decorators</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>definition</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="datasource-definition.html">datasource-definition</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>deltaspike</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-fullstack.html">deltaspike-fullstack</a></li>
+
+ <li><a href="deltaspike-exception-handling.html">deltaspike-exception-handling</a></li>
+
+ <li><a href="deltaspike-i18n.html">deltaspike-i18n</a></li>
+
+ <li><a href="deltaspike-configproperty.html">deltaspike-configproperty</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>descriptor</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-stateless-with-descriptor.html">simple-stateless-with-descriptor</a></li>
+
+ <li><a href="simple-mdb-with-descriptor.html">simple-mdb-with-descriptor</a></li>
+
+ <li><a href="alternate-descriptors.html">alternate-descriptors</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>design</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bean-validation-design-by-contract.html">bean-validation-design-by-contract</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>disposes</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-produces-disposes.html">cdi-produces-disposes</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>dynamic</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-implementation.html">dynamic-implementation</a></li>
+
+ <li><a href="dynamic-datasource-routing.html">dynamic-datasource-routing</a></li>
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ <li><a href="dynamic-proxy-to-access-mbean.html">dynamic-proxy-to-access-mbean</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ear</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="ear-testing.html">ear-testing</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>eclipselink</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-eclipselink.html">jpa-eclipselink</a></li>
+
+ <li><a href="tomee-jersey-eclipselink.html">tomee-jersey-eclipselink</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ejb</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="rest-on-ejb.html">rest-on-ejb</a></li>
+
+ <li><a href="jsf-managedBean-and-ejb.html">jsf-managedBean-and-ejb</a></li>
+
+ <li><a href="ejb-examples.html">ejb-examples</a></li>
+
+ <li><a href="injection-of-ejbs.html">injection-of-ejbs</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ <li><a href="ejb-webservice.html">ejb-webservice</a></li>
+
+ <li><a href="lookup-of-ejbs.html">lookup-of-ejbs</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ejbcontext</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>entitymanager</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-entitymanager.html">injection-of-entitymanager</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>enumerated</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-enumerated.html">jpa-enumerated</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>enventry</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-env-entry.html">injection-of-env-entry</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>evaluation</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>event</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="server-events.html">server-events</a></li>
+
+ <li><a href="cdi-events.html">cdi-events</a></li>
+
+ <li><a href="schedule-events.html">schedule-events</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>examples</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="ejb-examples.html">ejb-examples</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>exception</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-exception-handling.html">deltaspike-exception-handling</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>expression</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="schedule-expression.html">schedule-expression</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>field</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-produces-field.html">cdi-produces-field</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>fragment</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="persistence-fragment.html">persistence-fragment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>fullstack</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-fullstack.html">deltaspike-fullstack</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>groovy</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="groovy-jpa.html">groovy-jpa</a></li>
+
+ <li><a href="groovy-spock.html">groovy-spock</a></li>
+
+ <li><a href="groovy-cdi.html">groovy-cdi</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>handlerchain</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-handlerchain.html">webservice-handlerchain</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>helloworld</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="helloworld-weblogic.html">helloworld-weblogic</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>hibernate</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-hibernate.html">jpa-hibernate</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>holder</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-holder.html">webservice-holder</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>i18n</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-i18n.html">deltaspike-i18n</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>implementation</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-implementation.html">dynamic-implementation</a></li>
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>inheritance</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-inheritance.html">webservice-inheritance</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>injection</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-connectionfactory.html">injection-of-connectionfactory</a></li>
+
+ <li><a href="testcase-injection.html">testcase-injection</a></li>
+
+ <li><a href="injection-of-env-entry.html">injection-of-env-entry</a></li>
+
+ <li><a href="injection-of-entitymanager.html">injection-of-entitymanager</a></li>
+
+ <li><a href="injection-of-datasource.html">injection-of-datasource</a></li>
+
+ <li><a href="injection-of-ejbs.html">injection-of-ejbs</a></li>
+
+ <li><a href="custom-injection.html">custom-injection</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>interceptor</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="interceptors.html">interceptors</a></li>
+
+ <li><a href="cdi-interceptors.html">cdi-interceptors</a></li>
+
+ <li><a href="simple-cdi-interceptor.html">simple-cdi-interceptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>interfaces</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="component-interfaces.html">component-interfaces</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jaas</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ <li><a href="rest-jaas.html">rest-jaas</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>javamail</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="javamail.html">javamail</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jaxws</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="change-jaxws-url.html">change-jaxws-url</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jersey</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="tomee-jersey-eclipselink.html">tomee-jersey-eclipselink</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jmx</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="resources-jmx-example.html">resources-jmx-example</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jpa</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-eclipselink.html">jpa-eclipselink</a></li>
+
+ <li><a href="groovy-jpa.html">groovy-jpa</a></li>
+
+ <li><a href="jpa-enumerated.html">jpa-enumerated</a></li>
+
+ <li><a href="jpa-hibernate.html">jpa-hibernate</a></li>
+
+ <li><a href="arquillian-jpa.html">arquillian-jpa</a></li>
+
+ <li><a href="multi-jpa-provider-testing.html">multi-jpa-provider-testing</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jsf</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jsf-managedBean-and-ejb.html">jsf-managedBean-and-ejb</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>json</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="rest-xml-json.html">rest-xml-json</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>lookup</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="lookup-of-ejbs.html">lookup-of-ejbs</a></li>
+
+ <li><a href="client-resource-lookup-preview.html">client-resource-lookup-preview</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ </div>
+</div>
+</div>
+
+<style>
+.typeahead {
+ padding-left: 43px;
+ padding-right: 43px;
+ border-radius: 23px;
+ border:1px #ccc solid;
+ height: 46px;
+ width: 100%;
+ outline: none;
+}
+.typeahead:focus {
+ border-color: #66afe9;
+ outline: 0;
+ box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
+}
+
+
+/* typeahead styling*/
+.tt-menu hr {
+ margin-bottom: 5px;
+ margin-top: 5px;
+}
+.tt-menu h3 {
+ margin-bottom: 2px;
+ margin-top: 2px;
+ padding-bottom: 2px;
+ padding-top: 2px;
+ font-size: 18px;
+ font-weight: bolder;
+}
+.tt-menu h2 {
+ font-weight: bold;
+}
+span.twitter-typeahead .tt-menu,
+span.twitter-typeahead .tt-dropdown-menu {
+ z-index: 1000;
+ display: none;
+ width: 100%;
+ min-width: 160px;
+ padding: 5px 0;
+ margin: 2px 0 0;
+ list-style: none;
+ text-align: left;
+ background-color: #ffffff;
+ border: 1px solid #cccccc;
+ border: 1px solid rgba(0, 0, 0, 0.15);
+ border-radius: 4px;
+ -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
+ box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
+ background-clip: padding-box;
+}
+span.twitter-typeahead h3 {
+ padding-left: 15px;
+ clear: both;
+}
+span.twitter-typeahead .tt-suggestion {
+ display: block;
+ padding: 3px 15px;
+ clear: both;
+ font-weight: normal;
+ line-height: 1.42857143;
+ color: #333333;
+}
+span.twitter-typeahead .tt-suggestion.tt-cursor,
+span.twitter-typeahead .tt-suggestion:hover,
+span.twitter-typeahead .tt-suggestion:focus {
+ color: #ffffff;
+ text-decoration: none;
+ outline: 0;
+ background-color: #337ab7;
+}
+.input-group.input-group-lg span.twitter-typeahead .form-control {
+ height: 46px;
+ padding: 10px 16px;
+ line-height: 1.3333333;
+ border-radius: 6px;
+}
+.input-group.input-group-sm span.twitter-typeahead .form-control {
+ height: 30px;
+ padding: 5px 10px;
+ line-height: 1.5;
+ border-radius: 3px;
+}
+span.twitter-typeahead {
+ width: 100%;
+}
+.input-group span.twitter-typeahead {
+ display: block !important;
+ height: 34px;
+}
+.input-group span.twitter-typeahead .tt-menu,
+.input-group span.twitter-typeahead .tt-dropdown-menu {
+ top: 32px !important;
+}
+.input-group span.twitter-typeahead:not(:first-child):not(:last-child) .form-control {
+ border-radius: 0;
+}
+.input-group span.twitter-typeahead:first-child .form-control {
+ border-top-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+ border-top-right-radius: 0;
+ border-bottom-right-radius: 0;
+}
+.input-group span.twitter-typeahead:last-child .form-control {
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+ border-top-right-radius: 4px;
+ border-bottom-right-radius: 4px;
+}
+.input-group.input-group-sm span.twitter-typeahead {
+ height: 30px;
+}
+.input-group.input-group-sm span.twitter-typeahead .tt-menu,
+.input-group.input-group-sm span.twitter-typeahead .tt-dropdown-menu {
+ top: 30px !important;
+}
+.input-group.input-group-lg span.twitter-typeahead {
+ height: 46px;
+}
+.input-group.input-group-lg span.twitter-typeahead .tt-menu,
+.input-group.input-group-lg span.twitter-typeahead .tt-dropdown-menu {
+ top: 46px !important;
+}
+</style>
+<script src="../js/jquery-1.11.1.min.js"></script>
+<script src="../js/typeahead.bundle.min.js"></script>
+<script>
+(function () {
+ var names = [];
+ document.querySelectorAll('.examples li > a').forEach(function (s) {
+ names.push(s.innerHTML);
+ });
+ var engine = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.nonword,
+ queryTokenizer: Bloodhound.tokenizers.nonword,
+ local: names
+ });
+ var input = jQuery('#example-search');
+ input.typeahead({ minLength: 1, highlight: true }, {
+ name: 'Examples',
+ source: engine,
+ templates: {
+ suggestion: function (item) {
+ return '<a href="' + item + '.html">' + item + '</a>';
+ }
+ }
+ });
+ input.bind('typeahead:select', function (evt, item) {
+ jQuery('li > a[href="' + item + '.html"]').click();
+ });
+})();
+
+</script>
+
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
+
diff --git a/content/examples/index-ng.pdf b/content/examples/index-ng.pdf
new file mode 100644
index 0000000..fcf8cce
--- /dev/null
+++ b/content/examples/index-ng.pdf
Binary files differ
diff --git a/content/examples/index-old.md b/content/examples/index-old.md
new file mode 100755
index 0000000..5ab136d
--- /dev/null
+++ b/content/examples/index-old.md
@@ -0,0 +1,178 @@
+Title: JavaEE Examples
+Notice: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+If there is a particular example that you do not see here please feel free to [ask](mailto:dev@openejb.apache.org?subject=Example+request), the odds are good that someone will create it for you.
+All the examples show source code, but some are better documented than others.
+If you need a little more help understanding an example then please drop us a [line](mailto:dev@openejb.apache.org?subject=Example+request) or visit us on IRC freenode.net #openejb
+
+{row
+{span-one-third
+###Session Beans
+[simple-singleton](simple-singleton/README.html)
+[simple-stateful](simple-stateful/README.html)
+[simple-stateless](simple-stateless/README.html)
+[simple-stateless-with-descriptor](simple-stateless-with-descriptor/README.html)
+}
+{span-one-third
+###EntityManagers
+[injection-of-entitymanager](injection-of-entitymanager/README.html)
+[jpa-eclipselink](jpa-eclipselink/README.html)
+[jpa-hibernate](jpa-hibernate/README.html)
+[jpa-enumerated](jpa-enumerated/README.html)
+}
+{span-one-third
+###CDI
+[cdi-basic](cdi-basic/README.html)
+[cdi-request-scope](cdi-request-scope/README.html)
+[cdi-application-scope](cdi-application-scope/README.html)
+[simple-cdi-interceptor](simple-cdi-interceptor/README.html)
+[cdi-produces-disposes](cdi-produces-disposes/README.html)
+[decorators](decorators/README.html)
+[cdi-alternative-and-stereotypes](cdi-alternative-and-stereotypes/README.html)
+}
+}
+{row
+{span-one-third
+###EJB
+[access-timeout](access-timeout/README.html)
+[async-methods](async-methods/README.html)
+[schedule-expression](schedule-expression/README.html)
+[schedule-methods](schedule-methods/README.html)
+[interceptors](interceptors/README.html)
+[async-postconstruct](async-postconstruct/README.html)
+}
+{span-one-third
+###REST
+[simple-rest](simple-rest/README.html)
+[rest-example](rest-example/README.html)
+[rest-example-with-application](rest-example-with-application/README.html)
+[rest-on-ejb](rest-on-ejb/README.html)
+[rest-xml-json](rest-example/README.html)
+}
+{span-one-third
+###Web Services
+[simple-webservice](simple-webservice/README.html)
+[webservice-handlerchain](webservice-handlerchain/README.html)
+[webservice-holder](webservice-holder/README.html)
+[webservice-attachments](webservice-attachments/README.html)
+[webservice-inheritance](webservice-inheritance/README.html)
+[webservice-security](webservice-security/README.html)
+[webservice-ws-security](webservice-ws-security/README.html)
+}
+}
+{row
+{span-one-third
+###JMS and MDBs
+[injection-of-connectionfactory](injection-of-connectionfactory/README.html)
+[simple-mdb-with-descriptor](simple-mdb-with-descriptor/README.html)
+[simple-mdb](simple-mdb/README.html)
+}
+{span-one-third
+### Transactions
+[testing-transactions](testing-transactions/README.html)
+[transaction-rollback](transaction-rollback/README.html)
+[applicationexception](applicationexception/README.html)
+}
+{span-one-third
+### Security
+[testing-security-3](testing-security-3/README.html)
+[testing-security-2](testing-security-2/README.html)
+[testing-security](testing-security/README.html)
+}
+}
+{row
+{span-one-third
+###DataSources
+[injection-of-datasource](injection-of-datasource/README.html)
+[datasource-ciphered-password](datasource-ciphered-password/README.html)
+[dynamic-datasource-routing](dynamic-datasource-routing/README.html)
+[resources-declared-in-webapp](resources-declared-in-webapp/README.html)
+}
+{span-one-third
+###Referencing EJBs
+[injection-of-ejbs](injection-of-ejbs/README.html)
+[lookup-of-ejbs-with-descriptor](lookup-of-ejbs-with-descriptor/README.html)
+[lookup-of-ejbs](lookup-of-ejbs/README.html)
+}
+{span-one-third
+###Environment Entries
+[injection-of-env-entry](injection-of-env-entry/README.html)
+[custom-injection](custom-injection/README.html)
+}
+}
+{row
+{span-one-third
+###Java EE Connectors
+[quartz-app](quartz-app/README.html)
+}
+{span-one-third
+###Testing Techniques
+[alternate-descriptors](alternate-descriptors/README.html)
+[application-composer](application-composer/README.html)
+[testcase-injection](testcase-injection/README.html)
+[ear-testing](ear-testing/README.html)
+}
+{span-one-third
+### Frameworks
+[spring-data-proxy-meta](spring-data-proxy-meta/README.html)
+[spring-data-proxy](spring-data-proxy/README.html)
+[struts](struts/README.html)
+}
+}
+{row
+{span-one-third
+###Meta-Annotations
+[access-timeout-meta](access-timeout-meta/README.html)
+[schedule-methods-meta](schedule-methods-meta/README.html)
+[testing-security-meta](testing-security-meta/README.html)
+[movies-complete-meta](movies-complete-meta/README.html)
+[movies-complete](movies-complete/README.html)
+}
+{span-one-third
+### Proxy Beans
+[dynamic-dao-implementation](dynamic-dao-implementation/README.html)
+[dynamic-implementation](dynamic-implementation/README.html)
+[dynamic-proxy-to-access-mbean](dynamic-proxy-to-access-mbean/README.html)
+[spring-data-proxy](spring-data-proxy/README.html)
+}
+{span-one-third
+###EJB Legacy
+[cmp2-entitybeans](simple-cmp2/README.html)
+[component-interfaces](component-interfaces/README.html)
+}
+}
+{row
+{span-one-third
+### Other Features
+[mbean-auto-registration](mbean-auto-registration/README.html)
+[bean-validation-design-by-contract](bean-validation-design-by-contract/README.html)
+[telephone-stateful](telephone-stateful/README.html)
+[troubleshooting](troubleshooting/README.html)
+}
+{span-two-thirds
+###Misc
+[applet](applet/README.html)
+[ejb-examples](ejb-examples/README.html)
+[ejb-webservice](ejb-webservice/README.html)
+[jsf-cdi-and-ejb](jsf-cdi-and-ejb/README.html)
+[jsf-managedBean-and-ejb](jsf-managedBean-and-ejb/README.html)
+[moviefun](moviefun/README.html)
+[helloworld-weblogic](helloworld-weblogic/README.html)
+[polling-parent](polling-parent/README.html)
+}
+}
\ No newline at end of file
diff --git a/content/examples/index.html b/content/examples/index.html
new file mode 100644
index 0000000..eb5b7a8
--- /dev/null
+++ b/content/examples/index.html
@@ -0,0 +1,1829 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+<div id="main-block" class="container section-padded">
+<div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right'>
+ <div class='btn-group'>
+ <a class="btn" href="../examples/index.pdf">
+ <i class="fa fa-file-pdf-o"></i> Download as PDF
+ </a>
+ </div>
+ </div>
+
+ <h2>Examples</h2>
+ </div>
+</div>
+<div class="row">
+ <div class="col-md-12">
+ <input id="example-search" placeholder="Search an example and click on it to browse it..." class="typeahead"/>
+ </div>
+ <div class="vspace"> </div>
+ <div class="col-md-12 examples text-center">
+
+ <div class="col-sm-6">
+ <h3>adapters</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="multiple-arquillian-adapters.html">multiple-arquillian-adapters</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>alternate</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="alternate-descriptors.html">alternate-descriptors</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>alternative</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applet</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applet.html">applet</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applicationcomposer</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="rest-applicationcomposer.html">rest-applicationcomposer</a></li>
+
+ <li><a href="application-composer.html">application-composer</a></li>
+
+ <li><a href="rest-applicationcomposer-mockito.html">rest-applicationcomposer-mockito</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applicationexception</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationexception.html">applicationexception</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>arquillian</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="arquillian-jpa.html">arquillian-jpa</a></li>
+
+ <li><a href="multiple-tomee-arquillian.html">multiple-tomee-arquillian</a></li>
+
+ <li><a href="multiple-arquillian-adapters.html">multiple-arquillian-adapters</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>async</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="async-postconstruct.html">async-postconstruct</a></li>
+
+ <li><a href="async-methods.html">async-methods</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>attachments</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-attachments.html">webservice-attachments</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>bmt</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="testing-transactions-bmt.html">testing-transactions-bmt</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>bval</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>callbacks</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-stateful-callbacks.html">simple-stateful-callbacks</a></li>
+
+ <li><a href="simple-stateless-callbacks.html">simple-stateless-callbacks</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cdi</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="cdi-basic.html">cdi-basic</a></li>
+
+ <li><a href="simple-mdb-and-cdi.html">simple-mdb-and-cdi</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ <li><a href="groovy-cdi.html">groovy-cdi</a></li>
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ <li><a href="cdi-produces-disposes.html">cdi-produces-disposes</a></li>
+
+ <li><a href="cdi-interceptors.html">cdi-interceptors</a></li>
+
+ <li><a href="cdi-application-scope.html">cdi-application-scope</a></li>
+
+ <li><a href="cdi-request-scope.html">cdi-request-scope</a></li>
+
+ <li><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li>
+
+ <li><a href="cdi-produces-field.html">cdi-produces-field</a></li>
+
+ <li><a href="simple-cdi-interceptor.html">simple-cdi-interceptor</a></li>
+
+ <li><a href="cdi-events.html">cdi-events</a></li>
+
+ <li><a href="cdi-realm.html">cdi-realm</a></li>
+
+ <li><a href="rest-cdi.html">rest-cdi</a></li>
+
+ <li><a href="cdi-session-scope.html">cdi-session-scope</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ciphered</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="datasource-ciphered-password.html">datasource-ciphered-password</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>client</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="client-resource-lookup-preview.html">client-resource-lookup-preview</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cmp2</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-cmp2.html">simple-cmp2</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>codi</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="myfaces-codi-demo.html">myfaces-codi-demo</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>component</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="component-interfaces.html">component-interfaces</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>config</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-configproperty.html">deltaspike-configproperty</a></li>
+
+ <li><a href="webservice-ws-with-resources-config.html">webservice-ws-with-resources-config</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>connectionfactory</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-connectionfactory.html">injection-of-connectionfactory</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>contract</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bean-validation-design-by-contract.html">bean-validation-design-by-contract</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cucumber</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cucumber-jvm.html">cucumber-jvm</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>dao</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>data</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="spring-data-proxy.html">spring-data-proxy</a></li>
+
+ <li><a href="spring-data-proxy-meta.html">spring-data-proxy-meta</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>datasource</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-datasource-routing.html">dynamic-datasource-routing</a></li>
+
+ <li><a href="injection-of-datasource.html">injection-of-datasource</a></li>
+
+ <li><a href="datasource-definition.html">datasource-definition</a></li>
+
+ <li><a href="datasource-versioning.html">datasource-versioning</a></li>
+
+ <li><a href="datasource-ciphered-password.html">datasource-ciphered-password</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>decorators</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="decorators.html">decorators</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>definition</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="datasource-definition.html">datasource-definition</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>deltaspike</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-fullstack.html">deltaspike-fullstack</a></li>
+
+ <li><a href="deltaspike-exception-handling.html">deltaspike-exception-handling</a></li>
+
+ <li><a href="deltaspike-i18n.html">deltaspike-i18n</a></li>
+
+ <li><a href="deltaspike-configproperty.html">deltaspike-configproperty</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>descriptor</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-stateless-with-descriptor.html">simple-stateless-with-descriptor</a></li>
+
+ <li><a href="simple-mdb-with-descriptor.html">simple-mdb-with-descriptor</a></li>
+
+ <li><a href="alternate-descriptors.html">alternate-descriptors</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>design</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bean-validation-design-by-contract.html">bean-validation-design-by-contract</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>disposes</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-produces-disposes.html">cdi-produces-disposes</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>dynamic</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-implementation.html">dynamic-implementation</a></li>
+
+ <li><a href="dynamic-datasource-routing.html">dynamic-datasource-routing</a></li>
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ <li><a href="dynamic-proxy-to-access-mbean.html">dynamic-proxy-to-access-mbean</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ear</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="ear-testing.html">ear-testing</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>eclipselink</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-eclipselink.html">jpa-eclipselink</a></li>
+
+ <li><a href="tomee-jersey-eclipselink.html">tomee-jersey-eclipselink</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ejb</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="rest-on-ejb.html">rest-on-ejb</a></li>
+
+ <li><a href="jsf-managedBean-and-ejb.html">jsf-managedBean-and-ejb</a></li>
+
+ <li><a href="ejb-examples.html">ejb-examples</a></li>
+
+ <li><a href="injection-of-ejbs.html">injection-of-ejbs</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ <li><a href="ejb-webservice.html">ejb-webservice</a></li>
+
+ <li><a href="lookup-of-ejbs.html">lookup-of-ejbs</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ejbcontext</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>entitymanager</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-entitymanager.html">injection-of-entitymanager</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>enumerated</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-enumerated.html">jpa-enumerated</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>enventry</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-env-entry.html">injection-of-env-entry</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>evaluation</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>event</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="server-events.html">server-events</a></li>
+
+ <li><a href="cdi-events.html">cdi-events</a></li>
+
+ <li><a href="schedule-events.html">schedule-events</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>examples</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="ejb-examples.html">ejb-examples</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>exception</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-exception-handling.html">deltaspike-exception-handling</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>expression</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="schedule-expression.html">schedule-expression</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>field</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-produces-field.html">cdi-produces-field</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>fragment</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="persistence-fragment.html">persistence-fragment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>fullstack</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-fullstack.html">deltaspike-fullstack</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>groovy</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="groovy-jpa.html">groovy-jpa</a></li>
+
+ <li><a href="groovy-spock.html">groovy-spock</a></li>
+
+ <li><a href="groovy-cdi.html">groovy-cdi</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>handlerchain</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-handlerchain.html">webservice-handlerchain</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>helloworld</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="helloworld-weblogic.html">helloworld-weblogic</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>hibernate</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-hibernate.html">jpa-hibernate</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>holder</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-holder.html">webservice-holder</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>i18n</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-i18n.html">deltaspike-i18n</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>implementation</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-implementation.html">dynamic-implementation</a></li>
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>inheritance</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-inheritance.html">webservice-inheritance</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>injection</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-connectionfactory.html">injection-of-connectionfactory</a></li>
+
+ <li><a href="testcase-injection.html">testcase-injection</a></li>
+
+ <li><a href="injection-of-env-entry.html">injection-of-env-entry</a></li>
+
+ <li><a href="injection-of-entitymanager.html">injection-of-entitymanager</a></li>
+
+ <li><a href="injection-of-datasource.html">injection-of-datasource</a></li>
+
+ <li><a href="injection-of-ejbs.html">injection-of-ejbs</a></li>
+
+ <li><a href="custom-injection.html">custom-injection</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>interceptor</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="interceptors.html">interceptors</a></li>
+
+ <li><a href="cdi-interceptors.html">cdi-interceptors</a></li>
+
+ <li><a href="simple-cdi-interceptor.html">simple-cdi-interceptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>interfaces</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="component-interfaces.html">component-interfaces</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jaas</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ <li><a href="rest-jaas.html">rest-jaas</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>javamail</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="javamail.html">javamail</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jaxws</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="change-jaxws-url.html">change-jaxws-url</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jersey</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="tomee-jersey-eclipselink.html">tomee-jersey-eclipselink</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jmx</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="resources-jmx-example.html">resources-jmx-example</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jpa</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-eclipselink.html">jpa-eclipselink</a></li>
+
+ <li><a href="groovy-jpa.html">groovy-jpa</a></li>
+
+ <li><a href="jpa-enumerated.html">jpa-enumerated</a></li>
+
+ <li><a href="jpa-hibernate.html">jpa-hibernate</a></li>
+
+ <li><a href="arquillian-jpa.html">arquillian-jpa</a></li>
+
+ <li><a href="multi-jpa-provider-testing.html">multi-jpa-provider-testing</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jsf</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jsf-managedBean-and-ejb.html">jsf-managedBean-and-ejb</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>json</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="rest-xml-json.html">rest-xml-json</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>lookup</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="lookup-of-ejbs.html">lookup-of-ejbs</a></li>
+
+ <li><a href="client-resource-lookup-preview.html">client-resource-lookup-preview</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>adapters</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="multiple-arquillian-adapters.html">multiple-arquillian-adapters</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>alternate</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="alternate-descriptors.html">alternate-descriptors</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>alternative</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applet</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applet.html">applet</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applicationcomposer</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="rest-applicationcomposer.html">rest-applicationcomposer</a></li>
+
+ <li><a href="application-composer.html">application-composer</a></li>
+
+ <li><a href="rest-applicationcomposer-mockito.html">rest-applicationcomposer-mockito</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>applicationexception</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationexception.html">applicationexception</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>arquillian</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="arquillian-jpa.html">arquillian-jpa</a></li>
+
+ <li><a href="multiple-tomee-arquillian.html">multiple-tomee-arquillian</a></li>
+
+ <li><a href="multiple-arquillian-adapters.html">multiple-arquillian-adapters</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>async</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="async-postconstruct.html">async-postconstruct</a></li>
+
+ <li><a href="async-methods.html">async-methods</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>attachments</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-attachments.html">webservice-attachments</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>bmt</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="testing-transactions-bmt.html">testing-transactions-bmt</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>bval</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>callbacks</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-stateful-callbacks.html">simple-stateful-callbacks</a></li>
+
+ <li><a href="simple-stateless-callbacks.html">simple-stateless-callbacks</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cdi</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="cdi-basic.html">cdi-basic</a></li>
+
+ <li><a href="simple-mdb-and-cdi.html">simple-mdb-and-cdi</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ <li><a href="groovy-cdi.html">groovy-cdi</a></li>
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ <li><a href="cdi-produces-disposes.html">cdi-produces-disposes</a></li>
+
+ <li><a href="cdi-interceptors.html">cdi-interceptors</a></li>
+
+ <li><a href="cdi-application-scope.html">cdi-application-scope</a></li>
+
+ <li><a href="cdi-request-scope.html">cdi-request-scope</a></li>
+
+ <li><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li>
+
+ <li><a href="cdi-produces-field.html">cdi-produces-field</a></li>
+
+ <li><a href="simple-cdi-interceptor.html">simple-cdi-interceptor</a></li>
+
+ <li><a href="cdi-events.html">cdi-events</a></li>
+
+ <li><a href="cdi-realm.html">cdi-realm</a></li>
+
+ <li><a href="rest-cdi.html">rest-cdi</a></li>
+
+ <li><a href="cdi-session-scope.html">cdi-session-scope</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ciphered</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="datasource-ciphered-password.html">datasource-ciphered-password</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>client</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="client-resource-lookup-preview.html">client-resource-lookup-preview</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cmp2</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-cmp2.html">simple-cmp2</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>codi</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="myfaces-codi-demo.html">myfaces-codi-demo</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>component</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="component-interfaces.html">component-interfaces</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>config</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-configproperty.html">deltaspike-configproperty</a></li>
+
+ <li><a href="webservice-ws-with-resources-config.html">webservice-ws-with-resources-config</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>connectionfactory</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-connectionfactory.html">injection-of-connectionfactory</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>contract</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bean-validation-design-by-contract.html">bean-validation-design-by-contract</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>cucumber</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cucumber-jvm.html">cucumber-jvm</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>dao</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>data</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="spring-data-proxy.html">spring-data-proxy</a></li>
+
+ <li><a href="spring-data-proxy-meta.html">spring-data-proxy-meta</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>datasource</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-datasource-routing.html">dynamic-datasource-routing</a></li>
+
+ <li><a href="injection-of-datasource.html">injection-of-datasource</a></li>
+
+ <li><a href="datasource-definition.html">datasource-definition</a></li>
+
+ <li><a href="datasource-versioning.html">datasource-versioning</a></li>
+
+ <li><a href="datasource-ciphered-password.html">datasource-ciphered-password</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>decorators</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="decorators.html">decorators</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>definition</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="datasource-definition.html">datasource-definition</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>deltaspike</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-fullstack.html">deltaspike-fullstack</a></li>
+
+ <li><a href="deltaspike-exception-handling.html">deltaspike-exception-handling</a></li>
+
+ <li><a href="deltaspike-i18n.html">deltaspike-i18n</a></li>
+
+ <li><a href="deltaspike-configproperty.html">deltaspike-configproperty</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>descriptor</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="simple-stateless-with-descriptor.html">simple-stateless-with-descriptor</a></li>
+
+ <li><a href="simple-mdb-with-descriptor.html">simple-mdb-with-descriptor</a></li>
+
+ <li><a href="alternate-descriptors.html">alternate-descriptors</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>design</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bean-validation-design-by-contract.html">bean-validation-design-by-contract</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>disposes</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-produces-disposes.html">cdi-produces-disposes</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>dynamic</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-implementation.html">dynamic-implementation</a></li>
+
+ <li><a href="dynamic-datasource-routing.html">dynamic-datasource-routing</a></li>
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ <li><a href="dynamic-proxy-to-access-mbean.html">dynamic-proxy-to-access-mbean</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ear</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="ear-testing.html">ear-testing</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>eclipselink</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-eclipselink.html">jpa-eclipselink</a></li>
+
+ <li><a href="tomee-jersey-eclipselink.html">tomee-jersey-eclipselink</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ejb</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="rest-on-ejb.html">rest-on-ejb</a></li>
+
+ <li><a href="jsf-managedBean-and-ejb.html">jsf-managedBean-and-ejb</a></li>
+
+ <li><a href="ejb-examples.html">ejb-examples</a></li>
+
+ <li><a href="injection-of-ejbs.html">injection-of-ejbs</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ <li><a href="ejb-webservice.html">ejb-webservice</a></li>
+
+ <li><a href="lookup-of-ejbs.html">lookup-of-ejbs</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>ejbcontext</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>entitymanager</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-entitymanager.html">injection-of-entitymanager</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>enumerated</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-enumerated.html">jpa-enumerated</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>enventry</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-env-entry.html">injection-of-env-entry</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>evaluation</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>event</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="server-events.html">server-events</a></li>
+
+ <li><a href="cdi-events.html">cdi-events</a></li>
+
+ <li><a href="schedule-events.html">schedule-events</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>examples</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="ejb-examples.html">ejb-examples</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>exception</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-exception-handling.html">deltaspike-exception-handling</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>expression</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="schedule-expression.html">schedule-expression</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>field</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-produces-field.html">cdi-produces-field</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>fragment</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="persistence-fragment.html">persistence-fragment</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>fullstack</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-fullstack.html">deltaspike-fullstack</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>groovy</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="groovy-jpa.html">groovy-jpa</a></li>
+
+ <li><a href="groovy-spock.html">groovy-spock</a></li>
+
+ <li><a href="groovy-cdi.html">groovy-cdi</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>handlerchain</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-handlerchain.html">webservice-handlerchain</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>helloworld</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="helloworld-weblogic.html">helloworld-weblogic</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>hibernate</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-hibernate.html">jpa-hibernate</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>holder</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-holder.html">webservice-holder</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>i18n</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="deltaspike-i18n.html">deltaspike-i18n</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>implementation</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="dynamic-implementation.html">dynamic-implementation</a></li>
+
+ <li><a href="dynamic-dao-implementation.html">dynamic-dao-implementation</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>inheritance</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="webservice-inheritance.html">webservice-inheritance</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>injection</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="injection-of-connectionfactory.html">injection-of-connectionfactory</a></li>
+
+ <li><a href="testcase-injection.html">testcase-injection</a></li>
+
+ <li><a href="injection-of-env-entry.html">injection-of-env-entry</a></li>
+
+ <li><a href="injection-of-entitymanager.html">injection-of-entitymanager</a></li>
+
+ <li><a href="injection-of-datasource.html">injection-of-datasource</a></li>
+
+ <li><a href="injection-of-ejbs.html">injection-of-ejbs</a></li>
+
+ <li><a href="custom-injection.html">custom-injection</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>interceptor</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="interceptors.html">interceptors</a></li>
+
+ <li><a href="cdi-interceptors.html">cdi-interceptors</a></li>
+
+ <li><a href="simple-cdi-interceptor.html">simple-cdi-interceptor</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>interfaces</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="component-interfaces.html">component-interfaces</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jaas</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="cdi-ejbcontext-jaas.html">cdi-ejbcontext-jaas</a></li>
+
+ <li><a href="rest-jaas.html">rest-jaas</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>javamail</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="javamail.html">javamail</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jaxws</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="applicationcomposer-jaxws-cdi.html">applicationcomposer-jaxws-cdi</a></li>
+
+ <li><a href="change-jaxws-url.html">change-jaxws-url</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jersey</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="tomee-jersey-eclipselink.html">tomee-jersey-eclipselink</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jmx</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="resources-jmx-example.html">resources-jmx-example</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jpa</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jpa-eclipselink.html">jpa-eclipselink</a></li>
+
+ <li><a href="groovy-jpa.html">groovy-jpa</a></li>
+
+ <li><a href="jpa-enumerated.html">jpa-enumerated</a></li>
+
+ <li><a href="jpa-hibernate.html">jpa-hibernate</a></li>
+
+ <li><a href="arquillian-jpa.html">arquillian-jpa</a></li>
+
+ <li><a href="multi-jpa-provider-testing.html">multi-jpa-provider-testing</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>jsf</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="jsf-managedBean-and-ejb.html">jsf-managedBean-and-ejb</a></li>
+
+ <li><a href="jsf-cdi-and-ejb.html">jsf-cdi-and-ejb</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>json</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="rest-xml-json.html">rest-xml-json</a></li>
+
+ </ul>
+ </div>
+
+ <div class="col-sm-6">
+ <h3>lookup</h3>
+ <ul class="list-unstyled">
+
+ <li><a href="lookup-of-ejbs.html">lookup-of-ejbs</a></li>
+
+ <li><a href="client-resource-lookup-preview.html">client-resource-lookup-preview</a></li>
+
+ <li><a href="lookup-of-ejbs-with-descriptor.html">lookup-of-ejbs-with-descriptor</a></li>
+
+ </ul>
+ </div>
+
+ </div>
+</div>
+</div>
+
+<style>
+.typeahead {
+ padding-left: 43px;
+ padding-right: 43px;
+ border-radius: 23px;
+ border:1px #ccc solid;
+ height: 46px;
+ width: 100%;
+ outline: none;
+}
+.typeahead:focus {
+ border-color: #66afe9;
+ outline: 0;
+ box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
+}
+
+
+/* typeahead styling*/
+.tt-menu hr {
+ margin-bottom: 5px;
+ margin-top: 5px;
+}
+.tt-menu h3 {
+ margin-bottom: 2px;
+ margin-top: 2px;
+ padding-bottom: 2px;
+ padding-top: 2px;
+ font-size: 18px;
+ font-weight: bolder;
+}
+.tt-menu h2 {
+ font-weight: bold;
+}
+span.twitter-typeahead .tt-menu,
+span.twitter-typeahead .tt-dropdown-menu {
+ z-index: 1000;
+ display: none;
+ width: 100%;
+ min-width: 160px;
+ padding: 5px 0;
+ margin: 2px 0 0;
+ list-style: none;
+ text-align: left;
+ background-color: #ffffff;
+ border: 1px solid #cccccc;
+ border: 1px solid rgba(0, 0, 0, 0.15);
+ border-radius: 4px;
+ -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
+ box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
+ background-clip: padding-box;
+}
+span.twitter-typeahead h3 {
+ padding-left: 15px;
+ clear: both;
+}
+span.twitter-typeahead .tt-suggestion {
+ display: block;
+ padding: 3px 15px;
+ clear: both;
+ font-weight: normal;
+ line-height: 1.42857143;
+ color: #333333;
+}
+span.twitter-typeahead .tt-suggestion.tt-cursor,
+span.twitter-typeahead .tt-suggestion:hover,
+span.twitter-typeahead .tt-suggestion:focus {
+ color: #ffffff;
+ text-decoration: none;
+ outline: 0;
+ background-color: #337ab7;
+}
+.input-group.input-group-lg span.twitter-typeahead .form-control {
+ height: 46px;
+ padding: 10px 16px;
+ line-height: 1.3333333;
+ border-radius: 6px;
+}
+.input-group.input-group-sm span.twitter-typeahead .form-control {
+ height: 30px;
+ padding: 5px 10px;
+ line-height: 1.5;
+ border-radius: 3px;
+}
+span.twitter-typeahead {
+ width: 100%;
+}
+.input-group span.twitter-typeahead {
+ display: block !important;
+ height: 34px;
+}
+.input-group span.twitter-typeahead .tt-menu,
+.input-group span.twitter-typeahead .tt-dropdown-menu {
+ top: 32px !important;
+}
+.input-group span.twitter-typeahead:not(:first-child):not(:last-child) .form-control {
+ border-radius: 0;
+}
+.input-group span.twitter-typeahead:first-child .form-control {
+ border-top-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+ border-top-right-radius: 0;
+ border-bottom-right-radius: 0;
+}
+.input-group span.twitter-typeahead:last-child .form-control {
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+ border-top-right-radius: 4px;
+ border-bottom-right-radius: 4px;
+}
+.input-group.input-group-sm span.twitter-typeahead {
+ height: 30px;
+}
+.input-group.input-group-sm span.twitter-typeahead .tt-menu,
+.input-group.input-group-sm span.twitter-typeahead .tt-dropdown-menu {
+ top: 30px !important;
+}
+.input-group.input-group-lg span.twitter-typeahead {
+ height: 46px;
+}
+.input-group.input-group-lg span.twitter-typeahead .tt-menu,
+.input-group.input-group-lg span.twitter-typeahead .tt-dropdown-menu {
+ top: 46px !important;
+}
+</style>
+<script src="../js/jquery-1.11.1.min.js"></script>
+<script src="../js/typeahead.bundle.min.js"></script>
+<script>
+(function () {
+ var names = [];
+ document.querySelectorAll('.examples li > a').forEach(function (s) {
+ names.push(s.innerHTML);
+ });
+ var engine = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.nonword,
+ queryTokenizer: Bloodhound.tokenizers.nonword,
+ local: names
+ });
+ var input = jQuery('#example-search');
+ input.typeahead({ minLength: 1, highlight: true }, {
+ name: 'Examples',
+ source: engine,
+ templates: {
+ suggestion: function (item) {
+ return '<a href="' + item + '.html">' + item + '</a>';
+ }
+ }
+ });
+ input.bind('typeahead:select', function (evt, item) {
+ jQuery('li > a[href="' + item + '.html"]').click();
+ });
+})();
+
+</script>
+
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
+
diff --git a/content/examples/index.md b/content/examples/index.md
new file mode 100755
index 0000000..5ab136d
--- /dev/null
+++ b/content/examples/index.md
@@ -0,0 +1,178 @@
+Title: JavaEE Examples
+Notice: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+If there is a particular example that you do not see here please feel free to [ask](mailto:dev@openejb.apache.org?subject=Example+request), the odds are good that someone will create it for you.
+All the examples show source code, but some are better documented than others.
+If you need a little more help understanding an example then please drop us a [line](mailto:dev@openejb.apache.org?subject=Example+request) or visit us on IRC freenode.net #openejb
+
+{row
+{span-one-third
+###Session Beans
+[simple-singleton](simple-singleton/README.html)
+[simple-stateful](simple-stateful/README.html)
+[simple-stateless](simple-stateless/README.html)
+[simple-stateless-with-descriptor](simple-stateless-with-descriptor/README.html)
+}
+{span-one-third
+###EntityManagers
+[injection-of-entitymanager](injection-of-entitymanager/README.html)
+[jpa-eclipselink](jpa-eclipselink/README.html)
+[jpa-hibernate](jpa-hibernate/README.html)
+[jpa-enumerated](jpa-enumerated/README.html)
+}
+{span-one-third
+###CDI
+[cdi-basic](cdi-basic/README.html)
+[cdi-request-scope](cdi-request-scope/README.html)
+[cdi-application-scope](cdi-application-scope/README.html)
+[simple-cdi-interceptor](simple-cdi-interceptor/README.html)
+[cdi-produces-disposes](cdi-produces-disposes/README.html)
+[decorators](decorators/README.html)
+[cdi-alternative-and-stereotypes](cdi-alternative-and-stereotypes/README.html)
+}
+}
+{row
+{span-one-third
+###EJB
+[access-timeout](access-timeout/README.html)
+[async-methods](async-methods/README.html)
+[schedule-expression](schedule-expression/README.html)
+[schedule-methods](schedule-methods/README.html)
+[interceptors](interceptors/README.html)
+[async-postconstruct](async-postconstruct/README.html)
+}
+{span-one-third
+###REST
+[simple-rest](simple-rest/README.html)
+[rest-example](rest-example/README.html)
+[rest-example-with-application](rest-example-with-application/README.html)
+[rest-on-ejb](rest-on-ejb/README.html)
+[rest-xml-json](rest-example/README.html)
+}
+{span-one-third
+###Web Services
+[simple-webservice](simple-webservice/README.html)
+[webservice-handlerchain](webservice-handlerchain/README.html)
+[webservice-holder](webservice-holder/README.html)
+[webservice-attachments](webservice-attachments/README.html)
+[webservice-inheritance](webservice-inheritance/README.html)
+[webservice-security](webservice-security/README.html)
+[webservice-ws-security](webservice-ws-security/README.html)
+}
+}
+{row
+{span-one-third
+###JMS and MDBs
+[injection-of-connectionfactory](injection-of-connectionfactory/README.html)
+[simple-mdb-with-descriptor](simple-mdb-with-descriptor/README.html)
+[simple-mdb](simple-mdb/README.html)
+}
+{span-one-third
+### Transactions
+[testing-transactions](testing-transactions/README.html)
+[transaction-rollback](transaction-rollback/README.html)
+[applicationexception](applicationexception/README.html)
+}
+{span-one-third
+### Security
+[testing-security-3](testing-security-3/README.html)
+[testing-security-2](testing-security-2/README.html)
+[testing-security](testing-security/README.html)
+}
+}
+{row
+{span-one-third
+###DataSources
+[injection-of-datasource](injection-of-datasource/README.html)
+[datasource-ciphered-password](datasource-ciphered-password/README.html)
+[dynamic-datasource-routing](dynamic-datasource-routing/README.html)
+[resources-declared-in-webapp](resources-declared-in-webapp/README.html)
+}
+{span-one-third
+###Referencing EJBs
+[injection-of-ejbs](injection-of-ejbs/README.html)
+[lookup-of-ejbs-with-descriptor](lookup-of-ejbs-with-descriptor/README.html)
+[lookup-of-ejbs](lookup-of-ejbs/README.html)
+}
+{span-one-third
+###Environment Entries
+[injection-of-env-entry](injection-of-env-entry/README.html)
+[custom-injection](custom-injection/README.html)
+}
+}
+{row
+{span-one-third
+###Java EE Connectors
+[quartz-app](quartz-app/README.html)
+}
+{span-one-third
+###Testing Techniques
+[alternate-descriptors](alternate-descriptors/README.html)
+[application-composer](application-composer/README.html)
+[testcase-injection](testcase-injection/README.html)
+[ear-testing](ear-testing/README.html)
+}
+{span-one-third
+### Frameworks
+[spring-data-proxy-meta](spring-data-proxy-meta/README.html)
+[spring-data-proxy](spring-data-proxy/README.html)
+[struts](struts/README.html)
+}
+}
+{row
+{span-one-third
+###Meta-Annotations
+[access-timeout-meta](access-timeout-meta/README.html)
+[schedule-methods-meta](schedule-methods-meta/README.html)
+[testing-security-meta](testing-security-meta/README.html)
+[movies-complete-meta](movies-complete-meta/README.html)
+[movies-complete](movies-complete/README.html)
+}
+{span-one-third
+### Proxy Beans
+[dynamic-dao-implementation](dynamic-dao-implementation/README.html)
+[dynamic-implementation](dynamic-implementation/README.html)
+[dynamic-proxy-to-access-mbean](dynamic-proxy-to-access-mbean/README.html)
+[spring-data-proxy](spring-data-proxy/README.html)
+}
+{span-one-third
+###EJB Legacy
+[cmp2-entitybeans](simple-cmp2/README.html)
+[component-interfaces](component-interfaces/README.html)
+}
+}
+{row
+{span-one-third
+### Other Features
+[mbean-auto-registration](mbean-auto-registration/README.html)
+[bean-validation-design-by-contract](bean-validation-design-by-contract/README.html)
+[telephone-stateful](telephone-stateful/README.html)
+[troubleshooting](troubleshooting/README.html)
+}
+{span-two-thirds
+###Misc
+[applet](applet/README.html)
+[ejb-examples](ejb-examples/README.html)
+[ejb-webservice](ejb-webservice/README.html)
+[jsf-cdi-and-ejb](jsf-cdi-and-ejb/README.html)
+[jsf-managedBean-and-ejb](jsf-managedBean-and-ejb/README.html)
+[moviefun](moviefun/README.html)
+[helloworld-weblogic](helloworld-weblogic/README.html)
+[polling-parent](polling-parent/README.html)
+}
+}
\ No newline at end of file
diff --git a/content/examples/index.pdf b/content/examples/index.pdf
new file mode 100644
index 0000000..c63cdd2
--- /dev/null
+++ b/content/examples/index.pdf
Binary files differ
diff --git a/content/examples/injection-of-connectionfactory.html b/content/examples/injection-of-connectionfactory.html
new file mode 100644
index 0000000..062a1e5
--- /dev/null
+++ b/content/examples/injection-of-connectionfactory.html
@@ -0,0 +1,363 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/injection-of-connectionfactory.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Injection Of Connectionfactory</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example injection-of-connectionfactory can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/injection-of-connectionfactory" class="bare">https://github.com/apache/tomee/tree/master/examples/injection-of-connectionfactory</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_messages">Messages</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.jms;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+@Stateless
+public class Messages {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource
+ private Queue chatQueue;
+
+
+ public void sendMessage(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(chatQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+
+ public String receiveMessage() throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+ MessageConsumer consumer = null;
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageConsumer from the Session to the Topic or Queue
+ consumer = session.createConsumer(chatQueue);
+
+ // Wait for a message
+ TextMessage message = (TextMessage) consumer.receive(1000);
+
+ return message.getText();
+ } finally {
+ if (consumer != null) consumer.close();
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_messagingbeantest">MessagingBeanTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.jms;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+public class MessagingBeanTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ Messages messages = (Messages) context.lookup("java:global/injection-of-connectionfactory/Messages");
+
+ messages.sendMessage("Hello World!");
+ messages.sendMessage("How are you?");
+ messages.sendMessage("Still spinning?");
+
+ assertEquals(messages.receiveMessage(), "Hello World!");
+ assertEquals(messages.receiveMessage(), "How are you?");
+ assertEquals(messages.receiveMessage(), "Still spinning?");
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.jms.MessagingBeanTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/injection-of-connectionfactory
+INFO - openejb.base = /Users/dblevins/examples/injection-of-connectionfactory
+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/injection-of-connectionfactory/target/classes
+INFO - Beginning load: /Users/dblevins/examples/injection-of-connectionfactory/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-connectionfactory
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean Messages: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default JMS Connection Factory, type=Resource, provider-id=Default JMS Connection Factory)
+INFO - Auto-creating a Resource with id 'Default JMS Connection Factory' of type 'javax.jms.ConnectionFactory for 'Messages'.
+INFO - Configuring Service(id=Default JMS Resource Adapter, type=Resource, provider-id=Default JMS Resource Adapter)
+INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.injection.jms.Messages/connectionFactory' in bean Messages to Resource(id=Default JMS Connection Factory)
+INFO - Configuring Service(id=org.superbiz.injection.jms.Messages/chatQueue, type=Resource, provider-id=Default Queue)
+INFO - Auto-creating a Resource with id 'org.superbiz.injection.jms.Messages/chatQueue' of type 'javax.jms.Queue for 'Messages'.
+INFO - Auto-linking resource-env-ref 'java:comp/env/org.superbiz.injection.jms.Messages/chatQueue' in bean Messages to Resource(id=org.superbiz.injection.jms.Messages/chatQueue)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.jms.MessagingBeanTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/injection-of-connectionfactory" loaded.
+INFO - Assembling app: /Users/dblevins/examples/injection-of-connectionfactory
+INFO - Jndi(name="java:global/injection-of-connectionfactory/Messages!org.superbiz.injection.jms.Messages")
+INFO - Jndi(name="java:global/injection-of-connectionfactory/Messages")
+INFO - Jndi(name="java:global/EjbModule1634151355/org.superbiz.injection.jms.MessagingBeanTest!org.superbiz.injection.jms.MessagingBeanTest")
+INFO - Jndi(name="java:global/EjbModule1634151355/org.superbiz.injection.jms.MessagingBeanTest")
+INFO - Created Ejb(deployment-id=Messages, ejb-name=Messages, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.jms.MessagingBeanTest, ejb-name=org.superbiz.injection.jms.MessagingBeanTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Messages, ejb-name=Messages, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.jms.MessagingBeanTest, ejb-name=org.superbiz.injection.jms.MessagingBeanTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-connectionfactory)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.562 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/injection-of-connectionfactory.pdf b/content/examples/injection-of-connectionfactory.pdf
new file mode 100644
index 0000000..3aa93d8
--- /dev/null
+++ b/content/examples/injection-of-connectionfactory.pdf
Binary files differ
diff --git a/content/examples/injection-of-connectionfactory/README.md b/content/examples/injection-of-connectionfactory/README.md
new file mode 100755
index 0000000..771c22f
--- /dev/null
+++ b/content/examples/injection-of-connectionfactory/README.md
@@ -0,0 +1,158 @@
+Title: Injection Of Connectionfactory
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Messages
+
+ package org.superbiz.injection.jms;
+
+ import javax.annotation.Resource;
+ import javax.ejb.Stateless;
+ import javax.jms.Connection;
+ import javax.jms.ConnectionFactory;
+ import javax.jms.DeliveryMode;
+ import javax.jms.JMSException;
+ import javax.jms.MessageConsumer;
+ import javax.jms.MessageProducer;
+ import javax.jms.Queue;
+ import javax.jms.Session;
+ import javax.jms.TextMessage;
+
+ @Stateless
+ public class Messages {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource
+ private Queue chatQueue;
+
+
+ public void sendMessage(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(chatQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+
+ public String receiveMessage() throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+ MessageConsumer consumer = null;
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageConsumer from the Session to the Topic or Queue
+ consumer = session.createConsumer(chatQueue);
+
+ // Wait for a message
+ TextMessage message = (TextMessage) consumer.receive(1000);
+
+ return message.getText();
+ } finally {
+ if (consumer != null) consumer.close();
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+ }
+
+## MessagingBeanTest
+
+ package org.superbiz.injection.jms;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+
+ public class MessagingBeanTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ Messages messages = (Messages) context.lookup("java:global/injection-of-connectionfactory/Messages");
+
+ messages.sendMessage("Hello World!");
+ messages.sendMessage("How are you?");
+ messages.sendMessage("Still spinning?");
+
+ assertEquals(messages.receiveMessage(), "Hello World!");
+ assertEquals(messages.receiveMessage(), "How are you?");
+ assertEquals(messages.receiveMessage(), "Still spinning?");
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.jms.MessagingBeanTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/injection-of-connectionfactory
+ INFO - openejb.base = /Users/dblevins/examples/injection-of-connectionfactory
+ 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/injection-of-connectionfactory/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/injection-of-connectionfactory/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-connectionfactory
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean Messages: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default JMS Connection Factory, type=Resource, provider-id=Default JMS Connection Factory)
+ INFO - Auto-creating a Resource with id 'Default JMS Connection Factory' of type 'javax.jms.ConnectionFactory for 'Messages'.
+ INFO - Configuring Service(id=Default JMS Resource Adapter, type=Resource, provider-id=Default JMS Resource Adapter)
+ INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.injection.jms.Messages/connectionFactory' in bean Messages to Resource(id=Default JMS Connection Factory)
+ INFO - Configuring Service(id=org.superbiz.injection.jms.Messages/chatQueue, type=Resource, provider-id=Default Queue)
+ INFO - Auto-creating a Resource with id 'org.superbiz.injection.jms.Messages/chatQueue' of type 'javax.jms.Queue for 'Messages'.
+ INFO - Auto-linking resource-env-ref 'java:comp/env/org.superbiz.injection.jms.Messages/chatQueue' in bean Messages to Resource(id=org.superbiz.injection.jms.Messages/chatQueue)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.jms.MessagingBeanTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/injection-of-connectionfactory" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/injection-of-connectionfactory
+ INFO - Jndi(name="java:global/injection-of-connectionfactory/Messages!org.superbiz.injection.jms.Messages")
+ INFO - Jndi(name="java:global/injection-of-connectionfactory/Messages")
+ INFO - Jndi(name="java:global/EjbModule1634151355/org.superbiz.injection.jms.MessagingBeanTest!org.superbiz.injection.jms.MessagingBeanTest")
+ INFO - Jndi(name="java:global/EjbModule1634151355/org.superbiz.injection.jms.MessagingBeanTest")
+ INFO - Created Ejb(deployment-id=Messages, ejb-name=Messages, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.jms.MessagingBeanTest, ejb-name=org.superbiz.injection.jms.MessagingBeanTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Messages, ejb-name=Messages, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.jms.MessagingBeanTest, ejb-name=org.superbiz.injection.jms.MessagingBeanTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-connectionfactory)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.562 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/injection-of-connectionfactory/build.xml b/content/examples/injection-of-connectionfactory/build.xml
new file mode 100755
index 0000000..567603e
--- /dev/null
+++ b/content/examples/injection-of-connectionfactory/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 635408 $ $Date: 2008-03-09 17:48:40 -0700 (Sun, 09 Mar 2008) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/injection-of-connectionfactory/pom.xml b/content/examples/injection-of-connectionfactory/pom.xml
new file mode 100755
index 0000000..8ab43bf
--- /dev/null
+++ b/content/examples/injection-of-connectionfactory/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 638272 $ $Date: 2008-03-18 01:59:59 -0700 (Tue, 18 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>injection-of-connectionfactory</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @Resource javax.jms.ConnectionFactory</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/injection-of-connectionfactory/src/main/java/org/superbiz/injection/jms/Messages.java b/content/examples/injection-of-connectionfactory/src/main/java/org/superbiz/injection/jms/Messages.java
new file mode 100755
index 0000000..f126c1a
--- /dev/null
+++ b/content/examples/injection-of-connectionfactory/src/main/java/org/superbiz/injection/jms/Messages.java
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.injection.jms;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+@Stateless
+public class Messages {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource
+ private Queue chatQueue;
+
+ public void sendMessage(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(chatQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) {
+ session.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+
+ public String receiveMessage() throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+ MessageConsumer consumer = null;
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageConsumer from the Session to the Topic or Queue
+ consumer = session.createConsumer(chatQueue);
+
+ // Wait for a message
+ TextMessage message = (TextMessage) consumer.receive(1000);
+
+ return message.getText();
+ } finally {
+ if (consumer != null) {
+ consumer.close();
+ }
+ if (session != null) {
+ session.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ }
+
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-connectionfactory/src/test/java/org/superbiz/injection/jms/MessagingBeanTest.java b/content/examples/injection-of-connectionfactory/src/test/java/org/superbiz/injection/jms/MessagingBeanTest.java
new file mode 100755
index 0000000..2726530
--- /dev/null
+++ b/content/examples/injection-of-connectionfactory/src/test/java/org/superbiz/injection/jms/MessagingBeanTest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.injection.jms;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+public class MessagingBeanTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ Messages messages = (Messages) context.lookup("java:global/injection-of-connectionfactory/Messages");
+
+ messages.sendMessage("Hello World!");
+ messages.sendMessage("How are you?");
+ messages.sendMessage("Still spinning?");
+
+ assertEquals(messages.receiveMessage(), "Hello World!");
+ assertEquals(messages.receiveMessage(), "How are you?");
+ assertEquals(messages.receiveMessage(), "Still spinning?");
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-datasource.html b/content/examples/injection-of-datasource.html
new file mode 100644
index 0000000..8258092
--- /dev/null
+++ b/content/examples/injection-of-datasource.html
@@ -0,0 +1,432 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/injection-of-datasource.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Injection Of Datasource</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example injection-of-datasource can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/injection-of-datasource" class="bare">https://github.com/apache/tomee/tree/master/examples/injection-of-datasource</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class Movie {
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.Stateful;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ /**
+ * The field name "movieDatabase" matches the DataSource we
+ * configure in the TestCase via :
+ * p.put("movieDatabase", "new://Resource?type=DataSource");
+ * <p/>
+ * This would also match an equivalent delcaration in an openejb.xml:
+ * <Resource id="movieDatabase" type="DataSource"/>
+ * <p/>
+ * If you'd like the freedom to change the field name without
+ * impact on your configuration you can set the "name" attribute
+ * of the @Resource annotation to "movieDatabase" instead.
+ */
+ @Resource
+ private DataSource movieDatabase;
+
+ @PostConstruct
+ private void construct() throws Exception {
+ Connection connection = movieDatabase.getConnection();
+ try {
+ PreparedStatement stmt = connection.prepareStatement("CREATE TABLE movie ( director VARCHAR(255), title VARCHAR(255), year integer)");
+ stmt.execute();
+ } finally {
+ connection.close();
+ }
+ }
+
+ public void addMovie(Movie movie) throws Exception {
+ Connection conn = movieDatabase.getConnection();
+ try {
+ PreparedStatement sql = conn.prepareStatement("INSERT into movie (director, title, year) values (?, ?, ?)");
+ sql.setString(1, movie.getDirector());
+ sql.setString(2, movie.getTitle());
+ sql.setInt(3, movie.getYear());
+ sql.execute();
+ } finally {
+ conn.close();
+ }
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ Connection conn = movieDatabase.getConnection();
+ try {
+ PreparedStatement sql = conn.prepareStatement("DELETE from movie where director = ? AND title = ? AND year = ?");
+ sql.setString(1, movie.getDirector());
+ sql.setString(2, movie.getTitle());
+ sql.setInt(3, movie.getYear());
+ sql.execute();
+ } finally {
+ conn.close();
+ }
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ ArrayList<Movie> movies = new ArrayList<Movie>();
+ Connection conn = movieDatabase.getConnection();
+ try {
+ PreparedStatement sql = conn.prepareStatement("SELECT director, title, year from movie");
+ ResultSet set = sql.executeQuery();
+ while (set.next()) {
+ Movie movie = new Movie();
+ movie.setDirector(set.getString("director"));
+ movie.setTitle(set.getString("title"));
+ movie.setYear(set.getInt("year"));
+ movies.add(movie);
+ }
+ } finally {
+ conn.close();
+ }
+ return movies;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ Context context = EJBContainer.createEJBContainer(p).getContext();
+
+ Movies movies = (Movies) context.lookup("java:global/injection-of-datasource/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/injection-of-datasource
+INFO - openejb.base = /Users/dblevins/examples/injection-of-datasource
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/injection-of-datasource/target/classes
+INFO - Beginning load: /Users/dblevins/examples/injection-of-datasource/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-datasource
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.injection.Movies/movieDatabase' in bean Movies to Resource(id=movieDatabase)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/injection-of-datasource" loaded.
+INFO - Assembling app: /Users/dblevins/examples/injection-of-datasource
+INFO - Jndi(name="java:global/injection-of-datasource/Movies!org.superbiz.injection.Movies")
+INFO - Jndi(name="java:global/injection-of-datasource/Movies")
+INFO - Jndi(name="java:global/EjbModule1508028338/org.superbiz.injection.MoviesTest!org.superbiz.injection.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1508028338/org.superbiz.injection.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.MoviesTest, ejb-name=org.superbiz.injection.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.MoviesTest, ejb-name=org.superbiz.injection.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-datasource)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.276 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/injection-of-datasource.pdf b/content/examples/injection-of-datasource.pdf
new file mode 100644
index 0000000..42c0f4d
--- /dev/null
+++ b/content/examples/injection-of-datasource.pdf
Binary files differ
diff --git a/content/examples/injection-of-datasource/README.md b/content/examples/injection-of-datasource/README.md
new file mode 100755
index 0000000..8a65f6f
--- /dev/null
+++ b/content/examples/injection-of-datasource/README.md
@@ -0,0 +1,221 @@
+Title: Injection Of Datasource
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Movie
+
+ package org.superbiz.injection;
+
+ /**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class Movie {
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection;
+
+ import javax.annotation.PostConstruct;
+ import javax.annotation.Resource;
+ import javax.ejb.Stateful;
+ import javax.sql.DataSource;
+ import java.sql.Connection;
+ import java.sql.PreparedStatement;
+ import java.sql.ResultSet;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ @Stateful
+ public class Movies {
+
+ /**
+ * The field name "movieDatabase" matches the DataSource we
+ * configure in the TestCase via :
+ * p.put("movieDatabase", "new://Resource?type=DataSource");
+ * <p/>
+ * This would also match an equivalent delcaration in an openejb.xml:
+ * <Resource id="movieDatabase" type="DataSource"/>
+ * <p/>
+ * If you'd like the freedom to change the field name without
+ * impact on your configuration you can set the "name" attribute
+ * of the @Resource annotation to "movieDatabase" instead.
+ */
+ @Resource
+ private DataSource movieDatabase;
+
+ @PostConstruct
+ private void construct() throws Exception {
+ Connection connection = movieDatabase.getConnection();
+ try {
+ PreparedStatement stmt = connection.prepareStatement("CREATE TABLE movie ( director VARCHAR(255), title VARCHAR(255), year integer)");
+ stmt.execute();
+ } finally {
+ connection.close();
+ }
+ }
+
+ public void addMovie(Movie movie) throws Exception {
+ Connection conn = movieDatabase.getConnection();
+ try {
+ PreparedStatement sql = conn.prepareStatement("INSERT into movie (director, title, year) values (?, ?, ?)");
+ sql.setString(1, movie.getDirector());
+ sql.setString(2, movie.getTitle());
+ sql.setInt(3, movie.getYear());
+ sql.execute();
+ } finally {
+ conn.close();
+ }
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ Connection conn = movieDatabase.getConnection();
+ try {
+ PreparedStatement sql = conn.prepareStatement("DELETE from movie where director = ? AND title = ? AND year = ?");
+ sql.setString(1, movie.getDirector());
+ sql.setString(2, movie.getTitle());
+ sql.setInt(3, movie.getYear());
+ sql.execute();
+ } finally {
+ conn.close();
+ }
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ ArrayList<Movie> movies = new ArrayList<Movie>();
+ Connection conn = movieDatabase.getConnection();
+ try {
+ PreparedStatement sql = conn.prepareStatement("SELECT director, title, year from movie");
+ ResultSet set = sql.executeQuery();
+ while (set.next()) {
+ Movie movie = new Movie();
+ movie.setDirector(set.getString("director"));
+ movie.setTitle(set.getString("title"));
+ movie.setYear(set.getInt("year"));
+ movies.add(movie);
+ }
+ } finally {
+ conn.close();
+ }
+ return movies;
+ }
+ }
+
+## MoviesTest
+
+ package org.superbiz.injection;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import java.util.List;
+ import java.util.Properties;
+
+ //START SNIPPET: code
+ public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ Context context = EJBContainer.createEJBContainer(p).getContext();
+
+ Movies movies = (Movies) context.lookup("java:global/injection-of-datasource/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/injection-of-datasource
+ INFO - openejb.base = /Users/dblevins/examples/injection-of-datasource
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/injection-of-datasource/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/injection-of-datasource/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-datasource
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.injection.Movies/movieDatabase' in bean Movies to Resource(id=movieDatabase)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/injection-of-datasource" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/injection-of-datasource
+ INFO - Jndi(name="java:global/injection-of-datasource/Movies!org.superbiz.injection.Movies")
+ INFO - Jndi(name="java:global/injection-of-datasource/Movies")
+ INFO - Jndi(name="java:global/EjbModule1508028338/org.superbiz.injection.MoviesTest!org.superbiz.injection.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1508028338/org.superbiz.injection.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.MoviesTest, ejb-name=org.superbiz.injection.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.MoviesTest, ejb-name=org.superbiz.injection.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-datasource)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.276 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/injection-of-datasource/build.xml b/content/examples/injection-of-datasource/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/injection-of-datasource/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/injection-of-datasource/pom.xml b/content/examples/injection-of-datasource/pom.xml
new file mode 100755
index 0000000..ae7ad6d
--- /dev/null
+++ b/content/examples/injection-of-datasource/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>injection-of-datasource</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @Resource DataSource Injection</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movie.java b/content/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movie.java
new file mode 100755
index 0000000..cf554ea
--- /dev/null
+++ b/content/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection;
+
+/**
+ * @version $Revision: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movies.java b/content/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movies.java
new file mode 100755
index 0000000..d77fbdf
--- /dev/null
+++ b/content/examples/injection-of-datasource/src/main/java/org/superbiz/injection/Movies.java
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.injection;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.Stateful;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ /**
+ * The field name "movieDatabase" matches the DataSource we
+ * configure in the TestCase via :
+ * p.put("movieDatabase", "new://Resource?type=DataSource");
+ * <p/>
+ * This would also match an equivalent delcaration in an openejb.xml:
+ * <Resource id="movieDatabase" type="DataSource"/>
+ * <p/>
+ * If you'd like the freedom to change the field name without
+ * impact on your configuration you can set the "name" attribute
+ * of the @Resource annotation to "movieDatabase" instead.
+ */
+ @Resource
+ private DataSource movieDatabase;
+
+ @PostConstruct
+ private void construct() throws Exception {
+ Connection connection = movieDatabase.getConnection();
+ try {
+ PreparedStatement stmt = connection.prepareStatement("CREATE TABLE movie ( director VARCHAR(255), title VARCHAR(255), year integer)");
+ stmt.execute();
+ } finally {
+ connection.close();
+ }
+ }
+
+ public void addMovie(Movie movie) throws Exception {
+ Connection conn = movieDatabase.getConnection();
+ try {
+ PreparedStatement sql = conn.prepareStatement("INSERT into movie (director, title, year) values (?, ?, ?)");
+ sql.setString(1, movie.getDirector());
+ sql.setString(2, movie.getTitle());
+ sql.setInt(3, movie.getYear());
+ sql.execute();
+ } finally {
+ conn.close();
+ }
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ Connection conn = movieDatabase.getConnection();
+ try {
+ PreparedStatement sql = conn.prepareStatement("DELETE from movie where director = ? AND title = ? AND year = ?");
+ sql.setString(1, movie.getDirector());
+ sql.setString(2, movie.getTitle());
+ sql.setInt(3, movie.getYear());
+ sql.execute();
+ } finally {
+ conn.close();
+ }
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ ArrayList<Movie> movies = new ArrayList<Movie>();
+ Connection conn = movieDatabase.getConnection();
+ try {
+ PreparedStatement sql = conn.prepareStatement("SELECT director, title, year from movie");
+ ResultSet set = sql.executeQuery();
+ while (set.next()) {
+ Movie movie = new Movie();
+ movie.setDirector(set.getString("director"));
+ movie.setTitle(set.getString("title"));
+ movie.setYear(set.getInt("year"));
+ movies.add(movie);
+ }
+
+ } finally {
+ conn.close();
+ }
+ return movies;
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-datasource/src/test/java/org/superbiz/injection/MoviesTest.java b/content/examples/injection-of-datasource/src/test/java/org/superbiz/injection/MoviesTest.java
new file mode 100755
index 0000000..628575b
--- /dev/null
+++ b/content/examples/injection-of-datasource/src/test/java/org/superbiz/injection/MoviesTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ Context context = EJBContainer.createEJBContainer(p).getContext();
+
+ Movies movies = (Movies) context.lookup("java:global/injection-of-datasource/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-ejbs.html b/content/examples/injection-of-ejbs.html
new file mode 100644
index 0000000..5560d6a
--- /dev/null
+++ b/content/examples/injection-of-ejbs.html
@@ -0,0 +1,430 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/injection-of-ejbs.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Injection Of Ejbs</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example injection-of-ejbs can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/injection-of-ejbs" class="bare">https://github.com/apache/tomee/tree/master/examples/injection-of-ejbs</a></p>
+</div>
+<div class="paragraph">
+<p>This example shows how to use the @EJB annotation on a bean class to refer to other beans.</p>
+</div>
+<div class="paragraph">
+<p>This functionality is often referred as dependency injection (see
+<a href="http://www.martinfowler.com/articles/injection.html" class="bare">http://www.martinfowler.com/articles/injection.html</a>), and has been recently introduced in
+Java EE 5.</p>
+</div>
+<div class="paragraph">
+<p>In this particular example, we will create two session stateless beans</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>a DataStore session bean</p>
+</li>
+<li>
+<p>a DataReader session bean</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>The DataReader bean uses the DataStore to retrieve some informations, and
+we will see how we can, inside the DataReader bean, get a reference to the
+DataStore bean using the @EJB annotation, thus avoiding the use of the
+JNDI API.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_datareader">DataReader</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+
+/**
+ * This is an EJB 3.1 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has 2 business interfaces: DataReaderRemote, a remote business
+ * interface, and DataReaderLocal, a local business interface
+ * <p/>
+ * The instance variables 'dataStoreRemote' is annotated with the @EJB annotation:
+ * this means that the application server, at runtime, will inject in this instance
+ * variable a reference to the EJB DataStoreRemote
+ * <p/>
+ * The instance variables 'dataStoreLocal' is annotated with the @EJB annotation:
+ * this means that the application server, at runtime, will inject in this instance
+ * variable a reference to the EJB DataStoreLocal
+ */
+//START SNIPPET: code
+@Stateless
+public class DataReader {
+
+ @EJB
+ private DataStoreRemote dataStoreRemote;
+ @EJB
+ private DataStoreLocal dataStoreLocal;
+ @EJB
+ private DataStore dataStore;
+
+ public String readDataFromLocalStore() {
+ return "LOCAL:" + dataStoreLocal.getData();
+ }
+
+ public String readDataFromLocalBeanStore() {
+ return "LOCALBEAN:" + dataStore.getData();
+ }
+
+ public String readDataFromRemoteStore() {
+ return "REMOTE:" + dataStoreRemote.getData();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_datastore">DataStore</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection;
+
+import javax.ejb.LocalBean;
+import javax.ejb.Stateless;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has 2 business interfaces: DataStoreRemote, a remote business
+ * interface, and DataStoreLocal, a local business interface
+ */
+//START SNIPPET: code
+@Stateless
+@LocalBean
+public class DataStore implements DataStoreLocal, DataStoreRemote {
+
+ public String getData() {
+ return "42";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_datastorelocal">DataStoreLocal</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection;
+
+import javax.ejb.Local;
+
+/**
+ * This is an EJB 3 local business interface
+ * A local business interface may be annotated with the @Local
+ * annotation, but it's optional. A business interface which is
+ * not annotated with @Local or @Remote is assumed to be Local
+ */
+//START SNIPPET: code
+@Local
+public interface DataStoreLocal {
+
+ public String getData();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_datastoreremote">DataStoreRemote</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection;
+
+import javax.ejb.Remote;
+
+/**
+ * This is an EJB 3 remote business interface
+ * A remote business interface must be annotated with the @Remote
+ * annotation
+ */
+//START SNIPPET: code
+@Remote
+public interface DataStoreRemote {
+
+ public String getData();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejbdependencytest">EjbDependencyTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+/**
+ * A test case for DataReaderImpl ejb, testing both the remote and local interface
+ */
+//START SNIPPET: code
+public class EjbDependencyTest extends TestCase {
+
+ public void test() throws Exception {
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ DataReader dataReader = (DataReader) context.lookup("java:global/injection-of-ejbs/DataReader");
+
+ assertNotNull(dataReader);
+
+ assertEquals("LOCAL:42", dataReader.readDataFromLocalStore());
+ assertEquals("REMOTE:42", dataReader.readDataFromRemoteStore());
+ assertEquals("LOCALBEAN:42", dataReader.readDataFromLocalBeanStore());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.EjbDependencyTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/injection-of-ejbs
+INFO - openejb.base = /Users/dblevins/examples/injection-of-ejbs
+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/injection-of-ejbs/target/classes
+INFO - Beginning load: /Users/dblevins/examples/injection-of-ejbs/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-ejbs
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean DataReader: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.EjbDependencyTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/injection-of-ejbs" loaded.
+INFO - Assembling app: /Users/dblevins/examples/injection-of-ejbs
+INFO - Jndi(name="java:global/injection-of-ejbs/DataReader!org.superbiz.injection.DataReader")
+INFO - Jndi(name="java:global/injection-of-ejbs/DataReader")
+INFO - Jndi(name="java:global/injection-of-ejbs/DataStore!org.superbiz.injection.DataStore")
+INFO - Jndi(name="java:global/injection-of-ejbs/DataStore!org.superbiz.injection.DataStoreLocal")
+INFO - Jndi(name="java:global/injection-of-ejbs/DataStore!org.superbiz.injection.DataStoreRemote")
+INFO - Jndi(name="java:global/injection-of-ejbs/DataStore")
+INFO - Jndi(name="java:global/EjbModule355598874/org.superbiz.injection.EjbDependencyTest!org.superbiz.injection.EjbDependencyTest")
+INFO - Jndi(name="java:global/EjbModule355598874/org.superbiz.injection.EjbDependencyTest")
+INFO - Created Ejb(deployment-id=DataReader, ejb-name=DataReader, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=DataStore, ejb-name=DataStore, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.EjbDependencyTest, ejb-name=org.superbiz.injection.EjbDependencyTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=DataReader, ejb-name=DataReader, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=DataStore, ejb-name=DataStore, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.EjbDependencyTest, ejb-name=org.superbiz.injection.EjbDependencyTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-ejbs)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.225 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/injection-of-ejbs.pdf b/content/examples/injection-of-ejbs.pdf
new file mode 100644
index 0000000..b179264
--- /dev/null
+++ b/content/examples/injection-of-ejbs.pdf
Binary files differ
diff --git a/content/examples/injection-of-ejbs/README.md b/content/examples/injection-of-ejbs/README.md
new file mode 100755
index 0000000..ea35fe7
--- /dev/null
+++ b/content/examples/injection-of-ejbs/README.md
@@ -0,0 +1,197 @@
+Title: Injection Of Ejbs
+
+This example shows how to use the @EJB annotation on a bean class to refer to other beans.
+
+This functionality is often referred as dependency injection (see
+http://www.martinfowler.com/articles/injection.html), and has been recently introduced in
+Java EE 5.
+
+In this particular example, we will create two session stateless beans
+
+ * a DataStore session bean
+ * a DataReader session bean
+
+The DataReader bean uses the DataStore to retrieve some informations, and
+we will see how we can, inside the DataReader bean, get a reference to the
+DataStore bean using the @EJB annotation, thus avoiding the use of the
+JNDI API.
+
+## DataReader
+
+ package org.superbiz.injection;
+
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+
+ /**
+ * This is an EJB 3.1 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has 2 business interfaces: DataReaderRemote, a remote business
+ * interface, and DataReaderLocal, a local business interface
+ * <p/>
+ * The instance variables 'dataStoreRemote' is annotated with the @EJB annotation:
+ * this means that the application server, at runtime, will inject in this instance
+ * variable a reference to the EJB DataStoreRemote
+ * <p/>
+ * The instance variables 'dataStoreLocal' is annotated with the @EJB annotation:
+ * this means that the application server, at runtime, will inject in this instance
+ * variable a reference to the EJB DataStoreLocal
+ */
+ //START SNIPPET: code
+ @Stateless
+ public class DataReader {
+
+ @EJB
+ private DataStoreRemote dataStoreRemote;
+ @EJB
+ private DataStoreLocal dataStoreLocal;
+ @EJB
+ private DataStore dataStore;
+
+ public String readDataFromLocalStore() {
+ return "LOCAL:" + dataStoreLocal.getData();
+ }
+
+ public String readDataFromLocalBeanStore() {
+ return "LOCALBEAN:" + dataStore.getData();
+ }
+
+ public String readDataFromRemoteStore() {
+ return "REMOTE:" + dataStoreRemote.getData();
+ }
+ }
+
+## DataStore
+
+ package org.superbiz.injection;
+
+ import javax.ejb.LocalBean;
+ import javax.ejb.Stateless;
+
+ /**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has 2 business interfaces: DataStoreRemote, a remote business
+ * interface, and DataStoreLocal, a local business interface
+ */
+ //START SNIPPET: code
+ @Stateless
+ @LocalBean
+ public class DataStore implements DataStoreLocal, DataStoreRemote {
+
+ public String getData() {
+ return "42";
+ }
+ }
+
+## DataStoreLocal
+
+ package org.superbiz.injection;
+
+ import javax.ejb.Local;
+
+ /**
+ * This is an EJB 3 local business interface
+ * A local business interface may be annotated with the @Local
+ * annotation, but it's optional. A business interface which is
+ * not annotated with @Local or @Remote is assumed to be Local
+ */
+ //START SNIPPET: code
+ @Local
+ public interface DataStoreLocal {
+
+ public String getData();
+ }
+
+## DataStoreRemote
+
+ package org.superbiz.injection;
+
+ import javax.ejb.Remote;
+
+ /**
+ * This is an EJB 3 remote business interface
+ * A remote business interface must be annotated with the @Remote
+ * annotation
+ */
+ //START SNIPPET: code
+ @Remote
+ public interface DataStoreRemote {
+
+ public String getData();
+ }
+
+## EjbDependencyTest
+
+ package org.superbiz.injection;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+
+ /**
+ * A test case for DataReaderImpl ejb, testing both the remote and local interface
+ */
+ //START SNIPPET: code
+ public class EjbDependencyTest extends TestCase {
+
+ public void test() throws Exception {
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ DataReader dataReader = (DataReader) context.lookup("java:global/injection-of-ejbs/DataReader");
+
+ assertNotNull(dataReader);
+
+ assertEquals("LOCAL:42", dataReader.readDataFromLocalStore());
+ assertEquals("REMOTE:42", dataReader.readDataFromRemoteStore());
+ assertEquals("LOCALBEAN:42", dataReader.readDataFromLocalBeanStore());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.EjbDependencyTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/injection-of-ejbs
+ INFO - openejb.base = /Users/dblevins/examples/injection-of-ejbs
+ 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/injection-of-ejbs/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/injection-of-ejbs/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-ejbs
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean DataReader: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.EjbDependencyTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/injection-of-ejbs" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/injection-of-ejbs
+ INFO - Jndi(name="java:global/injection-of-ejbs/DataReader!org.superbiz.injection.DataReader")
+ INFO - Jndi(name="java:global/injection-of-ejbs/DataReader")
+ INFO - Jndi(name="java:global/injection-of-ejbs/DataStore!org.superbiz.injection.DataStore")
+ INFO - Jndi(name="java:global/injection-of-ejbs/DataStore!org.superbiz.injection.DataStoreLocal")
+ INFO - Jndi(name="java:global/injection-of-ejbs/DataStore!org.superbiz.injection.DataStoreRemote")
+ INFO - Jndi(name="java:global/injection-of-ejbs/DataStore")
+ INFO - Jndi(name="java:global/EjbModule355598874/org.superbiz.injection.EjbDependencyTest!org.superbiz.injection.EjbDependencyTest")
+ INFO - Jndi(name="java:global/EjbModule355598874/org.superbiz.injection.EjbDependencyTest")
+ INFO - Created Ejb(deployment-id=DataReader, ejb-name=DataReader, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=DataStore, ejb-name=DataStore, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.EjbDependencyTest, ejb-name=org.superbiz.injection.EjbDependencyTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=DataReader, ejb-name=DataReader, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=DataStore, ejb-name=DataStore, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.EjbDependencyTest, ejb-name=org.superbiz.injection.EjbDependencyTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-ejbs)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.225 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/injection-of-ejbs/build.xml b/content/examples/injection-of-ejbs/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/injection-of-ejbs/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/injection-of-ejbs/pom.xml b/content/examples/injection-of-ejbs/pom.xml
new file mode 100755
index 0000000..0270bd0
--- /dev/null
+++ b/content/examples/injection-of-ejbs/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>injection-of-ejbs</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @EJB Injection</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataReader.java b/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataReader.java
new file mode 100755
index 0000000..d6c566c
--- /dev/null
+++ b/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataReader.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+
+/**
+ * This is an EJB 3.1 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has 2 business interfaces: DataReaderRemote, a remote business
+ * interface, and DataReaderLocal, a local business interface
+ * <p/>
+ * The instance variables 'dataStoreRemote' is annotated with the @EJB annotation:
+ * this means that the application server, at runtime, will inject in this instance
+ * variable a reference to the EJB DataStoreRemote
+ * <p/>
+ * The instance variables 'dataStoreLocal' is annotated with the @EJB annotation:
+ * this means that the application server, at runtime, will inject in this instance
+ * variable a reference to the EJB DataStoreLocal
+ */
+//START SNIPPET: code
+@Stateless
+public class DataReader {
+
+ @EJB
+ private DataStoreRemote dataStoreRemote;
+ @EJB
+ private DataStoreLocal dataStoreLocal;
+ @EJB
+ private DataStore dataStore;
+
+ public String readDataFromLocalStore() {
+ return "LOCAL:" + dataStoreLocal.getData();
+ }
+
+ public String readDataFromLocalBeanStore() {
+ return "LOCALBEAN:" + dataStore.getData();
+ }
+
+ public String readDataFromRemoteStore() {
+ return "REMOTE:" + dataStoreRemote.getData();
+ }
+}
+//END SNIPPET: code
\ No newline at end of file
diff --git a/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStore.java b/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStore.java
new file mode 100755
index 0000000..fcf9eb7
--- /dev/null
+++ b/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStore.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection;
+
+import javax.ejb.LocalBean;
+import javax.ejb.Stateless;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has 2 business interfaces: DataStoreRemote, a remote business
+ * interface, and DataStoreLocal, a local business interface
+ */
+//START SNIPPET: code
+@Stateless
+@LocalBean
+public class DataStore implements DataStoreLocal, DataStoreRemote {
+
+ public String getData() {
+ return "42";
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreLocal.java b/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreLocal.java
new file mode 100755
index 0000000..1046480
--- /dev/null
+++ b/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreLocal.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection;
+
+import javax.ejb.Local;
+
+/**
+ * This is an EJB 3 local business interface
+ * A local business interface may be annotated with the @Local
+ * annotation, but it's optional. A business interface which is
+ * not annotated with @Local or @Remote is assumed to be Local
+ */
+//START SNIPPET: code
+@Local
+public interface DataStoreLocal {
+
+ public String getData();
+
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreRemote.java b/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreRemote.java
new file mode 100755
index 0000000..3421448
--- /dev/null
+++ b/content/examples/injection-of-ejbs/src/main/java/org/superbiz/injection/DataStoreRemote.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection;
+
+import javax.ejb.Remote;
+
+/**
+ * This is an EJB 3 remote business interface
+ * A remote business interface must be annotated with the @Remote
+ * annotation
+ */
+//START SNIPPET: code
+@Remote
+public interface DataStoreRemote {
+
+ public String getData();
+
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-ejbs/src/test/java/org/superbiz/injection/EjbDependencyTest.java b/content/examples/injection-of-ejbs/src/test/java/org/superbiz/injection/EjbDependencyTest.java
new file mode 100755
index 0000000..95bee23
--- /dev/null
+++ b/content/examples/injection-of-ejbs/src/test/java/org/superbiz/injection/EjbDependencyTest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+/**
+ * A test case for DataReaderImpl ejb, testing both the remote and local interface
+ */
+//START SNIPPET: code
+public class EjbDependencyTest extends TestCase {
+
+ public void test() throws Exception {
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ DataReader dataReader = (DataReader) context.lookup("java:global/injection-of-ejbs/DataReader");
+
+ assertNotNull(dataReader);
+
+ assertEquals("LOCAL:42", dataReader.readDataFromLocalStore());
+ assertEquals("REMOTE:42", dataReader.readDataFromRemoteStore());
+ assertEquals("LOCALBEAN:42", dataReader.readDataFromLocalBeanStore());
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-entitymanager.html b/content/examples/injection-of-entitymanager.html
new file mode 100644
index 0000000..d11486c
--- /dev/null
+++ b/content/examples/injection-of-entitymanager.html
@@ -0,0 +1,444 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/injection-of-entitymanager.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Injection Of Entitymanager</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example injection-of-entitymanager can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/injection-of-entitymanager" class="bare">https://github.com/apache/tomee/tree/master/examples/injection-of-entitymanager</a></p>
+</div>
+<div class="paragraph">
+<p>This example shows use of <code>@PersistenceContext</code> to have an <code>EntityManager</code> with an
+<code>EXTENDED</code> persistence context injected into a <code>@Stateful bean</code>. A JPA
+<code>@Entity</code> bean is used with the <code>EntityManager</code> to create, persist and merge
+data to a database.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_creating_the_jpa_entity">Creating the JPA Entity</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The entity itself is simply a pojo annotated with <code>@Entity</code>. We create one called <code>Movie</code> which we can use to hold movie records.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.jpa;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ @Id @GeneratedValue
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_configure_the_entitymanager_via_a_persistence_xml_file">Configure the EntityManager via a persistence.xml file</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The above <code>Movie</code> entity can be created, removed, updated or deleted via an <code>EntityManager</code> object. The <code>EntityManager</code> itself is
+configured via a <code>META-INF/persistence.xml</code> file that is placed in the same jar as the <code>Movie</code> entity.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.jpa.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Notice that the <code>Movie</code> entity is listed via a <code><class></code> element. This is not required, but can help when testing or when the
+<code>Movie</code> class is located in a different jar than the jar containing the <code>persistence.xml</code> file.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_injection_via_persistencecontext">Injection via @PersistenceContext</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The <code>EntityManager</code> itself is created by the container using the information in the <code>persistence.xml</code>, so to use it at
+runtime, we simply need to request it be injected into one of our components. We do this via <code>@PersistenceContext</code></p>
+</div>
+<div class="paragraph">
+<p>The <code>@PersistenceContext</code> annotation can be used on any CDI bean, EJB, Servlet, Servlet Listener, Servlet Filter, or JSF ManagedBean. If you don’t use an EJB you will need to use a <code>UserTransaction</code> begin and commit transactions manually. A transaction is required for any of the create, update or delete methods of the EntityManager to work.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.jpa;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This particular <code>EntityManager</code> is injected as an <code>EXTENDED</code> persistence context, which simply means that the <code>EntityManager</code>
+is created when the <code>@Stateful</code> bean is created and destroyed when the <code>@Stateful</code> bean is destroyed. Simply put, the
+data in the <code>EntityManager</code> is cached for the lifetime of the <code>@Stateful</code> bean.</p>
+</div>
+<div class="paragraph">
+<p>The use of <code>EXTENDED</code> persistence contexts is <strong>only</strong> available to <code>@Stateful</code> beans. See the <a href="../../jpa-concepts.html">JPA Concepts</a> page for an high level explanation of what a "persistence context" really is and how it is significant to JPA.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Testing JPA is quite easy, we can simply use the <code>EJBContainer</code> API to create a container in our test case.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.jpa;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+
+ Movies movies = (Movies) context.lookup("java:global/injection-of-entitymanager/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>When we run our test case we should see output similar to the following.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.jpa.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/injection-of-entitymanager
+INFO - openejb.base = /Users/dblevins/examples/injection-of-entitymanager
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/injection-of-entitymanager/target/classes
+INFO - Beginning load: /Users/dblevins/examples/injection-of-entitymanager/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-entitymanager
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.jpa.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/injection-of-entitymanager" loaded.
+INFO - Assembling app: /Users/dblevins/examples/injection-of-entitymanager
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 462ms
+INFO - Jndi(name="java:global/injection-of-entitymanager/Movies!org.superbiz.injection.jpa.Movies")
+INFO - Jndi(name="java:global/injection-of-entitymanager/Movies")
+INFO - Jndi(name="java:global/EjbModule1461341140/org.superbiz.injection.jpa.MoviesTest!org.superbiz.injection.jpa.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1461341140/org.superbiz.injection.jpa.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.jpa.MoviesTest, ejb-name=org.superbiz.injection.jpa.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.jpa.MoviesTest, ejb-name=org.superbiz.injection.jpa.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-entitymanager)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.301 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/injection-of-entitymanager.pdf b/content/examples/injection-of-entitymanager.pdf
new file mode 100644
index 0000000..0905e74
--- /dev/null
+++ b/content/examples/injection-of-entitymanager.pdf
Binary files differ
diff --git a/content/examples/injection-of-entitymanager/README.md b/content/examples/injection-of-entitymanager/README.md
new file mode 100755
index 0000000..fb1e37f
--- /dev/null
+++ b/content/examples/injection-of-entitymanager/README.md
@@ -0,0 +1,217 @@
+Title: Injection Of Entitymanager
+
+This example shows use of `@PersistenceContext` to have an `EntityManager` with an
+`EXTENDED` persistence context injected into a `@Stateful bean`. A JPA
+`@Entity` bean is used with the `EntityManager` to create, persist and merge
+data to a database.
+
+## Creating the JPA Entity
+
+The entity itself is simply a pojo annotated with `@Entity`. We create one called `Movie` which we can use to hold movie records.
+
+ package org.superbiz.injection.jpa;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ @Id @GeneratedValue
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+ }
+
+## Configure the EntityManager via a persistence.xml file
+
+The above `Movie` entity can be created, removed, updated or deleted via an `EntityManager` object. The `EntityManager` itself is
+configured via a `META-INF/persistence.xml` file that is placed in the same jar as the `Movie` entity.
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.jpa.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+Notice that the `Movie` entity is listed via a `<class>` element. This is not required, but can help when testing or when the
+`Movie` class is located in a different jar than the jar containing the `persistence.xml` file.
+
+## Injection via @PersistenceContext
+
+The `EntityManager` itself is created by the container using the information in the `persistence.xml`, so to use it at
+runtime, we simply need to request it be injected into one of our components. We do this via `@PersistenceContext`
+
+The `@PersistenceContext` annotation can be used on any CDI bean, EJB, Servlet, Servlet Listener, Servlet Filter, or JSF ManagedBean. If you don't use an EJB you will need to use a `UserTransaction` begin and commit transactions manually. A transaction is required for any of the create, update or delete methods of the EntityManager to work.
+
+ package org.superbiz.injection.jpa;
+
+ import javax.ejb.Stateful;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ @Stateful
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+This particular `EntityManager` is injected as an `EXTENDED` persistence context, which simply means that the `EntityManager`
+is created when the `@Stateful` bean is created and destroyed when the `@Stateful` bean is destroyed. Simply put, the
+data in the `EntityManager` is cached for the lifetime of the `@Stateful` bean.
+
+The use of `EXTENDED` persistence contexts is **only** available to `@Stateful` beans. See the [JPA Concepts](../../jpa-concepts.html) page for an high level explanation of what a "persistence context" really is and how it is significant to JPA.
+
+## MoviesTest
+
+Testing JPA is quite easy, we can simply use the `EJBContainer` API to create a container in our test case.
+
+ package org.superbiz.injection.jpa;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import java.util.List;
+ import java.util.Properties;
+
+ //START SNIPPET: code
+ public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+
+ Movies movies = (Movies) context.lookup("java:global/injection-of-entitymanager/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+ }
+
+# Running
+
+When we run our test case we should see output similar to the following.
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.jpa.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/injection-of-entitymanager
+ INFO - openejb.base = /Users/dblevins/examples/injection-of-entitymanager
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/injection-of-entitymanager/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/injection-of-entitymanager/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-entitymanager
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.jpa.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/injection-of-entitymanager" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/injection-of-entitymanager
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 462ms
+ INFO - Jndi(name="java:global/injection-of-entitymanager/Movies!org.superbiz.injection.jpa.Movies")
+ INFO - Jndi(name="java:global/injection-of-entitymanager/Movies")
+ INFO - Jndi(name="java:global/EjbModule1461341140/org.superbiz.injection.jpa.MoviesTest!org.superbiz.injection.jpa.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1461341140/org.superbiz.injection.jpa.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.jpa.MoviesTest, ejb-name=org.superbiz.injection.jpa.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.jpa.MoviesTest, ejb-name=org.superbiz.injection.jpa.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-entitymanager)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.301 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/injection-of-entitymanager/build.xml b/content/examples/injection-of-entitymanager/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/injection-of-entitymanager/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/injection-of-entitymanager/pom.xml b/content/examples/injection-of-entitymanager/pom.xml
new file mode 100755
index 0000000..ba96999
--- /dev/null
+++ b/content/examples/injection-of-entitymanager/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>injection-of-entitymanager</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @PersistenceContext EntityManager Injection</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/injection-of-entitymanager/src/main/java/org/superbiz/injection/jpa/Movie.java b/content/examples/injection-of-entitymanager/src/main/java/org/superbiz/injection/jpa/Movie.java
new file mode 100755
index 0000000..e1128ae
--- /dev/null
+++ b/content/examples/injection-of-entitymanager/src/main/java/org/superbiz/injection/jpa/Movie.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.jpa;
+//START SNIPPET: code
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-entitymanager/src/main/java/org/superbiz/injection/jpa/Movies.java b/content/examples/injection-of-entitymanager/src/main/java/org/superbiz/injection/jpa/Movies.java
new file mode 100755
index 0000000..f56c718
--- /dev/null
+++ b/content/examples/injection-of-entitymanager/src/main/java/org/superbiz/injection/jpa/Movies.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.jpa;
+
+//START SNIPPET: code
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-entitymanager/src/main/resources/META-INF/persistence.xml b/content/examples/injection-of-entitymanager/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..798f6a9
--- /dev/null
+++ b/content/examples/injection-of-entitymanager/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- START SNIPPET: code -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.jpa.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
+ <!-- END SNIPPET: code -->
diff --git a/content/examples/injection-of-entitymanager/src/test/java/org/superbiz/injection/jpa/MoviesTest.java b/content/examples/injection-of-entitymanager/src/test/java/org/superbiz/injection/jpa/MoviesTest.java
new file mode 100755
index 0000000..8fd2684
--- /dev/null
+++ b/content/examples/injection-of-entitymanager/src/test/java/org/superbiz/injection/jpa/MoviesTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.jpa;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer container = EJBContainer.createEJBContainer(p);
+ final Context context = container.getContext();
+
+ Movies movies = (Movies) context.lookup("java:global/injection-of-entitymanager/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+
+ container.close();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-env-entry.html b/content/examples/injection-of-env-entry.html
new file mode 100644
index 0000000..f1f48fa
--- /dev/null
+++ b/content/examples/injection-of-env-entry.html
@@ -0,0 +1,493 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/injection-of-env-entry.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Using EnvEntries</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example injection-of-env-entry can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/injection-of-env-entry" class="bare">https://github.com/apache/tomee/tree/master/examples/injection-of-env-entry</a></p>
+</div>
+<div class="paragraph">
+<p>The <code>@Resource</code> annotation can be used to inject several things including
+DataSources, Topics, Queues, etc. Most of these are container supplied objects.</p>
+</div>
+<div class="paragraph">
+<p>It is possible, however, to supply your own values to be injected via an <code><env-entry></code>
+in your <code>ejb-jar.xml</code> or <code>web.xml</code> deployment descriptor. Java EE 6 supported <code><env-entry></code> types
+are limited to the following:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>java.lang.String</p>
+</li>
+<li>
+<p>java.lang.Integer</p>
+</li>
+<li>
+<p>java.lang.Short</p>
+</li>
+<li>
+<p>java.lang.Float</p>
+</li>
+<li>
+<p>java.lang.Double</p>
+</li>
+<li>
+<p>java.lang.Byte</p>
+</li>
+<li>
+<p>java.lang.Character</p>
+</li>
+<li>
+<p>java.lang.Boolean</p>
+</li>
+<li>
+<p>java.lang.Class</p>
+</li>
+<li>
+<p>java.lang.Enum (any enum)</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>See also the <a href="../custom-injection">Custom Injection</a> exmaple for a TomEE and OpenEJB feature that will let you
+use more than just the above types as well as declare <code><env-entry></code> items with a plain properties file.</p>
+</div>
+</div>
+</div>
+<h1 id="_using_resource_for_basic_properties" class="sect0">Using @Resource for basic properties</h1>
+<div class="paragraph">
+<p>The use of the <code>@Resource</code> annotation isn’t limited to setters. For
+example, this annotation could have been used on the corresponding <strong>field</strong>
+like so:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Resource
+private int maxLineItems;
+
+A fuller example might look like this:
+
+package org.superbiz.injection.enventry;
+
+import javax.annotation.Resource;
+import javax.ejb.Singleton;
+import java.util.Date;
+
+@Singleton
+public class Configuration {
+
+ @Resource
+ private String color;
+
+ @Resource
+ private Shape shape;
+
+ @Resource
+ private Class strategy;
+
+ @Resource(name = "date")
+ private long date;
+
+ public String getColor() {
+ return color;
+ }
+
+ public Shape getShape() {
+ return shape;
+ }
+
+ public Class getStrategy() {
+ return strategy;
+ }
+
+ public Date getDate() {
+ return new Date(date);
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Here we have an <code>@Singleton</code> bean called <code>Confuration</code> that has the following properties (<code><env-entry></code> items)</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>String color</p>
+</li>
+<li>
+<p>Shape shape</p>
+</li>
+<li>
+<p>Class strategy</p>
+</li>
+<li>
+<p>long date</p>
+</li>
+</ul>
+</div>
+<div class="sect1">
+<h2 id="_supplying_resource_values_for_env_entry_items_in_ejb_jar_xml">Supplying @Resource values for <env-entry> items in ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The values for our <code>color</code>, <code>shape</code>, <code>strategy</code> and <code>date</code> properties are supplied via <code><env-entry></code> elements in the <code>ejb-jar.xml</code> file or the
+<code>web.xml</code> file like so:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.0" metadata-complete="false">
+ <enterprise-beans>
+ <session>
+ <ejb-name>Configuration</ejb-name>
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/color</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>orange</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/shape</env-entry-name>
+ <env-entry-type>org.superbiz.injection.enventry.Shape</env-entry-type>
+ <env-entry-value>TRIANGLE</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/strategy</env-entry-name>
+ <env-entry-type>java.lang.Class</env-entry-type>
+ <env-entry-value>org.superbiz.injection.enventry.Widget</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <description>The name was explicitly set in the annotation so the classname prefix isn't required</description>
+ <env-entry-name>date</env-entry-name>
+ <env-entry-type>java.lang.Long</env-entry-type>
+ <env-entry-value>123456789</env-entry-value>
+ </env-entry>
+ </session>
+ </enterprise-beans>
+</ejb-jar></code></pre>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_using_the_resource_name_attribute">Using the @Resource 'name' attribute</h3>
+<div class="paragraph">
+<p>Note that <code>date</code> was referenced by <code>name</code> as:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Resource(name = "date")
+private long date;
+
+When the `@Resource(name)` is used, you do not need to specify the full class name of the bean and can do it briefly like so:
+
+ <env-entry>
+ <description>The name was explicitly set in the annotation so the classname prefix isn't required</description>
+ <env-entry-name>date</env-entry-name>
+ <env-entry-type>java.lang.Long</env-entry-type>
+ <env-entry-value>123456789</env-entry-value>
+ </env-entry>
+
+Conversly, `color` was not referenced by `name`
+
+@Resource
+private String color;
+
+When something is not referenced by `name` in the `@Resource` annotation a default name is created. The format is essentially this:
+
+bean.getClass() + "/" + field.getName()
+
+So the default `name` of the above `color` property ends up being `org.superbiz.injection.enventry.Configuration/color`. This is the name
+we must use when we attempt to decalre a value for it in xml.
+
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/color</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>orange</env-entry-value>
+ </env-entry>
+
+### @Resource and Enum (Enumerations)
+
+The `shape` field is actually a custom Java Enum type
+
+package org.superbiz.injection.enventry;
+
+public enum Shape {
+
+ CIRCLE,
+ TRIANGLE,
+ SQUARE
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>As of Java EE 6, java.lang.Enum types are allowed as <code><env-entry></code> items. Declaring one in xml is done using the actual enum’s class name like so:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/shape</env-entry-name>
+ <env-entry-type>org.superbiz.injection.enventry.Shape</env-entry-type>
+ <env-entry-value>TRIANGLE</env-entry-value>
+</env-entry></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Do not use <code><env-entry-type>java.lang.Enum</env-entry-type></code> or it will not work!</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_configurationtest">ConfigurationTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.enventry;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.Date;
+
+public class ConfigurationTest extends TestCase {
+
+
+ public void test() throws Exception {
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final Configuration configuration = (Configuration) context.lookup("java:global/injection-of-env-entry/Configuration");
+
+ assertEquals("orange", configuration.getColor());
+
+ assertEquals(Shape.TRIANGLE, configuration.getShape());
+
+ assertEquals(Widget.class, configuration.getStrategy());
+
+ assertEquals(new Date(123456789), configuration.getDate());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.enventry.ConfigurationTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/injection-of-env-entry
+INFO - openejb.base = /Users/dblevins/examples/injection-of-env-entry
+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/injection-of-env-entry/target/classes
+INFO - Beginning load: /Users/dblevins/examples/injection-of-env-entry/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-env-entry
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean Configuration: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.enventry.ConfigurationTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/injection-of-env-entry" loaded.
+INFO - Assembling app: /Users/dblevins/examples/injection-of-env-entry
+INFO - Jndi(name="java:global/injection-of-env-entry/Configuration!org.superbiz.injection.enventry.Configuration")
+INFO - Jndi(name="java:global/injection-of-env-entry/Configuration")
+INFO - Jndi(name="java:global/EjbModule1355224018/org.superbiz.injection.enventry.ConfigurationTest!org.superbiz.injection.enventry.ConfigurationTest")
+INFO - Jndi(name="java:global/EjbModule1355224018/org.superbiz.injection.enventry.ConfigurationTest")
+INFO - Created Ejb(deployment-id=org.superbiz.injection.enventry.ConfigurationTest, ejb-name=org.superbiz.injection.enventry.ConfigurationTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=Configuration, ejb-name=Configuration, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.enventry.ConfigurationTest, ejb-name=org.superbiz.injection.enventry.ConfigurationTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Configuration, ejb-name=Configuration, container=Default Singleton Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-env-entry)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.664 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/injection-of-env-entry.pdf b/content/examples/injection-of-env-entry.pdf
new file mode 100644
index 0000000..95cef4a
--- /dev/null
+++ b/content/examples/injection-of-env-entry.pdf
Binary files differ
diff --git a/content/examples/injection-of-env-entry/README.md b/content/examples/injection-of-env-entry/README.md
new file mode 100755
index 0000000..82e781d
--- /dev/null
+++ b/content/examples/injection-of-env-entry/README.md
@@ -0,0 +1,239 @@
+Title: Using EnvEntries
+
+The `@Resource` annotation can be used to inject several things including
+DataSources, Topics, Queues, etc. Most of these are container supplied objects.
+
+It is possible, however, to supply your own values to be injected via an `<env-entry>`
+in your `ejb-jar.xml` or `web.xml` deployment descriptor. Java EE 6 supported `<env-entry>` types
+are limited to the following:
+
+ - java.lang.String
+ - java.lang.Integer
+ - java.lang.Short
+ - java.lang.Float
+ - java.lang.Double
+ - java.lang.Byte
+ - java.lang.Character
+ - java.lang.Boolean
+ - java.lang.Class
+ - java.lang.Enum (any enum)
+
+See also the [Custom Injection](../custom-injection) exmaple for a TomEE and OpenEJB feature that will let you
+use more than just the above types as well as declare `<env-entry>` items with a plain properties file.
+
+# Using @Resource for basic properties
+
+The use of the `@Resource` annotation isn't limited to setters. For
+example, this annotation could have been used on the corresponding *field*
+like so:
+
+ @Resource
+ private int maxLineItems;
+
+A fuller example might look like this:
+
+ package org.superbiz.injection.enventry;
+
+ import javax.annotation.Resource;
+ import javax.ejb.Singleton;
+ import java.util.Date;
+
+ @Singleton
+ public class Configuration {
+
+ @Resource
+ private String color;
+
+ @Resource
+ private Shape shape;
+
+ @Resource
+ private Class strategy;
+
+ @Resource(name = "date")
+ private long date;
+
+ public String getColor() {
+ return color;
+ }
+
+ public Shape getShape() {
+ return shape;
+ }
+
+ public Class getStrategy() {
+ return strategy;
+ }
+
+ public Date getDate() {
+ return new Date(date);
+ }
+ }
+
+Here we have an `@Singleton` bean called `Confuration` that has the following properties (`<env-entry>` items)
+
+- String color
+- Shape shape
+- Class strategy
+- long date
+
+## Supplying @Resource values for <env-entry> items in ejb-jar.xml
+
+The values for our `color`, `shape`, `strategy` and `date` properties are supplied via `<env-entry>` elements in the `ejb-jar.xml` file or the
+`web.xml` file like so:
+
+
+ <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.0" metadata-complete="false">
+ <enterprise-beans>
+ <session>
+ <ejb-name>Configuration</ejb-name>
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/color</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>orange</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/shape</env-entry-name>
+ <env-entry-type>org.superbiz.injection.enventry.Shape</env-entry-type>
+ <env-entry-value>TRIANGLE</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/strategy</env-entry-name>
+ <env-entry-type>java.lang.Class</env-entry-type>
+ <env-entry-value>org.superbiz.injection.enventry.Widget</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <description>The name was explicitly set in the annotation so the classname prefix isn't required</description>
+ <env-entry-name>date</env-entry-name>
+ <env-entry-type>java.lang.Long</env-entry-type>
+ <env-entry-value>123456789</env-entry-value>
+ </env-entry>
+ </session>
+ </enterprise-beans>
+ </ejb-jar>
+
+
+### Using the @Resource 'name' attribute
+
+Note that `date` was referenced by `name` as:
+
+ @Resource(name = "date")
+ private long date;
+
+When the `@Resource(name)` is used, you do not need to specify the full class name of the bean and can do it briefly like so:
+
+ <env-entry>
+ <description>The name was explicitly set in the annotation so the classname prefix isn't required</description>
+ <env-entry-name>date</env-entry-name>
+ <env-entry-type>java.lang.Long</env-entry-type>
+ <env-entry-value>123456789</env-entry-value>
+ </env-entry>
+
+Conversly, `color` was not referenced by `name`
+
+ @Resource
+ private String color;
+
+When something is not referenced by `name` in the `@Resource` annotation a default name is created. The format is essentially this:
+
+ bean.getClass() + "/" + field.getName()
+
+So the default `name` of the above `color` property ends up being `org.superbiz.injection.enventry.Configuration/color`. This is the name
+we must use when we attempt to decalre a value for it in xml.
+
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/color</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>orange</env-entry-value>
+ </env-entry>
+
+### @Resource and Enum (Enumerations)
+
+The `shape` field is actually a custom Java Enum type
+
+ package org.superbiz.injection.enventry;
+
+ public enum Shape {
+
+ CIRCLE,
+ TRIANGLE,
+ SQUARE
+ }
+
+As of Java EE 6, java.lang.Enum types are allowed as `<env-entry>` items. Declaring one in xml is done using the actual enum's class name like so:
+
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/shape</env-entry-name>
+ <env-entry-type>org.superbiz.injection.enventry.Shape</env-entry-type>
+ <env-entry-value>TRIANGLE</env-entry-value>
+ </env-entry>
+
+Do not use `<env-entry-type>java.lang.Enum</env-entry-type>` or it will not work!
+
+## ConfigurationTest
+
+ package org.superbiz.injection.enventry;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import java.util.Date;
+
+ public class ConfigurationTest extends TestCase {
+
+
+ public void test() throws Exception {
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final Configuration configuration = (Configuration) context.lookup("java:global/injection-of-env-entry/Configuration");
+
+ assertEquals("orange", configuration.getColor());
+
+ assertEquals(Shape.TRIANGLE, configuration.getShape());
+
+ assertEquals(Widget.class, configuration.getStrategy());
+
+ assertEquals(new Date(123456789), configuration.getDate());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.enventry.ConfigurationTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/injection-of-env-entry
+ INFO - openejb.base = /Users/dblevins/examples/injection-of-env-entry
+ 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/injection-of-env-entry/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/injection-of-env-entry/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/injection-of-env-entry
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean Configuration: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.enventry.ConfigurationTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/injection-of-env-entry" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/injection-of-env-entry
+ INFO - Jndi(name="java:global/injection-of-env-entry/Configuration!org.superbiz.injection.enventry.Configuration")
+ INFO - Jndi(name="java:global/injection-of-env-entry/Configuration")
+ INFO - Jndi(name="java:global/EjbModule1355224018/org.superbiz.injection.enventry.ConfigurationTest!org.superbiz.injection.enventry.ConfigurationTest")
+ INFO - Jndi(name="java:global/EjbModule1355224018/org.superbiz.injection.enventry.ConfigurationTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.enventry.ConfigurationTest, ejb-name=org.superbiz.injection.enventry.ConfigurationTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=Configuration, ejb-name=Configuration, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.enventry.ConfigurationTest, ejb-name=org.superbiz.injection.enventry.ConfigurationTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Configuration, ejb-name=Configuration, container=Default Singleton Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/injection-of-env-entry)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.664 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/injection-of-env-entry/build.xml b/content/examples/injection-of-env-entry/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/injection-of-env-entry/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/injection-of-env-entry/pom.xml b/content/examples/injection-of-env-entry/pom.xml
new file mode 100755
index 0000000..d0b91ec
--- /dev/null
+++ b/content/examples/injection-of-env-entry/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>injection-of-env-entry</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @Resource env-entry Injection</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/injection-of-env-entry/src/main/java/org/superbiz/injection/enventry/Configuration.java b/content/examples/injection-of-env-entry/src/main/java/org/superbiz/injection/enventry/Configuration.java
new file mode 100755
index 0000000..728742a
--- /dev/null
+++ b/content/examples/injection-of-env-entry/src/main/java/org/superbiz/injection/enventry/Configuration.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.enventry;
+
+import javax.annotation.Resource;
+import javax.ejb.Singleton;
+import java.util.Date;
+
+/**
+ * This example demostrates the use of the injection of environment entries
+ * using <b>Resource</b> annotation.
+ * <p/>
+ * "EJB Core Contracts and Requirements" specification section 16.4.1.1.
+ *
+ * @version $Rev: 1090807 $ $Date: 2011-04-10 16:12:31 +0200 (Sun, 10 Apr 2011) $
+ */
+//START SNIPPET: code
+@Singleton
+public class Configuration {
+
+ @Resource
+ private String color;
+
+ @Resource
+ private Shape shape;
+
+ @Resource
+ private Class strategy;
+
+ @Resource(name = "date")
+ private long date;
+
+ public String getColor() {
+ return color;
+ }
+
+ public Shape getShape() {
+ return shape;
+ }
+
+ public Class getStrategy() {
+ return strategy;
+ }
+
+ public Date getDate() {
+ return new Date(date);
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/injection-of-env-entry/src/main/java/org/superbiz/injection/enventry/Shape.java b/content/examples/injection-of-env-entry/src/main/java/org/superbiz/injection/enventry/Shape.java
new file mode 100755
index 0000000..6579490
--- /dev/null
+++ b/content/examples/injection-of-env-entry/src/main/java/org/superbiz/injection/enventry/Shape.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.enventry;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public enum Shape {
+
+ CIRCLE,
+ TRIANGLE,
+ SQUARE
+
+}
diff --git a/content/examples/injection-of-env-entry/src/main/java/org/superbiz/injection/enventry/Widget.java b/content/examples/injection-of-env-entry/src/main/java/org/superbiz/injection/enventry/Widget.java
new file mode 100755
index 0000000..eacf373
--- /dev/null
+++ b/content/examples/injection-of-env-entry/src/main/java/org/superbiz/injection/enventry/Widget.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.enventry;
+
+/**
+ * Exists to show that any class object can be injected and does
+ * not need to be loaded directly in app code.
+ *
+ * @version $Revision$ $Date$
+ */
+public class Widget {
+
+}
diff --git a/content/examples/injection-of-env-entry/src/main/resources/META-INF/ejb-jar.xml b/content/examples/injection-of-env-entry/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..1c73d17
--- /dev/null
+++ b/content/examples/injection-of-env-entry/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 16:49:26 +0200 (Sun, 10 Apr 2011) $ -->
+
+<!-- START SNIPPET: code -->
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.0" metadata-complete="false">
+ <enterprise-beans>
+ <session>
+ <ejb-name>Configuration</ejb-name>
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/color</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>orange</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/shape</env-entry-name>
+ <env-entry-type>org.superbiz.injection.enventry.Shape</env-entry-type>
+ <env-entry-value>TRIANGLE</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <env-entry-name>org.superbiz.injection.enventry.Configuration/strategy</env-entry-name>
+ <env-entry-type>java.lang.Class</env-entry-type>
+ <env-entry-value>org.superbiz.injection.enventry.Widget</env-entry-value>
+ </env-entry>
+ <env-entry>
+ <description>The name was explicitly set in the annotation so the classname prefix isn't required</description>
+ <env-entry-name>date</env-entry-name>
+ <env-entry-type>java.lang.Long</env-entry-type>
+ <env-entry-value>123456789</env-entry-value>
+ </env-entry>
+ </session>
+ </enterprise-beans>
+</ejb-jar>
+ <!-- END SNIPPET: code -->
diff --git a/content/examples/injection-of-env-entry/src/test/java/org/superbiz/injection/enventry/ConfigurationTest.java b/content/examples/injection-of-env-entry/src/test/java/org/superbiz/injection/enventry/ConfigurationTest.java
new file mode 100755
index 0000000..490800a
--- /dev/null
+++ b/content/examples/injection-of-env-entry/src/test/java/org/superbiz/injection/enventry/ConfigurationTest.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.enventry;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.Date;
+
+//START SNIPPET: code
+public class ConfigurationTest extends TestCase {
+
+ public void test() throws Exception {
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final Configuration configuration = (Configuration) context.lookup("java:global/injection-of-env-entry/Configuration");
+
+ assertEquals("orange", configuration.getColor());
+
+ assertEquals(Shape.TRIANGLE, configuration.getShape());
+
+ assertEquals(Widget.class, configuration.getStrategy());
+
+ assertEquals(new Date(123456789), configuration.getDate());
+ }
+}
+//END SNIPPET: code
+
+
+
diff --git a/content/examples/interceptors.html b/content/examples/interceptors.html
new file mode 100644
index 0000000..8fe4f37
--- /dev/null
+++ b/content/examples/interceptors.html
@@ -0,0 +1,1094 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/interceptors.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Interceptors</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example interceptors can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/interceptors" class="bare">https://github.com/apache/tomee/tree/master/examples/interceptors</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_classlevelinterceptorone">ClassLevelInterceptorOne</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class ClassLevelInterceptorOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_classlevelinterceptorsuperclassone">ClassLevelInterceptorSuperClassOne</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class ClassLevelInterceptorSuperClassOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_classlevelinterceptorsuperclasstwo">ClassLevelInterceptorSuperClassTwo</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class ClassLevelInterceptorSuperClassTwo extends SuperClassOfClassLevelInterceptor {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_classlevelinterceptortwo">ClassLevelInterceptorTwo</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class ClassLevelInterceptorTwo {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_defaultinterceptorone">DefaultInterceptorOne</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class DefaultInterceptorOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+ @PostConstruct
+ protected void postConstructInterceptor(InvocationContext ic) throws Exception {
+ Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_defaultinterceptortwo">DefaultInterceptorTwo</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class DefaultInterceptorTwo {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_fullyintercepted">FullyIntercepted</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import java.util.List;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public interface FullyIntercepted {
+
+ List<String> businessMethod();
+
+ List<String> methodWithDefaultInterceptorsExcluded();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_fullyinterceptedbean">FullyInterceptedBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+@Stateless
+@Local
+@Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+public class FullyInterceptedBean extends FullyInterceptedSuperClass implements FullyIntercepted {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> businessMethod() {
+ List<String> list = new ArrayList<String>();
+ list.add("businessMethod");
+ return list;
+ }
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> methodWithDefaultInterceptorsExcluded() {
+ List<String> list = new ArrayList<String>();
+ list.add("methodWithDefaultInterceptorsExcluded");
+ return list;
+ }
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, "beanClassBusinessMethodInterceptor");
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_fullyinterceptedsuperclass">FullyInterceptedSuperClass</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.interceptor.Interceptors;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+@Interceptors({ClassLevelInterceptorSuperClassOne.class, ClassLevelInterceptorSuperClassTwo.class})
+public class FullyInterceptedSuperClass {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_methodlevelinterceptorone">MethodLevelInterceptorOne</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class MethodLevelInterceptorOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_methodlevelinterceptoronlyintf">MethodLevelInterceptorOnlyIntf</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import java.io.Serializable;
+import java.util.List;
+
+public interface MethodLevelInterceptorOnlyIntf<T extends Serializable> {
+ public List<T> makePersistent(T entity);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_methodlevelinterceptoronlyparent">MethodLevelInterceptorOnlyParent</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import java.util.List;
+
+public interface MethodLevelInterceptorOnlyParent extends MethodLevelInterceptorOnlyIntf<String> {
+
+ public List<String> makePersistent(String entity);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_methodlevelinterceptoronlyslsbean">MethodLevelInterceptorOnlySLSBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+import javax.interceptor.Interceptors;
+import java.util.ArrayList;
+import java.util.List;
+
+@Local(MethodLevelInterceptorOnlyParent.class)
+@Stateless
+public class MethodLevelInterceptorOnlySLSBean implements MethodLevelInterceptorOnlyParent {
+
+ @Interceptors(MethodLevelInterceptorOne.class)
+ public List<String> makePersistent(String entity) {
+ List<String> list = new ArrayList<String>();
+ list.add("makePersistent");
+ return list;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_methodlevelinterceptortwo">MethodLevelInterceptorTwo</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class MethodLevelInterceptorTwo {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_secondstatelessinterceptedbean">SecondStatelessInterceptedBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev: 808273 $ $Date: 2009-08-26 20:42:06 -0700 (Wed, 26 Aug 2009) $
+ */
+@Stateless
+@Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+public class SecondStatelessInterceptedBean implements SecondStatelessInterceptedLocal {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> methodWithDefaultInterceptorsExcluded() {
+ List<String> list = new ArrayList<String>();
+ list.add("methodWithDefaultInterceptorsExcluded");
+ return list;
+ }
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_secondstatelessinterceptedlocal">SecondStatelessInterceptedLocal</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import java.util.List;
+
+/**
+ * @version $Rev: 808273 $ $Date: 2009-08-26 20:42:06 -0700 (Wed, 26 Aug 2009) $
+ */
+public interface SecondStatelessInterceptedLocal {
+ List<String> methodWithDefaultInterceptorsExcluded();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_superclassofclasslevelinterceptor">SuperClassOfClassLevelInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class SuperClassOfClassLevelInterceptor {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+ @PostConstruct
+ protected void postConstructInterceptor(InvocationContext ic) throws Exception {
+ Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_thirdslsbean">ThirdSLSBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+@Stateless
+@Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+@ExcludeDefaultInterceptors
+public class ThirdSLSBean implements ThirdSLSBeanLocal {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> businessMethod() {
+ List<String> list = new ArrayList<String>();
+ list.add("businessMethod");
+ return list;
+ }
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ @ExcludeClassInterceptors
+ public List<String> anotherBusinessMethod() {
+ List<String> list = new ArrayList<String>();
+ list.add("anotherBusinessMethod");
+ return list;
+ }
+
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_thirdslsbeanlocal">ThirdSLSBeanLocal</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import java.util.List;
+
+/**
+ * @version $Rev: 607320 $ $Date: 2007-12-28 12:15:06 -0800 (Fri, 28 Dec 2007) $
+ */
+public interface ThirdSLSBeanLocal {
+ List<String> businessMethod();
+
+ List<String> anotherBusinessMethod();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_utils">Utils</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev: 808273 $ $Date: 2009-08-26 20:42:06 -0700 (Wed, 26 Aug 2009) $
+ */
+public class Utils {
+
+ public static List<String> addClassSimpleName(InvocationContext ic, String classSimpleName) throws Exception {
+ List<String> list = new ArrayList<String>();
+ list.add(classSimpleName);
+ List<String> listOfStrings = (List<String>) ic.proceed();
+ if (listOfStrings != null) {
+ list.addAll(listOfStrings);
+ }
+ return list;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar 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/ejb-jar_3_0.xsd"
+ version="3.0">
+ <interceptors>
+ <interceptor>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorOne</interceptor-class>
+ </interceptor>
+ <interceptor>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorTwo</interceptor-class>
+ </interceptor>
+ </interceptors>
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorOne</interceptor-class>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorTwo</interceptor-class>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>FullyInterceptedBean</ejb-name>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ <method>
+ <method-name>methodWithDefaultInterceptorsExcluded</method-name>
+ </method>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>SecondStatelessInterceptedBean</ejb-name>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>MethodLevelInterceptorOnlySLSBean</ejb-name>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_fullyinterceptedtest">FullyInterceptedTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+public class FullyInterceptedTest extends TestCase {
+
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testBusinessMethod() throws Exception {
+
+ FullyIntercepted fullyIntercepted = (FullyIntercepted) initCtx.lookup("FullyInterceptedBeanLocal");
+
+ assert fullyIntercepted != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("DefaultInterceptorOne");
+ expected.add("DefaultInterceptorTwo");
+ expected.add("ClassLevelInterceptorSuperClassOne");
+ expected.add("ClassLevelInterceptorSuperClassTwo");
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("beanClassBusinessMethodInterceptor");
+ expected.add("businessMethod");
+
+ List<String> actual = fullyIntercepted.businessMethod();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+
+ FullyIntercepted fullyIntercepted = (FullyIntercepted) initCtx.lookup("FullyInterceptedBeanLocal");
+
+ assert fullyIntercepted != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorSuperClassOne");
+ expected.add("ClassLevelInterceptorSuperClassTwo");
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("beanClassBusinessMethodInterceptor");
+ expected.add("methodWithDefaultInterceptorsExcluded");
+
+ List<String> actual = fullyIntercepted.methodWithDefaultInterceptorsExcluded();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ initCtx.close();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_methodlevelinterceptoronlytest">MethodLevelInterceptorOnlyTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 895825 $ $Date: 2010-01-04 15:35:22 -0800 (Mon, 04 Jan 2010) $
+ */
+public class MethodLevelInterceptorOnlyTest extends TestCase {
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testInterceptedGenerifiedBusinessIntfMethod() throws Exception {
+ MethodLevelInterceptorOnlyParent bean = (MethodLevelInterceptorOnlyParent) initCtx.lookup("MethodLevelInterceptorOnlySLSBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("makePersistent");
+
+ List<String> actual = bean.makePersistent(null);
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_secondstatelessinterceptedtest">SecondStatelessInterceptedTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+public class SecondStatelessInterceptedTest extends TestCase {
+
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+ SecondStatelessInterceptedLocal bean =
+ (SecondStatelessInterceptedLocal) initCtx.lookup("SecondStatelessInterceptedBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("SecondStatelessInterceptedBean");
+ expected.add("methodWithDefaultInterceptorsExcluded");
+
+ List<String> actual = bean.methodWithDefaultInterceptorsExcluded();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_thirdslsbeantest">ThirdSLSBeanTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.interceptors;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+public class ThirdSLSBeanTest extends TestCase {
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+ ThirdSLSBeanLocal bean = (ThirdSLSBeanLocal) initCtx.lookup("ThirdSLSBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("ThirdSLSBean");
+ expected.add("businessMethod");
+
+ List<String> actual = bean.businessMethod();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+
+ @Test
+ public void testMethodWithDefaultAndClassInterceptorsExcluded() throws Exception {
+ ThirdSLSBeanLocal bean = (ThirdSLSBeanLocal) initCtx.lookup("ThirdSLSBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("ThirdSLSBean");
+ expected.add("anotherBusinessMethod");
+
+ List<String> actual = bean.anotherBusinessMethod();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.interceptors.FullyInterceptedTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/interceptors
+INFO - openejb.base = /Users/dblevins/examples/interceptors
+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 - Using 'openejb.deployments.classpath.include=.*interceptors/target/classes.*'
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/interceptors/target/classes
+INFO - Beginning load: /Users/dblevins/examples/interceptors/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/interceptors/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean FullyInterceptedBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "/Users/dblevins/examples/interceptors/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/interceptors/classpath.ear
+INFO - Jndi(name=FullyInterceptedBeanLocal) --> Ejb(deployment-id=FullyInterceptedBean)
+INFO - Jndi(name=global/classpath.ear/interceptors/FullyInterceptedBean!org.superbiz.interceptors.FullyIntercepted) --> Ejb(deployment-id=FullyInterceptedBean)
+INFO - Jndi(name=global/classpath.ear/interceptors/FullyInterceptedBean) --> Ejb(deployment-id=FullyInterceptedBean)
+INFO - Jndi(name=ThirdSLSBeanLocal) --> Ejb(deployment-id=ThirdSLSBean)
+INFO - Jndi(name=global/classpath.ear/interceptors/ThirdSLSBean!org.superbiz.interceptors.ThirdSLSBeanLocal) --> Ejb(deployment-id=ThirdSLSBean)
+INFO - Jndi(name=global/classpath.ear/interceptors/ThirdSLSBean) --> Ejb(deployment-id=ThirdSLSBean)
+INFO - Jndi(name=SecondStatelessInterceptedBeanLocal) --> Ejb(deployment-id=SecondStatelessInterceptedBean)
+INFO - Jndi(name=global/classpath.ear/interceptors/SecondStatelessInterceptedBean!org.superbiz.interceptors.SecondStatelessInterceptedLocal) --> Ejb(deployment-id=SecondStatelessInterceptedBean)
+INFO - Jndi(name=global/classpath.ear/interceptors/SecondStatelessInterceptedBean) --> Ejb(deployment-id=SecondStatelessInterceptedBean)
+INFO - Jndi(name=MethodLevelInterceptorOnlySLSBeanLocal) --> Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean)
+INFO - Jndi(name=global/classpath.ear/interceptors/MethodLevelInterceptorOnlySLSBean!org.superbiz.interceptors.MethodLevelInterceptorOnlyParent) --> Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean)
+INFO - Jndi(name=global/classpath.ear/interceptors/MethodLevelInterceptorOnlySLSBean) --> Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean)
+INFO - Created Ejb(deployment-id=ThirdSLSBean, ejb-name=ThirdSLSBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=SecondStatelessInterceptedBean, ejb-name=SecondStatelessInterceptedBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=FullyInterceptedBean, ejb-name=FullyInterceptedBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean, ejb-name=MethodLevelInterceptorOnlySLSBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=ThirdSLSBean, ejb-name=ThirdSLSBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=SecondStatelessInterceptedBean, ejb-name=SecondStatelessInterceptedBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=FullyInterceptedBean, ejb-name=FullyInterceptedBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean, ejb-name=MethodLevelInterceptorOnlySLSBean, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/interceptors/classpath.ear)
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.564 sec
+Running org.superbiz.interceptors.MethodLevelInterceptorOnlyTest
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
+Running org.superbiz.interceptors.SecondStatelessInterceptedTest
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec
+Running org.superbiz.interceptors.ThirdSLSBeanTest
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
+
+Results :
+
+Tests run: 6, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/interceptors.pdf b/content/examples/interceptors.pdf
new file mode 100644
index 0000000..66b1137
--- /dev/null
+++ b/content/examples/interceptors.pdf
Binary files differ
diff --git a/content/examples/interceptors/README.md b/content/examples/interceptors/README.md
new file mode 100755
index 0000000..d92c7a6
--- /dev/null
+++ b/content/examples/interceptors/README.md
@@ -0,0 +1,751 @@
+Title: Interceptors
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## ClassLevelInterceptorOne
+
+ package org.superbiz.interceptors;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class ClassLevelInterceptorOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## ClassLevelInterceptorSuperClassOne
+
+ package org.superbiz.interceptors;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class ClassLevelInterceptorSuperClassOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## ClassLevelInterceptorSuperClassTwo
+
+ package org.superbiz.interceptors;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class ClassLevelInterceptorSuperClassTwo extends SuperClassOfClassLevelInterceptor {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## ClassLevelInterceptorTwo
+
+ package org.superbiz.interceptors;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class ClassLevelInterceptorTwo {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## DefaultInterceptorOne
+
+ package org.superbiz.interceptors;
+
+ import javax.annotation.PostConstruct;
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class DefaultInterceptorOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+ @PostConstruct
+ protected void postConstructInterceptor(InvocationContext ic) throws Exception {
+ Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## DefaultInterceptorTwo
+
+ package org.superbiz.interceptors;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class DefaultInterceptorTwo {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## FullyIntercepted
+
+ package org.superbiz.interceptors;
+
+ import java.util.List;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public interface FullyIntercepted {
+
+ List<String> businessMethod();
+
+ List<String> methodWithDefaultInterceptorsExcluded();
+ }
+
+## FullyInterceptedBean
+
+ package org.superbiz.interceptors;
+
+ import javax.ejb.Local;
+ import javax.ejb.Stateless;
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.Interceptors;
+ import javax.interceptor.InvocationContext;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ @Stateless
+ @Local
+ @Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+ public class FullyInterceptedBean extends FullyInterceptedSuperClass implements FullyIntercepted {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> businessMethod() {
+ List<String> list = new ArrayList<String>();
+ list.add("businessMethod");
+ return list;
+ }
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> methodWithDefaultInterceptorsExcluded() {
+ List<String> list = new ArrayList<String>();
+ list.add("methodWithDefaultInterceptorsExcluded");
+ return list;
+ }
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, "beanClassBusinessMethodInterceptor");
+ }
+ }
+
+## FullyInterceptedSuperClass
+
+ package org.superbiz.interceptors;
+
+ import javax.interceptor.Interceptors;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ @Interceptors({ClassLevelInterceptorSuperClassOne.class, ClassLevelInterceptorSuperClassTwo.class})
+ public class FullyInterceptedSuperClass {
+ }
+
+## MethodLevelInterceptorOne
+
+ package org.superbiz.interceptors;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class MethodLevelInterceptorOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## MethodLevelInterceptorOnlyIntf
+
+ package org.superbiz.interceptors;
+
+ import java.io.Serializable;
+ import java.util.List;
+
+ public interface MethodLevelInterceptorOnlyIntf<T extends Serializable> {
+ public List<T> makePersistent(T entity);
+ }
+
+## MethodLevelInterceptorOnlyParent
+
+ package org.superbiz.interceptors;
+
+ import java.util.List;
+
+ public interface MethodLevelInterceptorOnlyParent extends MethodLevelInterceptorOnlyIntf<String> {
+
+ public List<String> makePersistent(String entity);
+ }
+
+## MethodLevelInterceptorOnlySLSBean
+
+ package org.superbiz.interceptors;
+
+ import javax.ejb.Local;
+ import javax.ejb.Stateless;
+ import javax.interceptor.Interceptors;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ @Local(MethodLevelInterceptorOnlyParent.class)
+ @Stateless
+ public class MethodLevelInterceptorOnlySLSBean implements MethodLevelInterceptorOnlyParent {
+
+ @Interceptors(MethodLevelInterceptorOne.class)
+ public List<String> makePersistent(String entity) {
+ List<String> list = new ArrayList<String>();
+ list.add("makePersistent");
+ return list;
+ }
+ }
+
+## MethodLevelInterceptorTwo
+
+ package org.superbiz.interceptors;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class MethodLevelInterceptorTwo {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## SecondStatelessInterceptedBean
+
+ package org.superbiz.interceptors;
+
+ import javax.ejb.Stateless;
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.Interceptors;
+ import javax.interceptor.InvocationContext;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ /**
+ * @version $Rev: 808273 $ $Date: 2009-08-26 20:42:06 -0700 (Wed, 26 Aug 2009) $
+ */
+ @Stateless
+ @Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+ public class SecondStatelessInterceptedBean implements SecondStatelessInterceptedLocal {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> methodWithDefaultInterceptorsExcluded() {
+ List<String> list = new ArrayList<String>();
+ list.add("methodWithDefaultInterceptorsExcluded");
+ return list;
+ }
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## SecondStatelessInterceptedLocal
+
+ package org.superbiz.interceptors;
+
+ import java.util.List;
+
+ /**
+ * @version $Rev: 808273 $ $Date: 2009-08-26 20:42:06 -0700 (Wed, 26 Aug 2009) $
+ */
+ public interface SecondStatelessInterceptedLocal {
+ List<String> methodWithDefaultInterceptorsExcluded();
+ }
+
+## SuperClassOfClassLevelInterceptor
+
+ package org.superbiz.interceptors;
+
+ import javax.annotation.PostConstruct;
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class SuperClassOfClassLevelInterceptor {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+ @PostConstruct
+ protected void postConstructInterceptor(InvocationContext ic) throws Exception {
+ Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## ThirdSLSBean
+
+ package org.superbiz.interceptors;
+
+ import javax.ejb.Stateless;
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.ExcludeClassInterceptors;
+ import javax.interceptor.ExcludeDefaultInterceptors;
+ import javax.interceptor.Interceptors;
+ import javax.interceptor.InvocationContext;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ /**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+ @Stateless
+ @Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+ @ExcludeDefaultInterceptors
+ public class ThirdSLSBean implements ThirdSLSBeanLocal {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> businessMethod() {
+ List<String> list = new ArrayList<String>();
+ list.add("businessMethod");
+ return list;
+ }
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ @ExcludeClassInterceptors
+ public List<String> anotherBusinessMethod() {
+ List<String> list = new ArrayList<String>();
+ list.add("anotherBusinessMethod");
+ return list;
+ }
+
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+ }
+
+## ThirdSLSBeanLocal
+
+ package org.superbiz.interceptors;
+
+ import java.util.List;
+
+ /**
+ * @version $Rev: 607320 $ $Date: 2007-12-28 12:15:06 -0800 (Fri, 28 Dec 2007) $
+ */
+ public interface ThirdSLSBeanLocal {
+ List<String> businessMethod();
+
+ List<String> anotherBusinessMethod();
+ }
+
+## Utils
+
+ package org.superbiz.interceptors;
+
+ import javax.interceptor.InvocationContext;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ /**
+ * @version $Rev: 808273 $ $Date: 2009-08-26 20:42:06 -0700 (Wed, 26 Aug 2009) $
+ */
+ public class Utils {
+
+ public static List<String> addClassSimpleName(InvocationContext ic, String classSimpleName) throws Exception {
+ List<String> list = new ArrayList<String>();
+ list.add(classSimpleName);
+ List<String> listOfStrings = (List<String>) ic.proceed();
+ if (listOfStrings != null) {
+ list.addAll(listOfStrings);
+ }
+ return list;
+ }
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar 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/ejb-jar_3_0.xsd"
+ version="3.0">
+ <interceptors>
+ <interceptor>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorOne</interceptor-class>
+ </interceptor>
+ <interceptor>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorTwo</interceptor-class>
+ </interceptor>
+ </interceptors>
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorOne</interceptor-class>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorTwo</interceptor-class>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>FullyInterceptedBean</ejb-name>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ <method>
+ <method-name>methodWithDefaultInterceptorsExcluded</method-name>
+ </method>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>SecondStatelessInterceptedBean</ejb-name>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>MethodLevelInterceptorOnlySLSBean</ejb-name>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ </interceptor-binding>
+ </assembly-descriptor>
+ </ejb-jar>
+
+## FullyInterceptedTest
+
+ package org.superbiz.interceptors;
+
+ import junit.framework.TestCase;
+ import org.junit.After;
+ import org.junit.Before;
+ import org.junit.Test;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Properties;
+
+ /**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+ public class FullyInterceptedTest extends TestCase {
+
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testBusinessMethod() throws Exception {
+
+ FullyIntercepted fullyIntercepted = (FullyIntercepted) initCtx.lookup("FullyInterceptedBeanLocal");
+
+ assert fullyIntercepted != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("DefaultInterceptorOne");
+ expected.add("DefaultInterceptorTwo");
+ expected.add("ClassLevelInterceptorSuperClassOne");
+ expected.add("ClassLevelInterceptorSuperClassTwo");
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("beanClassBusinessMethodInterceptor");
+ expected.add("businessMethod");
+
+ List<String> actual = fullyIntercepted.businessMethod();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+
+ FullyIntercepted fullyIntercepted = (FullyIntercepted) initCtx.lookup("FullyInterceptedBeanLocal");
+
+ assert fullyIntercepted != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorSuperClassOne");
+ expected.add("ClassLevelInterceptorSuperClassTwo");
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("beanClassBusinessMethodInterceptor");
+ expected.add("methodWithDefaultInterceptorsExcluded");
+
+ List<String> actual = fullyIntercepted.methodWithDefaultInterceptorsExcluded();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ initCtx.close();
+ }
+ }
+
+## MethodLevelInterceptorOnlyTest
+
+ package org.superbiz.interceptors;
+
+ import junit.framework.TestCase;
+ import org.junit.Before;
+ import org.junit.Test;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Properties;
+
+ /**
+ * @version $Rev: 895825 $ $Date: 2010-01-04 15:35:22 -0800 (Mon, 04 Jan 2010) $
+ */
+ public class MethodLevelInterceptorOnlyTest extends TestCase {
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testInterceptedGenerifiedBusinessIntfMethod() throws Exception {
+ MethodLevelInterceptorOnlyParent bean = (MethodLevelInterceptorOnlyParent) initCtx.lookup("MethodLevelInterceptorOnlySLSBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("makePersistent");
+
+ List<String> actual = bean.makePersistent(null);
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+ }
+
+## SecondStatelessInterceptedTest
+
+ package org.superbiz.interceptors;
+
+ import junit.framework.TestCase;
+ import org.junit.Before;
+ import org.junit.Test;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Properties;
+
+ /**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+ public class SecondStatelessInterceptedTest extends TestCase {
+
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+ SecondStatelessInterceptedLocal bean =
+ (SecondStatelessInterceptedLocal) initCtx.lookup("SecondStatelessInterceptedBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("SecondStatelessInterceptedBean");
+ expected.add("methodWithDefaultInterceptorsExcluded");
+
+ List<String> actual = bean.methodWithDefaultInterceptorsExcluded();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+ }
+
+## ThirdSLSBeanTest
+
+ package org.superbiz.interceptors;
+
+ import junit.framework.TestCase;
+ import org.junit.Before;
+ import org.junit.Test;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Properties;
+
+ /**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+ public class ThirdSLSBeanTest extends TestCase {
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+ ThirdSLSBeanLocal bean = (ThirdSLSBeanLocal) initCtx.lookup("ThirdSLSBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("ThirdSLSBean");
+ expected.add("businessMethod");
+
+ List<String> actual = bean.businessMethod();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+
+ @Test
+ public void testMethodWithDefaultAndClassInterceptorsExcluded() throws Exception {
+ ThirdSLSBeanLocal bean = (ThirdSLSBeanLocal) initCtx.lookup("ThirdSLSBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("ThirdSLSBean");
+ expected.add("anotherBusinessMethod");
+
+ List<String> actual = bean.anotherBusinessMethod();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.interceptors.FullyInterceptedTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/interceptors
+ INFO - openejb.base = /Users/dblevins/examples/interceptors
+ 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 - Using 'openejb.deployments.classpath.include=.*interceptors/target/classes.*'
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/interceptors/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/interceptors/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/interceptors/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean FullyInterceptedBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "/Users/dblevins/examples/interceptors/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/interceptors/classpath.ear
+ INFO - Jndi(name=FullyInterceptedBeanLocal) --> Ejb(deployment-id=FullyInterceptedBean)
+ INFO - Jndi(name=global/classpath.ear/interceptors/FullyInterceptedBean!org.superbiz.interceptors.FullyIntercepted) --> Ejb(deployment-id=FullyInterceptedBean)
+ INFO - Jndi(name=global/classpath.ear/interceptors/FullyInterceptedBean) --> Ejb(deployment-id=FullyInterceptedBean)
+ INFO - Jndi(name=ThirdSLSBeanLocal) --> Ejb(deployment-id=ThirdSLSBean)
+ INFO - Jndi(name=global/classpath.ear/interceptors/ThirdSLSBean!org.superbiz.interceptors.ThirdSLSBeanLocal) --> Ejb(deployment-id=ThirdSLSBean)
+ INFO - Jndi(name=global/classpath.ear/interceptors/ThirdSLSBean) --> Ejb(deployment-id=ThirdSLSBean)
+ INFO - Jndi(name=SecondStatelessInterceptedBeanLocal) --> Ejb(deployment-id=SecondStatelessInterceptedBean)
+ INFO - Jndi(name=global/classpath.ear/interceptors/SecondStatelessInterceptedBean!org.superbiz.interceptors.SecondStatelessInterceptedLocal) --> Ejb(deployment-id=SecondStatelessInterceptedBean)
+ INFO - Jndi(name=global/classpath.ear/interceptors/SecondStatelessInterceptedBean) --> Ejb(deployment-id=SecondStatelessInterceptedBean)
+ INFO - Jndi(name=MethodLevelInterceptorOnlySLSBeanLocal) --> Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean)
+ INFO - Jndi(name=global/classpath.ear/interceptors/MethodLevelInterceptorOnlySLSBean!org.superbiz.interceptors.MethodLevelInterceptorOnlyParent) --> Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean)
+ INFO - Jndi(name=global/classpath.ear/interceptors/MethodLevelInterceptorOnlySLSBean) --> Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean)
+ INFO - Created Ejb(deployment-id=ThirdSLSBean, ejb-name=ThirdSLSBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=SecondStatelessInterceptedBean, ejb-name=SecondStatelessInterceptedBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=FullyInterceptedBean, ejb-name=FullyInterceptedBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean, ejb-name=MethodLevelInterceptorOnlySLSBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=ThirdSLSBean, ejb-name=ThirdSLSBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=SecondStatelessInterceptedBean, ejb-name=SecondStatelessInterceptedBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=FullyInterceptedBean, ejb-name=FullyInterceptedBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=MethodLevelInterceptorOnlySLSBean, ejb-name=MethodLevelInterceptorOnlySLSBean, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/interceptors/classpath.ear)
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.564 sec
+ Running org.superbiz.interceptors.MethodLevelInterceptorOnlyTest
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
+ Running org.superbiz.interceptors.SecondStatelessInterceptedTest
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec
+ Running org.superbiz.interceptors.ThirdSLSBeanTest
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
+
+ Results :
+
+ Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/interceptors/build.xml b/content/examples/interceptors/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/interceptors/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/interceptors/pom.xml b/content/examples/interceptors/pom.xml
new file mode 100755
index 0000000..47df29a
--- /dev/null
+++ b/content/examples/interceptors/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>interceptors</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Interceptors</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that none of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
+
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorOne.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorOne.java
new file mode 100755
index 0000000..d2ca0f0
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorOne.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public class ClassLevelInterceptorOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorSuperClassOne.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorSuperClassOne.java
new file mode 100755
index 0000000..11f6808
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorSuperClassOne.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public class ClassLevelInterceptorSuperClassOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorSuperClassTwo.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorSuperClassTwo.java
new file mode 100755
index 0000000..2385d8c
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorSuperClassTwo.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public class ClassLevelInterceptorSuperClassTwo extends SuperClassOfClassLevelInterceptor {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorTwo.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorTwo.java
new file mode 100755
index 0000000..858c133
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ClassLevelInterceptorTwo.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public class ClassLevelInterceptorTwo {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/DefaultInterceptorOne.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/DefaultInterceptorOne.java
new file mode 100755
index 0000000..ccee61d
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/DefaultInterceptorOne.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public class DefaultInterceptorOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+ @PostConstruct
+ protected void postConstructInterceptor(InvocationContext ic) throws Exception {
+ Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/DefaultInterceptorTwo.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/DefaultInterceptorTwo.java
new file mode 100755
index 0000000..feadbfd
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/DefaultInterceptorTwo.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public class DefaultInterceptorTwo {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/FullyIntercepted.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/FullyIntercepted.java
new file mode 100755
index 0000000..2406e40
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/FullyIntercepted.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import java.util.List;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public interface FullyIntercepted {
+
+ List<String> businessMethod();
+
+ List<String> methodWithDefaultInterceptorsExcluded();
+
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/FullyInterceptedBean.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/FullyInterceptedBean.java
new file mode 100755
index 0000000..3a976d4
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/FullyInterceptedBean.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+@Stateless
+@Local
+@Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+public class FullyInterceptedBean extends FullyInterceptedSuperClass implements FullyIntercepted {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> businessMethod() {
+ List<String> list = new ArrayList<String>();
+ list.add("businessMethod");
+ return list;
+ }
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> methodWithDefaultInterceptorsExcluded() {
+ List<String> list = new ArrayList<String>();
+ list.add("methodWithDefaultInterceptorsExcluded");
+ return list;
+ }
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, "beanClassBusinessMethodInterceptor");
+ }
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/FullyInterceptedSuperClass.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/FullyInterceptedSuperClass.java
new file mode 100755
index 0000000..b376f58
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/FullyInterceptedSuperClass.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.interceptor.Interceptors;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+@Interceptors({ClassLevelInterceptorSuperClassOne.class, ClassLevelInterceptorSuperClassTwo.class})
+public class FullyInterceptedSuperClass {
+
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOne.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOne.java
new file mode 100755
index 0000000..a1adf4e
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOne.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public class MethodLevelInterceptorOne {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOnlyIntf.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOnlyIntf.java
new file mode 100755
index 0000000..6f5de3f
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOnlyIntf.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import java.io.Serializable;
+import java.util.List;
+
+public interface MethodLevelInterceptorOnlyIntf<T extends Serializable> {
+
+ public List<T> makePersistent(T entity);
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOnlyParent.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOnlyParent.java
new file mode 100755
index 0000000..60632a0
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOnlyParent.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import java.util.List;
+
+public interface MethodLevelInterceptorOnlyParent extends MethodLevelInterceptorOnlyIntf<String> {
+
+ public List<String> makePersistent(String entity);
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOnlySLSBean.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOnlySLSBean.java
new file mode 100755
index 0000000..865a6c9
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorOnlySLSBean.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+import javax.interceptor.Interceptors;
+import java.util.ArrayList;
+import java.util.List;
+
+@Local(MethodLevelInterceptorOnlyParent.class)
+@Stateless
+public class MethodLevelInterceptorOnlySLSBean implements MethodLevelInterceptorOnlyParent {
+
+ @Interceptors(MethodLevelInterceptorOne.class)
+ public List<String> makePersistent(String entity) {
+ List<String> list = new ArrayList<String>();
+ list.add("makePersistent");
+ return list;
+ }
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorTwo.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorTwo.java
new file mode 100755
index 0000000..6f903ff
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/MethodLevelInterceptorTwo.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public class MethodLevelInterceptorTwo {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedBean.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedBean.java
new file mode 100755
index 0000000..bec090b
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedBean.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev: 808273 $ $Date: 2009-08-27 05:42:06 +0200 (Thu, 27 Aug 2009) $
+ */
+@Stateless
+@Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+public class SecondStatelessInterceptedBean implements SecondStatelessInterceptedLocal {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> methodWithDefaultInterceptorsExcluded() {
+ List<String> list = new ArrayList<String>();
+ list.add("methodWithDefaultInterceptorsExcluded");
+ return list;
+
+ }
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedLocal.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedLocal.java
new file mode 100755
index 0000000..97a0283
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/SecondStatelessInterceptedLocal.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import java.util.List;
+
+/**
+ * @version $Rev: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+public interface SecondStatelessInterceptedLocal {
+
+ List<String> methodWithDefaultInterceptorsExcluded();
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/SuperClassOfClassLevelInterceptor.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/SuperClassOfClassLevelInterceptor.java
new file mode 100755
index 0000000..6cbc130
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/SuperClassOfClassLevelInterceptor.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Rev: 607077 $ $Date: 2007-12-27 15:55:23 +0100 (Thu, 27 Dec 2007) $
+ */
+public class SuperClassOfClassLevelInterceptor {
+
+ @AroundInvoke
+ protected Object businessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+
+ @PostConstruct
+ protected void postConstructInterceptor(InvocationContext ic) throws Exception {
+ Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ThirdSLSBean.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ThirdSLSBean.java
new file mode 100755
index 0000000..32843c9
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ThirdSLSBean.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+@Stateless
+@Interceptors({ClassLevelInterceptorOne.class, ClassLevelInterceptorTwo.class})
+@ExcludeDefaultInterceptors
+public class ThirdSLSBean implements ThirdSLSBeanLocal {
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ public List<String> businessMethod() {
+ List<String> list = new ArrayList<String>();
+ list.add("businessMethod");
+ return list;
+ }
+
+ @Interceptors({MethodLevelInterceptorOne.class, MethodLevelInterceptorTwo.class})
+ @ExcludeClassInterceptors
+ public List<String> anotherBusinessMethod() {
+ List<String> list = new ArrayList<String>();
+ list.add("anotherBusinessMethod");
+ return list;
+ }
+
+ @AroundInvoke
+ protected Object beanClassBusinessMethodInterceptor(InvocationContext ic) throws Exception {
+ return Utils.addClassSimpleName(ic, this.getClass().getSimpleName());
+ }
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ThirdSLSBeanLocal.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ThirdSLSBeanLocal.java
new file mode 100755
index 0000000..ba7953f
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/ThirdSLSBeanLocal.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import java.util.List;
+
+/**
+ * @version $Rev: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+public interface ThirdSLSBeanLocal {
+
+ List<String> businessMethod();
+
+ List<String> anotherBusinessMethod();
+}
diff --git a/content/examples/interceptors/src/main/java/org/superbiz/interceptors/Utils.java b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/Utils.java
new file mode 100755
index 0000000..6604f5a
--- /dev/null
+++ b/content/examples/interceptors/src/main/java/org/superbiz/interceptors/Utils.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import javax.interceptor.InvocationContext;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev: 808273 $ $Date: 2009-08-27 05:42:06 +0200 (Thu, 27 Aug 2009) $
+ */
+public class Utils {
+
+ public static List<String> addClassSimpleName(InvocationContext ic, String classSimpleName) throws Exception {
+ List<String> list = new ArrayList<String>();
+ list.add(classSimpleName);
+ List<String> listOfStrings = (List<String>) ic.proceed();
+ if (listOfStrings != null) {
+ list.addAll(listOfStrings);
+ }
+ return list;
+ }
+
+}
diff --git a/content/examples/interceptors/src/main/resources/META-INF/ejb-jar.xml b/content/examples/interceptors/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..c4d1882
--- /dev/null
+++ b/content/examples/interceptors/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 895457 $ $Date: 2010-01-03 19:11:07 +0100 (Sun, 03 Jan 2010) $ -->
+
+<ejb-jar 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/ejb-jar_3_0.xsd"
+ version="3.0">
+ <interceptors>
+ <interceptor>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorOne</interceptor-class>
+ </interceptor>
+ <interceptor>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorTwo</interceptor-class>
+ </interceptor>
+ </interceptors>
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorOne</interceptor-class>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.superbiz.interceptors.DefaultInterceptorTwo</interceptor-class>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>FullyInterceptedBean</ejb-name>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ <method>
+ <method-name>methodWithDefaultInterceptorsExcluded</method-name>
+ </method>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>SecondStatelessInterceptedBean</ejb-name>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>MethodLevelInterceptorOnlySLSBean</ejb-name>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar>
\ No newline at end of file
diff --git a/content/examples/interceptors/src/test/java/org/superbiz/interceptors/FullyInterceptedTest.java b/content/examples/interceptors/src/test/java/org/superbiz/interceptors/FullyInterceptedTest.java
new file mode 100755
index 0000000..a356b00
--- /dev/null
+++ b/content/examples/interceptors/src/test/java/org/superbiz/interceptors/FullyInterceptedTest.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 1227481 $ $Date: 2012-01-05 05:39:55 +0100 (Thu, 05 Jan 2012) $
+ */
+public class FullyInterceptedTest extends TestCase {
+
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testBusinessMethod() throws Exception {
+
+ FullyIntercepted fullyIntercepted = (FullyIntercepted) initCtx.lookup("FullyInterceptedBeanLocal");
+
+ assert fullyIntercepted != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("DefaultInterceptorOne");
+ expected.add("DefaultInterceptorTwo");
+ expected.add("ClassLevelInterceptorSuperClassOne");
+ expected.add("ClassLevelInterceptorSuperClassTwo");
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("beanClassBusinessMethodInterceptor");
+ expected.add("businessMethod");
+
+ List<String> actual = fullyIntercepted.businessMethod();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+
+ FullyIntercepted fullyIntercepted = (FullyIntercepted) initCtx.lookup("FullyInterceptedBeanLocal");
+
+ assert fullyIntercepted != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorSuperClassOne");
+ expected.add("ClassLevelInterceptorSuperClassTwo");
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("beanClassBusinessMethodInterceptor");
+ expected.add("methodWithDefaultInterceptorsExcluded");
+
+ List<String> actual = fullyIntercepted.methodWithDefaultInterceptorsExcluded();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ initCtx.close();
+ }
+}
diff --git a/content/examples/interceptors/src/test/java/org/superbiz/interceptors/MethodLevelInterceptorOnlyTest.java b/content/examples/interceptors/src/test/java/org/superbiz/interceptors/MethodLevelInterceptorOnlyTest.java
new file mode 100755
index 0000000..d3def6b
--- /dev/null
+++ b/content/examples/interceptors/src/test/java/org/superbiz/interceptors/MethodLevelInterceptorOnlyTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+public class MethodLevelInterceptorOnlyTest extends TestCase {
+
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testInterceptedGenerifiedBusinessIntfMethod() throws Exception {
+ MethodLevelInterceptorOnlyParent bean = (MethodLevelInterceptorOnlyParent) initCtx.lookup("MethodLevelInterceptorOnlySLSBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("makePersistent");
+
+ List<String> actual = bean.makePersistent(null);
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+}
\ No newline at end of file
diff --git a/content/examples/interceptors/src/test/java/org/superbiz/interceptors/SecondStatelessInterceptedTest.java b/content/examples/interceptors/src/test/java/org/superbiz/interceptors/SecondStatelessInterceptedTest.java
new file mode 100755
index 0000000..29ef50f
--- /dev/null
+++ b/content/examples/interceptors/src/test/java/org/superbiz/interceptors/SecondStatelessInterceptedTest.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+public class SecondStatelessInterceptedTest extends TestCase {
+
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+ SecondStatelessInterceptedLocal bean =
+ (SecondStatelessInterceptedLocal) initCtx.lookup("SecondStatelessInterceptedBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("SecondStatelessInterceptedBean");
+ expected.add("methodWithDefaultInterceptorsExcluded");
+
+ List<String> actual = bean.methodWithDefaultInterceptorsExcluded();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+}
diff --git a/content/examples/interceptors/src/test/java/org/superbiz/interceptors/ThirdSLSBeanTest.java b/content/examples/interceptors/src/test/java/org/superbiz/interceptors/ThirdSLSBeanTest.java
new file mode 100755
index 0000000..31933b9
--- /dev/null
+++ b/content/examples/interceptors/src/test/java/org/superbiz/interceptors/ThirdSLSBeanTest.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.interceptors;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 1516150 $ $Date: 2013-08-21 15:09:35 +0200 (Wed, 21 Aug 2013) $
+ */
+public class ThirdSLSBeanTest extends TestCase {
+
+ private InitialContext initCtx;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.deployments.classpath.include", ".*interceptors/target/classes.*");
+
+ initCtx = new InitialContext(properties);
+ }
+
+ @Test
+ public void testMethodWithDefaultInterceptorsExcluded() throws Exception {
+ ThirdSLSBeanLocal bean = (ThirdSLSBeanLocal) initCtx.lookup("ThirdSLSBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("ClassLevelInterceptorOne");
+ expected.add("ClassLevelInterceptorTwo");
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("ThirdSLSBean");
+ expected.add("businessMethod");
+
+ List<String> actual = bean.businessMethod();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+
+ @Test
+ public void testMethodWithDefaultAndClassInterceptorsExcluded() throws Exception {
+ ThirdSLSBeanLocal bean = (ThirdSLSBeanLocal) initCtx.lookup("ThirdSLSBeanLocal");
+
+ assert bean != null;
+
+ List<String> expected = new ArrayList<String>();
+ expected.add("MethodLevelInterceptorOne");
+ expected.add("MethodLevelInterceptorTwo");
+ expected.add("ThirdSLSBean");
+ expected.add("anotherBusinessMethod");
+
+ List<String> actual = bean.anotherBusinessMethod();
+ assert expected.equals(actual) : "Expected " + expected + ", but got " + actual;
+ }
+}
diff --git a/content/examples/javamail.html b/content/examples/javamail.html
new file mode 100644
index 0000000..aba4bee
--- /dev/null
+++ b/content/examples/javamail.html
@@ -0,0 +1,397 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/javamail.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Javamail API</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example javamail can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/javamail" class="bare">https://github.com/apache/tomee/tree/master/examples/javamail</a></p>
+</div>
+<div class="paragraph">
+<p>This is just a simple example to demonstrate a very basic usage of the API. It should be enough to get you started using the java mail packages.</p>
+</div>
+</div>
+</div>
+<h1 id="_the_code" class="sect0">The Code</h1>
+<div class="sect1">
+<h2 id="_a_simple_rest_service_using_the_javamail_api">A simple REST service using the Javamail API</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Here we see a very simple RESTful endpoint that can be called with a message to send by Email. It would not be hard to modify the application to provide
+more useful configuration options. As is, this will not send anything, but if you change the parameters to match your mail server then you’ll see the message being sent.
+You can find much more detailed information on the <a href="https://java.net/projects/javamail/pages/Home#Samples">Javamail API here</a></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest;
+
+import javax.mail.Authenticator;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import java.util.Date;
+import java.util.Properties;
+
+@Path("/email")
+public class EmailService {
+
+ @POST
+ public String lowerCase(final String message) {
+
+ try {
+
+ //Create some properties and get the default Session
+ final Properties props = new Properties();
+ props.put("mail.smtp.host", "your.mailserver.host");
+ props.put("mail.debug", "true");
+
+ final Session session = Session.getInstance(props, new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication("MyUsername", "MyPassword");
+ }
+ });
+
+ //Set this just to see some internal logging
+ session.setDebug(true);
+
+ //Create a message
+ final MimeMessage msg = new MimeMessage(session);
+ msg.setFrom(new InternetAddress("your@email.address"));
+ final InternetAddress[] address = {new InternetAddress("general@tomitribe.com")};
+ msg.setRecipients(Message.RecipientType.TO, address);
+ msg.setSubject("JavaMail API test");
+ msg.setSentDate(new Date());
+ msg.setText(message, "UTF-8");
+
+
+ Transport.send(msg);
+ } catch (MessagingException e) {
+ return "Failed to send message: " + e.getMessage();
+ }
+
+ return "Sent";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_testing" class="sect0">Testing</h1>
+<div class="sect1">
+<h2 id="_test_for_the_jaxrs_service">Test for the JAXRS service</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The test uses the OpenEJB ApplicationComposer to make it trivial.</p>
+</div>
+<div class="paragraph">
+<p>The idea is first to activate the jaxrs services. This is done using @EnableServices annotation.</p>
+</div>
+<div class="paragraph">
+<p>Then we create on the fly the application simply returning an object representing the web.xml. Here we simply
+use it to define the context root but you can use it to define your REST Application too. And to complete the
+application definition we add @Classes annotation to define the set of classes to use in this app.</p>
+</div>
+<div class="paragraph">
+<p>Finally to test it we use cxf client API to call the REST service post() method.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs")
+@RunWith(ApplicationComposer.class)
+public class EmailServiceTest {
+
+ @Module
+ @Classes(EmailService.class)
+ public WebApp app() {
+ return new WebApp().contextRoot("test");
+ }
+
+ @Test
+ public void post() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/email/").post("Hello Tomitribe", String.class);
+ assertEquals("Failed to send message: Unknown SMTP host: your.mailserver.host", message);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>Running the example is fairly simple. In the "javamail-api" directory run:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>$ mvn clean install</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Which should create output like the following.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>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 - Initializing network services
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Creating ServerService(id=httpejbd)
+INFO - Created ServicePool 'httpejbd' with (10) core threads, limited to (200) threads with a queue of (9)
+INFO - Initializing network services
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: D:\github\tomee\examples\javamail\EmailServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.EmailServiceTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Using directory D:\windows\tmp for stateful session passivation
+INFO - Configuring Service(id=comp/DefaultManagedExecutorService, type=Resource, provider-id=Default Executor Service)
+INFO - Auto-creating a Resource with id 'comp/DefaultManagedExecutorService' of type 'javax.enterprise.concurrent.ManagedExecutorService for 'test'.
+INFO - Configuring Service(id=comp/DefaultManagedScheduledExecutorService, type=Resource, provider-id=Default Scheduled Executor Service)
+INFO - Auto-creating a Resource with id 'comp/DefaultManagedScheduledExecutorService' of type 'javax.enterprise.concurrent.ManagedScheduledExecutorService for 'test'.
+INFO - Configuring Service(id=comp/DefaultManagedThreadFactory, type=Resource, provider-id=Default Managed Thread Factory)
+INFO - Auto-creating a Resource with id 'comp/DefaultManagedThreadFactory' of type 'javax.enterprise.concurrent.ManagedThreadFactory for 'test'.
+INFO - Enterprise application "D:\github\tomee\examples\javamail\EmailServiceTest" loaded.
+INFO - Creating dedicated application classloader for EmailServiceTest
+INFO - Assembling app: D:\github\tomee\examples\javamail\EmailServiceTest
+INFO - Using providers:
+INFO - org.apache.johnzon.jaxrs.JohnzonProvider@2687f956
+INFO - org.apache.cxf.jaxrs.provider.JAXBElementProvider@1ded7b14
+INFO - org.apache.johnzon.jaxrs.JsrProvider@29be7749
+INFO - org.apache.johnzon.jaxrs.WadlDocumentMessageBodyWriter@5f84abe8
+INFO - org.apache.openejb.server.cxf.rs.EJBAccessExceptionMapper@4650a407
+INFO - org.apache.cxf.jaxrs.validation.ValidationExceptionMapper@30135202
+INFO - REST Application: http://127.0.0.1:4204/test/ -> org.apache.openejb.server.rest.InternalApplication
+INFO - Service URI: http://127.0.0.1:4204/test/email -> Pojo org.superbiz.rest.EmailService
+INFO - POST http://127.0.0.1:4204/test/email/ -> String lowerCase(String)
+INFO - Deployed Application(path=D:\github\tomee\examples\javamail\EmailServiceTest)
+DEBUG: JavaMail version 1.4ea
+DEBUG: java.io.FileNotFoundException: D:\java\jdk8\jre\lib\javamail.providers (The system cannot find the file specified)
+DEBUG: !anyLoaded
+DEBUG: not loading resource: /META-INF/javamail.providers
+DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
+DEBUG: Tables of loaded providers
+DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
+DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
+DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
+DEBUG: !anyLoaded
+DEBUG: not loading resource: /META-INF/javamail.address.map
+DEBUG: java.io.FileNotFoundException: D:\java\jdk8\jre\lib\javamail.address.map (The system cannot find the file specified)
+DEBUG: setDebug: JavaMail version 1.4ea
+DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
+DEBUG SMTP: useEhlo true, useAuth false
+DEBUG SMTP: trying to connect to host "your.mailserver.host", port 25, isSSL false
+INFO - Undeploying app: D:\github\tomee\examples\javamail\EmailServiceTest
+INFO - Stopping network services
+INFO - Stopping server services</pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/javamail.pdf b/content/examples/javamail.pdf
new file mode 100644
index 0000000..20b8ac8
--- /dev/null
+++ b/content/examples/javamail.pdf
Binary files differ
diff --git a/content/examples/jpa-eclipselink.html b/content/examples/jpa-eclipselink.html
new file mode 100644
index 0000000..ffcafc7
--- /dev/null
+++ b/content/examples/jpa-eclipselink.html
@@ -0,0 +1,428 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/jpa-eclipselink.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>JPA Eclipselink</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example jpa-eclipselink can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/jpa-eclipselink" class="bare">https://github.com/apache/tomee/tree/master/examples/jpa-eclipselink</a></p>
+</div>
+<div class="paragraph">
+<p>This example shows how to configure <code>persistence.xml</code> to work with Eclipselink. It uses an <code>@Entity</code> class and a <code>@Stateful</code> bean to add and delete entities from a database.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_creating_the_jpa_entity">Creating the JPA Entity</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The entity itself is simply a pojo annotated with <code>@Entity</code>. We create one pojo called <code>Movie</code> which we can use to hold movie records.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.eclipselink;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_database_operations">Database Operations</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>This is the bean responsible for database operations; it allows us to persist or delete entities.
+For more information we recommend you to see <a href="http://tomee.apache.org/examples-trunk/injection-of-entitymanager/README.html">injection-of-entitymanager</a></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.eclipselink;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml_with_eclipselink_configuration">Persistence.xml with EclipseLink configuration</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>This operation is too easy, just set the <code>provider</code> to <code>org.eclipse.persistence.jpa.PersistenceProvider</code> and add additional properties to the persistence unit.
+The example has followed a strategy that allows the creation of tables in a HSQL database.
+For a complete list of persistence unit properties see <a href="http://www.eclipse.org/eclipselink/api/2.4/org/eclipse/persistence/config/PersistenceUnitProperties.html">here</a></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence version="1.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="movie-unit">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <properties>
+ <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.HSQLPlatform"/>
+ <property name="eclipselink.ddl-generation" value="create-tables"/>
+ <property name="eclipselink.ddl-generation.output-mode" value="database"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Testing JPA is quite easy, we can simply use the <code>EJBContainer</code> API to create a container in our test case.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.eclipselink;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+
+ Movies movies = (Movies) context.lookup("java:global/jpa-eclipselink/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>When we run our test case we should see output similar to the following.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.eclipselink.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/jpa-eclipselink
+INFO - openejb.base = /Users/dblevins/examples/jpa-eclipselink
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/jpa-eclipselink/target/classes
+INFO - Beginning load: /Users/dblevins/examples/jpa-eclipselink/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/jpa-eclipselink
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.eclipselink.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit, provider=org.eclipse.persistence.jpa.PersistenceProvider)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/jpa-eclipselink" loaded.
+INFO - Assembling app: /Users/dblevins/examples/jpa-eclipselink
+INFO - PersistenceUnit(name=movie-unit, provider=org.eclipse.persistence.jpa.PersistenceProvider) - provider time 511ms
+INFO - Jndi(name="java:global/jpa-eclipselink/Movies!org.superbiz.eclipselink.Movies")
+INFO - Jndi(name="java:global/jpa-eclipselink/Movies")
+INFO - Jndi(name="java:global/EjbModule225280863/org.superbiz.eclipselink.MoviesTest!org.superbiz.eclipselink.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule225280863/org.superbiz.eclipselink.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.eclipselink.MoviesTest, ejb-name=org.superbiz.eclipselink.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.eclipselink.MoviesTest, ejb-name=org.superbiz.eclipselink.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/jpa-eclipselink)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.188 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/jpa-eclipselink.pdf b/content/examples/jpa-eclipselink.pdf
new file mode 100644
index 0000000..9798f8c
--- /dev/null
+++ b/content/examples/jpa-eclipselink.pdf
Binary files differ
diff --git a/content/examples/jpa-eclipselink/README.md b/content/examples/jpa-eclipselink/README.md
new file mode 100755
index 0000000..694bf4b
--- /dev/null
+++ b/content/examples/jpa-eclipselink/README.md
@@ -0,0 +1,207 @@
+Title: JPA Eclipselink
+
+This example shows how to configure `persistence.xml` to work with Eclipselink. It uses an `@Entity` class and a `@Stateful` bean to add and delete entities from a database.
+
+## Creating the JPA Entity
+
+The entity itself is simply a pojo annotated with `@Entity`. We create one pojo called `Movie` which we can use to hold movie records.
+
+ package org.superbiz.eclipselink;
+
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.GenerationType;
+ import javax.persistence.Id;
+
+ @Entity
+ public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Database Operations
+
+This is the bean responsible for database operations; it allows us to persist or delete entities.
+For more information we recommend you to see [injection-of-entitymanager](http://openejb.apache.org/examples-trunk/injection-of-entitymanager/README.html)
+
+
+ package org.superbiz.eclipselink;
+
+ import javax.ejb.Stateful;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ @Stateful
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## Persistence.xml with EclipseLink configuration
+
+This operation is too easy, just set the `provider` to `org.eclipse.persistence.jpa.PersistenceProvider` and add additional properties to the persistence unit.
+The example has followed a strategy that allows the creation of tables in a HSQL database.
+For a complete list of persistence unit properties see [here](http://www.eclipse.org/eclipselink/api/2.4/org/eclipse/persistence/config/PersistenceUnitProperties.html)
+
+ <persistence version="1.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="movie-unit">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <properties>
+ <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.HSQLPlatform"/>
+ <property name="eclipselink.ddl-generation" value="create-tables"/>
+ <property name="eclipselink.ddl-generation.output-mode" value="database"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+
+## MoviesTest
+
+Testing JPA is quite easy, we can simply use the `EJBContainer` API to create a container in our test case.
+
+ package org.superbiz.eclipselink;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import java.util.List;
+ import java.util.Properties;
+
+ /**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+
+ Movies movies = (Movies) context.lookup("java:global/jpa-eclipselink/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+ }
+
+# Running
+
+When we run our test case we should see output similar to the following.
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.eclipselink.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/jpa-eclipselink
+ INFO - openejb.base = /Users/dblevins/examples/jpa-eclipselink
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/jpa-eclipselink/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/jpa-eclipselink/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/jpa-eclipselink
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.eclipselink.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit, provider=org.eclipse.persistence.jpa.PersistenceProvider)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/jpa-eclipselink" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/jpa-eclipselink
+ INFO - PersistenceUnit(name=movie-unit, provider=org.eclipse.persistence.jpa.PersistenceProvider) - provider time 511ms
+ INFO - Jndi(name="java:global/jpa-eclipselink/Movies!org.superbiz.eclipselink.Movies")
+ INFO - Jndi(name="java:global/jpa-eclipselink/Movies")
+ INFO - Jndi(name="java:global/EjbModule225280863/org.superbiz.eclipselink.MoviesTest!org.superbiz.eclipselink.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule225280863/org.superbiz.eclipselink.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.eclipselink.MoviesTest, ejb-name=org.superbiz.eclipselink.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.eclipselink.MoviesTest, ejb-name=org.superbiz.eclipselink.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/jpa-eclipselink)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.188 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
\ No newline at end of file
diff --git a/content/examples/jpa-eclipselink/pom.xml b/content/examples/jpa-eclipselink/pom.xml
new file mode 100755
index 0000000..97574fd
--- /dev/null
+++ b/content/examples/jpa-eclipselink/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>jpa-eclipselink</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: JPA with EclipseLink</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ <repository>
+ <id>eclipselink-repo</id>
+ <name>EclipseLink Repository</name>
+ <url>http://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/rt/eclipselink/maven.repo</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <!-- spec apis such as javax.persistence -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- openejb container for running tests -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- toplink dependencies -->
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>2.3.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/jpa-eclipselink/src/main/java/org/superbiz/eclipselink/Movie.java b/content/examples/jpa-eclipselink/src/main/java/org/superbiz/eclipselink/Movie.java
new file mode 100755
index 0000000..5811bf2
--- /dev/null
+++ b/content/examples/jpa-eclipselink/src/main/java/org/superbiz/eclipselink/Movie.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.eclipselink;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/jpa-eclipselink/src/main/java/org/superbiz/eclipselink/Movies.java b/content/examples/jpa-eclipselink/src/main/java/org/superbiz/eclipselink/Movies.java
new file mode 100755
index 0000000..2b0cad2
--- /dev/null
+++ b/content/examples/jpa-eclipselink/src/main/java/org/superbiz/eclipselink/Movies.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.eclipselink;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+}
diff --git a/content/examples/jpa-eclipselink/src/main/resources/META-INF/persistence.xml b/content/examples/jpa-eclipselink/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..4d5af59
--- /dev/null
+++ b/content/examples/jpa-eclipselink/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="1.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="movie-unit">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <properties>
+ <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.HSQLPlatform"/>
+ <property name="eclipselink.ddl-generation" value="create-tables"/>
+ <property name="eclipselink.ddl-generation.output-mode" value="database"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/jpa-eclipselink/src/test/java/org/superbiz/eclipselink/MoviesTest.java b/content/examples/jpa-eclipselink/src/test/java/org/superbiz/eclipselink/MoviesTest.java
new file mode 100755
index 0000000..ad3701d
--- /dev/null
+++ b/content/examples/jpa-eclipselink/src/test/java/org/superbiz/eclipselink/MoviesTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.eclipselink;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+
+ Movies movies = (Movies) context.lookup("java:global/jpa-eclipselink/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+}
diff --git a/content/examples/jpa-enumerated.html b/content/examples/jpa-enumerated.html
new file mode 100644
index 0000000..2179791
--- /dev/null
+++ b/content/examples/jpa-enumerated.html
@@ -0,0 +1,508 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/jpa-enumerated.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>JPA and Enums via @Enumerated</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example jpa-enumerated can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/jpa-enumerated" class="bare">https://github.com/apache/tomee/tree/master/examples/jpa-enumerated</a></p>
+</div>
+<div class="paragraph">
+<p>It can sometimes be desirable to have a Java <code>enum</code> type to represent a particular column in a database. JPA supports converting database data to and from Java <code>enum</code> types via the <code>@javax.persistence.Enumerated</code> annotation.</p>
+</div>
+<div class="paragraph">
+<p>This example will show basic <code>@Enumerated</code> usage in a field of an <code>@Entity</code> as well as <code>enum`s as the parameter of a `Query</code>. We’ll also see that the actual database representation can be effectively <code>String</code> or <code>int</code>.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_enum">Enum</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>For our example we will leverage the familiar <code>Movie</code> entity and add a new field to represent the MPAA.org rating of the movie. This is defined via a simple <code>enum</code> that requires no JPA specific annotations.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public enum Rating {
+ UNRATED,
+ G,
+ PG,
+ PG13,
+ R,
+ NC17
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="__enumerated">@Enumerated</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>In our <code>Movie</code> entity, we add a <code>rating</code> field of the enum type <code>Rating</code> and annotate it with <code>@Enumerated(EnumType.STRING)</code> to declare that its value should be converted from what is effectively a <code>String</code> in the database to the <code>Rating</code> type.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue
+ private int id;
+ private String director;
+ private String title;
+ private int year;
+
+ @Enumerated(EnumType.STRING)
+ private Rating rating;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year, Rating rating) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ this.rating = rating;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public Rating getRating() {
+ return rating;
+ }
+
+ public void setRating(Rating rating) {
+ this.rating = rating;
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The above is enough and we are effectively done. For the sake of completeness we’ll show a sample <code>Query</code></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_enum_in_jpql_query">Enum in JPQL Query</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Note the <code>findByRating</code> method which creates a <code>Query</code> with a <code>rating</code> named parameter. The key thing to notice is that the <code>rating</code> enum instance itself is passed into the
+ <code>query.setParameter</code> method, <strong>not</strong> <code>rating.name()</code> or <code>rating.ordinal()</code>.</p>
+</div>
+<div class="paragraph">
+<p>Regardless if you use <code>EnumType.STRING</code> or <code>EnumType.ORDINAL</code>, you still always pass the enum itself in calls to <code>query.setParameter</code>.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> findByRating(Rating rating) {
+ final Query query = entityManager.createQuery("SELECT m FROM Movie as m WHERE m.rating = :rating");
+ query.setParameter("rating", rating);
+ return query.getResultList();
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_enumtype_string_vs_enumtype_ordinal">EnumType.STRING vs EnumType.ORDINAL</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>It is a matter of style how you would like your <code>enum</code> data represented in the database. Either <code>name()</code> or <code>ordinal()</code> are supported:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><code>@Enumerated(EnumType.STRING) Rating rating</code> the value of <code>rating.name()</code> is written and read from the corresponding database column; e.g. <code>G</code>, <code>PG</code>, <code>PG13</code></p>
+</li>
+<li>
+<p><code>@Enumerated(EnumType.ORDINAL) Rating rating</code> the value of <code>rating.ordinal()</code> is written and read from the corresponding database column; e.g. <code>0</code>, <code>1</code>, <code>2</code></p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>The default is <code>EnumType.ORDINAL</code></p>
+</div>
+<div class="paragraph">
+<p>There are advantages and disadvantages to each.</p>
+</div>
+<div class="sect2">
+<h3 id="_disadvantage_of_enumtype_ordinal">Disadvantage of EnumType.ORDINAL</h3>
+<div class="paragraph">
+<p>A disadvantage of <code>EnumType.ORDINAL</code> is the effect of time and the desire to keep <code>enums</code> in a logical order. With <code>EnumType.ORDINAL</code> any new enum elements must be added to the
+<strong>end</strong> of the list or you will accidentally change the meaning of all your records.</p>
+</div>
+<div class="paragraph">
+<p>Let’s use our <code>Rating</code> enum and see how it would have had to evolve over time to keep up with changes in the MPAA.org ratings system.</p>
+</div>
+<div class="paragraph">
+<p><strong>1980</strong></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public enum Rating {
+ G,
+ PG,
+ R,
+ UNRATED
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><strong>1984</strong> PG-13 is added</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public enum Rating {
+ G,
+ PG,
+ R,
+ UNRATED,
+ PG13
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><strong>1990</strong> NC-17 is added</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public enum Rating {
+ G,
+ PG,
+ R,
+ UNRATED,
+ PG13,
+ NC17
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>If <code>EnumType.STRING</code> was used, then the enum could be reordered at anytime and would instead look as we have defined it originally with ratings starting at <code>G</code> and increasing in severity to <code>NC17</code> and eventually <code>UNRATED</code>. With <code>EnumType.ORDINAL</code> the logical ordering would not have withstood the test of time as new values were added.</p>
+</div>
+<div class="paragraph">
+<p>If the order of the enum values is significant to your code, avoid <code>EnumType.ORDINAL</code></p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_unit_testing_the_jpa_enumerated">Unit Testing the JPA @Enumerated</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer container = EJBContainer.createEJBContainer(p);
+ final Context context = container.getContext();
+
+ final Movies movies = (Movies) context.lookup("java:global/jpa-scratch/Movies");
+
+ movies.addMovie(new Movie("James Frawley", "The Muppet Movie", 1979, Rating.G));
+ movies.addMovie(new Movie("Jim Henson", "The Great Muppet Caper", 1981, Rating.G));
+ movies.addMovie(new Movie("Frank Oz", "The Muppets Take Manhattan", 1984, Rating.G));
+ movies.addMovie(new Movie("James Bobin", "The Muppets", 2011, Rating.PG));
+
+ assertEquals("List.size()", 4, movies.getMovies().size());
+
+ assertEquals("List.size()", 3, movies.findByRating(Rating.G).size());
+
+ assertEquals("List.size()", 1, movies.findByRating(Rating.PG).size());
+
+ assertEquals("List.size()", 0, movies.findByRating(Rating.R).size());
+
+ container.close();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>To run the example via maven:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>cd jpa-enumerated
+mvn clean install</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Which will generate output similar to the following:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.jpa.enums.MoviesTest
+Apache OpenEJB 4.0.0-beta-2 build: 20120115-08:26
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/openejb/examples/jpa-enumerated
+INFO - openejb.base = /Users/dblevins/openejb/examples/jpa-enumerated
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/openejb/examples/jpa-enumerated/target/classes
+INFO - Beginning load: /Users/dblevins/openejb/examples/jpa-enumerated/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/openejb/examples/jpa-enumerated
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.jpa.enums.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/openejb/examples/jpa-enumerated" loaded.
+INFO - Assembling app: /Users/dblevins/openejb/examples/jpa-enumerated
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 406ms
+INFO - Jndi(name="java:global/jpa-enumerated/Movies!org.superbiz.jpa.enums.Movies")
+INFO - Jndi(name="java:global/jpa-enumerated/Movies")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Deployed Application(path=/Users/dblevins/openejb/examples/jpa-enumerated)
+INFO - Undeploying app: /Users/dblevins/openejb/examples/jpa-enumerated
+INFO - Closing DataSource: movieDatabase
+INFO - Closing DataSource: movieDatabaseNonJta
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.831 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/jpa-enumerated.pdf b/content/examples/jpa-enumerated.pdf
new file mode 100644
index 0000000..61d473b
--- /dev/null
+++ b/content/examples/jpa-enumerated.pdf
Binary files differ
diff --git a/content/examples/jpa-enumerated/README.md b/content/examples/jpa-enumerated/README.md
new file mode 100755
index 0000000..6552e44
--- /dev/null
+++ b/content/examples/jpa-enumerated/README.md
@@ -0,0 +1,248 @@
+Title: JPA and Enums via @Enumerated
+
+It can sometimes be desirable to have a Java `enum` type to represent a particular column in a database. JPA supports converting database data to and from Java `enum` types via the `@javax.persistence.Enumerated` annotation.
+
+This example will show basic `@Enumerated` usage in a field of an `@Entity` as well as `enum`s as the parameter of a `Query`. We'll also see that the actual database representation can be effectively `String` or `int`.
+
+## Enum
+
+For our example we will leverage the familiar `Movie` entity and add a new field to represent the MPAA.org rating of the movie. This is defined via a simple `enum` that requires no JPA specific annotations.
+
+ public enum Rating {
+ UNRATED,
+ G,
+ PG,
+ PG13,
+ R,
+ NC17
+ }
+
+## @Enumerated
+
+In our `Movie` entity, we add a `rating` field of the enum type `Rating` and annotate it with `@Enumerated(EnumType.STRING)` to declare that its value should be converted from what is effectively a `String` in the database to the `Rating` type.
+
+ @Entity
+ public class Movie {
+
+ @Id
+ @GeneratedValue
+ private int id;
+ private String director;
+ private String title;
+ private int year;
+
+ @Enumerated(EnumType.STRING)
+ private Rating rating;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year, Rating rating) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ this.rating = rating;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public Rating getRating() {
+ return rating;
+ }
+
+ public void setRating(Rating rating) {
+ this.rating = rating;
+ }
+ }
+
+The above is enough and we are effectively done. For the sake of completeness we'll show a sample `Query`
+
+## Enum in JPQL Query
+
+Note the `findByRating` method which creates a `Query` with a `rating` named parameter. The key thing to notice is that the `rating` enum instance itself is passed into the
+ `query.setParameter` method, **not** `rating.name()` or `rating.ordinal()`.
+
+Regardless if you use `EnumType.STRING` or `EnumType.ORDINAL`, you still always pass the enum itself in calls to `query.setParameter`.
+
+ @Stateful
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> findByRating(Rating rating) {
+ final Query query = entityManager.createQuery("SELECT m FROM Movie as m WHERE m.rating = :rating");
+ query.setParameter("rating", rating);
+ return query.getResultList();
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+ }
+
+## EnumType.STRING vs EnumType.ORDINAL
+
+It is a matter of style how you would like your `enum` data represented in the database. Either `name()` or `ordinal()` are supported:
+
+ - `@Enumerated(EnumType.STRING) Rating rating` the value of `rating.name()` is written and read from the corresponding database column; e.g. `G`, `PG`, `PG13`
+ - `@Enumerated(EnumType.ORDINAL) Rating rating` the value of `rating.ordinal()` is written and read from the corresponding database column; e.g. `0`, `1`, `2`
+
+The default is `EnumType.ORDINAL`
+
+There are advantages and disadvantages to each.
+
+### Disadvantage of EnumType.ORDINAL
+
+A disadvantage of `EnumType.ORDINAL` is the effect of time and the desire to keep `enums` in a logical order. With `EnumType.ORDINAL` any new enum elements must be added to the
+**end** of the list or you will accidentally change the meaning of all your records.
+
+Let's use our `Rating` enum and see how it would have had to evolve over time to keep up with changes in the MPAA.org ratings system.
+
+**1980**
+
+ public enum Rating {
+ G,
+ PG,
+ R,
+ UNRATED
+ }
+
+**1984** PG-13 is added
+
+ public enum Rating {
+ G,
+ PG,
+ R,
+ UNRATED,
+ PG13
+ }
+
+**1990** NC-17 is added
+
+ public enum Rating {
+ G,
+ PG,
+ R,
+ UNRATED,
+ PG13,
+ NC17
+ }
+
+If `EnumType.STRING` was used, then the enum could be reordered at anytime and would instead look as we have defined it originally with ratings starting at `G` and increasing in severity to `NC17` and eventually `UNRATED`. With `EnumType.ORDINAL` the logical ordering would not have withstood the test of time as new values were added.
+
+If the order of the enum values is significant to your code, avoid `EnumType.ORDINAL`
+
+## Unit Testing the JPA @Enumerated
+
+ public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer container = EJBContainer.createEJBContainer(p);
+ final Context context = container.getContext();
+
+ final Movies movies = (Movies) context.lookup("java:global/jpa-scratch/Movies");
+
+ movies.addMovie(new Movie("James Frawley", "The Muppet Movie", 1979, Rating.G));
+ movies.addMovie(new Movie("Jim Henson", "The Great Muppet Caper", 1981, Rating.G));
+ movies.addMovie(new Movie("Frank Oz", "The Muppets Take Manhattan", 1984, Rating.G));
+ movies.addMovie(new Movie("James Bobin", "The Muppets", 2011, Rating.PG));
+
+ assertEquals("List.size()", 4, movies.getMovies().size());
+
+ assertEquals("List.size()", 3, movies.findByRating(Rating.G).size());
+
+ assertEquals("List.size()", 1, movies.findByRating(Rating.PG).size());
+
+ assertEquals("List.size()", 0, movies.findByRating(Rating.R).size());
+
+ container.close();
+ }
+ }
+
+# Running
+
+To run the example via maven:
+
+ cd jpa-enumerated
+ mvn clean install
+
+Which will generate output similar to the following:
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.jpa.enums.MoviesTest
+ Apache OpenEJB 4.0.0-beta-2 build: 20120115-08:26
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/openejb/examples/jpa-enumerated
+ INFO - openejb.base = /Users/dblevins/openejb/examples/jpa-enumerated
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/openejb/examples/jpa-enumerated/target/classes
+ INFO - Beginning load: /Users/dblevins/openejb/examples/jpa-enumerated/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/openejb/examples/jpa-enumerated
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.jpa.enums.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/openejb/examples/jpa-enumerated" loaded.
+ INFO - Assembling app: /Users/dblevins/openejb/examples/jpa-enumerated
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 406ms
+ INFO - Jndi(name="java:global/jpa-enumerated/Movies!org.superbiz.jpa.enums.Movies")
+ INFO - Jndi(name="java:global/jpa-enumerated/Movies")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Deployed Application(path=/Users/dblevins/openejb/examples/jpa-enumerated)
+ INFO - Undeploying app: /Users/dblevins/openejb/examples/jpa-enumerated
+ INFO - Closing DataSource: movieDatabase
+ INFO - Closing DataSource: movieDatabaseNonJta
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.831 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
diff --git a/content/examples/jpa-enumerated/build.xml b/content/examples/jpa-enumerated/build.xml
new file mode 100755
index 0000000..3e4c294
--- /dev/null
+++ b/content/examples/jpa-enumerated/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 18:48:17 -0600 (Sun, 29 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/jpa-enumerated/pom.xml b/content/examples/jpa-enumerated/pom.xml
new file mode 100755
index 0000000..efce395
--- /dev/null
+++ b/content/examples/jpa-enumerated/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 18:48:17 -0600 (Sun, 29 Jan 2012) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>jpa-enumerated</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: JPA @Enumerated</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/jpa-enumerated/src/main/java/org/superbiz/jpa/enums/Movie.java b/content/examples/jpa-enumerated/src/main/java/org/superbiz/jpa/enums/Movie.java
new file mode 100755
index 0000000..90ed7bc
--- /dev/null
+++ b/content/examples/jpa-enumerated/src/main/java/org/superbiz/jpa/enums/Movie.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jpa.enums;
+
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue
+ private int id;
+ private String director;
+ private String title;
+ private int year;
+
+ @Enumerated(EnumType.STRING)
+ private Rating rating;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year, Rating rating) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ this.rating = rating;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public Rating getRating() {
+ return rating;
+ }
+
+ public void setRating(Rating rating) {
+ this.rating = rating;
+ }
+}
diff --git a/content/examples/jpa-enumerated/src/main/java/org/superbiz/jpa/enums/Movies.java b/content/examples/jpa-enumerated/src/main/java/org/superbiz/jpa/enums/Movies.java
new file mode 100755
index 0000000..5ea03d4
--- /dev/null
+++ b/content/examples/jpa-enumerated/src/main/java/org/superbiz/jpa/enums/Movies.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jpa.enums;
+
+//START SNIPPET: code
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> findByRating(Rating rating) {
+ final Query query = entityManager.createQuery("SELECT m FROM Movie as m WHERE m.rating = :rating");
+ query.setParameter("rating", rating);
+ return query.getResultList();
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/jpa-enumerated/src/main/java/org/superbiz/jpa/enums/Rating.java b/content/examples/jpa-enumerated/src/main/java/org/superbiz/jpa/enums/Rating.java
new file mode 100755
index 0000000..339c526
--- /dev/null
+++ b/content/examples/jpa-enumerated/src/main/java/org/superbiz/jpa/enums/Rating.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jpa.enums;
+
+public enum Rating {
+ G,
+ PG,
+ PG13,
+ R,
+ NC17,
+ UNRATED
+}
diff --git a/content/examples/jpa-enumerated/src/main/resources/META-INF/persistence.xml b/content/examples/jpa-enumerated/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..6632e3a
--- /dev/null
+++ b/content/examples/jpa-enumerated/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- START SNIPPET: code -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.jpa.enums.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
+ <!-- END SNIPPET: code -->
diff --git a/content/examples/jpa-enumerated/src/test/java/org/superbiz/jpa/enums/MoviesTest.java b/content/examples/jpa-enumerated/src/test/java/org/superbiz/jpa/enums/MoviesTest.java
new file mode 100755
index 0000000..82eaebd
--- /dev/null
+++ b/content/examples/jpa-enumerated/src/test/java/org/superbiz/jpa/enums/MoviesTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jpa.enums;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.Properties;
+
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer container = EJBContainer.createEJBContainer(p);
+ final Context context = container.getContext();
+
+ final Movies movies = (Movies) context.lookup("java:global/jpa-enumerated/Movies");
+
+ movies.addMovie(new Movie("James Frawley", "The Muppet Movie", 1979, Rating.G));
+ movies.addMovie(new Movie("Jim Henson", "The Great Muppet Caper", 1981, Rating.G));
+ movies.addMovie(new Movie("Frank Oz", "The Muppets Take Manhattan", 1984, Rating.G));
+ movies.addMovie(new Movie("James Bobin", "The Muppets", 2011, Rating.PG));
+
+ assertEquals("List.size()", 4, movies.getMovies().size());
+
+ assertEquals("List.size()", 3, movies.findByRating(Rating.G).size());
+
+ assertEquals("List.size()", 1, movies.findByRating(Rating.PG).size());
+
+ assertEquals("List.size()", 0, movies.findByRating(Rating.R).size());
+
+ container.close();
+ }
+}
diff --git a/content/examples/jpa-hibernate.html b/content/examples/jpa-hibernate.html
new file mode 100644
index 0000000..463c46b
--- /dev/null
+++ b/content/examples/jpa-hibernate.html
@@ -0,0 +1,408 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/jpa-hibernate.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>JPA Hibernate</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example jpa-hibernate can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/jpa-hibernate" class="bare">https://github.com/apache/tomee/tree/master/examples/jpa-hibernate</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.h3jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.h3jpa;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence version="1.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="movie-unit">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.h3jpa;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+ Movies movies = (Movies) context.lookup("java:global/jpa-hibernate/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.h3jpa.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/jpa-hibernate
+INFO - openejb.base = /Users/dblevins/examples/jpa-hibernate
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/jpa-hibernate/target/classes
+INFO - Beginning load: /Users/dblevins/examples/jpa-hibernate/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/jpa-hibernate
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.h3jpa.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit, provider=org.hibernate.ejb.HibernatePersistence)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/jpa-hibernate" loaded.
+INFO - Assembling app: /Users/dblevins/examples/jpa-hibernate
+INFO - PersistenceUnit(name=movie-unit, provider=org.hibernate.ejb.HibernatePersistence) - provider time 631ms
+INFO - Jndi(name="java:global/jpa-hibernate/Movies!org.superbiz.injection.h3jpa.Movies")
+INFO - Jndi(name="java:global/jpa-hibernate/Movies")
+INFO - Jndi(name="java:global/EjbModule1235930463/org.superbiz.injection.h3jpa.MoviesTest!org.superbiz.injection.h3jpa.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1235930463/org.superbiz.injection.h3jpa.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.h3jpa.MoviesTest, ejb-name=org.superbiz.injection.h3jpa.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.h3jpa.MoviesTest, ejb-name=org.superbiz.injection.h3jpa.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/jpa-hibernate)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.22 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/jpa-hibernate.pdf b/content/examples/jpa-hibernate.pdf
new file mode 100644
index 0000000..2534399
--- /dev/null
+++ b/content/examples/jpa-hibernate.pdf
Binary files differ
diff --git a/content/examples/jpa-hibernate/README.md b/content/examples/jpa-hibernate/README.md
new file mode 100755
index 0000000..91e0c95
--- /dev/null
+++ b/content/examples/jpa-hibernate/README.md
@@ -0,0 +1,192 @@
+Title: JPA Hibernate
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Movie
+
+ package org.superbiz.injection.h3jpa;
+
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.GenerationType;
+ import javax.persistence.Id;
+
+ @Entity
+ public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection.h3jpa;
+
+ import javax.ejb.Stateful;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ @Stateful
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## persistence.xml
+
+ <persistence version="1.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="movie-unit">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+
+## MoviesTest
+
+ package org.superbiz.injection.h3jpa;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import java.util.List;
+ import java.util.Properties;
+
+ /**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+ Movies movies = (Movies) context.lookup("java:global/jpa-hibernate/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.h3jpa.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/jpa-hibernate
+ INFO - openejb.base = /Users/dblevins/examples/jpa-hibernate
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/jpa-hibernate/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/jpa-hibernate/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/jpa-hibernate
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.h3jpa.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit, provider=org.hibernate.ejb.HibernatePersistence)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/jpa-hibernate" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/jpa-hibernate
+ INFO - PersistenceUnit(name=movie-unit, provider=org.hibernate.ejb.HibernatePersistence) - provider time 631ms
+ INFO - Jndi(name="java:global/jpa-hibernate/Movies!org.superbiz.injection.h3jpa.Movies")
+ INFO - Jndi(name="java:global/jpa-hibernate/Movies")
+ INFO - Jndi(name="java:global/EjbModule1235930463/org.superbiz.injection.h3jpa.MoviesTest!org.superbiz.injection.h3jpa.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1235930463/org.superbiz.injection.h3jpa.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.h3jpa.MoviesTest, ejb-name=org.superbiz.injection.h3jpa.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.h3jpa.MoviesTest, ejb-name=org.superbiz.injection.h3jpa.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/jpa-hibernate)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.22 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/jpa-hibernate/pom.xml b/content/examples/jpa-hibernate/pom.xml
new file mode 100755
index 0000000..0a75809
--- /dev/null
+++ b/content/examples/jpa-hibernate/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>jpa-hibernate</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: JPA with Hibernate</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- openejb (with hibernate) container for running tests -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core-hibernate</artifactId>
+ <version>4.7.1</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movie.java b/content/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movie.java
new file mode 100755
index 0000000..6135344
--- /dev/null
+++ b/content/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movie.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.h3jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movies.java b/content/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movies.java
new file mode 100755
index 0000000..62624f5
--- /dev/null
+++ b/content/examples/jpa-hibernate/src/main/java/org/superbiz/injection/h3jpa/Movies.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.h3jpa;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+}
diff --git a/content/examples/jpa-hibernate/src/main/resources/META-INF/persistence.xml b/content/examples/jpa-hibernate/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..77aba69
--- /dev/null
+++ b/content/examples/jpa-hibernate/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="1.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="movie-unit">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/jpa-hibernate/src/test/java/org/superbiz/injection/h3jpa/MoviesTest.java b/content/examples/jpa-hibernate/src/test/java/org/superbiz/injection/h3jpa/MoviesTest.java
new file mode 100755
index 0000000..556840b
--- /dev/null
+++ b/content/examples/jpa-hibernate/src/test/java/org/superbiz/injection/h3jpa/MoviesTest.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.h3jpa;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final Context context = EJBContainer.createEJBContainer(p).getContext();
+ Movies movies = (Movies) context.lookup("java:global/jpa-hibernate/Movies");
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+}
diff --git a/content/examples/jsf-cdi-and-ejb.html b/content/examples/jsf-cdi-and-ejb.html
new file mode 100644
index 0000000..8365b24
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb.html
@@ -0,0 +1,499 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/jsf-cdi-and-ejb.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>JSF-CDI-EJB</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example jsf-cdi-and-ejb can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/jsf-cdi-and-ejb" class="bare">https://github.com/apache/tomee/tree/master/examples/jsf-cdi-and-ejb</a></p>
+</div>
+<div class="paragraph">
+<p>The simple application contains a CDI managed bean <code>CalculatorBean</code>, which uses the <code>Calculator</code> EJB to add two numbers
+and display the results to the user. The EJB is injected in the managed bean using @Inject annotation.</p>
+</div>
+<div class="paragraph">
+<p>You could run this in the latest Apache TomEE <a href="https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/">snapshot</a></p>
+</div>
+<div class="paragraph">
+<p>The complete source code is below but lets break down to look at some smaller snippets and see how it works.</p>
+</div>
+<div class="paragraph">
+<p>A little note on the setup:</p>
+</div>
+<div class="paragraph">
+<p>As for the libraries, myfaces-api and myfaces-impl are provided in tomee/lib and hence they should not be a part of the
+war. In maven terms, they would be with scope 'provided'</p>
+</div>
+<div class="paragraph">
+<p>Also note that we use servlet 2.5 declaration in web.xml
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ <a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"" class="bare">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"</a>
+ version="2.5"></p>
+</div>
+<div class="paragraph">
+<p>And we use 2.0 version of faces-config</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0"></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>To make this a cdi-aware-archive (i.e bean archive) an empty beans.xml is added in WEB-INF</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><?xml version="1.0" encoding="UTF-8"?></pre>
+</div>
+</div>
+<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 class="paragraph">
+<p>We’ll first declare the FacesServlet in the web.xml</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+</servlet></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>FacesServlet acts as the master controller.</p>
+</div>
+<div class="paragraph">
+<p>We’ll then create the calculator.xhtml file.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><h:outputText value='Enter first number'/>
+<h:inputText value='#{calculatorBean.x}'/>
+<h:outputText value='Enter second number'/>
+<h:inputText value='#{calculatorBean.y}'/>
+<h:commandButton action="#{calculatorBean.add}" value="Add"/></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Notice how we’ve used the bean here. By default, the bean name would be the simple name of the bean
+class with the first letter in lower case.</p>
+</div>
+<div class="paragraph">
+<p>We’ve annotated the <code>CalculatorBean</code> with <code>@RequestScoped</code>.
+So when a request comes in, the bean is instantiated and placed in the request scope.</p>
+</div>
+<div class="paragraph">
+<p><h:inputText value='#{calculatorBean.x}'/></p>
+</div>
+<div class="paragraph">
+<p>Here, getX() method of calculatorBean is invoked and the resulting value is displayed.
+x being a Double, we rightly should see 0.0 displayed.</p>
+</div>
+<div class="paragraph">
+<p>When you change the value and submit the form, these entered values are bound using the setters
+in the bean and then the commandButton-action method is invoked.</p>
+</div>
+<div class="paragraph">
+<p>In this case, CalculatorBean#add() is invoked.</p>
+</div>
+<div class="paragraph">
+<p>Calculator#add() delegates the work to the ejb, gets the result, stores it
+and then returns what view is to be rendered.</p>
+</div>
+<div class="paragraph">
+<p>The return value "success" is checked up in faces-config navigation-rules
+and the respective page is rendered.</p>
+</div>
+<div class="paragraph">
+<p>In our case, 'result.xhtml' page is rendered where
+use EL and display the result from the request-scoped <code>calculatorBean</code>.</p>
+</div>
+</div>
+</div>
+<h1 id="_source_code" class="sect0">Source Code</h1>
+<div class="sect1">
+<h2 id="_calculatorbean">CalculatorBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+import javax.inject.Inject;
+
+@RequestScoped
+@Named
+public class CalculatorBean {
+ @Inject
+ Calculator calculator;
+ private double x;
+ private double y;
+ private double result;
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getResult() {
+ return result;
+ }
+
+ public void setResult(double result) {
+ this.result = result;
+ }
+
+ public String add() {
+ result = calculator.add(x, y);
+ return "success";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculator">Calculator</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.jsf;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class Calculator{
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_web_xml" class="sect0">web.xml</h1>
+<div class="paragraph">
+<p><?xml version="1.0"?></p>
+</div>
+<div class="paragraph">
+<p><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ <a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"" class="bare">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"</a>
+ version="2.5"></p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><description>MyProject web.xml</description></pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><!-- Faces Servlet -->
+<servlet></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><servlet-name>Faces Servlet</servlet-name>
+<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+<load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+<servlet-name>Faces Servlet</servlet-name>
+<url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+<welcome-file>index.jsp</welcome-file>
+<welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
+
+
+#Calculator.xhtml
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+
+<h:body bgcolor="white">
+<f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+ </h:panelGrid>
+ </h:form>
+</f:view>
+</h:body>
+</html>
+
+
+ #Result.xhtml
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+<h:body>
+<f:view>
+<h:form id="mainForm">
+ <h2><h:outputText value="Result of adding #{calculatorBean.x} and #{calculatorBean.y} is #{calculatorBean.result }"/></h2>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+</h:form>
+</f:view>
+</h:body>
+</html>
+
+ #faces-config.xml
+
+ <?xml version="1.0"?>
+ <faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <navigation-rule>
+ <from-view-id>/calculator.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/result.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/result.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/calculator.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ </faces-config></code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/jsf-cdi-and-ejb.pdf b/content/examples/jsf-cdi-and-ejb.pdf
new file mode 100644
index 0000000..e64ab46
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb.pdf
Binary files differ
diff --git a/content/examples/jsf-cdi-and-ejb/README.md b/content/examples/jsf-cdi-and-ejb/README.md
new file mode 100755
index 0000000..5b1b68d
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/README.md
@@ -0,0 +1,252 @@
+Title: JSF-CDI-EJB
+
+The simple application contains a CDI managed bean `CalculatorBean`, which uses the `Calculator` EJB to add two numbers
+and display the results to the user. The EJB is injected in the managed bean using @Inject annotation.
+
+You could run this in the latest Apache TomEE [snapshot](https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/)
+
+The complete source code is below but lets break down to look at some smaller snippets and see how it works.
+
+
+A little note on the setup:
+
+As for the libraries, myfaces-api and myfaces-impl are provided in tomee/lib and hence they should not be a part of the
+war. In maven terms, they would be with scope 'provided'
+
+Also note that we use servlet 2.5 declaration in web.xml
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+And we use 2.0 version of faces-config
+
+ <faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+To make this a cdi-aware-archive (i.e bean archive) an empty beans.xml is added in WEB-INF
+
+ <?xml version="1.0" encoding="UTF-8"?>
+
+ <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>
+
+We'll first declare the FacesServlet in the web.xml
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+FacesServlet acts as the master controller.
+
+We'll then create the calculator.xhtml file.
+
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+
+Notice how we've used the bean here. By default, the bean name would be the simple name of the bean
+class with the first letter in lower case.
+
+We've annotated the `CalculatorBean` with `@RequestScoped`.
+So when a request comes in, the bean is instantiated and placed in the request scope.
+
+<h:inputText value='#{calculatorBean.x}'/>
+
+Here, getX() method of calculatorBean is invoked and the resulting value is displayed.
+x being a Double, we rightly should see 0.0 displayed.
+
+When you change the value and submit the form, these entered values are bound using the setters
+in the bean and then the commandButton-action method is invoked.
+
+In this case, CalculatorBean#add() is invoked.
+
+Calculator#add() delegates the work to the ejb, gets the result, stores it
+and then returns what view is to be rendered.
+
+The return value "success" is checked up in faces-config navigation-rules
+and the respective page is rendered.
+
+In our case, 'result.xhtml' page is rendered where
+use EL and display the result from the request-scoped `calculatorBean`.
+
+#Source Code
+
+## CalculatorBean
+
+ import javax.enterprise.context.RequestScoped;
+ import javax.inject.Named;
+ import javax.inject.Inject;
+
+ @RequestScoped
+ @Named
+ public class CalculatorBean {
+ @Inject
+ Calculator calculator;
+ private double x;
+ private double y;
+ private double result;
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getResult() {
+ return result;
+ }
+
+ public void setResult(double result) {
+ this.result = result;
+ }
+
+ public String add() {
+ result = calculator.add(x, y);
+ return "success";
+ }
+ }
+
+## Calculator
+
+ package org.superbiz.jsf;
+
+ import javax.ejb.Stateless;
+
+ @Stateless
+ public class Calculator{
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+ }
+
+
+#web.xml
+
+<?xml version="1.0"?>
+
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <description>MyProject web.xml</description>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
+
+
+#Calculator.xhtml
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+
+<h:body bgcolor="white">
+ <f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+</h:body>
+</html>
+
+
+ #Result.xhtml
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+<h:body>
+<f:view>
+ <h:form id="mainForm">
+ <h2><h:outputText value="Result of adding #{calculatorBean.x} and #{calculatorBean.y} is #{calculatorBean.result }"/></h2>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+ </h:form>
+</f:view>
+</h:body>
+</html>
+
+ #faces-config.xml
+
+ <?xml version="1.0"?>
+ <faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <navigation-rule>
+ <from-view-id>/calculator.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/result.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/result.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/calculator.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ </faces-config>
\ No newline at end of file
diff --git a/content/examples/jsf-cdi-and-ejb/pom.xml b/content/examples/jsf-cdi-and-ejb/pom.xml
new file mode 100755
index 0000000..691a446
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz.jsf</groupId>
+ <artifactId>jsf-cdi-and-ejb</artifactId>
+ <packaging>war</packaging>
+ <name>OpenEJB :: Web Examples :: JSF - CDI and EJB</name>
+ <version>1.1.1-SNAPSHOT</version>
+ <url>http://openejb.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <finalName>jsf-cdi-and-ejb</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tomcat.maven</groupId>
+ <artifactId>tomcat7-maven-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <url>http://localhost:8080/manager/html
+ </url>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots/>
+ <id>apache-maven-snapshots</id>
+ <url>http://repository.apache.org/snapshots/
+ </url>
+ </repository>
+ <repository>
+ <id>java.net</id>
+ <url>http://download.java.net/maven/1</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>2.1.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <version>2.1.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.tomahawk</groupId>
+ <artifactId>tomahawk20</artifactId>
+ <version>1.1.13</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xmlParserAPIs</artifactId>
+ <groupId>xml-apis</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java b/content/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java
new file mode 100755
index 0000000..109b6e6
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java
@@ -0,0 +1,29 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jsf;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class Calculator {
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+
+}
diff --git a/content/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java b/content/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
new file mode 100755
index 0000000..757378a
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.superbiz.jsf;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@RequestScoped
+@Named
+public class CalculatorBean {
+
+ @Inject
+ Calculator calculator;
+ private double x;
+ private double y;
+ private double result;
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getResult() {
+ return result;
+ }
+
+ public void setResult(double result) {
+ this.result = result;
+ }
+
+ public String add() {
+ result = calculator.add(x, y);
+ return "success";
+ }
+}
\ No newline at end of file
diff --git a/content/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/beans.xml b/content/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/beans.xml
new file mode 100755
index 0000000..084709d
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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>
\ No newline at end of file
diff --git a/content/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/faces-config.xml b/content/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100755
index 0000000..ede89f1
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <navigation-rule>
+ <from-view-id>/calculator.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/result.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/result.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/calculator.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+</faces-config>
\ No newline at end of file
diff --git a/content/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/web.xml b/content/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..def607c
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <description>MyProject web.xml</description>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/content/examples/jsf-cdi-and-ejb/src/main/webapp/calculator.xhtml b/content/examples/jsf-cdi-and-ejb/src/main/webapp/calculator.xhtml
new file mode 100755
index 0000000..40979b1
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/src/main/webapp/calculator.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+
+<h:body bgcolor="white">
+ <f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+</h:body>
+</html>
diff --git a/content/examples/jsf-cdi-and-ejb/src/main/webapp/index.jsp b/content/examples/jsf-cdi-and-ejb/src/main/webapp/index.jsp
new file mode 100755
index 0000000..5b2b11b
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/src/main/webapp/index.jsp
@@ -0,0 +1,22 @@
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+-->
+<%@ page session="false" %>
+<%
+ response.sendRedirect("calculator.jsf");
+%>
\ No newline at end of file
diff --git a/content/examples/jsf-cdi-and-ejb/src/main/webapp/result.xhtml b/content/examples/jsf-cdi-and-ejb/src/main/webapp/result.xhtml
new file mode 100755
index 0000000..02309ef
--- /dev/null
+++ b/content/examples/jsf-cdi-and-ejb/src/main/webapp/result.xhtml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+<h:body>
+ <f:view>
+ <h:form id="mainForm">
+ <h2>Result of adding #{calculatorBean.x} and #{calculatorBean.y} is #{calculatorBean.result }</h2>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+ </h:form>
+ </f:view>
+</h:body>
+</html>
\ No newline at end of file
diff --git a/content/examples/jsf-managedBean-and-ejb.html b/content/examples/jsf-managedBean-and-ejb.html
new file mode 100644
index 0000000..0eb9fe0
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb.html
@@ -0,0 +1,468 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/jsf-managedBean-and-ejb.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>JSF Application that uses managed-bean and ejb</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example jsf-managedBean-and-ejb can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/jsf-managedBean-and-ejb" class="bare">https://github.com/apache/tomee/tree/master/examples/jsf-managedBean-and-ejb</a></p>
+</div>
+<div class="paragraph">
+<p>This is a simple web-app showing how to use dependency injection in JSF managed beans using TomEE.</p>
+</div>
+<div class="paragraph">
+<p>It contains a Local Stateless session bean <code>CalculatorImpl</code> which adds two numbers and returns the result.
+The application also contains a JSF managed bean <code>CalculatorBean</code>, which uses the EJB to add two numbers
+and display the results to the user. The EJB is injected in the managed bean using <code>@EJB</code> annotation.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_a_little_note_on_the_setup">A little note on the setup:</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>You could run this in the latest Apache TomEE <a href="https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/">snapshot</a></p>
+</div>
+<div class="paragraph">
+<p>As for the libraries, myfaces-api and myfaces-impl are provided in tomee/lib and hence they should not be a part of the
+war. In maven terms, they would be with scope 'provided'</p>
+</div>
+<div class="paragraph">
+<p>Also note that we use servlet 2.5 declaration in web.xml</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns="http://java.sun.com/xml/ns/javaee"
+xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+version="2.5">
+
+And we use 2.0 version of faces-config
+
+ <faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+
+The complete source code is provided below but let's break down to look at some smaller snippets and see how it works.
+
+We'll first declare the `FacesServlet` in the `web.xml`
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+`FacesServlet` acts as the master controller.
+
+We'll then create the `calculator.xhtml` file.
+
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+
+
+Notice how we've use the bean here.
+By default it is the simple class name of the managed bean.
+
+When a request comes in, the bean is instantiated and placed in the appropriate scope.
+By default, the bean is placed in the request scope.
+
+ <h:inputText value='#{calculatorBean.x}'/>
+
+Here, getX() method of calculatorBean is invoked and the resulting value is displayed.
+x being a Double, we rightly should see 0.0 displayed.
+
+When you change the value and submit the form, these entered values are bound using the setters
+in the bean and then the commandButton-action method is invoked.
+
+In this case, `CalculatorBean#add()` is invoked.
+
+`Calculator#add()` delegates the work to the ejb, gets the result, stores it
+and then instructs what view is to be rendered.
+
+You're right. The return value "success" is checked up in faces-config navigation-rules
+and the respective page is rendered.
+
+In our case, `result.xhtml` page is rendered.
+
+The request scoped `calculatorBean` is available here, and we use EL to display the values.
+
+## Source
+
+## Calculator
+
+package org.superbiz.jsf;
+
+import javax.ejb.Local;
+
+@Local
+public interface Calculator {
+ public double add(double x, double y);
+}
+
+
+## CalculatorBean
+
+package org.superbiz.jsf;
+
+import javax.ejb.EJB;
+import javax.faces.bean.ManagedBean;
+
+@ManagedBean
+public class CalculatorBean {
+ @EJB
+ Calculator calculator;
+ private double x;
+ private double y;
+ private double result;
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getResult() {
+ return result;
+ }
+
+ public void setResult(double result) {
+ this.result = result;
+ }
+
+ public String add() {
+ result = calculator.add(x, y);
+ return "success";
+ }
+}
+
+## CalculatorImpl
+
+package org.superbiz.jsf;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class CalculatorImpl implements Calculator {
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+}
+
+
+# web.xml
+
+<?xml version="1.0"?>
+
+ <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <description>MyProject web.xml</description>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+ </web-app></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculator_xhtml">Calculator.xhtml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+xmlns:f="http://java.sun.com/jsf/core"
+xmlns:h="http://java.sun.com/jsf/html">
+
+
+<h:body bgcolor="white">
+ <f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+</h:body>
+</html>
+
+
+##Result.xhtml
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+xmlns:f="http://java.sun.com/jsf/core"
+xmlns:h="http://java.sun.com/jsf/html">
+
+<h:body>
+ <f:view>
+ <h:form id="mainForm">
+ <h2><h:outputText value="Result of adding #{calculatorBean.x} and #{calculatorBean.y} is #{calculatorBean.result }"/></h2>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+ </h:form>
+ </f:view>
+</h:body>
+</html>
+
+#faces-config.xml
+
+<?xml version="1.0"?>
+<faces-config 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/web-facesconfig_2_0.xsd"
+version="2.0">
+
+<navigation-rule>
+ <from-view-id>/calculator.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/result.xhtml</to-view-id>
+ </navigation-case>
+</navigation-rule>
+
+<navigation-rule>
+ <from-view-id>/result.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/calculator.xhtml</to-view-id>
+ </navigation-case>
+</navigation-rule>
+</faces-config></code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/jsf-managedBean-and-ejb.pdf b/content/examples/jsf-managedBean-and-ejb.pdf
new file mode 100644
index 0000000..8a25019
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb.pdf
Binary files differ
diff --git a/content/examples/jsf-managedBean-and-ejb/README.md b/content/examples/jsf-managedBean-and-ejb/README.md
new file mode 100755
index 0000000..76241d2
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/README.md
@@ -0,0 +1,261 @@
+Title: JSF Application that uses managed-bean and ejb
+
+This is a simple web-app showing how to use dependency injection in JSF managed beans using TomEE.
+
+It contains a Local Stateless session bean `CalculatorImpl` which adds two numbers and returns the result.
+The application also contains a JSF managed bean `CalculatorBean`, which uses the EJB to add two numbers
+and display the results to the user. The EJB is injected in the managed bean using `@EJB` annotation.
+
+
+## A little note on the setup:
+
+You could run this in the latest Apache TomEE [snapshot](https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/)
+
+As for the libraries, myfaces-api and myfaces-impl are provided in tomee/lib and hence they should not be a part of the
+war. In maven terms, they would be with scope 'provided'
+
+Also note that we use servlet 2.5 declaration in web.xml
+
+ <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+And we use 2.0 version of faces-config
+
+ <faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+
+The complete source code is provided below but let's break down to look at some smaller snippets and see how it works.
+
+We'll first declare the `FacesServlet` in the `web.xml`
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+`FacesServlet` acts as the master controller.
+
+We'll then create the `calculator.xhtml` file.
+
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+
+
+Notice how we've use the bean here.
+By default it is the simple class name of the managed bean.
+
+When a request comes in, the bean is instantiated and placed in the appropriate scope.
+By default, the bean is placed in the request scope.
+
+ <h:inputText value='#{calculatorBean.x}'/>
+
+Here, getX() method of calculatorBean is invoked and the resulting value is displayed.
+x being a Double, we rightly should see 0.0 displayed.
+
+When you change the value and submit the form, these entered values are bound using the setters
+in the bean and then the commandButton-action method is invoked.
+
+In this case, `CalculatorBean#add()` is invoked.
+
+`Calculator#add()` delegates the work to the ejb, gets the result, stores it
+and then instructs what view is to be rendered.
+
+You're right. The return value "success" is checked up in faces-config navigation-rules
+and the respective page is rendered.
+
+In our case, `result.xhtml` page is rendered.
+
+The request scoped `calculatorBean` is available here, and we use EL to display the values.
+
+## Source
+
+## Calculator
+
+ package org.superbiz.jsf;
+
+ import javax.ejb.Remote;
+
+ @Remote
+ public interface Calculator {
+ public double add(double x, double y);
+ }
+
+
+## CalculatorBean
+
+ package org.superbiz.jsf;
+
+ import javax.ejb.EJB;
+ import javax.faces.bean.ManagedBean;
+
+ @ManagedBean
+ public class CalculatorBean {
+ @EJB
+ Calculator calculator;
+ private double x;
+ private double y;
+ private double result;
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getResult() {
+ return result;
+ }
+
+ public void setResult(double result) {
+ this.result = result;
+ }
+
+ public String add() {
+ result = calculator.add(x, y);
+ return "success";
+ }
+ }
+
+## CalculatorImpl
+
+ package org.superbiz.jsf;
+
+ import javax.ejb.Stateless;
+
+ @Stateless
+ public class CalculatorImpl implements Calculator {
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+ }
+
+
+# web.xml
+
+ <?xml version="1.0"?>
+
+ <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <description>MyProject web.xml</description>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+ </web-app>
+
+
+##Calculator.xhtml
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+
+ <h:body bgcolor="white">
+ <f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+ </h:body>
+ </html>
+
+
+##Result.xhtml
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <h:body>
+ <f:view>
+ <h:form id="mainForm">
+ <h2><h:outputText value="Result of adding #{calculatorBean.x} and #{calculatorBean.y} is #{calculatorBean.result }"/></h2>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+ </h:form>
+ </f:view>
+ </h:body>
+ </html>
+
+#faces-config.xml
+
+ <?xml version="1.0"?>
+ <faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <navigation-rule>
+ <from-view-id>/calculator.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/result.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/result.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/calculator.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ </faces-config>
\ No newline at end of file
diff --git a/content/examples/jsf-managedBean-and-ejb/pom.xml b/content/examples/jsf-managedBean-and-ejb/pom.xml
new file mode 100755
index 0000000..98efee3
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/pom.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz.jsf</groupId>
+ <artifactId>jsf-managedBean-and-ejb</artifactId>
+ <packaging>war</packaging>
+ <name>OpenEJB :: Web Examples :: JSF - ManangedBean and EJB</name>
+ <version>1.1.1-SNAPSHOT</version>
+ <url>http://openejb.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <finalName>jsf-managedBean-and-ejb</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots/>
+ <id>apache-maven-snapshots</id>
+ <url>http://repository.apache.org/snapshots/
+ </url>
+ </repository>
+ <repository>
+ <id>java.net</id>
+ <url>http://download.java.net/maven/1</url>
+ </repository>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>2.1.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <version>2.1.15</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.tomahawk</groupId>
+ <artifactId>tomahawk20</artifactId>
+ <version>1.1.13</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xmlParserAPIs</artifactId>
+ <groupId>xml-apis</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java b/content/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java
new file mode 100755
index 0000000..4acd132
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/Calculator.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jsf;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface Calculator {
+
+ public double add(double x, double y);
+}
diff --git a/content/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java b/content/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
new file mode 100755
index 0000000..a2a37fd
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorBean.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.superbiz.jsf;
+
+import javax.ejb.EJB;
+import javax.faces.bean.ManagedBean;
+
+@ManagedBean
+public class CalculatorBean {
+
+ @EJB
+ Calculator calculator;
+ private double x;
+ private double y;
+ private double result;
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getResult() {
+ return result;
+ }
+
+ public void setResult(double result) {
+ this.result = result;
+ }
+
+ public String add() {
+ result = calculator.add(x, y);
+ return "success";
+ }
+}
\ No newline at end of file
diff --git a/content/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java b/content/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java
new file mode 100755
index 0000000..59ce782
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/src/main/java/org/superbiz/jsf/CalculatorImpl.java
@@ -0,0 +1,29 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jsf;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class CalculatorImpl implements Calculator {
+
+ public double add(double x, double y) {
+ return x + y;
+ }
+
+}
diff --git a/content/examples/jsf-managedBean-and-ejb/src/main/webapp/WEB-INF/faces-config.xml b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100755
index 0000000..ede89f1
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <navigation-rule>
+ <from-view-id>/calculator.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/result.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/result.xhtml</from-view-id>
+ <navigation-case>
+ <from-outcome>back</from-outcome>
+ <to-view-id>/calculator.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+</faces-config>
\ No newline at end of file
diff --git a/content/examples/jsf-managedBean-and-ejb/src/main/webapp/WEB-INF/web.xml b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..def607c
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <description>MyProject web.xml</description>
+
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <!-- Welcome files -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
diff --git a/content/examples/jsf-managedBean-and-ejb/src/main/webapp/calculator.xhtml b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/calculator.xhtml
new file mode 100755
index 0000000..40979b1
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/calculator.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+
+<h:body bgcolor="white">
+ <f:view>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputText value='Enter first number'/>
+ <h:inputText value='#{calculatorBean.x}'/>
+ <h:outputText value='Enter second number'/>
+ <h:inputText value='#{calculatorBean.y}'/>
+ <h:commandButton action="#{calculatorBean.add}" value="Add"/>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+</h:body>
+</html>
diff --git a/content/examples/jsf-managedBean-and-ejb/src/main/webapp/index.jsp b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/index.jsp
new file mode 100755
index 0000000..5b2b11b
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/index.jsp
@@ -0,0 +1,22 @@
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+-->
+<%@ page session="false" %>
+<%
+ response.sendRedirect("calculator.jsf");
+%>
\ No newline at end of file
diff --git a/content/examples/jsf-managedBean-and-ejb/src/main/webapp/result.xhtml b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/result.xhtml
new file mode 100755
index 0000000..02309ef
--- /dev/null
+++ b/content/examples/jsf-managedBean-and-ejb/src/main/webapp/result.xhtml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+<h:body>
+ <f:view>
+ <h:form id="mainForm">
+ <h2>Result of adding #{calculatorBean.x} and #{calculatorBean.y} is #{calculatorBean.result }</h2>
+ <h:commandLink action="back">
+ <h:outputText value="Home"/>
+ </h:commandLink>
+ </h:form>
+ </f:view>
+</h:body>
+</html>
\ No newline at end of file
diff --git a/content/examples/lookup-of-ejbs-with-descriptor.html b/content/examples/lookup-of-ejbs-with-descriptor.html
new file mode 100644
index 0000000..2e20193
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor.html
@@ -0,0 +1,414 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/lookup-of-ejbs-with-descriptor.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Lookup Of Ejbs with Descriptor</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example lookup-of-ejbs-with-descriptor can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/lookup-of-ejbs-with-descriptor" class="bare">https://github.com/apache/tomee/tree/master/examples/lookup-of-ejbs-with-descriptor</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_bluebean">BlueBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.ejblookup;
+
+import javax.ejb.EJBException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+//START SNIPPET: code
+public class BlueBean implements Friend {
+
+ public String sayHello() {
+ return "Blue says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friend">Friend</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.ejblookup;
+
+/**
+ * This is an EJB 3 local business interface
+ * A local business interface may be annotated with the @Local
+ * annotation, but it's optional. A business interface which is
+ * not annotated with @Local or @Remote is assumed to be Local
+ * if the bean does not implement any other interfaces
+ */
+//START SNIPPET: code
+public interface Friend {
+
+ public String sayHello();
+
+ public String helloFromFriend();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_redbean">RedBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.ejblookup;
+
+import javax.ejb.EJBException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+//START SNIPPET: code
+public class RedBean implements Friend {
+
+ public String sayHello() {
+ return "Red says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar xmlns="http://java.sun.com/xml/ns/javaee">
+
+ <!-- Notice this changes the global jndi name -->
+ <module-name>wombat</module-name>
+
+ <enterprise-beans>
+
+ <session>
+ <ejb-name>BlueBean</ejb-name>
+ <business-local>org.superbiz.ejblookup.Friend</business-local>
+ <ejb-class>org.superbiz.ejblookup.BlueBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <ejb-local-ref>
+ <ejb-ref-name>myFriend</ejb-ref-name>
+ <local>org.superbiz.ejblookup.Friend</local>
+ <ejb-link>RedBean</ejb-link>
+ </ejb-local-ref>
+ </session>
+
+ <session>
+ <ejb-name>RedBean</ejb-name>
+ <business-local>org.superbiz.ejblookup.Friend</business-local>
+ <ejb-class>org.superbiz.ejblookup.RedBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <ejb-local-ref>
+ <ejb-ref-name>myFriend</ejb-ref-name>
+ <local>org.superbiz.ejblookup.Friend</local>
+ <ejb-link>BlueBean</ejb-link>
+ </ejb-local-ref>
+ </session>
+
+ </enterprise-beans>
+</ejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejbdependencytest">EjbDependencyTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.ejblookup;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+//START SNIPPET: code
+public class EjbDependencyTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ public void testRed() throws Exception {
+
+ Friend red = (Friend) context.lookup("java:global/wombat/RedBean");
+
+ assertNotNull(red);
+ assertEquals("Red says, Hello!", red.sayHello());
+ assertEquals("My friend Blue says, Hello!", red.helloFromFriend());
+ }
+
+ public void testBlue() throws Exception {
+
+ Friend blue = (Friend) context.lookup("java:global/wombat/BlueBean");
+
+ assertNotNull(blue);
+ assertEquals("Blue says, Hello!", blue.sayHello());
+ assertEquals("My friend Red says, Hello!", blue.helloFromFriend());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.ejblookup.EjbDependencyTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/lookup-of-ejbs-with-descriptor
+INFO - openejb.base = /Users/dblevins/examples/lookup-of-ejbs-with-descriptor
+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/lookup-of-ejbs-with-descriptor/target/classes
+INFO - Beginning load: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean BlueBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.ejblookup.EjbDependencyTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/lookup-of-ejbs-with-descriptor" loaded.
+INFO - Assembling app: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor
+INFO - Jndi(name="java:global/wombat/BlueBean!org.superbiz.ejblookup.Friend")
+INFO - Jndi(name="java:global/wombat/BlueBean")
+INFO - Jndi(name="java:global/wombat/RedBean!org.superbiz.ejblookup.Friend")
+INFO - Jndi(name="java:global/wombat/RedBean")
+INFO - Jndi(name="java:global/EjbModule136565368/org.superbiz.ejblookup.EjbDependencyTest!org.superbiz.ejblookup.EjbDependencyTest")
+INFO - Jndi(name="java:global/EjbModule136565368/org.superbiz.ejblookup.EjbDependencyTest")
+INFO - Created Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/lookup-of-ejbs-with-descriptor)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.679 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/lookup-of-ejbs-with-descriptor.pdf b/content/examples/lookup-of-ejbs-with-descriptor.pdf
new file mode 100644
index 0000000..4216cde
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor.pdf
Binary files differ
diff --git a/content/examples/lookup-of-ejbs-with-descriptor/README.md b/content/examples/lookup-of-ejbs-with-descriptor/README.md
new file mode 100755
index 0000000..e3ecc39
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor/README.md
@@ -0,0 +1,192 @@
+Title: Lookup Of Ejbs with Descriptor
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## BlueBean
+
+ package org.superbiz.ejblookup;
+
+ import javax.ejb.EJBException;
+ import javax.naming.InitialContext;
+ import javax.naming.NamingException;
+
+ //START SNIPPET: code
+ public class BlueBean implements Friend {
+
+ public String sayHello() {
+ return "Blue says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+ }
+
+## Friend
+
+ package org.superbiz.ejblookup;
+
+ /**
+ * This is an EJB 3 local business interface
+ * A local business interface may be annotated with the @Local
+ * annotation, but it's optional. A business interface which is
+ * not annotated with @Local or @Remote is assumed to be Local
+ * if the bean does not implement any other interfaces
+ */
+ //START SNIPPET: code
+ public interface Friend {
+
+ public String sayHello();
+
+ public String helloFromFriend();
+ }
+
+## RedBean
+
+ package org.superbiz.ejblookup;
+
+ import javax.ejb.EJBException;
+ import javax.naming.InitialContext;
+ import javax.naming.NamingException;
+
+ //START SNIPPET: code
+ public class RedBean implements Friend {
+
+ public String sayHello() {
+ return "Red says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee">
+
+ <!-- Notice this changes the global jndi name -->
+ <module-name>wombat</module-name>
+
+ <enterprise-beans>
+
+ <session>
+ <ejb-name>BlueBean</ejb-name>
+ <business-local>org.superbiz.ejblookup.Friend</business-local>
+ <ejb-class>org.superbiz.ejblookup.BlueBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <ejb-local-ref>
+ <ejb-ref-name>myFriend</ejb-ref-name>
+ <local>org.superbiz.ejblookup.Friend</local>
+ <ejb-link>RedBean</ejb-link>
+ </ejb-local-ref>
+ </session>
+
+ <session>
+ <ejb-name>RedBean</ejb-name>
+ <business-local>org.superbiz.ejblookup.Friend</business-local>
+ <ejb-class>org.superbiz.ejblookup.RedBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <ejb-local-ref>
+ <ejb-ref-name>myFriend</ejb-ref-name>
+ <local>org.superbiz.ejblookup.Friend</local>
+ <ejb-link>BlueBean</ejb-link>
+ </ejb-local-ref>
+ </session>
+
+ </enterprise-beans>
+ </ejb-jar>
+
+
+## EjbDependencyTest
+
+ package org.superbiz.ejblookup;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+
+ //START SNIPPET: code
+ public class EjbDependencyTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ public void testRed() throws Exception {
+
+ Friend red = (Friend) context.lookup("java:global/wombat/RedBean");
+
+ assertNotNull(red);
+ assertEquals("Red says, Hello!", red.sayHello());
+ assertEquals("My friend Blue says, Hello!", red.helloFromFriend());
+ }
+
+ public void testBlue() throws Exception {
+
+ Friend blue = (Friend) context.lookup("java:global/wombat/BlueBean");
+
+ assertNotNull(blue);
+ assertEquals("Blue says, Hello!", blue.sayHello());
+ assertEquals("My friend Red says, Hello!", blue.helloFromFriend());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.ejblookup.EjbDependencyTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/lookup-of-ejbs-with-descriptor
+ INFO - openejb.base = /Users/dblevins/examples/lookup-of-ejbs-with-descriptor
+ 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/lookup-of-ejbs-with-descriptor/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean BlueBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.ejblookup.EjbDependencyTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/lookup-of-ejbs-with-descriptor" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor
+ INFO - Jndi(name="java:global/wombat/BlueBean!org.superbiz.ejblookup.Friend")
+ INFO - Jndi(name="java:global/wombat/BlueBean")
+ INFO - Jndi(name="java:global/wombat/RedBean!org.superbiz.ejblookup.Friend")
+ INFO - Jndi(name="java:global/wombat/RedBean")
+ INFO - Jndi(name="java:global/EjbModule136565368/org.superbiz.ejblookup.EjbDependencyTest!org.superbiz.ejblookup.EjbDependencyTest")
+ INFO - Jndi(name="java:global/EjbModule136565368/org.superbiz.ejblookup.EjbDependencyTest")
+ INFO - Created Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/lookup-of-ejbs-with-descriptor)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.679 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/lookup-of-ejbs-with-descriptor/build.xml b/content/examples/lookup-of-ejbs-with-descriptor/build.xml
new file mode 100755
index 0000000..51970b5
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1177449 $ $Date: 2011-09-30 00:26:03 +0200 (Fri, 30 Sep 2011) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-2"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/lookup-of-ejbs-with-descriptor/pom.xml b/content/examples/lookup-of-ejbs-with-descriptor/pom.xml
new file mode 100755
index 0000000..35c09e9
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>lookup-of-ejbs-with-descriptor</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: EJB Lookup with descriptor</name>
+ <properties>
+ <!--
+ - http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding
+ -->
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/BlueBean.java b/content/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/BlueBean.java
new file mode 100755
index 0000000..1006dd6
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/BlueBean.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ejblookup;
+
+import javax.ejb.EJBException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+//START SNIPPET: code
+public class BlueBean implements Friend {
+
+ public String sayHello() {
+ return "Blue says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/Friend.java b/content/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/Friend.java
new file mode 100755
index 0000000..33a88a4
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/Friend.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ejblookup;
+
+/**
+ * This is an EJB 3 local business interface
+ * A local business interface may be annotated with the @Local
+ * annotation, but it's optional. A business interface which is
+ * not annotated with @Local or @Remote is assumed to be Local
+ * if the bean does not implement any other interfaces
+ */
+//START SNIPPET: code
+public interface Friend {
+
+ public String sayHello();
+
+ public String helloFromFriend();
+
+}
+//END SNIPPET: code
diff --git a/content/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/RedBean.java b/content/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/RedBean.java
new file mode 100755
index 0000000..6f27003
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor/src/main/java/org/superbiz/ejblookup/RedBean.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ejblookup;
+
+import javax.ejb.EJBException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+//START SNIPPET: code
+public class RedBean implements Friend {
+
+ public String sayHello() {
+ return "Red says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+}
+//END SNIPPET: code
\ No newline at end of file
diff --git a/content/examples/lookup-of-ejbs-with-descriptor/src/main/resources/META-INF/ejb-jar.xml b/content/examples/lookup-of-ejbs-with-descriptor/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..e989693
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee">
+
+ <!-- Notice this changes the global jndi name -->
+ <module-name>wombat</module-name>
+
+ <enterprise-beans>
+
+ <session>
+ <ejb-name>BlueBean</ejb-name>
+ <business-local>org.superbiz.ejblookup.Friend</business-local>
+ <ejb-class>org.superbiz.ejblookup.BlueBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <ejb-local-ref>
+ <ejb-ref-name>myFriend</ejb-ref-name>
+ <local>org.superbiz.ejblookup.Friend</local>
+ <ejb-link>RedBean</ejb-link>
+ </ejb-local-ref>
+ </session>
+
+ <session>
+ <ejb-name>RedBean</ejb-name>
+ <business-local>org.superbiz.ejblookup.Friend</business-local>
+ <ejb-class>org.superbiz.ejblookup.RedBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ <ejb-local-ref>
+ <ejb-ref-name>myFriend</ejb-ref-name>
+ <local>org.superbiz.ejblookup.Friend</local>
+ <ejb-link>BlueBean</ejb-link>
+ </ejb-local-ref>
+ </session>
+
+ </enterprise-beans>
+</ejb-jar>
diff --git a/content/examples/lookup-of-ejbs-with-descriptor/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java b/content/examples/lookup-of-ejbs-with-descriptor/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java
new file mode 100755
index 0000000..7f119a9
--- /dev/null
+++ b/content/examples/lookup-of-ejbs-with-descriptor/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ejblookup;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+//START SNIPPET: code
+public class EjbDependencyTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ public void testRed() throws Exception {
+
+ Friend red = (Friend) context.lookup("java:global/wombat/RedBean");
+
+ assertNotNull(red);
+ assertEquals("Red says, Hello!", red.sayHello());
+ assertEquals("My friend Blue says, Hello!", red.helloFromFriend());
+
+ }
+
+ public void testBlue() throws Exception {
+
+ Friend blue = (Friend) context.lookup("java:global/wombat/BlueBean");
+
+ assertNotNull(blue);
+ assertEquals("Blue says, Hello!", blue.sayHello());
+ assertEquals("My friend Red says, Hello!", blue.helloFromFriend());
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/lookup-of-ejbs.html b/content/examples/lookup-of-ejbs.html
new file mode 100644
index 0000000..bf82612
--- /dev/null
+++ b/content/examples/lookup-of-ejbs.html
@@ -0,0 +1,381 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/lookup-of-ejbs.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Lookup Of Ejbs</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example lookup-of-ejbs can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/lookup-of-ejbs" class="bare">https://github.com/apache/tomee/tree/master/examples/lookup-of-ejbs</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_bluebean">BlueBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.ejblookup;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+//START SNIPPET: code
+@Stateless
+@EJB(beanInterface = Friend.class, beanName = "RedBean", name = "myFriend")
+public class BlueBean implements Friend {
+
+ public String sayHello() {
+ return "Blue says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_friend">Friend</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.ejblookup;
+
+import javax.ejb.Local;
+
+/**
+ * This is an EJB 3 local business interface
+ * A local business interface may be annotated with the @Local
+ * annotation, but it's optional. A business interface which is
+ * not annotated with @Local or @Remote is assumed to be Local
+ * if the bean does not implement any other interfaces
+ */
+//START SNIPPET: code
+@Local
+public interface Friend {
+
+ public String sayHello();
+
+ public String helloFromFriend();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_redbean">RedBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.ejblookup;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+//START SNIPPET: code
+@Stateless
+@EJB(beanInterface = Friend.class, beanName = "BlueBean", name = "myFriend")
+public class RedBean implements Friend {
+
+ public String sayHello() {
+ return "Red says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejbdependencytest">EjbDependencyTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.ejblookup;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+//START SNIPPET: code
+public class EjbDependencyTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ public void testRed() throws Exception {
+
+ Friend red = (Friend) context.lookup("java:global/lookup-of-ejbs/RedBean");
+
+ assertNotNull(red);
+ assertEquals("Red says, Hello!", red.sayHello());
+ assertEquals("My friend Blue says, Hello!", red.helloFromFriend());
+ }
+
+ public void testBlue() throws Exception {
+
+ Friend blue = (Friend) context.lookup("java:global/lookup-of-ejbs/BlueBean");
+
+ assertNotNull(blue);
+ assertEquals("Blue says, Hello!", blue.sayHello());
+ assertEquals("My friend Red says, Hello!", blue.helloFromFriend());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.ejblookup.EjbDependencyTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/lookup-of-ejbs
+INFO - openejb.base = /Users/dblevins/examples/lookup-of-ejbs
+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/lookup-of-ejbs/target/classes
+INFO - Beginning load: /Users/dblevins/examples/lookup-of-ejbs/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/lookup-of-ejbs
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean RedBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.ejblookup.EjbDependencyTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/lookup-of-ejbs" loaded.
+INFO - Assembling app: /Users/dblevins/examples/lookup-of-ejbs
+INFO - Jndi(name="java:global/lookup-of-ejbs/RedBean!org.superbiz.ejblookup.Friend")
+INFO - Jndi(name="java:global/lookup-of-ejbs/RedBean")
+INFO - Jndi(name="java:global/lookup-of-ejbs/BlueBean!org.superbiz.ejblookup.Friend")
+INFO - Jndi(name="java:global/lookup-of-ejbs/BlueBean")
+INFO - Jndi(name="java:global/EjbModule1374821456/org.superbiz.ejblookup.EjbDependencyTest!org.superbiz.ejblookup.EjbDependencyTest")
+INFO - Jndi(name="java:global/EjbModule1374821456/org.superbiz.ejblookup.EjbDependencyTest")
+INFO - Created Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/lookup-of-ejbs)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.267 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/lookup-of-ejbs.pdf b/content/examples/lookup-of-ejbs.pdf
new file mode 100644
index 0000000..fee13c6
--- /dev/null
+++ b/content/examples/lookup-of-ejbs.pdf
Binary files differ
diff --git a/content/examples/lookup-of-ejbs/README.md b/content/examples/lookup-of-ejbs/README.md
new file mode 100755
index 0000000..981ea56
--- /dev/null
+++ b/content/examples/lookup-of-ejbs/README.md
@@ -0,0 +1,164 @@
+Title: Lookup Of Ejbs
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## BlueBean
+
+ package org.superbiz.ejblookup;
+
+ import javax.ejb.EJB;
+ import javax.ejb.EJBException;
+ import javax.ejb.Stateless;
+ import javax.naming.InitialContext;
+ import javax.naming.NamingException;
+
+ //START SNIPPET: code
+ @Stateless
+ @EJB(beanInterface = Friend.class, beanName = "RedBean", name = "myFriend")
+ public class BlueBean implements Friend {
+
+ public String sayHello() {
+ return "Blue says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+ }
+
+## Friend
+
+ package org.superbiz.ejblookup;
+
+ import javax.ejb.Local;
+
+ /**
+ * This is an EJB 3 local business interface
+ * A local business interface may be annotated with the @Local
+ * annotation, but it's optional. A business interface which is
+ * not annotated with @Local or @Remote is assumed to be Local
+ * if the bean does not implement any other interfaces
+ */
+ //START SNIPPET: code
+ @Local
+ public interface Friend {
+
+ public String sayHello();
+
+ public String helloFromFriend();
+ }
+
+## RedBean
+
+ package org.superbiz.ejblookup;
+
+ import javax.ejb.EJB;
+ import javax.ejb.EJBException;
+ import javax.ejb.Stateless;
+ import javax.naming.InitialContext;
+ import javax.naming.NamingException;
+
+ //START SNIPPET: code
+ @Stateless
+ @EJB(beanInterface = Friend.class, beanName = "BlueBean", name = "myFriend")
+ public class RedBean implements Friend {
+
+ public String sayHello() {
+ return "Red says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+ }
+
+## EjbDependencyTest
+
+ package org.superbiz.ejblookup;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+
+ //START SNIPPET: code
+ public class EjbDependencyTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ public void testRed() throws Exception {
+
+ Friend red = (Friend) context.lookup("java:global/lookup-of-ejbs/RedBean");
+
+ assertNotNull(red);
+ assertEquals("Red says, Hello!", red.sayHello());
+ assertEquals("My friend Blue says, Hello!", red.helloFromFriend());
+ }
+
+ public void testBlue() throws Exception {
+
+ Friend blue = (Friend) context.lookup("java:global/lookup-of-ejbs/BlueBean");
+
+ assertNotNull(blue);
+ assertEquals("Blue says, Hello!", blue.sayHello());
+ assertEquals("My friend Red says, Hello!", blue.helloFromFriend());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.ejblookup.EjbDependencyTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/lookup-of-ejbs
+ INFO - openejb.base = /Users/dblevins/examples/lookup-of-ejbs
+ 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/lookup-of-ejbs/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/lookup-of-ejbs/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/lookup-of-ejbs
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean RedBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.ejblookup.EjbDependencyTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/lookup-of-ejbs" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/lookup-of-ejbs
+ INFO - Jndi(name="java:global/lookup-of-ejbs/RedBean!org.superbiz.ejblookup.Friend")
+ INFO - Jndi(name="java:global/lookup-of-ejbs/RedBean")
+ INFO - Jndi(name="java:global/lookup-of-ejbs/BlueBean!org.superbiz.ejblookup.Friend")
+ INFO - Jndi(name="java:global/lookup-of-ejbs/BlueBean")
+ INFO - Jndi(name="java:global/EjbModule1374821456/org.superbiz.ejblookup.EjbDependencyTest!org.superbiz.ejblookup.EjbDependencyTest")
+ INFO - Jndi(name="java:global/EjbModule1374821456/org.superbiz.ejblookup.EjbDependencyTest")
+ INFO - Created Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/lookup-of-ejbs)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.267 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/lookup-of-ejbs/README.txt b/content/examples/lookup-of-ejbs/README.txt
new file mode 100755
index 0000000..2364c7e
--- /dev/null
+++ b/content/examples/lookup-of-ejbs/README.txt
@@ -0,0 +1,16 @@
+This example shows how to use the @EJB annotation on a bean class to refer to other beans.
+
+This functionality is often referred as dependency injection (see
+http://www.martinfowler.com/articles/injection.html), and has been recently introduced in
+Java EE 5.
+
+In this particular example, we will create two session stateless beans
+
+ * a DataStore session bean
+ * a DataReader session bean
+
+The DataReader bean uses the DataStore to retrieve some informations, and
+we will see how we can, inside the DataReader bean, get a reference to the
+DataStore bean using the @EJB annotation, thus avoiding the use of the
+JNDI API.
+
diff --git a/content/examples/lookup-of-ejbs/build.xml b/content/examples/lookup-of-ejbs/build.xml
new file mode 100755
index 0000000..51970b5
--- /dev/null
+++ b/content/examples/lookup-of-ejbs/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1177449 $ $Date: 2011-09-30 00:26:03 +0200 (Fri, 30 Sep 2011) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-2"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/lookup-of-ejbs/pom.xml b/content/examples/lookup-of-ejbs/pom.xml
new file mode 100755
index 0000000..8d6f00c
--- /dev/null
+++ b/content/examples/lookup-of-ejbs/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>lookup-of-ejbs</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @EJB Lookup</name>
+ <properties>
+ <!--
+ - http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding
+ -->
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/BlueBean.java b/content/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/BlueBean.java
new file mode 100755
index 0000000..f5dfa1a
--- /dev/null
+++ b/content/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/BlueBean.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ejblookup;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+//START SNIPPET: code
+@Stateless
+@EJB(beanInterface = Friend.class, beanName = "RedBean", name = "myFriend")
+public class BlueBean implements Friend {
+
+ public String sayHello() {
+ return "Blue says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/Friend.java b/content/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/Friend.java
new file mode 100755
index 0000000..c0601b6
--- /dev/null
+++ b/content/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/Friend.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ejblookup;
+
+import javax.ejb.Local;
+
+/**
+ * This is an EJB 3 local business interface
+ * A local business interface may be annotated with the @Local
+ * annotation, but it's optional. A business interface which is
+ * not annotated with @Local or @Remote is assumed to be Local
+ * if the bean does not implement any other interfaces
+ */
+//START SNIPPET: code
+@Local
+public interface Friend {
+
+ public String sayHello();
+
+ public String helloFromFriend();
+
+}
+//END SNIPPET: code
diff --git a/content/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/RedBean.java b/content/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/RedBean.java
new file mode 100755
index 0000000..b75bd6c
--- /dev/null
+++ b/content/examples/lookup-of-ejbs/src/main/java/org/superbiz/ejblookup/RedBean.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ejblookup;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+//START SNIPPET: code
+@Stateless
+@EJB(beanInterface = Friend.class, beanName = "BlueBean", name = "myFriend")
+public class RedBean implements Friend {
+
+ public String sayHello() {
+ return "Red says, Hello!";
+ }
+
+ public String helloFromFriend() {
+ try {
+ Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend");
+ return "My friend " + friend.sayHello();
+ } catch (NamingException e) {
+ throw new EJBException(e);
+ }
+ }
+}
+//END SNIPPET: code
\ No newline at end of file
diff --git a/content/examples/lookup-of-ejbs/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java b/content/examples/lookup-of-ejbs/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java
new file mode 100755
index 0000000..bf4fbb9
--- /dev/null
+++ b/content/examples/lookup-of-ejbs/src/test/java/org/superbiz/ejblookup/EjbDependencyTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ejblookup;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+//START SNIPPET: code
+public class EjbDependencyTest extends TestCase {
+
+ private Context context;
+
+ protected void setUp() throws Exception {
+ context = EJBContainer.createEJBContainer().getContext();
+ }
+
+ public void testRed() throws Exception {
+
+ Friend red = (Friend) context.lookup("java:global/lookup-of-ejbs/RedBean");
+
+ assertNotNull(red);
+ assertEquals("Red says, Hello!", red.sayHello());
+ assertEquals("My friend Blue says, Hello!", red.helloFromFriend());
+
+ }
+
+ public void testBlue() throws Exception {
+
+ Friend blue = (Friend) context.lookup("java:global/lookup-of-ejbs/BlueBean");
+
+ assertNotNull(blue);
+ assertEquals("Blue says, Hello!", blue.sayHello());
+ assertEquals("My friend Red says, Hello!", blue.helloFromFriend());
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/mbean-auto-registration.html b/content/examples/mbean-auto-registration.html
new file mode 100644
index 0000000..782bec0
--- /dev/null
+++ b/content/examples/mbean-auto-registration.html
@@ -0,0 +1,354 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/mbean-auto-registration.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Mbean Auto Registration</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example mbean-auto-registration can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/mbean-auto-registration" class="bare">https://github.com/apache/tomee/tree/master/examples/mbean-auto-registration</a></p>
+</div>
+<div class="paragraph">
+<p>This example shows how to automatically create and register mbeans using TomEE features.</p>
+</div>
+</div>
+</div>
+<h1 id="_dependencies" class="sect0">Dependencies</h1>
+<div class="paragraph">
+<p>To be able to use it you need to import the mbean api (annotations):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>mbean-annotation-api</artifactId>
+ <version>4.5.0</version>
+ <scope>provided</scope>
+</dependency></code></pre>
+</div>
+</div>
+<h1 id="_the_mbean" class="sect0">The MBean</h1>
+<div class="paragraph">
+<p>The mbean implements a simple game where the goal is to guess a number.</p>
+</div>
+<div class="paragraph">
+<p>It allows the user to change the value too.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.mbean;
+
+import javax.management.Description;
+import javax.management.MBean;
+import javax.management.ManagedAttribute;
+import javax.management.ManagedOperation;
+
+@MBean
+@Description("play with me to guess a number")
+public class GuessHowManyMBean {
+ private int value = 0;
+
+ @ManagedAttribute
+ @Description("you are cheating!")
+ public int getValue() {
+ return value;
+ }
+
+ @ManagedAttribute
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ @ManagedOperation
+ public String tryValue(int userValue) {
+ if (userValue == value) {
+ return "winner";
+ }
+ return "not the correct value, please have another try";
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>To register a MBean you simply have to specify a property either in system.properties,
+or in intial context properties.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Properties properties = new Properties();
+properties.setProperty("openejb.user.mbeans.list", GuessHowManyMBean.class.getName());
+EJBContainer.createEJBContainer(properties);</pre>
+</div>
+</div>
+<h1 id="_accessing_the_mbean" class="sect0">Accessing the MBean</h1>
+<div class="paragraph">
+<p>Then simply get the platform server and you can play with parameters and operations:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.mbean;
+
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.management.Attribute;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+
+public class GuessHowManyMBeanTest {
+ private static final String OBJECT_NAME = "openejb.user.mbeans:group=org.superbiz.mbean,application=mbean-auto-registration,name=GuessHowManyMBean";
+
+ @Test
+ public void play() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.user.mbeans.list", GuessHowManyMBean.class.getName());
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ ObjectName objectName = new ObjectName(OBJECT_NAME);
+ MBeanInfo infos = server.getMBeanInfo(objectName);
+ assertEquals(0, server.getAttribute(objectName, "value"));
+ server.setAttribute(objectName, new Attribute("value", 3));
+ assertEquals(3, server.getAttribute(objectName, "value"));
+ assertEquals("winner", server.invoke(objectName, "tryValue", new Object[]{3}, null));
+ assertEquals("not the correct value, please have another try", server.invoke(objectName, "tryValue", new Object[]{2}, null));
+
+ container.close();
+ }
+}</code></pre>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_note">Note</h4>
+<div class="paragraph">
+<p>If OpenEJB can’t find any module it can’t start. So to force him to start even if the example has only the mbean
+as java class, we added a <code>beans.xml</code> file to turn our project into a Java EE module.</p>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.mbean.GuessHowManyMBeanTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/mbean-auto-registration
+INFO - openejb.base = /Users/dblevins/examples/mbean-auto-registration
+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/mbean-auto-registration/target/classes
+INFO - Beginning load: /Users/dblevins/examples/mbean-auto-registration/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/mbean-auto-registration
+INFO - MBean openejb.user.mbeans:application=,group=org.superbiz.mbean,name=GuessHowManyMBean registered.
+INFO - MBean openejb.user.mbeans:application=mbean-auto-registration,group=org.superbiz.mbean,name=GuessHowManyMBean registered.
+INFO - MBean openejb.user.mbeans:application=EjbModule1847652919,group=org.superbiz.mbean,name=GuessHowManyMBean registered.
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean mbean-auto-registration.Comp: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/mbean-auto-registration" loaded.
+INFO - Assembling app: /Users/dblevins/examples/mbean-auto-registration
+INFO - Jndi(name="java:global/mbean-auto-registration/mbean-auto-registration.Comp!org.apache.openejb.BeanContext$Comp")
+INFO - Jndi(name="java:global/mbean-auto-registration/mbean-auto-registration.Comp")
+INFO - Jndi(name="java:global/EjbModule1847652919/org.superbiz.mbean.GuessHowManyMBeanTest!org.superbiz.mbean.GuessHowManyMBeanTest")
+INFO - Jndi(name="java:global/EjbModule1847652919/org.superbiz.mbean.GuessHowManyMBeanTest")
+INFO - Created Ejb(deployment-id=mbean-auto-registration.Comp, ejb-name=mbean-auto-registration.Comp, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=org.superbiz.mbean.GuessHowManyMBeanTest, ejb-name=org.superbiz.mbean.GuessHowManyMBeanTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=mbean-auto-registration.Comp, ejb-name=mbean-auto-registration.Comp, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=org.superbiz.mbean.GuessHowManyMBeanTest, ejb-name=org.superbiz.mbean.GuessHowManyMBeanTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/mbean-auto-registration)
+INFO - Undeploying app: /Users/dblevins/examples/mbean-auto-registration
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.063 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/mbean-auto-registration.pdf b/content/examples/mbean-auto-registration.pdf
new file mode 100644
index 0000000..e72e13d
--- /dev/null
+++ b/content/examples/mbean-auto-registration.pdf
Binary files differ
diff --git a/content/examples/mbean-auto-registration/README.md b/content/examples/mbean-auto-registration/README.md
new file mode 100755
index 0000000..0f0f510
--- /dev/null
+++ b/content/examples/mbean-auto-registration/README.md
@@ -0,0 +1,145 @@
+Title: Mbean Auto Registration
+
+This example shows how to automatically create and register mbeans using TomEE features.
+
+# Dependencies
+
+To be able to use it you need to import the mbean api (annotations):
+
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>mbean-annotation-api</artifactId>
+ <version>4.5.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+# The MBean
+
+The mbean implements a simple game where the goal is to guess a number.
+
+It allows the user to change the value too.
+
+ package org.superbiz.mbean;
+
+ import javax.management.Description;
+ import javax.management.MBean;
+ import javax.management.ManagedAttribute;
+ import javax.management.ManagedOperation;
+
+ @MBean
+ @Description("play with me to guess a number")
+ public class GuessHowManyMBean {
+ private int value = 0;
+
+ @ManagedAttribute
+ @Description("you are cheating!")
+ public int getValue() {
+ return value;
+ }
+
+ @ManagedAttribute
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ @ManagedOperation
+ public String tryValue(int userValue) {
+ if (userValue == value) {
+ return "winner";
+ }
+ return "not the correct value, please have another try";
+ }
+ }
+
+To register a MBean you simply have to specify a property either in system.properties,
+or in intial context properties.
+
+ Properties properties = new Properties();
+ properties.setProperty("openejb.user.mbeans.list", GuessHowManyMBean.class.getName());
+ EJBContainer.createEJBContainer(properties);
+
+# Accessing the MBean
+
+Then simply get the platform server and you can play with parameters and operations:
+
+ package org.superbiz.mbean;
+
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.management.Attribute;
+ import javax.management.MBeanInfo;
+ import javax.management.MBeanServer;
+ import javax.management.ObjectName;
+ import java.lang.management.ManagementFactory;
+ import java.util.Properties;
+
+ import static junit.framework.Assert.assertEquals;
+
+ public class GuessHowManyMBeanTest {
+ private static final String OBJECT_NAME = "openejb.user.mbeans:group=org.superbiz.mbean,application=mbean-auto-registration,name=GuessHowManyMBean";
+
+ @Test
+ public void play() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.user.mbeans.list", GuessHowManyMBean.class.getName());
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ ObjectName objectName = new ObjectName(OBJECT_NAME);
+ MBeanInfo infos = server.getMBeanInfo(objectName);
+ assertEquals(0, server.getAttribute(objectName, "value"));
+ server.setAttribute(objectName, new Attribute("value", 3));
+ assertEquals(3, server.getAttribute(objectName, "value"));
+ assertEquals("winner", server.invoke(objectName, "tryValue", new Object[]{3}, null));
+ assertEquals("not the correct value, please have another try", server.invoke(objectName, "tryValue", new Object[]{2}, null));
+
+ container.close();
+ }
+ }
+
+#### Note
+
+If OpenEJB can't find any module it can't start. So to force him to start even if the example has only the mbean
+as java class, we added a `beans.xml` file to turn our project into a Java EE module.
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.mbean.GuessHowManyMBeanTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/mbean-auto-registration
+ INFO - openejb.base = /Users/dblevins/examples/mbean-auto-registration
+ 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/mbean-auto-registration/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/mbean-auto-registration/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/mbean-auto-registration
+ INFO - MBean openejb.user.mbeans:application=,group=org.superbiz.mbean,name=GuessHowManyMBean registered.
+ INFO - MBean openejb.user.mbeans:application=mbean-auto-registration,group=org.superbiz.mbean,name=GuessHowManyMBean registered.
+ INFO - MBean openejb.user.mbeans:application=EjbModule1847652919,group=org.superbiz.mbean,name=GuessHowManyMBean registered.
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean mbean-auto-registration.Comp: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/mbean-auto-registration" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/mbean-auto-registration
+ INFO - Jndi(name="java:global/mbean-auto-registration/mbean-auto-registration.Comp!org.apache.openejb.BeanContext$Comp")
+ INFO - Jndi(name="java:global/mbean-auto-registration/mbean-auto-registration.Comp")
+ INFO - Jndi(name="java:global/EjbModule1847652919/org.superbiz.mbean.GuessHowManyMBeanTest!org.superbiz.mbean.GuessHowManyMBeanTest")
+ INFO - Jndi(name="java:global/EjbModule1847652919/org.superbiz.mbean.GuessHowManyMBeanTest")
+ INFO - Created Ejb(deployment-id=mbean-auto-registration.Comp, ejb-name=mbean-auto-registration.Comp, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.mbean.GuessHowManyMBeanTest, ejb-name=org.superbiz.mbean.GuessHowManyMBeanTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=mbean-auto-registration.Comp, ejb-name=mbean-auto-registration.Comp, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.mbean.GuessHowManyMBeanTest, ejb-name=org.superbiz.mbean.GuessHowManyMBeanTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/mbean-auto-registration)
+ INFO - Undeploying app: /Users/dblevins/examples/mbean-auto-registration
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.063 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/mbean-auto-registration/pom.xml b/content/examples/mbean-auto-registration/pom.xml
new file mode 100755
index 0000000..e7d9acb
--- /dev/null
+++ b/content/examples/mbean-auto-registration/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>mbean-auto-registration</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: MBean Auto Registration</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>mbean-annotation-api</artifactId>
+ <version>4.7.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The scope test is to avoid to have any openejb binaries delivered by the application.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/mbean-auto-registration/src/main/java/org/superbiz/mbean/GuessHowManyMBean.java b/content/examples/mbean-auto-registration/src/main/java/org/superbiz/mbean/GuessHowManyMBean.java
new file mode 100755
index 0000000..5dadbe2
--- /dev/null
+++ b/content/examples/mbean-auto-registration/src/main/java/org/superbiz/mbean/GuessHowManyMBean.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mbean;
+
+import javax.management.Description;
+import javax.management.MBean;
+import javax.management.ManagedAttribute;
+import javax.management.ManagedOperation;
+
+@MBean
+@Description("play with me to guess a number")
+public class GuessHowManyMBean {
+
+ private int value = 0;
+
+ @ManagedAttribute
+ @Description("you are cheating!")
+ public int getValue() {
+ return value;
+ }
+
+ @ManagedAttribute
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ @ManagedOperation
+ public String tryValue(int userValue) {
+ if (userValue == value) {
+ return "winner";
+ }
+ return "not the correct value, please have another try";
+ }
+}
diff --git a/content/examples/mbean-auto-registration/src/main/resources/META-INF/beans.xml b/content/examples/mbean-auto-registration/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..3e10c38
--- /dev/null
+++ b/content/examples/mbean-auto-registration/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,17 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<beans/>
diff --git a/content/examples/mbean-auto-registration/src/test/java/org/superbiz/mbean/GuessHowManyMBeanTest.java b/content/examples/mbean-auto-registration/src/test/java/org/superbiz/mbean/GuessHowManyMBeanTest.java
new file mode 100755
index 0000000..1ef3031
--- /dev/null
+++ b/content/examples/mbean-auto-registration/src/test/java/org/superbiz/mbean/GuessHowManyMBeanTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mbean;
+
+import org.apache.openejb.monitoring.LocalMBeanServer;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+
+public class GuessHowManyMBeanTest {
+
+ private static final String OBJECT_NAME = "openejb.user.mbeans:group=org.superbiz.mbean,application=mbean-auto-registration,name=GuessHowManyMBean";
+
+ @Test
+ public void play() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(LocalMBeanServer.OPENEJB_JMX_ACTIVE, Boolean.TRUE.toString());
+ EJBContainer container = EJBContainer.createEJBContainer(properties);
+
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ ObjectName objectName = new ObjectName(OBJECT_NAME);
+ assertEquals(0, server.getAttribute(objectName, "value"));
+ server.setAttribute(objectName, new Attribute("value", 3));
+ assertEquals(3, server.getAttribute(objectName, "value"));
+ assertEquals("winner", server.invoke(objectName, "tryValue", new Object[]{3}, null));
+ assertEquals("not the correct value, please have another try", server.invoke(objectName, "tryValue", new Object[]{2}, null));
+
+ container.close();
+ }
+}
diff --git a/content/examples/moviefun-rest.html b/content/examples/moviefun-rest.html
new file mode 100644
index 0000000..1947282
--- /dev/null
+++ b/content/examples/moviefun-rest.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/moviefun-rest.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>moviefun-rest</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example moviefun-rest can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/moviefun-rest" class="bare">https://github.com/apache/tomee/tree/master/examples/moviefun-rest</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/moviefun-rest.pdf b/content/examples/moviefun-rest.pdf
new file mode 100644
index 0000000..70f3b01
--- /dev/null
+++ b/content/examples/moviefun-rest.pdf
Binary files differ
diff --git a/content/examples/moviefun-rest/pom.xml b/content/examples/moviefun-rest/pom.xml
new file mode 100755
index 0000000..fce26b5
--- /dev/null
+++ b/content/examples/moviefun-rest/pom.xml
@@ -0,0 +1,293 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+
+<!-- $Rev: 684173 $ $Date: 2008-08-08 20:13:24 -0700 (Fri, 08 Aug 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>moviefun-rest</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: Moviefun Rest</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <tomee.version>1.7.1</tomee.version>
+ <version.shrinkwrap.resolver>2.0.0</version.shrinkwrap.resolver>
+ <version.openejb>4.7.1</version.openejb>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <build>
+ <finalName>moviefun</finalName>
+ <plugins>
+ <plugin>
+ <groupId>com.googlecode.jslint4java</groupId>
+ <artifactId>jslint4java-maven-plugin</artifactId>
+ <version>2.0.5</version>
+ <configuration>
+ <failOnError>true</failOnError>
+ <options>
+ <vars>true</vars>
+ <unparam>true</unparam>
+ <predef>define,require,requirejs,window,Backbone,_,$,Handlebars,APP_CONFIG</predef>
+ <indent>4</indent>
+ </options>
+ <sourceFolders>
+ <sourceFolder>${basedir}/src/main/webapp/app/js</sourceFolder>
+ </sourceFolders>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>lint</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <id>copy-test-libs</id>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>
+ ${project.build.directory}/test-libs
+ </outputDirectory>
+ <stripVersion>true</stripVersion>
+ </configuration>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <reuseForks>false</reuseForks>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>${tomee.version}</version>
+ <configuration>
+ <tomeeClassifier>plus</tomeeClassifier>
+ <args>-Xmx512m -XX:PermSize=256m</args>
+ <config>${project.basedir}/src/main/tomee/</config>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencyManagement>
+ <dependencies>
+ <!-- Override dependency resolver with test version. This must go *BEFORE*
+ the Arquillian BOM. -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-bom</artifactId>
+ <version>${version.shrinkwrap.resolver}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ <!-- Now pull in our server-based unit testing framework -->
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-bom</artifactId>
+ <version>1.0.3.Final</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>${version.openejb}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-embedded</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>backbonejs</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>bootstrap</artifactId>
+ <version>3.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>handlebars</artifactId>
+ <version>1.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquery</artifactId>
+ <version>2.1.0-1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>json2</artifactId>
+ <version>20110223</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>less</artifactId>
+ <version>1.6.0-1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>requirejs</artifactId>
+ <version>2.1.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>requirejs-text</artifactId>
+ <version>2.0.10</version>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>arquillian-tomee-embedded</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-embedded</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>arquillian-tomee-remote</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/Movie.java b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/Movie.java
new file mode 100755
index 0000000..4a8032b
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/Movie.java
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@XmlRootElement(name = "movie")
+public class Movie {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+ private String genre;
+ private int rating;
+
+ public Movie() {
+ }
+
+ public Movie(String title, String director, String genre, int rating, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ this.genre = genre;
+ this.rating = rating;
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getGenre() {
+ return genre;
+ }
+
+ public void setGenre(String genre) {
+ this.genre = genre;
+ }
+
+ public int getRating() {
+ return rating;
+ }
+
+ public void setRating(int rating) {
+ this.rating = rating;
+ }
+}
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/MoviesBean.java b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/MoviesBean.java
new file mode 100755
index 0000000..6f90e82
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/MoviesBean.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.metamodel.EntityType;
+import java.util.List;
+
+@Stateless
+public class MoviesBean {
+
+ @PersistenceContext(unitName = "movie-unit")
+ private EntityManager entityManager;
+
+ public Movie find(Long id) {
+ return entityManager.find(Movie.class, id);
+ }
+
+ public void addMovie(Movie movie) {
+ entityManager.persist(movie);
+ }
+
+ public void editMovie(Movie movie) {
+ entityManager.merge(movie);
+ }
+
+ public void deleteMovie(long id) {
+ Movie movie = entityManager.find(Movie.class, id);
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies(Integer firstResult, Integer maxResults, String field, String searchTerm) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Movie> cq = qb.createQuery(Movie.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+ if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
+ cq.where(condition);
+ }
+ TypedQuery<Movie> q = entityManager.createQuery(cq);
+ if (maxResults != null) {
+ q.setMaxResults(maxResults);
+ }
+ if (firstResult != null) {
+ q.setFirstResult(firstResult);
+ }
+ return q.getResultList();
+ }
+
+ public int count(String field, String searchTerm) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Long> cq = qb.createQuery(Long.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+ cq.select(qb.count(root));
+ if (field != null && searchTerm != null && !"".equals(field.trim()) && !"".equals(searchTerm.trim())) {
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field.trim(), String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm.trim() + "%");
+ cq.where(condition);
+ }
+ return entityManager.createQuery(cq).getSingleResult().intValue();
+ }
+
+ public void clean() {
+ entityManager.createQuery("delete from Movie").executeUpdate();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
new file mode 100755
index 0000000..303dd6e
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/ApplicationConfig.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun.rest;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+@ApplicationPath("/rest")
+public class ApplicationConfig extends Application {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Set<Class<?>> getClasses() {
+ return new HashSet<Class<?>>(Arrays.asList(LoadRest.class, MoviesRest.class));
+ }
+}
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/LoadRest.java b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
new file mode 100755
index 0000000..021027b
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/LoadRest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun.rest;
+
+import org.superbiz.moviefun.Movie;
+import org.superbiz.moviefun.MoviesBean;
+
+import javax.ejb.EJB;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("load")
+public class LoadRest {
+ @EJB
+ private MoviesBean moviesBean;
+
+ @POST
+ public void load() {
+ moviesBean.addMovie(new Movie("Wedding Crashers", "David Dobkin", "Comedy", 7, 2005));
+ moviesBean.addMovie(new Movie("Starsky & Hutch", "Todd Phillips", "Action", 6, 2004));
+ moviesBean.addMovie(new Movie("Shanghai Knights", "David Dobkin", "Action", 6, 2003));
+ moviesBean.addMovie(new Movie("I-Spy", "Betty Thomas", "Adventure", 5, 2002));
+ moviesBean.addMovie(new Movie("The Royal Tenenbaums", "Wes Anderson", "Comedy", 8, 2001));
+ moviesBean.addMovie(new Movie("Zoolander", "Ben Stiller", "Comedy", 6, 2001));
+ moviesBean.addMovie(new Movie("Shanghai Noon", "Tom Dey", "Comedy", 7, 2000));
+ }
+
+}
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
new file mode 100755
index 0000000..74a8450
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/java/org/superbiz/moviefun/rest/MoviesRest.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun.rest;
+
+import org.superbiz.moviefun.Movie;
+import org.superbiz.moviefun.MoviesBean;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("movies")
+@Produces({"application/json"})
+public class MoviesRest {
+
+ @EJB
+ private MoviesBean service;
+
+ @GET
+ @Path("{id}")
+ public Movie find(@PathParam("id") Long id) {
+ return service.find(id);
+ }
+
+ @GET
+ public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
+ @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
+ return service.getMovies(first, max, field, searchTerm);
+ }
+
+ @POST
+ @Consumes("application/json")
+ public Movie addMovie(Movie movie) {
+ service.addMovie(movie);
+ return movie;
+ }
+
+ @PUT
+ @Path("{id}")
+ @Consumes("application/json")
+ public Movie editMovie(Movie movie) {
+ service.editMovie(movie);
+ return movie;
+ }
+
+ @DELETE
+ @Path("{id}")
+ public void deleteMovie(@PathParam("id") long id) {
+ service.deleteMovie(id);
+ }
+
+ @GET
+ @Path("count")
+ public int count(@QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
+ return service.count(field, searchTerm);
+ }
+
+}
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/resources/META-INF/persistence.xml b/content/examples/moviefun-rest/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..ec38aaa
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.moviefun.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/moviefun-rest/src/main/tomee/tomee.xml b/content/examples/moviefun-rest/src/main/tomee/tomee.xml
new file mode 100755
index 0000000..f25d5f8
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/tomee/tomee.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<tomee>
+ <Resource id="HSQLDB Database" type="DataSource">
+ JdbcDriver org.hsqldb.jdbcDriver
+ JdbcUrl jdbc:hsqldb:file:target/db/moviefun
+ UserName sa
+ Password
+ </Resource>
+</tomee>
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/webapp/WEB-INF/web.xml b/content/examples/moviefun-rest/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..328247d
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<web-app version="3.0" 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/web-app_3_0.xsd">
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+
+ <!-- The trick is to put all your static files under the same directory and map the "default" servlet to it -->
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/app/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/webjars/*</url-pattern>
+ </servlet-mapping>
+
+ <!-- Any other request will point to the "index.jsp" page. This way Backbone knows how to manage page transitions
+ at the client side in case the user starts the application from a permalink. -->
+ <servlet>
+ <servlet-name>application</servlet-name>
+ <jsp-file>/index.jsp</jsp-file>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>application</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/app.less b/content/examples/moviefun-rest/src/main/webapp/app/app.less
new file mode 100755
index 0000000..61fd5e2
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/app.less
@@ -0,0 +1,62 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+body {
+ @content-margin-top: 80px;
+
+ .ux-movie-window {
+ .modal-dialog {
+ padding-top: 90px;
+ padding-bottom: 0px;
+ }
+ }
+
+ .ux-landing {
+ margin-top: @content-margin-top;
+ }
+
+ .ux-setup {
+ margin-top: @content-margin-top;
+ }
+
+ .ux-application {
+ margin-top: @content-margin-top;
+
+ .pagination {
+ margin-top: 0px;
+ margin-bottom: 0px;
+ }
+
+ th:last-child {
+ width: 5px;
+ }
+
+ .ux-add-btn {
+ position: absolute;
+ bottom: 20px;
+ right: 30px;
+ }
+
+ a.ux-delete-row:hover, a.ux-edit-row:hover {
+ cursor: hand;
+ }
+
+ .panel-body>.input-group {
+ margin-bottom: 15px;
+ }
+ }
+}
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/config.js b/content/examples/moviefun-rest/src/main/webapp/app/config.js
new file mode 100755
index 0000000..bbdc5e1
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/config.js
@@ -0,0 +1,45 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var APP_CONFIG = {
+ baseUrl: window.ux.ROOT_URL,
+ paths: {
+ 'text': 'webjars/requirejs-text/2.0.10/text',
+ 'lib/less': 'webjars/less/1.6.0/less.min',
+ 'lib/jquery': 'webjars/jquery/2.1.0/jquery.min',
+ 'lib/bootstrap': 'webjars/bootstrap/3.1.0/js/bootstrap.min',
+ 'lib/handlebars': 'webjars/handlebars/1.2.1/handlebars.min',
+ 'lib/underscore': 'webjars/underscorejs/1.4.3/underscore-min',
+ 'lib/json2': 'webjars/json2/20110223/json2.min',
+ 'lib/backbone': 'webjars/backbonejs/1.0.0/backbone'
+ },
+ shim: {
+ 'lib/bootstrap': {
+ deps: ['lib/jquery']
+ },
+ 'lib/underscore': {
+ exports: '_'
+ },
+ 'lib/backbone': {
+ deps: ['lib/jquery', 'lib/json2', 'lib/underscore']
+ },
+ 'app/js/templates': {
+ deps: ['lib/underscore', 'app/js/i18n']
+ }
+ }
+};
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/application.js b/content/examples/moviefun-rest/src/main/webapp/app/js/application.js
new file mode 100755
index 0000000..9ec4cab
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/application.js
@@ -0,0 +1,193 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ var deps = [
+ 'app/js/view/container',
+ 'app/js/view/application',
+ 'app/js/view/application-table-paginator',
+ 'app/js/view/movie',
+ 'lib/underscore',
+ 'app/js/model/movies',
+ 'app/js/model/movie',
+ 'app/js/i18n',
+ 'lib/less', 'lib/backbone', 'lib/jquery', 'lib/bootstrap'
+ ];
+ define(deps, function (containerView, applicationView, paginator, MovieView, underscore, moviesList, MovieModel) {
+ var max = 5;
+ var appState = {
+ page: null,
+ fieldName: null,
+ fieldValue: null
+ };
+ containerView.render();
+
+ $.ajaxSetup({ cache: false });
+
+ function loadPage(pageNumber, fieldName, fieldValue) {
+ var data = {
+ max: max,
+ first: ((pageNumber - 1) * max)
+ };
+ if (fieldName && fieldValue) {
+ data.field = fieldName;
+ data.searchTerm = fieldValue;
+ }
+ applicationView.setFilter(fieldName, fieldValue);
+ moviesList.fetch({
+ data: data,
+ success: function (result) {
+ applicationView.addRows(result.models);
+
+ $.ajax({
+ url: window.ux.ROOT_URL + 'rest/movies/count/',
+ method: 'GET',
+ dataType: 'json',
+ data: {
+ field: appState.fieldName,
+ searchTerm: appState.fieldValue
+ },
+ success: function (total) {
+ var count = Math.ceil(total / max);
+ paginator.setCount(count);
+ applicationView.setPaginator(count);
+ }
+ });
+ }
+ });
+ }
+
+ function start() {
+ //Starting the backbone router.
+ var Router = Backbone.Router.extend({
+ routes: {
+ '': 'showApplication',
+ 'application': 'showApplication',
+ 'application/:page': 'showApplication',
+ 'application/:page/:field/:value': 'showApplication'
+ },
+
+ showApplication: function (page, fieldName, fieldValue) {
+ var me = this;
+ appState.page = page;
+ appState.fieldName = fieldName;
+ appState.fieldValue = fieldValue;
+ containerView.showView(applicationView);
+ if (!page || !underscore.isNumber(Number(page))) {
+ me.showApplication(1);
+ } else {
+ loadPage(Number(page), fieldName, fieldValue);
+ if (fieldName) {
+ me.navigate('application/' + page + '/' + fieldName + '/' + fieldValue, {
+ trigger: false
+ });
+ } else {
+ me.navigate('application/' + page, {
+ trigger: false
+ });
+ }
+ }
+ }
+ });
+ var router = new Router();
+
+ applicationView.on('load-sample', function () {
+ $.ajax({
+ url: window.ux.ROOT_URL + 'rest/load/',
+ method: 'POST',
+ dataType: 'json',
+ data: {},
+ success: function (data) {
+ router.showApplication();
+ }
+ });
+ });
+
+ applicationView.on('delete', function (data) {
+ data.model.destroy({
+ success: function () {
+ router.showApplication(appState.page, appState.fieldName, appState.fieldValue);
+ }
+ });
+ });
+
+ function showMovieWindow(model) {
+ var view = new MovieView({
+ model: model
+ });
+ view.render();
+ view.on('save-model', function (data) {
+ data.model.save({}, {
+ success: function () {
+ view.remove();
+ loadPage(appState.page, appState.fieldName, appState.fieldValue);
+ }
+ });
+ });
+ $('body').append(view.$el);
+ view.$el.modal({});
+ }
+
+ applicationView.on('add', function () {
+ showMovieWindow(new MovieModel({}));
+ });
+
+ applicationView.on('edit', function (data) {
+ showMovieWindow(data.model);
+ });
+
+ applicationView.on('filter', function (data) {
+ router.navigate('application/1/' + data.filterType + '/' + data.filterValue, {
+ trigger: true
+ });
+ });
+
+ applicationView.on('clear-filter', function (data) {
+ router.navigate('application/1', {
+ trigger: true
+ });
+ });
+
+ paginator.on('go-to-page', function (data) {
+ var page = data.number;
+ if (page === 'last') {
+ page = paginator.getCount();
+ }
+ router.showApplication(page, appState.fieldName, appState.fieldValue);
+ });
+
+ //Starting the backbone history.
+ Backbone.history.start({
+ pushState: true,
+ root: window.ux.ROOT_URL // This value is set by <c:url>
+ });
+
+ return {
+ getRouter: function () {
+ return router;
+ }
+ };
+ }
+
+ return {
+ start: start
+ };
+ });
+}());
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/i18n.js b/content/examples/moviefun-rest/src/main/webapp/app/js/i18n.js
new file mode 100755
index 0000000..2603dec
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/i18n.js
@@ -0,0 +1,66 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ "use strict";
+ */
+
+define(['lib/underscore', 'lib/handlebars', 'app/js/log'], function (underscore) {
+ 'use strict';
+
+ var missing = Handlebars.compile('[!{{key}}!]');
+ var messages = {
+ 'application.name': 'Moviefun',
+ 'load.dada': 'Click here to load sample data',
+ 'movies': 'Movies',
+ 'title': 'Title',
+ 'director': 'Director',
+ 'genre': 'Genre',
+ 'rating': 'Rating',
+ 'year': 'Year',
+ 'add.movie': 'Add movie',
+ 'movie': 'Movie',
+ 'close': 'Close',
+ 'save': 'Save',
+
+ 'dummy': ''
+ };
+
+ underscore.each(underscore.keys(messages), function (key) {
+ var template = Handlebars.compile(messages[key]);
+ messages[key] = template;
+ });
+
+ var get = function (key, values) {
+ var template = messages[key];
+ var cfg = values;
+ if (!template) {
+ template = missing;
+ cfg = {
+ key: key
+ };
+ window.console.error('Missing i18n message.', key);
+ }
+ return template(cfg);
+ };
+
+ Handlebars.registerHelper('i18n', function (key) {
+ return get(key);
+ });
+
+ return {
+ get: get
+ };
+});
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/id.js b/content/examples/moviefun-rest/src/main/webapp/app/js/id.js
new file mode 100755
index 0000000..fc4c56a
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/id.js
@@ -0,0 +1,43 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ "use strict";
+ */
+
+define(['lib/underscore', 'lib/handlebars'], function (underscore) {
+ 'use strict';
+
+ var value = underscore.uniqueId('moviefun_');
+
+ var current = function () {
+ return value;
+ };
+ var next = function () {
+ value = underscore.uniqueId('moviefun_');
+ return value;
+ };
+ Handlebars.registerHelper('id_current', function (key) {
+ return current();
+ });
+ Handlebars.registerHelper('id_next', function (key) {
+ return next();
+ });
+
+ return {
+ current: current,
+ next: next
+ };
+});
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/log.js b/content/examples/moviefun-rest/src/main/webapp/app/js/log.js
new file mode 100755
index 0000000..6e79b98
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/log.js
@@ -0,0 +1,40 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+define([], function () {
+ 'use strict';
+
+ var noOp = function () {
+ return ''; // no-op
+ };
+
+ if (!window.console) {
+ window.console = {};
+ }
+
+ function createIfNull(functionName) {
+ if (!window.console[functionName]) {
+ window.console[functionName] = noOp;
+ }
+ }
+
+ createIfNull('error');
+ createIfNull('warn');
+ createIfNull('log');
+ createIfNull('info');
+});
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/model/movie.js b/content/examples/moviefun-rest/src/main/webapp/app/js/model/movie.js
new file mode 100755
index 0000000..15936d0
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/model/movie.js
@@ -0,0 +1,38 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ var deps = ['lib/backbone'];
+ define(deps, function () {
+ return Backbone.Model.extend({
+ urlRoot: window.ux.ROOT_URL + 'rest/movies',
+ idAttribute: 'id',
+ toJSON: function () {
+ return {
+ 'movie': this.attributes
+ };
+ },
+ defaults: {
+ rating: 5,
+ year: new Date().getFullYear()
+ }
+ });
+ });
+}());
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/model/movies.js b/content/examples/moviefun-rest/src/main/webapp/app/js/model/movies.js
new file mode 100755
index 0000000..f03130d
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/model/movies.js
@@ -0,0 +1,35 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ var deps = ['app/js/model/movie', 'lib/backbone'];
+ define(deps, function (Movie) {
+ var Cls = Backbone.Collection.extend({
+ model: Movie,
+ url: window.ux.ROOT_URL + 'rest/movies',
+ parse: function (response) {
+ return response.movie;
+ }
+ });
+ return new Cls();
+ });
+}());
+
+
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/start.js b/content/examples/moviefun-rest/src/main/webapp/app/js/start.js
new file mode 100755
index 0000000..33f7fbd
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/start.js
@@ -0,0 +1,29 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require.config(APP_CONFIG);
+
+requirejs(['app/js/application'], function (app) {
+ 'use strict';
+
+ $(window.document).ready(function () {
+ // all the action is in app
+ app.start();
+ });
+});
+
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/templates.js b/content/examples/moviefun-rest/src/main/webapp/app/js/templates.js
new file mode 100755
index 0000000..e3f3300
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/templates.js
@@ -0,0 +1,69 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ var files = [
+ 'container',
+ 'application',
+ 'application-table-row',
+ 'application-table-paginator-button',
+ 'load-data-link',
+ 'movie'
+ ];
+
+ function loop(values, callback) {
+ var index;
+ for (index = 0; index < values.length; index += 1) {
+ callback(values[index], index);
+ }
+ }
+
+ // Preparing the "requirements" paths.
+ var requirements = [];
+ loop(files, function (file) {
+ requirements.push('text!app/js/templates/' + file + '.handlebars');
+ });
+
+ define(requirements, function () {
+ var templates = {};
+
+ var myArgs = arguments;
+ loop(files, function (file, i) {
+ templates[file] = Handlebars.compile(myArgs[i]);
+ });
+
+ return {
+ getValue: function (templateName, cfg) {
+ var template = templates[templateName];
+ if (!template) {
+ throw 'Template not registered. "' + templateName + '"';
+ }
+ var result;
+ if (cfg) {
+ result = template(cfg);
+ } else {
+ result = template({});
+ }
+ return result;
+ }
+ };
+ });
+}());
+
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/templates/application-table-paginator-button.handlebars b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/application-table-paginator-button.handlebars
new file mode 100755
index 0000000..0031aba
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/application-table-paginator-button.handlebars
@@ -0,0 +1 @@
+<li><a href="{{pageNumber}}">{{pageText}}</a></li>
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/templates/application-table-row.handlebars b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/application-table-row.handlebars
new file mode 100755
index 0000000..dc9bf7c
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/application-table-row.handlebars
@@ -0,0 +1,8 @@
+<td><a href="edit" class="ux-edit-row">{{title}}</a></td>
+<td>{{director}}</td>
+<td>{{genre}}</td>
+<td>{{rating}}</td>
+<td>{{year}}</td>
+<td>
+ <a href="delete" class="ux-delete-row"><span class="glyphicon glyphicon-trash"></span></a>
+</td>
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/templates/application.handlebars b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/application.handlebars
new file mode 100755
index 0000000..f15d1a9
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/application.handlebars
@@ -0,0 +1,50 @@
+<div class="row">
+ <div class="col-md-12">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">{{i18n "movies"}}</h3>
+ </div>
+ <div class="panel-body">
+ <div class="input-group">
+ <div class="input-group-btn">
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
+ <span class="ux-selected-filter">{{i18n "title"}}</span> <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu" role="menu">
+ <li><a href="title" class="ux-filter">{{i18n "title"}}</a></li>
+ <li><a href="director" class="ux-filter">{{i18n "director"}}</a></li>
+ <li><a href="genre" class="ux-filter">{{i18n "genre"}}</a></li>
+ <li><a href="rating" class="ux-filter">{{i18n "rating"}}</a></li>
+ <li><a href="year" class="ux-filter">{{i18n "year"}}</a></li>
+ </ul>
+ </div><!-- /btn-group -->
+ <input type="text" class="form-control ux-filter-field">
+ <span class="input-group-btn">
+ <button class="btn btn-primary ux-clear-filter-action" type="button">
+ <span class="glyphicon glyphicon-remove-circle"></span>
+ </button>
+ <button class="btn btn-primary ux-filter-action" type="button">
+ <span class="glyphicon glyphicon-search"></span>
+ </button>
+ </span>
+ </div>
+ <table class="table table-bordered table-striped table-hover">
+ <thead>
+ <tr>
+ <th>{{i18n "title"}}</th>
+ <th>{{i18n "director"}}</th>
+ <th>{{i18n "genre"}}</th>
+ <th>{{i18n "rating"}}</th>
+ <th>{{i18n "year"}}</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody></tbody>
+ </table>
+ <button type="button" class="btn btn-primary ux-add-btn">{{i18n "add.movie"}}</button>
+ </div>
+ </div>
+ </div>
+</div>
+
+
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/templates/container.handlebars b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/container.handlebars
new file mode 100755
index 0000000..dba60dd
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/container.handlebars
@@ -0,0 +1,10 @@
+<div class="navbar navbar-inverse navbar-fixed-top">
+ <div class="container">
+ <div class="navbar-header">
+ <a class="navbar-brand" href="#">{{i18n "application.name"}}</a>
+ </div>
+ </div>
+</div>
+<div class="container">
+ <div class="ux-contentarea"></div>
+</div>
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/templates/load-data-link.handlebars b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/load-data-link.handlebars
new file mode 100755
index 0000000..1785578
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/load-data-link.handlebars
@@ -0,0 +1 @@
+<a href="load-data">{{i18n "load.dada"}}</a>
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/templates/movie.handlebars b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/movie.handlebars
new file mode 100755
index 0000000..97c511c
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/templates/movie.handlebars
@@ -0,0 +1,56 @@
+<div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h4 class="modal-title">{{i18n "movie"}}</h4>
+ </div>
+ <div class="modal-body">
+ <form class="form-horizontal" role="form">
+ <div class="form-group">
+ <label for="{{id_next}}" class="col-lg-2 control-label">{{i18n "title"}}</label>
+
+ <div class="col-lg-10">
+ <input class="form-control ux-title" id="{{id_current}}" placeholder="{{i18n 'title'}}"
+ type="text" value="{{title}}">
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="{{id_next}}" class="col-lg-2 control-label">{{i18n "director"}}</label>
+
+ <div class="col-lg-10">
+ <input class="form-control ux-director" id="{{id_current}}"
+ type="text" placeholder="{{i18n 'director'}}" value="{{director}}">
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="{{id_next}}" class="col-lg-2 control-label">{{i18n "genre"}}</label>
+
+ <div class="col-lg-10">
+ <input class="form-control ux-genre" id="{{id_current}}" placeholder="{{i18n 'genre'}}"
+ type="text" value="{{genre}}">
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="{{id_next}}" class="col-lg-2 control-label">{{i18n "rating"}}</label>
+
+ <div class="col-lg-10">
+ <input class="form-control ux-rating" id="{{id_current}}"
+ type="number" min="0" max="10" placeholder="{{i18n 'rating'}}" value="{{rating}}">
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="{{id_next}}" class="col-lg-2 control-label">{{i18n "year"}}</label>
+
+ <div class="col-lg-10">
+ <input class="form-control ux-year" id="{{id_current}}" placeholder="{{i18n 'year'}}"
+ type="number" min="1900" max="{{currentYear}}" value="{{year}}">
+ </div>
+ </div>
+ </form>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default ux-close" data-dismiss="modal">{{i18n "close"}}</button>
+ <button type="button" class="btn btn-primary ux-save" data-dismiss="modal">{{i18n "save"}}</button>
+ </div>
+ </div>
+</div>
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/view/application-table-paginator.js b/content/examples/moviefun-rest/src/main/webapp/app/js/view/application-table-paginator.js
new file mode 100755
index 0000000..c5d2422
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/view/application-table-paginator.js
@@ -0,0 +1,77 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ var deps = ['app/js/templates', 'lib/backbone'];
+ define(deps, function (templates) {
+
+ var View = Backbone.View.extend({
+ tagName: 'ul',
+ className: 'pagination',
+
+ count: 0,
+
+ events: {
+ 'click a': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ var myLink = $(evt.target);
+ var href = myLink.attr('href');
+ me.trigger('go-to-page', {
+ number: href
+ });
+ }
+ },
+
+ render: function () {
+ var me = this;
+ me.$el.empty();
+ me.$el.append(templates.getValue('application-table-paginator-button', {
+ pageNumber: '1',
+ pageText: '<<'
+ }));
+ var i;
+ for (i = 1; i < me.count + 1; i += 1) {
+ me.$el.append(templates.getValue('application-table-paginator-button', {
+ pageNumber: i,
+ pageText: i
+ }));
+ }
+ me.$el.append(templates.getValue('application-table-paginator-button', {
+ pageNumber: 'last',
+ pageText: '>>'
+ }));
+ return this;
+ },
+
+ setCount: function (count) {
+ var me = this;
+ me.count = count;
+ me.render();
+ },
+
+ getCount: function () {
+ var me = this;
+ return me.count;
+ }
+ });
+ return new View().render();
+ });
+}());
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/view/application-table-row.js b/content/examples/moviefun-rest/src/main/webapp/app/js/view/application-table-row.js
new file mode 100755
index 0000000..771a062
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/view/application-table-row.js
@@ -0,0 +1,63 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ var deps = ['app/js/templates', 'lib/backbone'];
+ define(deps, function (templates) {
+
+ var View = Backbone.View.extend({
+ tagName: 'tr',
+ events: {
+ 'click .ux-delete-row': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ me.trigger('delete', {
+ model: me.model
+ });
+ me.remove();
+ },
+ 'click .ux-edit-row': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ me.trigger('edit', {
+ model: me.model
+ });
+ }
+ },
+
+ render: function () {
+ var me = this;
+ if (!this.options.isRendered) {
+ me.$el.empty();
+ me.$el.append(templates.getValue('application-table-row', {
+ title: me.model.get('title'),
+ director: me.model.get('director'),
+ genre: me.model.get('genre'),
+ rating: me.model.get('rating'),
+ year: me.model.get('year')
+ }));
+ me.options.isRendered = true;
+ }
+ return this;
+ }
+ });
+ return View;
+ });
+}());
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/view/application.js b/content/examples/moviefun-rest/src/main/webapp/app/js/view/application.js
new file mode 100755
index 0000000..7dae6b3
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/view/application.js
@@ -0,0 +1,135 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ var deps = ['app/js/templates', 'app/js/view/application-table-row', 'app/js/view/application-table-paginator',
+ 'lib/underscore', 'app/js/i18n', 'lib/backbone'];
+ define(deps, function (templates, TableRowView, paginator, underscore, i18n) {
+
+ var View = Backbone.View.extend({
+ tagName: 'div',
+ className: 'ux-application',
+
+ loadDataLink: $(templates.getValue('load-data-link', {})),
+
+ filterOption: 'title',
+
+ events: {
+ 'click .ux-filter': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ var selected = $(me.$el.find('.ux-selected-filter').get(0));
+ var myLink = $(evt.target);
+ me.filterOption = myLink.attr('href');
+ selected.html(i18n.get(me.filterOption, {}));
+ },
+ 'click .ux-filter-action': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ var filterValue = $(me.$el.find('.ux-filter-field').get(0)).val();
+ filterValue = $.trim(filterValue);
+ if (filterValue !== '') {
+ me.trigger('filter', {
+ filterType: me.filterOption,
+ filterValue: filterValue
+ });
+ }
+ },
+ 'click .ux-clear-filter-action': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ me.trigger('clear-filter', {});
+ },
+ 'click .ux-application': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ me.trigger('navigate', {
+ path: 'application'
+ });
+ },
+ 'click .ux-add-btn': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ me.trigger('add', {});
+ }
+ },
+
+ setFilter: function (fieldName, fieldValue) {
+ var field = fieldName;
+ var value = fieldValue;
+ if (!fieldName || $.trim(fieldName) === '') {
+ field = 'title';
+ value = '';
+ }
+ var me = this;
+ me.filterOption = field;
+ $(me.$el.find('.ux-selected-filter').get(0)).html(i18n.get(me.filterOption, {}));
+ $(me.$el.find('.ux-filter-field').get(0)).val(value);
+ },
+
+ render: function () {
+ var me = this;
+ if (!this.options.isRendered) {
+ me.$el.empty();
+ me.$el.append(templates.getValue('application', {}));
+ me.loadDataLink.on('click', function (evt) {
+ evt.preventDefault();
+ me.trigger('load-sample', {});
+ });
+ me.options.isRendered = true;
+ }
+ return this;
+ },
+
+ addRows: function (rows) {
+ var me = this;
+ var tbody = $(me.$el.find('tbody').get(0));
+ tbody.empty();
+ paginator.$el.detach();
+ me.loadDataLink.detach();
+ underscore.each(rows, function (model) {
+ var row = new TableRowView({
+ model: model
+ });
+ row.on('delete', function (data) {
+ me.trigger('delete', data);
+ });
+ row.on('edit', function (data) {
+ me.trigger('edit', data);
+ });
+ tbody.append(row.render().$el);
+ });
+ },
+
+ setPaginator: function (count) {
+ var me = this;
+ paginator.$el.detach();
+ me.loadDataLink.detach();
+ var table = $(me.$el.find('.table').get(0));
+ if (count) {
+ table.after(paginator.$el);
+ } else {
+ table.after(me.loadDataLink);
+ }
+ }
+ });
+ return new View();
+ });
+}());
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/view/container.js b/content/examples/moviefun-rest/src/main/webapp/app/js/view/container.js
new file mode 100755
index 0000000..73a57f1
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/view/container.js
@@ -0,0 +1,62 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ var deps = ['app/js/templates', 'app/js/i18n', 'lib/backbone'];
+ define(deps, function (templates) {
+
+ var View = Backbone.View.extend({
+ el: 'body',
+
+ showView: function (view) {
+ var me = this;
+ var contentarea = me.$('.ux-contentarea');
+ if (me.currentView) {
+ me.currentView.$el.detach();
+ }
+ me.currentView = view;
+ me.currentView.render();
+ contentarea.append(me.currentView.el);
+ if (view.renderCallback) {
+ view.renderCallback();
+ }
+ me.$('.ux-app-menu-item').removeClass('active');
+ var myMenuItem = me.$('li.ux-app-menu-item.' + view.className);
+ myMenuItem.addClass('active');
+ },
+
+ render: function () {
+ if (this.options.isRendered) {
+ return this;
+ }
+ var html = templates.getValue('container', {
+ userName: ''
+ });
+ this.$el.html(html);
+
+ // render it only once
+ this.options.isRendered = true;
+ return this;
+ }
+ });
+
+ return new View({});
+ });
+}());
diff --git a/content/examples/moviefun-rest/src/main/webapp/app/js/view/movie.js b/content/examples/moviefun-rest/src/main/webapp/app/js/view/movie.js
new file mode 100755
index 0000000..0417945
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/app/js/view/movie.js
@@ -0,0 +1,75 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+ 'use strict';
+
+ var deps = ['app/js/templates', 'lib/underscore', 'lib/backbone', 'app/js/id'];
+ define(deps, function (templates, underscore) {
+
+ var View = Backbone.View.extend({
+ tagName: 'div',
+ className: 'modal ux-movie-window',
+ events: {
+ 'click .ux-application': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ me.trigger('show-application', {});
+ },
+ 'click .ux-close': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ me.remove();
+ },
+ 'click .ux-save': function (evt) {
+ evt.preventDefault();
+ var me = this;
+ var model = me.model;
+
+ function set(name) {
+ var field = $(me.$el.find('.ux-' + name).get(0));
+ model.set(name, field.val());
+ }
+
+ set('title');
+ set('director');
+ set('genre');
+ set('rating');
+ set('year');
+ me.trigger('save-model', {
+ model: model
+ });
+ }
+ },
+ render: function () {
+ var me = this;
+ me.$el.empty();
+ me.$el.append(templates.getValue('movie', {
+ title: me.model.get('title'),
+ director: me.model.get('director'),
+ genre: me.model.get('genre'),
+ rating: me.model.get('rating'),
+ year: me.model.get('year'),
+ currentYear: new Date().getFullYear()
+ }));
+ return me;
+ }
+ });
+ return View;
+ });
+}());
diff --git a/content/examples/moviefun-rest/src/main/webapp/index.jsp b/content/examples/moviefun-rest/src/main/webapp/index.jsp
new file mode 100755
index 0000000..63d3e42
--- /dev/null
+++ b/content/examples/moviefun-rest/src/main/webapp/index.jsp
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Moviefun</title>
+ <link href="<c:url value='/webjars/bootstrap/3.1.0/css/bootstrap.min.css'/>" rel="stylesheet">
+ <link href="<c:url value='/app/app.less'/>" rel="stylesheet/less" type="text/css">
+ <script src="<c:url value='/webjars/requirejs/2.1.10/require.min.js'/>"></script>
+ <script type="text/javascript">
+ window.ux = window.ux || {};
+ window.ux.SESSION_ID = "<%=request.getSession().getId()%>";
+ window.ux.ROOT_URL = "<c:url value='/'/>".replace(';jsessionid=' + window.ux.SESSION_ID, '');
+ </script>
+ <script src="<c:url value='/app/config.js'/>"></script>
+ <script src="<c:url value='/app/js/start.js'/>"></script>
+</head>
+<body></body>
+</html>
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java b/content/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java
new file mode 100755
index 0000000..89fe1e1
--- /dev/null
+++ b/content/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.EJB;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class MoviesEJBTest {
+
+ @Deployment
+ public static WebArchive createDeployment() {
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(Movie.class, MoviesBean.class, MoviesEJBTest.class)
+ .addAsResource(new ClassLoaderAsset("META-INF/ejb-jar.xml"), "META-INF/ejb-jar.xml")
+ .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
+ }
+
+ @EJB
+ private MoviesBean movies;
+
+ @Before
+ @After
+ public void clean() {
+ movies.clean();
+ }
+
+ @Test
+ public void shouldBeAbleToAddAMovie() throws Exception {
+ assertNotNull("Verify that the ejb was injected", movies);
+
+ final Movie movie = new Movie();
+ movie.setDirector("Michael Bay");
+ movie.setGenre("Action");
+ movie.setRating(9);
+ movie.setTitle("Bad Boys");
+ movie.setYear(1995);
+ movies.addMovie(movie);
+
+ assertEquals(1, movies.count("title", "a"));
+ final List<Movie> moviesFound = movies.getMovies(0, 100, "title", "Bad Boys");
+ assertEquals(1, moviesFound.size());
+ assertEquals("Michael Bay", moviesFound.get(0).getDirector());
+ assertEquals("Action", moviesFound.get(0).getGenre());
+ assertEquals(9, moviesFound.get(0).getRating());
+ assertEquals("Bad Boys", moviesFound.get(0).getTitle());
+ assertEquals(1995, moviesFound.get(0).getYear());
+ }
+
+}
diff --git a/content/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java b/content/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java
new file mode 100755
index 0000000..b4c8c4e
--- /dev/null
+++ b/content/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class MoviesEmbeddedEJBTest {
+
+ private static EJBContainer ejbContainer;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ if (ejbContainer != null) {
+ ejbContainer.close();
+ }
+ }
+
+ @Before
+ @After
+ public void clean() throws Exception {
+ MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
+ movies.clean();
+ }
+
+ @Test
+ public void testShouldAddAMovie() throws Exception {
+ final MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
+
+ final Movie movie = new Movie();
+ movie.setDirector("Michael Bay");
+ movie.setGenre("Action");
+ movie.setRating(9);
+ movie.setTitle("Bad Boys");
+ movie.setYear(1995);
+ movies.addMovie(movie);
+
+ assertEquals(1, movies.count("title", "Bad Boys"));
+ final List<Movie> moviesFound = movies.getMovies(0, 100, "title", "Bad Boys");
+ assertEquals(1, moviesFound.size());
+ assertEquals("Michael Bay", moviesFound.get(0).getDirector());
+ assertEquals("Action", moviesFound.get(0).getGenre());
+ assertEquals(9, moviesFound.get(0).getRating());
+ assertEquals("Bad Boys", moviesFound.get(0).getTitle());
+ assertEquals(1995, moviesFound.get(0).getYear());
+ }
+
+}
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesTest.java b/content/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesTest.java
new file mode 100755
index 0000000..7e88d49
--- /dev/null
+++ b/content/examples/moviefun-rest/src/test/java/org/superbiz/moviefun/MoviesTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class MoviesTest {
+
+ private static EJBContainer ejbContainer;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ if (ejbContainer != null) {
+ ejbContainer.close();
+ }
+ }
+
+ @Before
+ @After
+ public void clean() throws Exception {
+ MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
+ movies.clean();
+ }
+
+ @Test
+ public void testShouldAddAMovie() throws Exception {
+ MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun-rest/MoviesBean!org.superbiz.moviefun.MoviesBean");
+
+ final Movie movie = new Movie();
+ movie.setDirector("Michael Bay");
+ movie.setGenre("Action");
+ movie.setRating(9);
+ movie.setTitle("Bad Boys");
+ movie.setYear(1995);
+ movies.addMovie(movie);
+
+ assertEquals(1, movies.count("title", "a"));
+ final List<Movie> moviesFound = movies.getMovies(0, 100, "title", "Bad Boys");
+ assertEquals(1, moviesFound.size());
+ assertEquals("Michael Bay", moviesFound.get(0).getDirector());
+ assertEquals("Action", moviesFound.get(0).getGenre());
+ assertEquals(9, moviesFound.get(0).getRating());
+ assertEquals("Bad Boys", moviesFound.get(0).getTitle());
+ assertEquals(1995, moviesFound.get(0).getYear());
+ }
+
+}
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/test/resources/META-INF/application-client.xml b/content/examples/moviefun-rest/src/test/resources/META-INF/application-client.xml
new file mode 100755
index 0000000..1e91dca
--- /dev/null
+++ b/content/examples/moviefun-rest/src/test/resources/META-INF/application-client.xml
@@ -0,0 +1 @@
+<application-client/>
\ No newline at end of file
diff --git a/content/examples/moviefun-rest/src/test/resources/arquillian.xml b/content/examples/moviefun-rest/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..4a2f32f
--- /dev/null
+++ b/content/examples/moviefun-rest/src/test/resources/arquillian.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+
+ <container qualifier="tomee" default="true">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="tomcatVersion"></property>
+ <property name="openejbVersion">${tomee.version}</property>
+ <property name="dir">target/apache-tomee-remote</property>
+ <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+ </configuration>
+ </container>
+</arquillian>
\ No newline at end of file
diff --git a/content/examples/moviefun.html b/content/examples/moviefun.html
new file mode 100644
index 0000000..c5a878c
--- /dev/null
+++ b/content/examples/moviefun.html
@@ -0,0 +1,573 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/moviefun.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Movies Complete</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example moviefun can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/moviefun" class="bare">https://github.com/apache/tomee/tree/master/examples/moviefun</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_addinterceptor">AddInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AddInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Add
+ return context.proceed();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_deleteinterceptor">DeleteInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class DeleteInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.interceptor.Interceptors;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+//START SNIPPET: code
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ @Interceptors(AddInterceptor.class)
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ @TransactionAttribute(TransactionAttributeType.MANDATORY)
+ @Interceptors(DeleteInterceptor.class)
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_readinterceptor">ReadInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class ReadInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import junit.framework.TestCase;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+/**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "TransactionBean")
+ private Caller transactionalCaller;
+
+ @EJB(beanName = "NoTransactionBean")
+ private Caller nonTransactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ nonTransactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public static class NoTransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.tx.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/movies-complete
+INFO - openejb.base = /Users/dblevins/examples/movies-complete
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/classes
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/test-classes
+INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/classes
+INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/test-classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/movies-complete
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/movies-complete" loaded.
+INFO - Assembling app: /Users/dblevins/examples/movies-complete
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 402ms
+INFO - Jndi(name="java:global/movies-complete/Movies!org.superbiz.injection.tx.Movies")
+INFO - Jndi(name="java:global/movies-complete/Movies")
+INFO - Jndi(name="java:global/movies-complete/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+INFO - Jndi(name="java:global/movies-complete/TransactionBean")
+INFO - Jndi(name="java:global/movies-complete/NoTransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+INFO - Jndi(name="java:global/movies-complete/NoTransactionBean")
+INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/movies-complete)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.418 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/moviefun.pdf b/content/examples/moviefun.pdf
new file mode 100644
index 0000000..f78aa4b
--- /dev/null
+++ b/content/examples/moviefun.pdf
Binary files differ
diff --git a/content/examples/moviefun/README.md b/content/examples/moviefun/README.md
new file mode 100755
index 0000000..990258a
--- /dev/null
+++ b/content/examples/moviefun/README.md
@@ -0,0 +1,338 @@
+Title: Movies Complete
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## AddInterceptor
+
+ package org.superbiz.injection.tx;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class AddInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Add
+ return context.proceed();
+ }
+ }
+
+## DeleteInterceptor
+
+ package org.superbiz.injection.tx;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class DeleteInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+ }
+
+## Movie
+
+ package org.superbiz.injection.tx;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection.tx;
+
+ import javax.annotation.security.PermitAll;
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.Stateful;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.interceptor.Interceptors;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ //START SNIPPET: code
+ @Stateful
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ @Interceptors(AddInterceptor.class)
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ @TransactionAttribute(TransactionAttributeType.MANDATORY)
+ @Interceptors(DeleteInterceptor.class)
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## ReadInterceptor
+
+ package org.superbiz.injection.tx;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class ReadInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MoviesTest
+
+ package org.superbiz.injection.tx;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.security.RunAs;
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.ejb.embeddable.EJBContainer;
+ import java.util.List;
+ import java.util.Properties;
+ import java.util.concurrent.Callable;
+
+ import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+ /**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+ //START SNIPPET: code
+ public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "TransactionBean")
+ private Caller transactionalCaller;
+
+ @EJB(beanName = "NoTransactionBean")
+ private Caller nonTransactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ nonTransactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public static class NoTransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.tx.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/movies-complete
+ INFO - openejb.base = /Users/dblevins/examples/movies-complete
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/classes
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/test-classes
+ INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/test-classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/movies-complete
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/movies-complete" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/movies-complete
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 402ms
+ INFO - Jndi(name="java:global/movies-complete/Movies!org.superbiz.injection.tx.Movies")
+ INFO - Jndi(name="java:global/movies-complete/Movies")
+ INFO - Jndi(name="java:global/movies-complete/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+ INFO - Jndi(name="java:global/movies-complete/TransactionBean")
+ INFO - Jndi(name="java:global/movies-complete/NoTransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+ INFO - Jndi(name="java:global/movies-complete/NoTransactionBean")
+ INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/movies-complete)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.418 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/moviefun/pom.xml b/content/examples/moviefun/pom.xml
new file mode 100755
index 0000000..be9ee6b
--- /dev/null
+++ b/content/examples/moviefun/pom.xml
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+
+<!-- $Rev: 684173 $ $Date: 2008-08-08 20:13:24 -0700 (Fri, 08 Aug 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>moviefun</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: Moviefun</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <tomee.version>1.7.1</tomee.version>
+ <version.shrinkwrap.resolver>2.0.0</version.shrinkwrap.resolver>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <build>
+ <finalName>moviefun</finalName>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.1</version>
+ <executions>
+ <execution>
+ <id>copy-test-libs</id>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>
+ ${project.build.directory}/test-libs
+ </outputDirectory>
+ <stripVersion>true</stripVersion>
+ </configuration>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <reuseForks>false</reuseForks> <!-- otherwise openejb embedded and tomee embedded shares the same context and EJBContainer is broken -->
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.9</version>
+ <configuration>
+ <configuration>
+ <wtpapplicationxml>true</wtpapplicationxml>
+ <wtpversion>2.0</wtpversion>
+ </configuration>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ <configuration>
+ <tomeeClassifier>plus</tomeeClassifier>
+ <args>-Xmx512m -XX:PermSize=256m</args>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencyManagement>
+ <dependencies>
+ <!-- Override dependency resolver with test version. This must go *BEFORE*
+ the Arquillian BOM. -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-bom</artifactId>
+ <version>${version.shrinkwrap.resolver}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ <!-- Now pull in our server-based unit testing framework -->
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-bom</artifactId>
+ <version>1.1.2.Final</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.8</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-embedded</artifactId>
+ <version>1.7.1</version>
+ <!--<classifier>uber</classifier> -->
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-depchain</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+ <profiles>
+ <profile>
+ <id>arquillian-tomee-embedded</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-embedded</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>arquillian-tomee-remote</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+</project>
diff --git a/content/examples/moviefun/src/main/java/org/superbiz/moviefun/ActionServlet.java b/content/examples/moviefun/src/main/java/org/superbiz/moviefun/ActionServlet.java
new file mode 100755
index 0000000..81e8821
--- /dev/null
+++ b/content/examples/moviefun/src/main/java/org/superbiz/moviefun/ActionServlet.java
@@ -0,0 +1,138 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import org.apache.commons.lang.StringUtils;
+
+import javax.ejb.EJB;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@WebServlet("/moviefun/*")
+public class ActionServlet extends HttpServlet {
+
+ private static final long serialVersionUID = -5832176047021911038L;
+
+ public static int PAGE_SIZE = 5;
+
+ @EJB
+ private MoviesBean moviesBean;
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ process(request, response);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ process(request, response);
+ }
+
+ private void process(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ String action = request.getParameter("action");
+
+ if ("Add".equals(action)) {
+
+ String title = request.getParameter("title");
+ String director = request.getParameter("director");
+ String genre = request.getParameter("genre");
+ int rating = Integer.parseInt(request.getParameter("rating"));
+ int year = Integer.parseInt(request.getParameter("year"));
+
+ Movie movie = new Movie(title, director, genre, rating, year);
+
+ moviesBean.addMovie(movie);
+ response.sendRedirect("moviefun");
+ return;
+
+ } else if ("Remove".equals(action)) {
+
+ String[] ids = request.getParameterValues("id");
+ for (String id : ids) {
+ moviesBean.deleteMovieId(new Long(id));
+ }
+
+ response.sendRedirect("moviefun");
+ return;
+
+ } else {
+ String key = request.getParameter("key");
+ String field = request.getParameter("field");
+
+ int count = 0;
+
+ if (StringUtils.isEmpty(key) || StringUtils.isEmpty(field)) {
+ count = moviesBean.countAll();
+ key = "";
+ field = "";
+ } else {
+ count = moviesBean.count(field, key);
+ }
+
+ int page = 1;
+
+ try {
+ page = Integer.parseInt(request.getParameter("page"));
+ } catch (Exception e) {
+ }
+
+ int pageCount = (count / PAGE_SIZE);
+ if (pageCount == 0 || count % PAGE_SIZE != 0) {
+ pageCount++;
+ }
+
+ if (page < 1) {
+ page = 1;
+ }
+
+ if (page > pageCount) {
+ page = pageCount;
+ }
+
+ int start = (page - 1) * PAGE_SIZE;
+ List<Movie> range;
+
+ if (StringUtils.isEmpty(key) || StringUtils.isEmpty(field)) {
+ range = moviesBean.findAll(start, PAGE_SIZE);
+ } else {
+ range = moviesBean.findRange(field, key, start, PAGE_SIZE);
+ }
+
+ int end = start + range.size();
+
+ request.setAttribute("count", count);
+ request.setAttribute("start", start + 1);
+ request.setAttribute("end", end);
+ request.setAttribute("page", page);
+ request.setAttribute("pageCount", pageCount);
+ request.setAttribute("movies", range);
+ request.setAttribute("key", key);
+ request.setAttribute("field", field);
+ }
+
+ request.getRequestDispatcher("WEB-INF/moviefun.jsp").forward(request, response);
+ }
+
+}
diff --git a/content/examples/moviefun/src/main/java/org/superbiz/moviefun/Movie.java b/content/examples/moviefun/src/main/java/org/superbiz/moviefun/Movie.java
new file mode 100755
index 0000000..e6ab8de
--- /dev/null
+++ b/content/examples/moviefun/src/main/java/org/superbiz/moviefun/Movie.java
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+@Entity
+public class Movie implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+ private String genre;
+ private int rating;
+
+ public Movie() {
+ }
+
+ public Movie(String title, String director, String genre, int rating, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ this.genre = genre;
+ this.rating = rating;
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getGenre() {
+ return genre;
+ }
+
+ public void setGenre(String genre) {
+ this.genre = genre;
+ }
+
+ public int getRating() {
+ return rating;
+ }
+
+ public void setRating(int rating) {
+ this.rating = rating;
+ }
+}
\ No newline at end of file
diff --git a/content/examples/moviefun/src/main/java/org/superbiz/moviefun/MoviesBean.java b/content/examples/moviefun/src/main/java/org/superbiz/moviefun/MoviesBean.java
new file mode 100755
index 0000000..cfee3f8
--- /dev/null
+++ b/content/examples/moviefun/src/main/java/org/superbiz/moviefun/MoviesBean.java
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.metamodel.EntityType;
+import java.util.List;
+
+@Stateless
+public class MoviesBean {
+
+ @PersistenceContext(unitName = "movie-unit")
+ private EntityManager entityManager;
+
+ public Movie find(Long id) {
+ return entityManager.find(Movie.class, id);
+ }
+
+ public void addMovie(Movie movie) {
+ entityManager.persist(movie);
+ }
+
+ public void editMovie(Movie movie) {
+ entityManager.merge(movie);
+ }
+
+ public void deleteMovie(Movie movie) {
+ entityManager.remove(movie);
+ }
+
+ public void deleteMovieId(long id) {
+ Movie movie = entityManager.find(Movie.class, id);
+ deleteMovie(movie);
+ }
+
+ public List<Movie> getMovies() {
+ CriteriaQuery<Movie> cq = entityManager.getCriteriaBuilder().createQuery(Movie.class);
+ cq.select(cq.from(Movie.class));
+ return entityManager.createQuery(cq).getResultList();
+ }
+
+ public List<Movie> findAll(int firstResult, int maxResults) {
+ CriteriaQuery<Movie> cq = entityManager.getCriteriaBuilder().createQuery(Movie.class);
+ cq.select(cq.from(Movie.class));
+ TypedQuery<Movie> q = entityManager.createQuery(cq);
+ q.setMaxResults(maxResults);
+ q.setFirstResult(firstResult);
+ return q.getResultList();
+ }
+
+ public int countAll() {
+ CriteriaQuery<Long> cq = entityManager.getCriteriaBuilder().createQuery(Long.class);
+ Root<Movie> rt = cq.from(Movie.class);
+ cq.select(entityManager.getCriteriaBuilder().count(rt));
+ TypedQuery<Long> q = entityManager.createQuery(cq);
+ return (q.getSingleResult()).intValue();
+ }
+
+ public int count(String field, String searchTerm) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Long> cq = qb.createQuery(Long.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field, String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm + "%");
+
+ cq.select(qb.count(root));
+ cq.where(condition);
+
+ return entityManager.createQuery(cq).getSingleResult().intValue();
+ }
+
+ public List<Movie> findRange(String field, String searchTerm, int firstResult, int maxResults) {
+ CriteriaBuilder qb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<Movie> cq = qb.createQuery(Movie.class);
+ Root<Movie> root = cq.from(Movie.class);
+ EntityType<Movie> type = entityManager.getMetamodel().entity(Movie.class);
+
+ Path<String> path = root.get(type.getDeclaredSingularAttribute(field, String.class));
+ Predicate condition = qb.like(path, "%" + searchTerm + "%");
+
+ cq.where(condition);
+ TypedQuery<Movie> q = entityManager.createQuery(cq);
+ q.setMaxResults(maxResults);
+ q.setFirstResult(firstResult);
+ return q.getResultList();
+ }
+
+ public void clean() {
+ entityManager.createQuery("delete from Movie").executeUpdate();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/moviefun/src/main/resources/META-INF/persistence.xml b/content/examples/moviefun/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..ec38aaa
--- /dev/null
+++ b/content/examples/moviefun/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.moviefun.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/moviefun/src/main/webapp/WEB-INF/moviefun.jsp b/content/examples/moviefun/src/main/webapp/WEB-INF/moviefun.jsp
new file mode 100755
index 0000000..c34dbfc
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/WEB-INF/moviefun.jsp
@@ -0,0 +1,128 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c' %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<c:set var="language" value="${pageContext.request.locale}"/>
+<fmt:setLocale value="${language}"/>
+
+<!DOCTYPE html>
+<html lang="${language}">
+<head>
+ <meta charset="utf-8">
+ <title>Moviefun</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <!-- Le styles -->
+ <link href="assets/css/bootstrap.css" rel="stylesheet">
+ <link href="assets/css/movie.css" rel="stylesheet">
+ <style>
+ body {
+ padding-top: 60px;
+ /* 60px to make the container go all the way to the bottom of the topbar */
+ }
+ </style>
+ <link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
+
+ <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+</head>
+
+<body>
+
+<div class="navbar navbar-inverse navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse"
+ data-target=".nav-collapse"> <span class="icon-bar"></span> <span
+ class="icon-bar"></span> <span class="icon-bar"></span>
+ </a> <a class="brand" href="#">Moviefun</a>
+
+ <form class="navbar-form pull-right">
+ <select name="field">
+ <option value="title">Title</option>
+ <option value="director">Director</option>
+ <option value="genre">Genre</option>
+ </select> <input type="text" name="key" size="20">
+ <button type="submit" class="btn">Search</button>
+ </form>
+
+ <!--/.nav-collapse -->
+ </div>
+ </div>
+</div>
+
+<div class="container">
+
+ <h1>Moviefun</h1>
+
+ <form class="movie-input-form form-inline" action="moviefun"
+ method="post">
+ <p>Add Movie</p>
+ <input type="text" name="title" placeholder="Title" size="29"/> <input
+ type="text" name="director" placeholder="Director" size="17"/> <input
+ type="text" name="genre" placeholder="Genre" size="14"/> <input
+ type="text" name="rating" placeholder="Rating" size="7"/> <input
+ type="text" name="year" placeholder="Year" size="4"
+ style="width: 110px;"/> <input type="submit" name="action"
+ class="btn btn-primary" value="Add"/>
+ </form>
+
+ <table class="table table-striped table-bordered">
+ <thead>
+ <tr>
+ <th>Title</th>
+ <th>Director</th>
+ <th>Genre</th>
+ <th>Rating</th>
+ <th>Year</th>
+ <th> </th>
+ </tr>
+ </thead>
+ <tbody>
+ <c:forEach items="${movies}" var="movie">
+ <tr>
+ <td><c:out value="${movie.title}"/></td>
+ <td><c:out value="${movie.director}"/></td>
+ <td><c:out value="${movie.genre}"/></td>
+ <td><c:out value="${movie.rating}"/></td>
+ <td><c:out value="${movie.year}"/></td>
+ <td><a href="?action=Remove&id=${movie.id}"><i
+ class="icon-trash"></i></a></td>
+ </tr>
+ </c:forEach>
+ </tbody>
+ </table>
+ <c:if test="${count > 0}">
+ <c:if test="${page > 1}">
+ <a href="<c:url value="moviefun"><c:param name="page" value="${page - 1}"/><c:param name="field" value="${field}"/><c:param name="key" value="${key}"/></c:url>">< Prev</a>
+ </c:if>
+ Showing records ${start} to ${end} of ${count}
+ <c:if test="${page < pageCount}">
+ <a href="<c:url value="moviefun"><c:param name="page" value="${page + 1}"/><c:param name="field" value="${field}"/><c:param name="key"
+ value="${key}"/></c:url>">Next ></a>
+ </c:if>
+ </c:if>
+</div>
+<!-- /container -->
+</body>
+</html>
diff --git a/content/examples/moviefun/src/main/webapp/WEB-INF/web.xml b/content/examples/moviefun/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..c2b6882
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<web-app version="3.0" 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/web-app_3_0.xsd">
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+</web-app>
+
diff --git a/content/examples/moviefun/src/main/webapp/assets/css/bootstrap-responsive.css b/content/examples/moviefun/src/main/webapp/assets/css/bootstrap-responsive.css
new file mode 100755
index 0000000..bfbd2c7
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/assets/css/bootstrap-responsive.css
@@ -0,0 +1,1285 @@
+/*!
+ * Bootstrap Responsive v2.1.1
+ *
+ * Copyright 2012 Twitter, Inc
+ * Licensed under the Apache License v2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Designed and built with all the love in the world @twitter by @mdo and @fat.
+ */
+
+.clearfix {
+ *zoom: 1;
+}
+
+.clearfix:before,
+.clearfix:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.clearfix:after {
+ clear: both;
+}
+
+.hide-text {
+ font: 0/0 a;
+ color: transparent;
+ text-shadow: none;
+ background-color: transparent;
+ border: 0;
+}
+
+.input-block-level {
+ display: block;
+ width: 100%;
+ min-height: 30px;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+.hidden {
+ display: none;
+ visibility: hidden;
+}
+
+.visible-phone {
+ display: none !important;
+}
+
+.visible-tablet {
+ display: none !important;
+}
+
+.hidden-desktop {
+ display: none !important;
+}
+
+.visible-desktop {
+ display: inherit !important;
+}
+
+@media (min-width: 768px) and (max-width: 979px) {
+ .hidden-desktop {
+ display: inherit !important;
+ }
+
+ .visible-desktop {
+ display: none !important;
+ }
+
+ .visible-tablet {
+ display: inherit !important;
+ }
+
+ .hidden-tablet {
+ display: none !important;
+ }
+}
+
+@media (max-width: 767px) {
+ .hidden-desktop {
+ display: inherit !important;
+ }
+
+ .visible-desktop {
+ display: none !important;
+ }
+
+ .visible-phone {
+ display: inherit !important;
+ }
+
+ .hidden-phone {
+ display: none !important;
+ }
+}
+
+@media (min-width: 1200px) {
+ .row {
+ margin-left: -30px;
+ *zoom: 1;
+ }
+
+ .row:before,
+ .row:after {
+ display: table;
+ line-height: 0;
+ content: "";
+ }
+
+ .row:after {
+ clear: both;
+ }
+
+ [class*="span"] {
+ float: left;
+ min-height: 1px;
+ margin-left: 30px;
+ }
+
+ .container,
+ .navbar-static-top .container,
+ .navbar-fixed-top .container,
+ .navbar-fixed-bottom .container {
+ width: 1170px;
+ }
+
+ .span12 {
+ width: 1170px;
+ }
+
+ .span11 {
+ width: 1070px;
+ }
+
+ .span10 {
+ width: 970px;
+ }
+
+ .span9 {
+ width: 870px;
+ }
+
+ .span8 {
+ width: 770px;
+ }
+
+ .span7 {
+ width: 670px;
+ }
+
+ .span6 {
+ width: 570px;
+ }
+
+ .span5 {
+ width: 470px;
+ }
+
+ .span4 {
+ width: 370px;
+ }
+
+ .span3 {
+ width: 270px;
+ }
+
+ .span2 {
+ width: 170px;
+ }
+
+ .span1 {
+ width: 70px;
+ }
+
+ .offset12 {
+ margin-left: 1230px;
+ }
+
+ .offset11 {
+ margin-left: 1130px;
+ }
+
+ .offset10 {
+ margin-left: 1030px;
+ }
+
+ .offset9 {
+ margin-left: 930px;
+ }
+
+ .offset8 {
+ margin-left: 830px;
+ }
+
+ .offset7 {
+ margin-left: 730px;
+ }
+
+ .offset6 {
+ margin-left: 630px;
+ }
+
+ .offset5 {
+ margin-left: 530px;
+ }
+
+ .offset4 {
+ margin-left: 430px;
+ }
+
+ .offset3 {
+ margin-left: 330px;
+ }
+
+ .offset2 {
+ margin-left: 230px;
+ }
+
+ .offset1 {
+ margin-left: 130px;
+ }
+
+ .row-fluid {
+ width: 100%;
+ *zoom: 1;
+ }
+
+ .row-fluid:before,
+ .row-fluid:after {
+ display: table;
+ line-height: 0;
+ content: "";
+ }
+
+ .row-fluid:after {
+ clear: both;
+ }
+
+ .row-fluid [class*="span"] {
+ display: block;
+ float: left;
+ width: 100%;
+ min-height: 30px;
+ margin-left: 2.564102564102564%;
+ *margin-left: 2.5109110747408616%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ }
+
+ .row-fluid [class*="span"]:first-child {
+ margin-left: 0;
+ }
+
+ .row-fluid .span12 {
+ width: 100%;
+ *width: 99.94680851063829%;
+ }
+
+ .row-fluid .span11 {
+ width: 91.45299145299145%;
+ *width: 91.39979996362975%;
+ }
+
+ .row-fluid .span10 {
+ width: 82.90598290598291%;
+ *width: 82.8527914166212%;
+ }
+
+ .row-fluid .span9 {
+ width: 74.35897435897436%;
+ *width: 74.30578286961266%;
+ }
+
+ .row-fluid .span8 {
+ width: 65.81196581196582%;
+ *width: 65.75877432260411%;
+ }
+
+ .row-fluid .span7 {
+ width: 57.26495726495726%;
+ *width: 57.21176577559556%;
+ }
+
+ .row-fluid .span6 {
+ width: 48.717948717948715%;
+ *width: 48.664757228587014%;
+ }
+
+ .row-fluid .span5 {
+ width: 40.17094017094017%;
+ *width: 40.11774868157847%;
+ }
+
+ .row-fluid .span4 {
+ width: 31.623931623931625%;
+ *width: 31.570740134569924%;
+ }
+
+ .row-fluid .span3 {
+ width: 23.076923076923077%;
+ *width: 23.023731587561375%;
+ }
+
+ .row-fluid .span2 {
+ width: 14.52991452991453%;
+ *width: 14.476723040552828%;
+ }
+
+ .row-fluid .span1 {
+ width: 5.982905982905983%;
+ *width: 5.929714493544281%;
+ }
+
+ .row-fluid .offset12 {
+ margin-left: 105.12820512820512%;
+ *margin-left: 105.02182214948171%;
+ }
+
+ .row-fluid .offset12:first-child {
+ margin-left: 102.56410256410257%;
+ *margin-left: 102.45771958537915%;
+ }
+
+ .row-fluid .offset11 {
+ margin-left: 96.58119658119658%;
+ *margin-left: 96.47481360247316%;
+ }
+
+ .row-fluid .offset11:first-child {
+ margin-left: 94.01709401709402%;
+ *margin-left: 93.91071103837061%;
+ }
+
+ .row-fluid .offset10 {
+ margin-left: 88.03418803418803%;
+ *margin-left: 87.92780505546462%;
+ }
+
+ .row-fluid .offset10:first-child {
+ margin-left: 85.47008547008548%;
+ *margin-left: 85.36370249136206%;
+ }
+
+ .row-fluid .offset9 {
+ margin-left: 79.48717948717949%;
+ *margin-left: 79.38079650845607%;
+ }
+
+ .row-fluid .offset9:first-child {
+ margin-left: 76.92307692307693%;
+ *margin-left: 76.81669394435352%;
+ }
+
+ .row-fluid .offset8 {
+ margin-left: 70.94017094017094%;
+ *margin-left: 70.83378796144753%;
+ }
+
+ .row-fluid .offset8:first-child {
+ margin-left: 68.37606837606839%;
+ *margin-left: 68.26968539734497%;
+ }
+
+ .row-fluid .offset7 {
+ margin-left: 62.393162393162385%;
+ *margin-left: 62.28677941443899%;
+ }
+
+ .row-fluid .offset7:first-child {
+ margin-left: 59.82905982905982%;
+ *margin-left: 59.72267685033642%;
+ }
+
+ .row-fluid .offset6 {
+ margin-left: 53.84615384615384%;
+ *margin-left: 53.739770867430444%;
+ }
+
+ .row-fluid .offset6:first-child {
+ margin-left: 51.28205128205128%;
+ *margin-left: 51.175668303327875%;
+ }
+
+ .row-fluid .offset5 {
+ margin-left: 45.299145299145295%;
+ *margin-left: 45.1927623204219%;
+ }
+
+ .row-fluid .offset5:first-child {
+ margin-left: 42.73504273504273%;
+ *margin-left: 42.62865975631933%;
+ }
+
+ .row-fluid .offset4 {
+ margin-left: 36.75213675213675%;
+ *margin-left: 36.645753773413354%;
+ }
+
+ .row-fluid .offset4:first-child {
+ margin-left: 34.18803418803419%;
+ *margin-left: 34.081651209310785%;
+ }
+
+ .row-fluid .offset3 {
+ margin-left: 28.205128205128204%;
+ *margin-left: 28.0987452264048%;
+ }
+
+ .row-fluid .offset3:first-child {
+ margin-left: 25.641025641025642%;
+ *margin-left: 25.53464266230224%;
+ }
+
+ .row-fluid .offset2 {
+ margin-left: 19.65811965811966%;
+ *margin-left: 19.551736679396257%;
+ }
+
+ .row-fluid .offset2:first-child {
+ margin-left: 17.094017094017094%;
+ *margin-left: 16.98763411529369%;
+ }
+
+ .row-fluid .offset1 {
+ margin-left: 11.11111111111111%;
+ *margin-left: 11.004728132387708%;
+ }
+
+ .row-fluid .offset1:first-child {
+ margin-left: 8.547008547008547%;
+ *margin-left: 8.440625568285142%;
+ }
+
+ input,
+ textarea,
+ .uneditable-input {
+ margin-left: 0;
+ }
+
+ .controls-row [class*="span"] + [class*="span"] {
+ margin-left: 30px;
+ }
+
+ input.span12,
+ textarea.span12,
+ .uneditable-input.span12 {
+ width: 1156px;
+ }
+
+ input.span11,
+ textarea.span11,
+ .uneditable-input.span11 {
+ width: 1056px;
+ }
+
+ input.span10,
+ textarea.span10,
+ .uneditable-input.span10 {
+ width: 956px;
+ }
+
+ input.span9,
+ textarea.span9,
+ .uneditable-input.span9 {
+ width: 856px;
+ }
+
+ input.span8,
+ textarea.span8,
+ .uneditable-input.span8 {
+ width: 756px;
+ }
+
+ input.span7,
+ textarea.span7,
+ .uneditable-input.span7 {
+ width: 656px;
+ }
+
+ input.span6,
+ textarea.span6,
+ .uneditable-input.span6 {
+ width: 556px;
+ }
+
+ input.span5,
+ textarea.span5,
+ .uneditable-input.span5 {
+ width: 456px;
+ }
+
+ input.span4,
+ textarea.span4,
+ .uneditable-input.span4 {
+ width: 356px;
+ }
+
+ input.span3,
+ textarea.span3,
+ .uneditable-input.span3 {
+ width: 256px;
+ }
+
+ input.span2,
+ textarea.span2,
+ .uneditable-input.span2 {
+ width: 156px;
+ }
+
+ input.span1,
+ textarea.span1,
+ .uneditable-input.span1 {
+ width: 56px;
+ }
+
+ .thumbnails {
+ margin-left: -30px;
+ }
+
+ .thumbnails > li {
+ margin-left: 30px;
+ }
+
+ .row-fluid .thumbnails {
+ margin-left: 0;
+ }
+}
+
+@media (min-width: 768px) and (max-width: 979px) {
+ .row {
+ margin-left: -20px;
+ *zoom: 1;
+ }
+
+ .row:before,
+ .row:after {
+ display: table;
+ line-height: 0;
+ content: "";
+ }
+
+ .row:after {
+ clear: both;
+ }
+
+ [class*="span"] {
+ float: left;
+ min-height: 1px;
+ margin-left: 20px;
+ }
+
+ .container,
+ .navbar-static-top .container,
+ .navbar-fixed-top .container,
+ .navbar-fixed-bottom .container {
+ width: 724px;
+ }
+
+ .span12 {
+ width: 724px;
+ }
+
+ .span11 {
+ width: 662px;
+ }
+
+ .span10 {
+ width: 600px;
+ }
+
+ .span9 {
+ width: 538px;
+ }
+
+ .span8 {
+ width: 476px;
+ }
+
+ .span7 {
+ width: 414px;
+ }
+
+ .span6 {
+ width: 352px;
+ }
+
+ .span5 {
+ width: 290px;
+ }
+
+ .span4 {
+ width: 228px;
+ }
+
+ .span3 {
+ width: 166px;
+ }
+
+ .span2 {
+ width: 104px;
+ }
+
+ .span1 {
+ width: 42px;
+ }
+
+ .offset12 {
+ margin-left: 764px;
+ }
+
+ .offset11 {
+ margin-left: 702px;
+ }
+
+ .offset10 {
+ margin-left: 640px;
+ }
+
+ .offset9 {
+ margin-left: 578px;
+ }
+
+ .offset8 {
+ margin-left: 516px;
+ }
+
+ .offset7 {
+ margin-left: 454px;
+ }
+
+ .offset6 {
+ margin-left: 392px;
+ }
+
+ .offset5 {
+ margin-left: 330px;
+ }
+
+ .offset4 {
+ margin-left: 268px;
+ }
+
+ .offset3 {
+ margin-left: 206px;
+ }
+
+ .offset2 {
+ margin-left: 144px;
+ }
+
+ .offset1 {
+ margin-left: 82px;
+ }
+
+ .row-fluid {
+ width: 100%;
+ *zoom: 1;
+ }
+
+ .row-fluid:before,
+ .row-fluid:after {
+ display: table;
+ line-height: 0;
+ content: "";
+ }
+
+ .row-fluid:after {
+ clear: both;
+ }
+
+ .row-fluid [class*="span"] {
+ display: block;
+ float: left;
+ width: 100%;
+ min-height: 30px;
+ margin-left: 2.7624309392265194%;
+ *margin-left: 2.709239449864817%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ }
+
+ .row-fluid [class*="span"]:first-child {
+ margin-left: 0;
+ }
+
+ .row-fluid .span12 {
+ width: 100%;
+ *width: 99.94680851063829%;
+ }
+
+ .row-fluid .span11 {
+ width: 91.43646408839778%;
+ *width: 91.38327259903608%;
+ }
+
+ .row-fluid .span10 {
+ width: 82.87292817679558%;
+ *width: 82.81973668743387%;
+ }
+
+ .row-fluid .span9 {
+ width: 74.30939226519337%;
+ *width: 74.25620077583166%;
+ }
+
+ .row-fluid .span8 {
+ width: 65.74585635359117%;
+ *width: 65.69266486422946%;
+ }
+
+ .row-fluid .span7 {
+ width: 57.18232044198895%;
+ *width: 57.12912895262725%;
+ }
+
+ .row-fluid .span6 {
+ width: 48.61878453038674%;
+ *width: 48.56559304102504%;
+ }
+
+ .row-fluid .span5 {
+ width: 40.05524861878453%;
+ *width: 40.00205712942283%;
+ }
+
+ .row-fluid .span4 {
+ width: 31.491712707182323%;
+ *width: 31.43852121782062%;
+ }
+
+ .row-fluid .span3 {
+ width: 22.92817679558011%;
+ *width: 22.87498530621841%;
+ }
+
+ .row-fluid .span2 {
+ width: 14.3646408839779%;
+ *width: 14.311449394616199%;
+ }
+
+ .row-fluid .span1 {
+ width: 5.801104972375691%;
+ *width: 5.747913483013988%;
+ }
+
+ .row-fluid .offset12 {
+ margin-left: 105.52486187845304%;
+ *margin-left: 105.41847889972962%;
+ }
+
+ .row-fluid .offset12:first-child {
+ margin-left: 102.76243093922652%;
+ *margin-left: 102.6560479605031%;
+ }
+
+ .row-fluid .offset11 {
+ margin-left: 96.96132596685082%;
+ *margin-left: 96.8549429881274%;
+ }
+
+ .row-fluid .offset11:first-child {
+ margin-left: 94.1988950276243%;
+ *margin-left: 94.09251204890089%;
+ }
+
+ .row-fluid .offset10 {
+ margin-left: 88.39779005524862%;
+ *margin-left: 88.2914070765252%;
+ }
+
+ .row-fluid .offset10:first-child {
+ margin-left: 85.6353591160221%;
+ *margin-left: 85.52897613729868%;
+ }
+
+ .row-fluid .offset9 {
+ margin-left: 79.8342541436464%;
+ *margin-left: 79.72787116492299%;
+ }
+
+ .row-fluid .offset9:first-child {
+ margin-left: 77.07182320441989%;
+ *margin-left: 76.96544022569647%;
+ }
+
+ .row-fluid .offset8 {
+ margin-left: 71.2707182320442%;
+ *margin-left: 71.16433525332079%;
+ }
+
+ .row-fluid .offset8:first-child {
+ margin-left: 68.50828729281768%;
+ *margin-left: 68.40190431409427%;
+ }
+
+ .row-fluid .offset7 {
+ margin-left: 62.70718232044199%;
+ *margin-left: 62.600799341718584%;
+ }
+
+ .row-fluid .offset7:first-child {
+ margin-left: 59.94475138121547%;
+ *margin-left: 59.838368402492065%;
+ }
+
+ .row-fluid .offset6 {
+ margin-left: 54.14364640883978%;
+ *margin-left: 54.037263430116376%;
+ }
+
+ .row-fluid .offset6:first-child {
+ margin-left: 51.38121546961326%;
+ *margin-left: 51.27483249088986%;
+ }
+
+ .row-fluid .offset5 {
+ margin-left: 45.58011049723757%;
+ *margin-left: 45.47372751851417%;
+ }
+
+ .row-fluid .offset5:first-child {
+ margin-left: 42.81767955801105%;
+ *margin-left: 42.71129657928765%;
+ }
+
+ .row-fluid .offset4 {
+ margin-left: 37.01657458563536%;
+ *margin-left: 36.91019160691196%;
+ }
+
+ .row-fluid .offset4:first-child {
+ margin-left: 34.25414364640884%;
+ *margin-left: 34.14776066768544%;
+ }
+
+ .row-fluid .offset3 {
+ margin-left: 28.45303867403315%;
+ *margin-left: 28.346655695309746%;
+ }
+
+ .row-fluid .offset3:first-child {
+ margin-left: 25.69060773480663%;
+ *margin-left: 25.584224756083227%;
+ }
+
+ .row-fluid .offset2 {
+ margin-left: 19.88950276243094%;
+ *margin-left: 19.783119783707537%;
+ }
+
+ .row-fluid .offset2:first-child {
+ margin-left: 17.12707182320442%;
+ *margin-left: 17.02068884448102%;
+ }
+
+ .row-fluid .offset1 {
+ margin-left: 11.32596685082873%;
+ *margin-left: 11.219583872105325%;
+ }
+
+ .row-fluid .offset1:first-child {
+ margin-left: 8.56353591160221%;
+ *margin-left: 8.457152932878806%;
+ }
+
+ input,
+ textarea,
+ .uneditable-input {
+ margin-left: 0;
+ }
+
+ .controls-row [class*="span"] + [class*="span"] {
+ margin-left: 20px;
+ }
+
+ input.span12,
+ textarea.span12,
+ .uneditable-input.span12 {
+ width: 710px;
+ }
+
+ input.span11,
+ textarea.span11,
+ .uneditable-input.span11 {
+ width: 648px;
+ }
+
+ input.span10,
+ textarea.span10,
+ .uneditable-input.span10 {
+ width: 586px;
+ }
+
+ input.span9,
+ textarea.span9,
+ .uneditable-input.span9 {
+ width: 524px;
+ }
+
+ input.span8,
+ textarea.span8,
+ .uneditable-input.span8 {
+ width: 462px;
+ }
+
+ input.span7,
+ textarea.span7,
+ .uneditable-input.span7 {
+ width: 400px;
+ }
+
+ input.span6,
+ textarea.span6,
+ .uneditable-input.span6 {
+ width: 338px;
+ }
+
+ input.span5,
+ textarea.span5,
+ .uneditable-input.span5 {
+ width: 276px;
+ }
+
+ input.span4,
+ textarea.span4,
+ .uneditable-input.span4 {
+ width: 214px;
+ }
+
+ input.span3,
+ textarea.span3,
+ .uneditable-input.span3 {
+ width: 152px;
+ }
+
+ input.span2,
+ textarea.span2,
+ .uneditable-input.span2 {
+ width: 90px;
+ }
+
+ input.span1,
+ textarea.span1,
+ .uneditable-input.span1 {
+ width: 28px;
+ }
+}
+
+@media (max-width: 767px) {
+ body {
+ padding-right: 20px;
+ padding-left: 20px;
+ }
+
+ .navbar-fixed-top,
+ .navbar-fixed-bottom,
+ .navbar-static-top {
+ margin-right: -20px;
+ margin-left: -20px;
+ }
+
+ .container-fluid {
+ padding: 0;
+ }
+
+ .dl-horizontal dt {
+ float: none;
+ width: auto;
+ clear: none;
+ text-align: left;
+ }
+
+ .dl-horizontal dd {
+ margin-left: 0;
+ }
+
+ .container {
+ width: auto;
+ }
+
+ .row-fluid {
+ width: 100%;
+ }
+
+ .row,
+ .thumbnails {
+ margin-left: 0;
+ }
+
+ .thumbnails > li {
+ float: none;
+ margin-left: 0;
+ }
+
+ [class*="span"],
+ .row-fluid [class*="span"] {
+ display: block;
+ float: none;
+ width: 100%;
+ margin-left: 0;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ }
+
+ .span12,
+ .row-fluid .span12 {
+ width: 100%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ }
+
+ .input-large,
+ .input-xlarge,
+ .input-xxlarge,
+ input[class*="span"],
+ select[class*="span"],
+ textarea[class*="span"],
+ .uneditable-input {
+ display: block;
+ width: 100%;
+ min-height: 30px;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ }
+
+ .input-prepend input,
+ .input-append input,
+ .input-prepend input[class*="span"],
+ .input-append input[class*="span"] {
+ display: inline-block;
+ width: auto;
+ }
+
+ .controls-row [class*="span"] + [class*="span"] {
+ margin-left: 0;
+ }
+
+ .modal {
+ position: fixed;
+ top: 20px;
+ right: 20px;
+ left: 20px;
+ width: auto;
+ margin: 0;
+ }
+
+ .modal.fade.in {
+ top: auto;
+ }
+}
+
+@media (max-width: 480px) {
+ .nav-collapse {
+ -webkit-transform: translate3d(0, 0, 0);
+ }
+
+ .page-header h1 small {
+ display: block;
+ line-height: 20px;
+ }
+
+ input[type="checkbox"],
+ input[type="radio"] {
+ border: 1px solid #ccc;
+ }
+
+ .form-horizontal .control-label {
+ float: none;
+ width: auto;
+ padding-top: 0;
+ text-align: left;
+ }
+
+ .form-horizontal .controls {
+ margin-left: 0;
+ }
+
+ .form-horizontal .control-list {
+ padding-top: 0;
+ }
+
+ .form-horizontal .form-actions {
+ padding-right: 10px;
+ padding-left: 10px;
+ }
+
+ .modal {
+ top: 10px;
+ right: 10px;
+ left: 10px;
+ }
+
+ .modal-header .close {
+ padding: 10px;
+ margin: -10px;
+ }
+
+ .carousel-caption {
+ position: static;
+ }
+}
+
+@media (max-width: 979px) {
+ body {
+ padding-top: 0;
+ }
+
+ .navbar-fixed-top,
+ .navbar-fixed-bottom {
+ position: static;
+ }
+
+ .navbar-fixed-top {
+ margin-bottom: 20px;
+ }
+
+ .navbar-fixed-bottom {
+ margin-top: 20px;
+ }
+
+ .navbar-fixed-top .navbar-inner,
+ .navbar-fixed-bottom .navbar-inner {
+ padding: 5px;
+ }
+
+ .navbar .container {
+ width: auto;
+ padding: 0;
+ }
+
+ .navbar .brand {
+ padding-right: 10px;
+ padding-left: 10px;
+ margin: 0 0 0 -5px;
+ }
+
+ .nav-collapse {
+ clear: both;
+ }
+
+ .nav-collapse .nav {
+ float: none;
+ margin: 0 0 10px;
+ }
+
+ .nav-collapse .nav > li {
+ float: none;
+ }
+
+ .nav-collapse .nav > li > a {
+ margin-bottom: 2px;
+ }
+
+ .nav-collapse .nav > .divider-vertical {
+ display: none;
+ }
+
+ .nav-collapse .nav .nav-header {
+ color: #777777;
+ text-shadow: none;
+ }
+
+ .nav-collapse .nav > li > a,
+ .nav-collapse .dropdown-menu a {
+ padding: 9px 15px;
+ font-weight: bold;
+ color: #777777;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+ }
+
+ .nav-collapse .btn {
+ padding: 4px 10px 4px;
+ font-weight: normal;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ }
+
+ .nav-collapse .dropdown-menu li + li a {
+ margin-bottom: 2px;
+ }
+
+ .nav-collapse .nav > li > a:hover,
+ .nav-collapse .dropdown-menu a:hover {
+ background-color: #f2f2f2;
+ }
+
+ .navbar-inverse .nav-collapse .nav > li > a:hover,
+ .navbar-inverse .nav-collapse .dropdown-menu a:hover {
+ background-color: #111111;
+ }
+
+ .nav-collapse.in .btn-group {
+ padding: 0;
+ margin-top: 5px;
+ }
+
+ .nav-collapse .dropdown-menu {
+ position: static;
+ top: auto;
+ left: auto;
+ display: block;
+ float: none;
+ max-width: none;
+ padding: 0;
+ margin: 0 15px;
+ background-color: transparent;
+ border: none;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ box-shadow: none;
+ }
+
+ .nav-collapse .dropdown-menu:before,
+ .nav-collapse .dropdown-menu:after {
+ display: none;
+ }
+
+ .nav-collapse .dropdown-menu .divider {
+ display: none;
+ }
+
+ .nav-collapse .nav > li > .dropdown-menu:before,
+ .nav-collapse .nav > li > .dropdown-menu:after {
+ display: none;
+ }
+
+ .nav-collapse .navbar-form,
+ .nav-collapse .navbar-search {
+ float: none;
+ padding: 10px 15px;
+ margin: 10px 0;
+ border-top: 1px solid #f2f2f2;
+ border-bottom: 1px solid #f2f2f2;
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
+ -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
+ }
+
+ .navbar-inverse .nav-collapse .navbar-form,
+ .navbar-inverse .nav-collapse .navbar-search {
+ border-top-color: #111111;
+ border-bottom-color: #111111;
+ }
+
+ .navbar .nav-collapse .nav.pull-right {
+ float: none;
+ margin-left: 0;
+ }
+
+ .nav-collapse,
+ .nav-collapse.collapse {
+ height: 0;
+ overflow: hidden;
+ }
+
+ .navbar .btn-navbar {
+ display: block;
+ }
+
+ .navbar-static .navbar-inner {
+ padding-right: 10px;
+ padding-left: 10px;
+ }
+}
+
+@media (min-width: 980px) {
+ .nav-collapse.collapse {
+ height: auto !important;
+ overflow: visible !important;
+ }
+}
diff --git a/content/examples/moviefun/src/main/webapp/assets/css/bootstrap-responsive.min.css b/content/examples/moviefun/src/main/webapp/assets/css/bootstrap-responsive.min.css
new file mode 100755
index 0000000..0a92e2a
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/assets/css/bootstrap-responsive.min.css
@@ -0,0 +1,1196 @@
+/*!
+ * Bootstrap Responsive v2.1.1
+ *
+ * Copyright 2012 Twitter, Inc
+ * Licensed under the Apache License v2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Designed and built with all the love in the world @twitter by @mdo and @fat.
+ */
+.clearfix {
+ *zoom: 1
+}
+
+.clearfix:before, .clearfix:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.clearfix:after {
+ clear: both
+}
+
+.hide-text {
+ font: 0/0 a;
+ color: transparent;
+ text-shadow: none;
+ background-color: transparent;
+ border: 0
+}
+
+.input-block-level {
+ display: block;
+ width: 100%;
+ min-height: 30px;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box
+}
+
+.hidden {
+ display: none;
+ visibility: hidden
+}
+
+.visible-phone {
+ display: none !important
+}
+
+.visible-tablet {
+ display: none !important
+}
+
+.hidden-desktop {
+ display: none !important
+}
+
+.visible-desktop {
+ display: inherit !important
+}
+
+@media (min-width:768px) and (max-width:979px) {
+ .hidden-desktop {
+ display: inherit !important
+ }
+
+ .visible-desktop {
+ display: none !important
+ }
+
+ .visible-tablet {
+ display: inherit !important
+ }
+
+ .hidden-tablet {
+ display: none !important
+ }
+}
+
+@media (max-width:767px) {
+ .hidden-desktop {
+ display: inherit !important
+ }
+
+ .visible-desktop {
+ display: none !important
+ }
+
+ .visible-phone {
+ display: inherit !important
+ }
+
+ .hidden-phone {
+ display: none !important
+ }
+}
+
+@media (min-width:1200px) {
+ .row {
+ margin-left: -30px;
+ *zoom: 1
+ }
+
+ .row:before, .row:after {
+ display: table;
+ line-height: 0;
+ content: ""
+ }
+
+ .row:after {
+ clear: both
+ }
+
+ [class*="span"] {
+ float: left;
+ min-height: 1px;
+ margin-left: 30px
+ }
+
+ .container, .navbar-static-top .container, .navbar-fixed-top .container, .navbar-fixed-bottom .container {
+ width: 1170px
+ }
+
+ .span12 {
+ width: 1170px
+ }
+
+ .span11 {
+ width: 1070px
+ }
+
+ .span10 {
+ width: 970px
+ }
+
+ .span9 {
+ width: 870px
+ }
+
+ .span8 {
+ width: 770px
+ }
+
+ .span7 {
+ width: 670px
+ }
+
+ .span6 {
+ width: 570px
+ }
+
+ .span5 {
+ width: 470px
+ }
+
+ .span4 {
+ width: 370px
+ }
+
+ .span3 {
+ width: 270px
+ }
+
+ .span2 {
+ width: 170px
+ }
+
+ .span1 {
+ width: 70px
+ }
+
+ .offset12 {
+ margin-left: 1230px
+ }
+
+ .offset11 {
+ margin-left: 1130px
+ }
+
+ .offset10 {
+ margin-left: 1030px
+ }
+
+ .offset9 {
+ margin-left: 930px
+ }
+
+ .offset8 {
+ margin-left: 830px
+ }
+
+ .offset7 {
+ margin-left: 730px
+ }
+
+ .offset6 {
+ margin-left: 630px
+ }
+
+ .offset5 {
+ margin-left: 530px
+ }
+
+ .offset4 {
+ margin-left: 430px
+ }
+
+ .offset3 {
+ margin-left: 330px
+ }
+
+ .offset2 {
+ margin-left: 230px
+ }
+
+ .offset1 {
+ margin-left: 130px
+ }
+
+ .row-fluid {
+ width: 100%;
+ *zoom: 1
+ }
+
+ .row-fluid:before, .row-fluid:after {
+ display: table;
+ line-height: 0;
+ content: ""
+ }
+
+ .row-fluid:after {
+ clear: both
+ }
+
+ .row-fluid [class*="span"] {
+ display: block;
+ float: left;
+ width: 100%;
+ min-height: 30px;
+ margin-left: 2.564102564102564%;
+ *margin-left: 2.5109110747408616%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box
+ }
+
+ .row-fluid [class*="span"]:first-child {
+ margin-left: 0
+ }
+
+ .row-fluid .span12 {
+ width: 100%;
+ *width: 99.94680851063829%
+ }
+
+ .row-fluid .span11 {
+ width: 91.45299145299145%;
+ *width: 91.39979996362975%
+ }
+
+ .row-fluid .span10 {
+ width: 82.90598290598291%;
+ *width: 82.8527914166212%
+ }
+
+ .row-fluid .span9 {
+ width: 74.35897435897436%;
+ *width: 74.30578286961266%
+ }
+
+ .row-fluid .span8 {
+ width: 65.81196581196582%;
+ *width: 65.75877432260411%
+ }
+
+ .row-fluid .span7 {
+ width: 57.26495726495726%;
+ *width: 57.21176577559556%
+ }
+
+ .row-fluid .span6 {
+ width: 48.717948717948715%;
+ *width: 48.664757228587014%
+ }
+
+ .row-fluid .span5 {
+ width: 40.17094017094017%;
+ *width: 40.11774868157847%
+ }
+
+ .row-fluid .span4 {
+ width: 31.623931623931625%;
+ *width: 31.570740134569924%
+ }
+
+ .row-fluid .span3 {
+ width: 23.076923076923077%;
+ *width: 23.023731587561375%
+ }
+
+ .row-fluid .span2 {
+ width: 14.52991452991453%;
+ *width: 14.476723040552828%
+ }
+
+ .row-fluid .span1 {
+ width: 5.982905982905983%;
+ *width: 5.929714493544281%
+ }
+
+ .row-fluid .offset12 {
+ margin-left: 105.12820512820512%;
+ *margin-left: 105.02182214948171%
+ }
+
+ .row-fluid .offset12:first-child {
+ margin-left: 102.56410256410257%;
+ *margin-left: 102.45771958537915%
+ }
+
+ .row-fluid .offset11 {
+ margin-left: 96.58119658119658%;
+ *margin-left: 96.47481360247316%
+ }
+
+ .row-fluid .offset11:first-child {
+ margin-left: 94.01709401709402%;
+ *margin-left: 93.91071103837061%
+ }
+
+ .row-fluid .offset10 {
+ margin-left: 88.03418803418803%;
+ *margin-left: 87.92780505546462%
+ }
+
+ .row-fluid .offset10:first-child {
+ margin-left: 85.47008547008548%;
+ *margin-left: 85.36370249136206%
+ }
+
+ .row-fluid .offset9 {
+ margin-left: 79.48717948717949%;
+ *margin-left: 79.38079650845607%
+ }
+
+ .row-fluid .offset9:first-child {
+ margin-left: 76.92307692307693%;
+ *margin-left: 76.81669394435352%
+ }
+
+ .row-fluid .offset8 {
+ margin-left: 70.94017094017094%;
+ *margin-left: 70.83378796144753%
+ }
+
+ .row-fluid .offset8:first-child {
+ margin-left: 68.37606837606839%;
+ *margin-left: 68.26968539734497%
+ }
+
+ .row-fluid .offset7 {
+ margin-left: 62.393162393162385%;
+ *margin-left: 62.28677941443899%
+ }
+
+ .row-fluid .offset7:first-child {
+ margin-left: 59.82905982905982%;
+ *margin-left: 59.72267685033642%
+ }
+
+ .row-fluid .offset6 {
+ margin-left: 53.84615384615384%;
+ *margin-left: 53.739770867430444%
+ }
+
+ .row-fluid .offset6:first-child {
+ margin-left: 51.28205128205128%;
+ *margin-left: 51.175668303327875%
+ }
+
+ .row-fluid .offset5 {
+ margin-left: 45.299145299145295%;
+ *margin-left: 45.1927623204219%
+ }
+
+ .row-fluid .offset5:first-child {
+ margin-left: 42.73504273504273%;
+ *margin-left: 42.62865975631933%
+ }
+
+ .row-fluid .offset4 {
+ margin-left: 36.75213675213675%;
+ *margin-left: 36.645753773413354%
+ }
+
+ .row-fluid .offset4:first-child {
+ margin-left: 34.18803418803419%;
+ *margin-left: 34.081651209310785%
+ }
+
+ .row-fluid .offset3 {
+ margin-left: 28.205128205128204%;
+ *margin-left: 28.0987452264048%
+ }
+
+ .row-fluid .offset3:first-child {
+ margin-left: 25.641025641025642%;
+ *margin-left: 25.53464266230224%
+ }
+
+ .row-fluid .offset2 {
+ margin-left: 19.65811965811966%;
+ *margin-left: 19.551736679396257%
+ }
+
+ .row-fluid .offset2:first-child {
+ margin-left: 17.094017094017094%;
+ *margin-left: 16.98763411529369%
+ }
+
+ .row-fluid .offset1 {
+ margin-left: 11.11111111111111%;
+ *margin-left: 11.004728132387708%
+ }
+
+ .row-fluid .offset1:first-child {
+ margin-left: 8.547008547008547%;
+ *margin-left: 8.440625568285142%
+ }
+
+ input, textarea, .uneditable-input {
+ margin-left: 0
+ }
+
+ .controls-row [class*="span"]+[class*="span"] {
+ margin-left: 30px
+ }
+
+ input.span12, textarea.span12, .uneditable-input.span12 {
+ width: 1156px
+ }
+
+ input.span11, textarea.span11, .uneditable-input.span11 {
+ width: 1056px
+ }
+
+ input.span10, textarea.span10, .uneditable-input.span10 {
+ width: 956px
+ }
+
+ input.span9, textarea.span9, .uneditable-input.span9 {
+ width: 856px
+ }
+
+ input.span8, textarea.span8, .uneditable-input.span8 {
+ width: 756px
+ }
+
+ input.span7, textarea.span7, .uneditable-input.span7 {
+ width: 656px
+ }
+
+ input.span6, textarea.span6, .uneditable-input.span6 {
+ width: 556px
+ }
+
+ input.span5, textarea.span5, .uneditable-input.span5 {
+ width: 456px
+ }
+
+ input.span4, textarea.span4, .uneditable-input.span4 {
+ width: 356px
+ }
+
+ input.span3, textarea.span3, .uneditable-input.span3 {
+ width: 256px
+ }
+
+ input.span2, textarea.span2, .uneditable-input.span2 {
+ width: 156px
+ }
+
+ input.span1, textarea.span1, .uneditable-input.span1 {
+ width: 56px
+ }
+
+ .thumbnails {
+ margin-left: -30px
+ }
+
+ .thumbnails>li {
+ margin-left: 30px
+ }
+
+ .row-fluid .thumbnails {
+ margin-left: 0
+ }
+}
+
+@media (min-width:768px) and (max-width:979px) {
+ .row {
+ margin-left: -20px;
+ *zoom: 1
+ }
+
+ .row:before, .row:after {
+ display: table;
+ line-height: 0;
+ content: ""
+ }
+
+ .row:after {
+ clear: both
+ }
+
+ [class*="span"] {
+ float: left;
+ min-height: 1px;
+ margin-left: 20px
+ }
+
+ .container, .navbar-static-top .container, .navbar-fixed-top .container, .navbar-fixed-bottom .container {
+ width: 724px
+ }
+
+ .span12 {
+ width: 724px
+ }
+
+ .span11 {
+ width: 662px
+ }
+
+ .span10 {
+ width: 600px
+ }
+
+ .span9 {
+ width: 538px
+ }
+
+ .span8 {
+ width: 476px
+ }
+
+ .span7 {
+ width: 414px
+ }
+
+ .span6 {
+ width: 352px
+ }
+
+ .span5 {
+ width: 290px
+ }
+
+ .span4 {
+ width: 228px
+ }
+
+ .span3 {
+ width: 166px
+ }
+
+ .span2 {
+ width: 104px
+ }
+
+ .span1 {
+ width: 42px
+ }
+
+ .offset12 {
+ margin-left: 764px
+ }
+
+ .offset11 {
+ margin-left: 702px
+ }
+
+ .offset10 {
+ margin-left: 640px
+ }
+
+ .offset9 {
+ margin-left: 578px
+ }
+
+ .offset8 {
+ margin-left: 516px
+ }
+
+ .offset7 {
+ margin-left: 454px
+ }
+
+ .offset6 {
+ margin-left: 392px
+ }
+
+ .offset5 {
+ margin-left: 330px
+ }
+
+ .offset4 {
+ margin-left: 268px
+ }
+
+ .offset3 {
+ margin-left: 206px
+ }
+
+ .offset2 {
+ margin-left: 144px
+ }
+
+ .offset1 {
+ margin-left: 82px
+ }
+
+ .row-fluid {
+ width: 100%;
+ *zoom: 1
+ }
+
+ .row-fluid:before, .row-fluid:after {
+ display: table;
+ line-height: 0;
+ content: ""
+ }
+
+ .row-fluid:after {
+ clear: both
+ }
+
+ .row-fluid [class*="span"] {
+ display: block;
+ float: left;
+ width: 100%;
+ min-height: 30px;
+ margin-left: 2.7624309392265194%;
+ *margin-left: 2.709239449864817%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box
+ }
+
+ .row-fluid [class*="span"]:first-child {
+ margin-left: 0
+ }
+
+ .row-fluid .span12 {
+ width: 100%;
+ *width: 99.94680851063829%
+ }
+
+ .row-fluid .span11 {
+ width: 91.43646408839778%;
+ *width: 91.38327259903608%
+ }
+
+ .row-fluid .span10 {
+ width: 82.87292817679558%;
+ *width: 82.81973668743387%
+ }
+
+ .row-fluid .span9 {
+ width: 74.30939226519337%;
+ *width: 74.25620077583166%
+ }
+
+ .row-fluid .span8 {
+ width: 65.74585635359117%;
+ *width: 65.69266486422946%
+ }
+
+ .row-fluid .span7 {
+ width: 57.18232044198895%;
+ *width: 57.12912895262725%
+ }
+
+ .row-fluid .span6 {
+ width: 48.61878453038674%;
+ *width: 48.56559304102504%
+ }
+
+ .row-fluid .span5 {
+ width: 40.05524861878453%;
+ *width: 40.00205712942283%
+ }
+
+ .row-fluid .span4 {
+ width: 31.491712707182323%;
+ *width: 31.43852121782062%
+ }
+
+ .row-fluid .span3 {
+ width: 22.92817679558011%;
+ *width: 22.87498530621841%
+ }
+
+ .row-fluid .span2 {
+ width: 14.3646408839779%;
+ *width: 14.311449394616199%
+ }
+
+ .row-fluid .span1 {
+ width: 5.801104972375691%;
+ *width: 5.747913483013988%
+ }
+
+ .row-fluid .offset12 {
+ margin-left: 105.52486187845304%;
+ *margin-left: 105.41847889972962%
+ }
+
+ .row-fluid .offset12:first-child {
+ margin-left: 102.76243093922652%;
+ *margin-left: 102.6560479605031%
+ }
+
+ .row-fluid .offset11 {
+ margin-left: 96.96132596685082%;
+ *margin-left: 96.8549429881274%
+ }
+
+ .row-fluid .offset11:first-child {
+ margin-left: 94.1988950276243%;
+ *margin-left: 94.09251204890089%
+ }
+
+ .row-fluid .offset10 {
+ margin-left: 88.39779005524862%;
+ *margin-left: 88.2914070765252%
+ }
+
+ .row-fluid .offset10:first-child {
+ margin-left: 85.6353591160221%;
+ *margin-left: 85.52897613729868%
+ }
+
+ .row-fluid .offset9 {
+ margin-left: 79.8342541436464%;
+ *margin-left: 79.72787116492299%
+ }
+
+ .row-fluid .offset9:first-child {
+ margin-left: 77.07182320441989%;
+ *margin-left: 76.96544022569647%
+ }
+
+ .row-fluid .offset8 {
+ margin-left: 71.2707182320442%;
+ *margin-left: 71.16433525332079%
+ }
+
+ .row-fluid .offset8:first-child {
+ margin-left: 68.50828729281768%;
+ *margin-left: 68.40190431409427%
+ }
+
+ .row-fluid .offset7 {
+ margin-left: 62.70718232044199%;
+ *margin-left: 62.600799341718584%
+ }
+
+ .row-fluid .offset7:first-child {
+ margin-left: 59.94475138121547%;
+ *margin-left: 59.838368402492065%
+ }
+
+ .row-fluid .offset6 {
+ margin-left: 54.14364640883978%;
+ *margin-left: 54.037263430116376%
+ }
+
+ .row-fluid .offset6:first-child {
+ margin-left: 51.38121546961326%;
+ *margin-left: 51.27483249088986%
+ }
+
+ .row-fluid .offset5 {
+ margin-left: 45.58011049723757%;
+ *margin-left: 45.47372751851417%
+ }
+
+ .row-fluid .offset5:first-child {
+ margin-left: 42.81767955801105%;
+ *margin-left: 42.71129657928765%
+ }
+
+ .row-fluid .offset4 {
+ margin-left: 37.01657458563536%;
+ *margin-left: 36.91019160691196%
+ }
+
+ .row-fluid .offset4:first-child {
+ margin-left: 34.25414364640884%;
+ *margin-left: 34.14776066768544%
+ }
+
+ .row-fluid .offset3 {
+ margin-left: 28.45303867403315%;
+ *margin-left: 28.346655695309746%
+ }
+
+ .row-fluid .offset3:first-child {
+ margin-left: 25.69060773480663%;
+ *margin-left: 25.584224756083227%
+ }
+
+ .row-fluid .offset2 {
+ margin-left: 19.88950276243094%;
+ *margin-left: 19.783119783707537%
+ }
+
+ .row-fluid .offset2:first-child {
+ margin-left: 17.12707182320442%;
+ *margin-left: 17.02068884448102%
+ }
+
+ .row-fluid .offset1 {
+ margin-left: 11.32596685082873%;
+ *margin-left: 11.219583872105325%
+ }
+
+ .row-fluid .offset1:first-child {
+ margin-left: 8.56353591160221%;
+ *margin-left: 8.457152932878806%
+ }
+
+ input, textarea, .uneditable-input {
+ margin-left: 0
+ }
+
+ .controls-row [class*="span"]+[class*="span"] {
+ margin-left: 20px
+ }
+
+ input.span12, textarea.span12, .uneditable-input.span12 {
+ width: 710px
+ }
+
+ input.span11, textarea.span11, .uneditable-input.span11 {
+ width: 648px
+ }
+
+ input.span10, textarea.span10, .uneditable-input.span10 {
+ width: 586px
+ }
+
+ input.span9, textarea.span9, .uneditable-input.span9 {
+ width: 524px
+ }
+
+ input.span8, textarea.span8, .uneditable-input.span8 {
+ width: 462px
+ }
+
+ input.span7, textarea.span7, .uneditable-input.span7 {
+ width: 400px
+ }
+
+ input.span6, textarea.span6, .uneditable-input.span6 {
+ width: 338px
+ }
+
+ input.span5, textarea.span5, .uneditable-input.span5 {
+ width: 276px
+ }
+
+ input.span4, textarea.span4, .uneditable-input.span4 {
+ width: 214px
+ }
+
+ input.span3, textarea.span3, .uneditable-input.span3 {
+ width: 152px
+ }
+
+ input.span2, textarea.span2, .uneditable-input.span2 {
+ width: 90px
+ }
+
+ input.span1, textarea.span1, .uneditable-input.span1 {
+ width: 28px
+ }
+}
+
+@media (max-width:767px) {
+ body {
+ padding-right: 20px;
+ padding-left: 20px
+ }
+
+ .navbar-fixed-top, .navbar-fixed-bottom, .navbar-static-top {
+ margin-right: -20px;
+ margin-left: -20px
+ }
+
+ .container-fluid {
+ padding: 0
+ }
+
+ .dl-horizontal dt {
+ float: none;
+ width: auto;
+ clear: none;
+ text-align: left
+ }
+
+ .dl-horizontal dd {
+ margin-left: 0
+ }
+
+ .container {
+ width: auto
+ }
+
+ .row-fluid {
+ width: 100%
+ }
+
+ .row, .thumbnails {
+ margin-left: 0
+ }
+
+ .thumbnails>li {
+ float: none;
+ margin-left: 0
+ }
+
+ [class*="span"], .row-fluid [class*="span"] {
+ display: block;
+ float: none;
+ width: 100%;
+ margin-left: 0;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box
+ }
+
+ .span12, .row-fluid .span12 {
+ width: 100%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box
+ }
+
+ .input-large, .input-xlarge, .input-xxlarge, input[class*="span"], select[class*="span"], textarea[class*="span"], .uneditable-input {
+ display: block;
+ width: 100%;
+ min-height: 30px;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box
+ }
+
+ .input-prepend input, .input-append input, .input-prepend input[class*="span"], .input-append input[class*="span"] {
+ display: inline-block;
+ width: auto
+ }
+
+ .controls-row [class*="span"]+[class*="span"] {
+ margin-left: 0
+ }
+
+ .modal {
+ position: fixed;
+ top: 20px;
+ right: 20px;
+ left: 20px;
+ width: auto;
+ margin: 0
+ }
+
+ .modal.fade.in {
+ top: auto
+ }
+}
+
+@media (max-width:480px) {
+ .nav-collapse {
+ -webkit-transform: translate3d(0, 0, 0)
+ }
+
+ .page-header h1 small {
+ display: block;
+ line-height: 20px
+ }
+
+ input[type="checkbox"], input[type="radio"] {
+ border: 1px solid #ccc
+ }
+
+ .form-horizontal .control-label {
+ float: none;
+ width: auto;
+ padding-top: 0;
+ text-align: left
+ }
+
+ .form-horizontal .controls {
+ margin-left: 0
+ }
+
+ .form-horizontal .control-list {
+ padding-top: 0
+ }
+
+ .form-horizontal .form-actions {
+ padding-right: 10px;
+ padding-left: 10px
+ }
+
+ .modal {
+ top: 10px;
+ right: 10px;
+ left: 10px
+ }
+
+ .modal-header .close {
+ padding: 10px;
+ margin: -10px
+ }
+
+ .carousel-caption {
+ position: static
+ }
+}
+
+@media (max-width:979px) {
+ body {
+ padding-top: 0
+ }
+
+ .navbar-fixed-top, .navbar-fixed-bottom {
+ position: static
+ }
+
+ .navbar-fixed-top {
+ margin-bottom: 20px
+ }
+
+ .navbar-fixed-bottom {
+ margin-top: 20px
+ }
+
+ .navbar-fixed-top .navbar-inner, .navbar-fixed-bottom .navbar-inner {
+ padding: 5px
+ }
+
+ .navbar .container {
+ width: auto;
+ padding: 0
+ }
+
+ .navbar .brand {
+ padding-right: 10px;
+ padding-left: 10px;
+ margin: 0 0 0 -5px
+ }
+
+ .nav-collapse {
+ clear: both
+ }
+
+ .nav-collapse .nav {
+ float: none;
+ margin: 0 0 10px
+ }
+
+ .nav-collapse .nav>li {
+ float: none
+ }
+
+ .nav-collapse .nav>li>a {
+ margin-bottom: 2px
+ }
+
+ .nav-collapse .nav>.divider-vertical {
+ display: none
+ }
+
+ .nav-collapse .nav .nav-header {
+ color: #777;
+ text-shadow: none
+ }
+
+ .nav-collapse .nav>li>a, .nav-collapse .dropdown-menu a {
+ padding: 9px 15px;
+ font-weight: bold;
+ color: #777;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px
+ }
+
+ .nav-collapse .btn {
+ padding: 4px 10px 4px;
+ font-weight: normal;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px
+ }
+
+ .nav-collapse .dropdown-menu li+li a {
+ margin-bottom: 2px
+ }
+
+ .nav-collapse .nav>li>a:hover, .nav-collapse .dropdown-menu a:hover {
+ background-color: #f2f2f2
+ }
+
+ .navbar-inverse .nav-collapse .nav>li>a:hover, .navbar-inverse .nav-collapse .dropdown-menu a:hover {
+ background-color: #111
+ }
+
+ .nav-collapse.in .btn-group {
+ padding: 0;
+ margin-top: 5px
+ }
+
+ .nav-collapse .dropdown-menu {
+ position: static;
+ top: auto;
+ left: auto;
+ display: block;
+ float: none;
+ max-width: none;
+ padding: 0;
+ margin: 0 15px;
+ background-color: transparent;
+ border: 0;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ box-shadow: none
+ }
+
+ .nav-collapse .dropdown-menu:before, .nav-collapse .dropdown-menu:after {
+ display: none
+ }
+
+ .nav-collapse .dropdown-menu .divider {
+ display: none
+ }
+
+ .nav-collapse .nav>li>.dropdown-menu:before, .nav-collapse .nav>li>.dropdown-menu:after {
+ display: none
+ }
+
+ .nav-collapse .navbar-form, .nav-collapse .navbar-search {
+ float: none;
+ padding: 10px 15px;
+ margin: 10px 0;
+ border-top: 1px solid #f2f2f2;
+ border-bottom: 1px solid #f2f2f2;
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
+ -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1)
+ }
+
+ .navbar-inverse .nav-collapse .navbar-form, .navbar-inverse .nav-collapse .navbar-search {
+ border-top-color: #111;
+ border-bottom-color: #111
+ }
+
+ .navbar .nav-collapse .nav.pull-right {
+ float: none;
+ margin-left: 0
+ }
+
+ .nav-collapse, .nav-collapse.collapse {
+ height: 0;
+ overflow: hidden
+ }
+
+ .navbar .btn-navbar {
+ display: block
+ }
+
+ .navbar-static .navbar-inner {
+ padding-right: 10px;
+ padding-left: 10px
+ }
+}
+
+@media (min-width:980px) {
+ .nav-collapse.collapse {
+ height: auto !important;
+ overflow: visible !important
+ }
+}
diff --git a/content/examples/moviefun/src/main/webapp/assets/css/bootstrap.css b/content/examples/moviefun/src/main/webapp/assets/css/bootstrap.css
new file mode 100755
index 0000000..241a984
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/assets/css/bootstrap.css
@@ -0,0 +1,5774 @@
+/*!
+ * Bootstrap v2.1.1
+ *
+ * Copyright 2012 Twitter, Inc
+ * Licensed under the Apache License v2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Designed and built with all the love in the world @twitter by @mdo and @fat.
+ */
+
+article,
+aside,
+details,
+figcaption,
+figure,
+footer,
+header,
+hgroup,
+nav,
+section {
+ display: block;
+}
+
+audio,
+canvas,
+video {
+ display: inline-block;
+ *display: inline;
+ *zoom: 1;
+}
+
+audio:not([controls]) {
+ display: none;
+}
+
+html {
+ font-size: 100%;
+ -webkit-text-size-adjust: 100%;
+ -ms-text-size-adjust: 100%;
+}
+
+a:focus {
+ outline: thin dotted #333;
+ outline: 5px auto -webkit-focus-ring-color;
+ outline-offset: -2px;
+}
+
+a:hover,
+a:active {
+ outline: 0;
+}
+
+sub,
+sup {
+ position: relative;
+ font-size: 75%;
+ line-height: 0;
+ vertical-align: baseline;
+}
+
+sup {
+ top: -0.5em;
+}
+
+sub {
+ bottom: -0.25em;
+}
+
+img {
+ width: auto\9;
+ height: auto;
+ max-width: 100%;
+ vertical-align: middle;
+ border: 0;
+ -ms-interpolation-mode: bicubic;
+}
+
+#map_canvas img {
+ max-width: none;
+}
+
+button,
+input,
+select,
+textarea {
+ margin: 0;
+ font-size: 100%;
+ vertical-align: middle;
+}
+
+button,
+input {
+ *overflow: visible;
+ line-height: normal;
+}
+
+button::-moz-focus-inner,
+input::-moz-focus-inner {
+ padding: 0;
+ border: 0;
+}
+
+button,
+input[type="button"],
+input[type="reset"],
+input[type="submit"] {
+ cursor: pointer;
+ -webkit-appearance: button;
+}
+
+input[type="search"] {
+ -webkit-box-sizing: content-box;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+ -webkit-appearance: textfield;
+}
+
+input[type="search"]::-webkit-search-decoration,
+input[type="search"]::-webkit-search-cancel-button {
+ -webkit-appearance: none;
+}
+
+textarea {
+ overflow: auto;
+ vertical-align: top;
+}
+
+.clearfix {
+ *zoom: 1;
+}
+
+.clearfix:before,
+.clearfix:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.clearfix:after {
+ clear: both;
+}
+
+.hide-text {
+ font: 0/0 a;
+ color: transparent;
+ text-shadow: none;
+ background-color: transparent;
+ border: 0;
+}
+
+.input-block-level {
+ display: block;
+ width: 100%;
+ min-height: 30px;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+body {
+ margin: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 14px;
+ line-height: 20px;
+ color: #333333;
+ background-color: #ffffff;
+}
+
+a {
+ color: #0088cc;
+ text-decoration: none;
+}
+
+a:hover {
+ color: #005580;
+ text-decoration: underline;
+}
+
+.img-rounded {
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+}
+
+.img-polaroid {
+ padding: 4px;
+ background-color: #fff;
+ border: 1px solid #ccc;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
+ -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
+}
+
+.img-circle {
+ -webkit-border-radius: 500px;
+ -moz-border-radius: 500px;
+ border-radius: 500px;
+}
+
+.row {
+ margin-left: -20px;
+ *zoom: 1;
+}
+
+.row:before,
+.row:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.row:after {
+ clear: both;
+}
+
+[class*="span"] {
+ float: left;
+ min-height: 1px;
+ margin-left: 20px;
+}
+
+.container,
+.navbar-static-top .container,
+.navbar-fixed-top .container,
+.navbar-fixed-bottom .container {
+ width: 940px;
+}
+
+.span12 {
+ width: 940px;
+}
+
+.span11 {
+ width: 860px;
+}
+
+.span10 {
+ width: 780px;
+}
+
+.span9 {
+ width: 700px;
+}
+
+.span8 {
+ width: 620px;
+}
+
+.span7 {
+ width: 540px;
+}
+
+.span6 {
+ width: 460px;
+}
+
+.span5 {
+ width: 380px;
+}
+
+.span4 {
+ width: 300px;
+}
+
+.span3 {
+ width: 220px;
+}
+
+.span2 {
+ width: 140px;
+}
+
+.span1 {
+ width: 60px;
+}
+
+.offset12 {
+ margin-left: 980px;
+}
+
+.offset11 {
+ margin-left: 900px;
+}
+
+.offset10 {
+ margin-left: 820px;
+}
+
+.offset9 {
+ margin-left: 740px;
+}
+
+.offset8 {
+ margin-left: 660px;
+}
+
+.offset7 {
+ margin-left: 580px;
+}
+
+.offset6 {
+ margin-left: 500px;
+}
+
+.offset5 {
+ margin-left: 420px;
+}
+
+.offset4 {
+ margin-left: 340px;
+}
+
+.offset3 {
+ margin-left: 260px;
+}
+
+.offset2 {
+ margin-left: 180px;
+}
+
+.offset1 {
+ margin-left: 100px;
+}
+
+.row-fluid {
+ width: 100%;
+ *zoom: 1;
+}
+
+.row-fluid:before,
+.row-fluid:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.row-fluid:after {
+ clear: both;
+}
+
+.row-fluid [class*="span"] {
+ display: block;
+ float: left;
+ width: 100%;
+ min-height: 30px;
+ margin-left: 2.127659574468085%;
+ *margin-left: 2.074468085106383%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+.row-fluid [class*="span"]:first-child {
+ margin-left: 0;
+}
+
+.row-fluid .span12 {
+ width: 100%;
+ *width: 99.94680851063829%;
+}
+
+.row-fluid .span11 {
+ width: 91.48936170212765%;
+ *width: 91.43617021276594%;
+}
+
+.row-fluid .span10 {
+ width: 82.97872340425532%;
+ *width: 82.92553191489361%;
+}
+
+.row-fluid .span9 {
+ width: 74.46808510638297%;
+ *width: 74.41489361702126%;
+}
+
+.row-fluid .span8 {
+ width: 65.95744680851064%;
+ *width: 65.90425531914893%;
+}
+
+.row-fluid .span7 {
+ width: 57.44680851063829%;
+ *width: 57.39361702127659%;
+}
+
+.row-fluid .span6 {
+ width: 48.93617021276595%;
+ *width: 48.88297872340425%;
+}
+
+.row-fluid .span5 {
+ width: 40.42553191489362%;
+ *width: 40.37234042553192%;
+}
+
+.row-fluid .span4 {
+ width: 31.914893617021278%;
+ *width: 31.861702127659576%;
+}
+
+.row-fluid .span3 {
+ width: 23.404255319148934%;
+ *width: 23.351063829787233%;
+}
+
+.row-fluid .span2 {
+ width: 14.893617021276595%;
+ *width: 14.840425531914894%;
+}
+
+.row-fluid .span1 {
+ width: 6.382978723404255%;
+ *width: 6.329787234042553%;
+}
+
+.row-fluid .offset12 {
+ margin-left: 104.25531914893617%;
+ *margin-left: 104.14893617021275%;
+}
+
+.row-fluid .offset12:first-child {
+ margin-left: 102.12765957446808%;
+ *margin-left: 102.02127659574467%;
+}
+
+.row-fluid .offset11 {
+ margin-left: 95.74468085106382%;
+ *margin-left: 95.6382978723404%;
+}
+
+.row-fluid .offset11:first-child {
+ margin-left: 93.61702127659574%;
+ *margin-left: 93.51063829787232%;
+}
+
+.row-fluid .offset10 {
+ margin-left: 87.23404255319149%;
+ *margin-left: 87.12765957446807%;
+}
+
+.row-fluid .offset10:first-child {
+ margin-left: 85.1063829787234%;
+ *margin-left: 84.99999999999999%;
+}
+
+.row-fluid .offset9 {
+ margin-left: 78.72340425531914%;
+ *margin-left: 78.61702127659572%;
+}
+
+.row-fluid .offset9:first-child {
+ margin-left: 76.59574468085106%;
+ *margin-left: 76.48936170212764%;
+}
+
+.row-fluid .offset8 {
+ margin-left: 70.2127659574468%;
+ *margin-left: 70.10638297872339%;
+}
+
+.row-fluid .offset8:first-child {
+ margin-left: 68.08510638297872%;
+ *margin-left: 67.9787234042553%;
+}
+
+.row-fluid .offset7 {
+ margin-left: 61.70212765957446%;
+ *margin-left: 61.59574468085106%;
+}
+
+.row-fluid .offset7:first-child {
+ margin-left: 59.574468085106375%;
+ *margin-left: 59.46808510638297%;
+}
+
+.row-fluid .offset6 {
+ margin-left: 53.191489361702125%;
+ *margin-left: 53.085106382978715%;
+}
+
+.row-fluid .offset6:first-child {
+ margin-left: 51.063829787234035%;
+ *margin-left: 50.95744680851063%;
+}
+
+.row-fluid .offset5 {
+ margin-left: 44.68085106382979%;
+ *margin-left: 44.57446808510638%;
+}
+
+.row-fluid .offset5:first-child {
+ margin-left: 42.5531914893617%;
+ *margin-left: 42.4468085106383%;
+}
+
+.row-fluid .offset4 {
+ margin-left: 36.170212765957444%;
+ *margin-left: 36.06382978723405%;
+}
+
+.row-fluid .offset4:first-child {
+ margin-left: 34.04255319148936%;
+ *margin-left: 33.93617021276596%;
+}
+
+.row-fluid .offset3 {
+ margin-left: 27.659574468085104%;
+ *margin-left: 27.5531914893617%;
+}
+
+.row-fluid .offset3:first-child {
+ margin-left: 25.53191489361702%;
+ *margin-left: 25.425531914893618%;
+}
+
+.row-fluid .offset2 {
+ margin-left: 19.148936170212764%;
+ *margin-left: 19.04255319148936%;
+}
+
+.row-fluid .offset2:first-child {
+ margin-left: 17.02127659574468%;
+ *margin-left: 16.914893617021278%;
+}
+
+.row-fluid .offset1 {
+ margin-left: 10.638297872340425%;
+ *margin-left: 10.53191489361702%;
+}
+
+.row-fluid .offset1:first-child {
+ margin-left: 8.51063829787234%;
+ *margin-left: 8.404255319148938%;
+}
+
+[class*="span"].hide,
+.row-fluid [class*="span"].hide {
+ display: none;
+}
+
+[class*="span"].pull-right,
+.row-fluid [class*="span"].pull-right {
+ float: right;
+}
+
+.container {
+ margin-right: auto;
+ margin-left: auto;
+ *zoom: 1;
+}
+
+.container:before,
+.container:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.container:after {
+ clear: both;
+}
+
+.container-fluid {
+ padding-right: 20px;
+ padding-left: 20px;
+ *zoom: 1;
+}
+
+.container-fluid:before,
+.container-fluid:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.container-fluid:after {
+ clear: both;
+}
+
+p {
+ margin: 0 0 10px;
+}
+
+.lead {
+ margin-bottom: 20px;
+ font-size: 21px;
+ font-weight: 200;
+ line-height: 30px;
+}
+
+small {
+ font-size: 85%;
+}
+
+strong {
+ font-weight: bold;
+}
+
+em {
+ font-style: italic;
+}
+
+cite {
+ font-style: normal;
+}
+
+.muted {
+ color: #999999;
+}
+
+.text-warning {
+ color: #c09853;
+}
+
+.text-error {
+ color: #b94a48;
+}
+
+.text-info {
+ color: #3a87ad;
+}
+
+.text-success {
+ color: #468847;
+}
+
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ margin: 10px 0;
+ font-family: inherit;
+ font-weight: bold;
+ line-height: 1;
+ color: inherit;
+ text-rendering: optimizelegibility;
+}
+
+h1 small,
+h2 small,
+h3 small,
+h4 small,
+h5 small,
+h6 small {
+ font-weight: normal;
+ line-height: 1;
+ color: #999999;
+}
+
+h1 {
+ font-size: 36px;
+ line-height: 40px;
+}
+
+h2 {
+ font-size: 30px;
+ line-height: 40px;
+}
+
+h3 {
+ font-size: 24px;
+ line-height: 40px;
+}
+
+h4 {
+ font-size: 18px;
+ line-height: 20px;
+}
+
+h5 {
+ font-size: 14px;
+ line-height: 20px;
+}
+
+h6 {
+ font-size: 12px;
+ line-height: 20px;
+}
+
+h1 small {
+ font-size: 24px;
+}
+
+h2 small {
+ font-size: 18px;
+}
+
+h3 small {
+ font-size: 14px;
+}
+
+h4 small {
+ font-size: 14px;
+}
+
+.page-header {
+ padding-bottom: 9px;
+ margin: 20px 0 30px;
+ border-bottom: 1px solid #eeeeee;
+}
+
+ul,
+ol {
+ padding: 0;
+ margin: 0 0 10px 25px;
+}
+
+ul ul,
+ul ol,
+ol ol,
+ol ul {
+ margin-bottom: 0;
+}
+
+li {
+ line-height: 20px;
+}
+
+ul.unstyled,
+ol.unstyled {
+ margin-left: 0;
+ list-style: none;
+}
+
+dl {
+ margin-bottom: 20px;
+}
+
+dt,
+dd {
+ line-height: 20px;
+}
+
+dt {
+ font-weight: bold;
+}
+
+dd {
+ margin-left: 10px;
+}
+
+.dl-horizontal {
+ *zoom: 1;
+}
+
+.dl-horizontal:before,
+.dl-horizontal:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.dl-horizontal:after {
+ clear: both;
+}
+
+.dl-horizontal dt {
+ float: left;
+ width: 160px;
+ overflow: hidden;
+ clear: left;
+ text-align: right;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.dl-horizontal dd {
+ margin-left: 180px;
+}
+
+hr {
+ margin: 20px 0;
+ border: 0;
+ border-top: 1px solid #eeeeee;
+ border-bottom: 1px solid #ffffff;
+}
+
+abbr[title] {
+ cursor: help;
+ border-bottom: 1px dotted #999999;
+}
+
+abbr.initialism {
+ font-size: 90%;
+ text-transform: uppercase;
+}
+
+blockquote {
+ padding: 0 0 0 15px;
+ margin: 0 0 20px;
+ border-left: 5px solid #eeeeee;
+}
+
+blockquote p {
+ margin-bottom: 0;
+ font-size: 16px;
+ font-weight: 300;
+ line-height: 25px;
+}
+
+blockquote small {
+ display: block;
+ line-height: 20px;
+ color: #999999;
+}
+
+blockquote small:before {
+ content: '\2014 \00A0';
+}
+
+blockquote.pull-right {
+ float: right;
+ padding-right: 15px;
+ padding-left: 0;
+ border-right: 5px solid #eeeeee;
+ border-left: 0;
+}
+
+blockquote.pull-right p,
+blockquote.pull-right small {
+ text-align: right;
+}
+
+blockquote.pull-right small:before {
+ content: '';
+}
+
+blockquote.pull-right small:after {
+ content: '\00A0 \2014';
+}
+
+q:before,
+q:after,
+blockquote:before,
+blockquote:after {
+ content: "";
+}
+
+address {
+ display: block;
+ margin-bottom: 20px;
+ font-style: normal;
+ line-height: 20px;
+}
+
+code,
+pre {
+ padding: 0 3px 2px;
+ font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
+ font-size: 12px;
+ color: #333333;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+}
+
+code {
+ padding: 2px 4px;
+ color: #d14;
+ background-color: #f7f7f9;
+ border: 1px solid #e1e1e8;
+}
+
+pre {
+ display: block;
+ padding: 9.5px;
+ margin: 0 0 10px;
+ font-size: 13px;
+ line-height: 20px;
+ word-break: break-all;
+ word-wrap: break-word;
+ white-space: pre;
+ white-space: pre-wrap;
+ background-color: #f5f5f5;
+ border: 1px solid #ccc;
+ border: 1px solid rgba(0, 0, 0, 0.15);
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+
+pre.prettyprint {
+ margin-bottom: 20px;
+}
+
+pre code {
+ padding: 0;
+ color: inherit;
+ background-color: transparent;
+ border: 0;
+}
+
+.pre-scrollable {
+ max-height: 340px;
+ overflow-y: scroll;
+}
+
+form {
+ margin: 0 0 20px;
+}
+
+fieldset {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+legend {
+ display: block;
+ width: 100%;
+ padding: 0;
+ margin-bottom: 20px;
+ font-size: 21px;
+ line-height: 40px;
+ color: #333333;
+ border: 0;
+ border-bottom: 1px solid #e5e5e5;
+}
+
+legend small {
+ font-size: 15px;
+ color: #999999;
+}
+
+label,
+input,
+button,
+select,
+textarea {
+ font-size: 14px;
+ font-weight: normal;
+ line-height: 20px;
+}
+
+input,
+button,
+select,
+textarea {
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+}
+
+label {
+ display: block;
+ margin-bottom: 5px;
+}
+
+select,
+textarea,
+input[type="text"],
+input[type="password"],
+input[type="datetime"],
+input[type="datetime-local"],
+input[type="date"],
+input[type="month"],
+input[type="time"],
+input[type="week"],
+input[type="number"],
+input[type="email"],
+input[type="url"],
+input[type="search"],
+input[type="tel"],
+input[type="color"],
+.uneditable-input {
+ display: inline-block;
+ height: 20px;
+ padding: 4px 6px;
+ margin-bottom: 9px;
+ font-size: 14px;
+ line-height: 20px;
+ color: #555555;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+}
+
+input,
+textarea,
+.uneditable-input {
+ width: 206px;
+}
+
+textarea {
+ height: auto;
+}
+
+textarea,
+input[type="text"],
+input[type="password"],
+input[type="datetime"],
+input[type="datetime-local"],
+input[type="date"],
+input[type="month"],
+input[type="time"],
+input[type="week"],
+input[type="number"],
+input[type="email"],
+input[type="url"],
+input[type="search"],
+input[type="tel"],
+input[type="color"],
+.uneditable-input {
+ background-color: #ffffff;
+ border: 1px solid #cccccc;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
+ -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
+ -o-transition: border linear 0.2s, box-shadow linear 0.2s;
+ transition: border linear 0.2s, box-shadow linear 0.2s;
+}
+
+textarea:focus,
+input[type="text"]:focus,
+input[type="password"]:focus,
+input[type="datetime"]:focus,
+input[type="datetime-local"]:focus,
+input[type="date"]:focus,
+input[type="month"]:focus,
+input[type="time"]:focus,
+input[type="week"]:focus,
+input[type="number"]:focus,
+input[type="email"]:focus,
+input[type="url"]:focus,
+input[type="search"]:focus,
+input[type="tel"]:focus,
+input[type="color"]:focus,
+.uneditable-input:focus {
+ border-color: rgba(82, 168, 236, 0.8);
+ outline: 0;
+ outline: thin dotted \9;
+ /* IE6-9 */
+
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
+}
+
+input[type="radio"],
+input[type="checkbox"] {
+ margin: 4px 0 0;
+ margin-top: 1px \9;
+ *margin-top: 0;
+ line-height: normal;
+ cursor: pointer;
+}
+
+input[type="file"],
+input[type="image"],
+input[type="submit"],
+input[type="reset"],
+input[type="button"],
+input[type="radio"],
+input[type="checkbox"] {
+ width: auto;
+}
+
+select,
+input[type="file"] {
+ height: 30px;
+ /* In IE7, the height of the select element cannot be changed by height, only font-size */
+
+ *margin-top: 4px;
+ /* For IE7, add top margin to align select with labels */
+
+ line-height: 30px;
+}
+
+select {
+ width: 220px;
+ background-color: #ffffff;
+ border: 1px solid #cccccc;
+}
+
+select[multiple],
+select[size] {
+ height: auto;
+}
+
+select:focus,
+input[type="file"]:focus,
+input[type="radio"]:focus,
+input[type="checkbox"]:focus {
+ outline: thin dotted #333;
+ outline: 5px auto -webkit-focus-ring-color;
+ outline-offset: -2px;
+}
+
+.uneditable-input,
+.uneditable-textarea {
+ color: #999999;
+ cursor: not-allowed;
+ background-color: #fcfcfc;
+ border-color: #cccccc;
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
+ -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
+}
+
+.uneditable-input {
+ overflow: hidden;
+ white-space: nowrap;
+}
+
+.uneditable-textarea {
+ width: auto;
+ height: auto;
+}
+
+input:-moz-placeholder,
+textarea:-moz-placeholder {
+ color: #999999;
+}
+
+input:-ms-input-placeholder,
+textarea:-ms-input-placeholder {
+ color: #999999;
+}
+
+input::-webkit-input-placeholder,
+textarea::-webkit-input-placeholder {
+ color: #999999;
+}
+
+.radio,
+.checkbox {
+ min-height: 18px;
+ padding-left: 18px;
+}
+
+.radio input[type="radio"],
+.checkbox input[type="checkbox"] {
+ float: left;
+ margin-left: -18px;
+}
+
+.controls > .radio:first-child,
+.controls > .checkbox:first-child {
+ padding-top: 5px;
+}
+
+.radio.inline,
+.checkbox.inline {
+ display: inline-block;
+ padding-top: 5px;
+ margin-bottom: 0;
+ vertical-align: middle;
+}
+
+.radio.inline + .radio.inline,
+.checkbox.inline + .checkbox.inline {
+ margin-left: 10px;
+}
+
+.input-mini {
+ width: 60px;
+}
+
+.input-small {
+ width: 90px;
+}
+
+.input-medium {
+ width: 150px;
+}
+
+.input-large {
+ width: 210px;
+}
+
+.input-xlarge {
+ width: 270px;
+}
+
+.input-xxlarge {
+ width: 530px;
+}
+
+input[class*="span"],
+select[class*="span"],
+textarea[class*="span"],
+.uneditable-input[class*="span"],
+.row-fluid input[class*="span"],
+.row-fluid select[class*="span"],
+.row-fluid textarea[class*="span"],
+.row-fluid .uneditable-input[class*="span"] {
+ float: none;
+ margin-left: 0;
+}
+
+.input-append input[class*="span"],
+.input-append .uneditable-input[class*="span"],
+.input-prepend input[class*="span"],
+.input-prepend .uneditable-input[class*="span"],
+.row-fluid input[class*="span"],
+.row-fluid select[class*="span"],
+.row-fluid textarea[class*="span"],
+.row-fluid .uneditable-input[class*="span"],
+.row-fluid .input-prepend [class*="span"],
+.row-fluid .input-append [class*="span"] {
+ display: inline-block;
+}
+
+input,
+textarea,
+.uneditable-input {
+ margin-left: 0;
+}
+
+.controls-row [class*="span"] + [class*="span"] {
+ margin-left: 20px;
+}
+
+input.span12,
+textarea.span12,
+.uneditable-input.span12 {
+ width: 926px;
+}
+
+input.span11,
+textarea.span11,
+.uneditable-input.span11 {
+ width: 846px;
+}
+
+input.span10,
+textarea.span10,
+.uneditable-input.span10 {
+ width: 766px;
+}
+
+input.span9,
+textarea.span9,
+.uneditable-input.span9 {
+ width: 686px;
+}
+
+input.span8,
+textarea.span8,
+.uneditable-input.span8 {
+ width: 606px;
+}
+
+input.span7,
+textarea.span7,
+.uneditable-input.span7 {
+ width: 526px;
+}
+
+input.span6,
+textarea.span6,
+.uneditable-input.span6 {
+ width: 446px;
+}
+
+input.span5,
+textarea.span5,
+.uneditable-input.span5 {
+ width: 366px;
+}
+
+input.span4,
+textarea.span4,
+.uneditable-input.span4 {
+ width: 286px;
+}
+
+input.span3,
+textarea.span3,
+.uneditable-input.span3 {
+ width: 206px;
+}
+
+input.span2,
+textarea.span2,
+.uneditable-input.span2 {
+ width: 126px;
+}
+
+input.span1,
+textarea.span1,
+.uneditable-input.span1 {
+ width: 46px;
+}
+
+.controls-row {
+ *zoom: 1;
+}
+
+.controls-row:before,
+.controls-row:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.controls-row:after {
+ clear: both;
+}
+
+.controls-row [class*="span"] {
+ float: left;
+}
+
+input[disabled],
+select[disabled],
+textarea[disabled],
+input[readonly],
+select[readonly],
+textarea[readonly] {
+ cursor: not-allowed;
+ background-color: #eeeeee;
+}
+
+input[type="radio"][disabled],
+input[type="checkbox"][disabled],
+input[type="radio"][readonly],
+input[type="checkbox"][readonly] {
+ background-color: transparent;
+}
+
+.control-group.warning > label,
+.control-group.warning .help-block,
+.control-group.warning .help-inline {
+ color: #c09853;
+}
+
+.control-group.warning .checkbox,
+.control-group.warning .radio,
+.control-group.warning input,
+.control-group.warning select,
+.control-group.warning textarea {
+ color: #c09853;
+}
+
+.control-group.warning input,
+.control-group.warning select,
+.control-group.warning textarea {
+ border-color: #c09853;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+}
+
+.control-group.warning input:focus,
+.control-group.warning select:focus,
+.control-group.warning textarea:focus {
+ border-color: #a47e3c;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
+}
+
+.control-group.warning .input-prepend .add-on,
+.control-group.warning .input-append .add-on {
+ color: #c09853;
+ background-color: #fcf8e3;
+ border-color: #c09853;
+}
+
+.control-group.error > label,
+.control-group.error .help-block,
+.control-group.error .help-inline {
+ color: #b94a48;
+}
+
+.control-group.error .checkbox,
+.control-group.error .radio,
+.control-group.error input,
+.control-group.error select,
+.control-group.error textarea {
+ color: #b94a48;
+}
+
+.control-group.error input,
+.control-group.error select,
+.control-group.error textarea {
+ border-color: #b94a48;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+}
+
+.control-group.error input:focus,
+.control-group.error select:focus,
+.control-group.error textarea:focus {
+ border-color: #953b39;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
+}
+
+.control-group.error .input-prepend .add-on,
+.control-group.error .input-append .add-on {
+ color: #b94a48;
+ background-color: #f2dede;
+ border-color: #b94a48;
+}
+
+.control-group.success > label,
+.control-group.success .help-block,
+.control-group.success .help-inline {
+ color: #468847;
+}
+
+.control-group.success .checkbox,
+.control-group.success .radio,
+.control-group.success input,
+.control-group.success select,
+.control-group.success textarea {
+ color: #468847;
+}
+
+.control-group.success input,
+.control-group.success select,
+.control-group.success textarea {
+ border-color: #468847;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+}
+
+.control-group.success input:focus,
+.control-group.success select:focus,
+.control-group.success textarea:focus {
+ border-color: #356635;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
+}
+
+.control-group.success .input-prepend .add-on,
+.control-group.success .input-append .add-on {
+ color: #468847;
+ background-color: #dff0d8;
+ border-color: #468847;
+}
+
+.control-group.info > label,
+.control-group.info .help-block,
+.control-group.info .help-inline {
+ color: #3a87ad;
+}
+
+.control-group.info .checkbox,
+.control-group.info .radio,
+.control-group.info input,
+.control-group.info select,
+.control-group.info textarea {
+ color: #3a87ad;
+}
+
+.control-group.info input,
+.control-group.info select,
+.control-group.info textarea {
+ border-color: #3a87ad;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+}
+
+.control-group.info input:focus,
+.control-group.info select:focus,
+.control-group.info textarea:focus {
+ border-color: #2d6987;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3;
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3;
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3;
+}
+
+.control-group.info .input-prepend .add-on,
+.control-group.info .input-append .add-on {
+ color: #3a87ad;
+ background-color: #d9edf7;
+ border-color: #3a87ad;
+}
+
+input:focus:required:invalid,
+textarea:focus:required:invalid,
+select:focus:required:invalid {
+ color: #b94a48;
+ border-color: #ee5f5b;
+}
+
+input:focus:required:invalid:focus,
+textarea:focus:required:invalid:focus,
+select:focus:required:invalid:focus {
+ border-color: #e9322d;
+ -webkit-box-shadow: 0 0 6px #f8b9b7;
+ -moz-box-shadow: 0 0 6px #f8b9b7;
+ box-shadow: 0 0 6px #f8b9b7;
+}
+
+.form-actions {
+ padding: 19px 20px 20px;
+ margin-top: 20px;
+ margin-bottom: 20px;
+ background-color: #f5f5f5;
+ border-top: 1px solid #e5e5e5;
+ *zoom: 1;
+}
+
+.form-actions:before,
+.form-actions:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.form-actions:after {
+ clear: both;
+}
+
+.help-block,
+.help-inline {
+ color: #595959;
+}
+
+.help-block {
+ display: block;
+ margin-bottom: 10px;
+}
+
+.help-inline {
+ display: inline-block;
+ *display: inline;
+ padding-left: 5px;
+ vertical-align: middle;
+ *zoom: 1;
+}
+
+.input-append,
+.input-prepend {
+ margin-bottom: 5px;
+ font-size: 0;
+ white-space: nowrap;
+}
+
+.input-append input,
+.input-prepend input,
+.input-append select,
+.input-prepend select,
+.input-append .uneditable-input,
+.input-prepend .uneditable-input {
+ position: relative;
+ margin-bottom: 0;
+ *margin-left: 0;
+ font-size: 14px;
+ vertical-align: top;
+ -webkit-border-radius: 0 3px 3px 0;
+ -moz-border-radius: 0 3px 3px 0;
+ border-radius: 0 3px 3px 0;
+}
+
+.input-append input:focus,
+.input-prepend input:focus,
+.input-append select:focus,
+.input-prepend select:focus,
+.input-append .uneditable-input:focus,
+.input-prepend .uneditable-input:focus {
+ z-index: 2;
+}
+
+.input-append .add-on,
+.input-prepend .add-on {
+ display: inline-block;
+ width: auto;
+ height: 20px;
+ min-width: 16px;
+ padding: 4px 5px;
+ font-size: 14px;
+ font-weight: normal;
+ line-height: 20px;
+ text-align: center;
+ text-shadow: 0 1px 0 #ffffff;
+ background-color: #eeeeee;
+ border: 1px solid #ccc;
+}
+
+.input-append .add-on,
+.input-prepend .add-on,
+.input-append .btn,
+.input-prepend .btn {
+ vertical-align: top;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+}
+
+.input-append .active,
+.input-prepend .active {
+ background-color: #a9dba9;
+ border-color: #46a546;
+}
+
+.input-prepend .add-on,
+.input-prepend .btn {
+ margin-right: -1px;
+}
+
+.input-prepend .add-on:first-child,
+.input-prepend .btn:first-child {
+ -webkit-border-radius: 3px 0 0 3px;
+ -moz-border-radius: 3px 0 0 3px;
+ border-radius: 3px 0 0 3px;
+}
+
+.input-append input,
+.input-append select,
+.input-append .uneditable-input {
+ -webkit-border-radius: 3px 0 0 3px;
+ -moz-border-radius: 3px 0 0 3px;
+ border-radius: 3px 0 0 3px;
+}
+
+.input-append .add-on,
+.input-append .btn {
+ margin-left: -1px;
+}
+
+.input-append .add-on:last-child,
+.input-append .btn:last-child {
+ -webkit-border-radius: 0 3px 3px 0;
+ -moz-border-radius: 0 3px 3px 0;
+ border-radius: 0 3px 3px 0;
+}
+
+.input-prepend.input-append input,
+.input-prepend.input-append select,
+.input-prepend.input-append .uneditable-input {
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+}
+
+.input-prepend.input-append .add-on:first-child,
+.input-prepend.input-append .btn:first-child {
+ margin-right: -1px;
+ -webkit-border-radius: 3px 0 0 3px;
+ -moz-border-radius: 3px 0 0 3px;
+ border-radius: 3px 0 0 3px;
+}
+
+.input-prepend.input-append .add-on:last-child,
+.input-prepend.input-append .btn:last-child {
+ margin-left: -1px;
+ -webkit-border-radius: 0 3px 3px 0;
+ -moz-border-radius: 0 3px 3px 0;
+ border-radius: 0 3px 3px 0;
+}
+
+input.search-query {
+ padding-right: 14px;
+ padding-right: 4px \9;
+ padding-left: 14px;
+ padding-left: 4px \9;
+ /* IE7-8 doesn't have border-radius, so don't indent the padding */
+
+ margin-bottom: 0;
+ -webkit-border-radius: 15px;
+ -moz-border-radius: 15px;
+ border-radius: 15px;
+}
+
+/* Allow for input prepend/append in search forms */
+
+.form-search .input-append .search-query,
+.form-search .input-prepend .search-query {
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+}
+
+.form-search .input-append .search-query {
+ -webkit-border-radius: 14px 0 0 14px;
+ -moz-border-radius: 14px 0 0 14px;
+ border-radius: 14px 0 0 14px;
+}
+
+.form-search .input-append .btn {
+ -webkit-border-radius: 0 14px 14px 0;
+ -moz-border-radius: 0 14px 14px 0;
+ border-radius: 0 14px 14px 0;
+}
+
+.form-search .input-prepend .search-query {
+ -webkit-border-radius: 0 14px 14px 0;
+ -moz-border-radius: 0 14px 14px 0;
+ border-radius: 0 14px 14px 0;
+}
+
+.form-search .input-prepend .btn {
+ -webkit-border-radius: 14px 0 0 14px;
+ -moz-border-radius: 14px 0 0 14px;
+ border-radius: 14px 0 0 14px;
+}
+
+.form-search input,
+.form-inline input,
+.form-horizontal input,
+.form-search textarea,
+.form-inline textarea,
+.form-horizontal textarea,
+.form-search select,
+.form-inline select,
+.form-horizontal select,
+.form-search .help-inline,
+.form-inline .help-inline,
+.form-horizontal .help-inline,
+.form-search .uneditable-input,
+.form-inline .uneditable-input,
+.form-horizontal .uneditable-input,
+.form-search .input-prepend,
+.form-inline .input-prepend,
+.form-horizontal .input-prepend,
+.form-search .input-append,
+.form-inline .input-append,
+.form-horizontal .input-append {
+ display: inline-block;
+ *display: inline;
+ margin-bottom: 0;
+ vertical-align: middle;
+ *zoom: 1;
+}
+
+.form-search .hide,
+.form-inline .hide,
+.form-horizontal .hide {
+ display: none;
+}
+
+.form-search label,
+.form-inline label,
+.form-search .btn-group,
+.form-inline .btn-group {
+ display: inline-block;
+}
+
+.form-search .input-append,
+.form-inline .input-append,
+.form-search .input-prepend,
+.form-inline .input-prepend {
+ margin-bottom: 0;
+}
+
+.form-search .radio,
+.form-search .checkbox,
+.form-inline .radio,
+.form-inline .checkbox {
+ padding-left: 0;
+ margin-bottom: 0;
+ vertical-align: middle;
+}
+
+.form-search .radio input[type="radio"],
+.form-search .checkbox input[type="checkbox"],
+.form-inline .radio input[type="radio"],
+.form-inline .checkbox input[type="checkbox"] {
+ float: left;
+ margin-right: 3px;
+ margin-left: 0;
+}
+
+.control-group {
+ margin-bottom: 10px;
+}
+
+legend + .control-group {
+ margin-top: 20px;
+ -webkit-margin-top-collapse: separate;
+}
+
+.form-horizontal .control-group {
+ margin-bottom: 20px;
+ *zoom: 1;
+}
+
+.form-horizontal .control-group:before,
+.form-horizontal .control-group:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.form-horizontal .control-group:after {
+ clear: both;
+}
+
+.form-horizontal .control-label {
+ float: left;
+ width: 160px;
+ padding-top: 5px;
+ text-align: right;
+}
+
+.form-horizontal .controls {
+ *display: inline-block;
+ *padding-left: 20px;
+ margin-left: 180px;
+ *margin-left: 0;
+}
+
+.form-horizontal .controls:first-child {
+ *padding-left: 180px;
+}
+
+.form-horizontal .help-block {
+ margin-bottom: 0;
+}
+
+.form-horizontal input + .help-block,
+.form-horizontal select + .help-block,
+.form-horizontal textarea + .help-block {
+ margin-top: 10px;
+}
+
+.form-horizontal .form-actions {
+ padding-left: 180px;
+}
+
+table {
+ max-width: 100%;
+ background-color: transparent;
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+
+.table {
+ width: 100%;
+ margin-bottom: 20px;
+}
+
+.table th,
+.table td {
+ padding: 8px;
+ line-height: 20px;
+ text-align: left;
+ vertical-align: top;
+ border-top: 1px solid #dddddd;
+}
+
+.table th {
+ font-weight: bold;
+}
+
+.table thead th {
+ vertical-align: bottom;
+}
+
+.table caption + thead tr:first-child th,
+.table caption + thead tr:first-child td,
+.table colgroup + thead tr:first-child th,
+.table colgroup + thead tr:first-child td,
+.table thead:first-child tr:first-child th,
+.table thead:first-child tr:first-child td {
+ border-top: 0;
+}
+
+.table tbody + tbody {
+ border-top: 2px solid #dddddd;
+}
+
+.table-condensed th,
+.table-condensed td {
+ padding: 4px 5px;
+}
+
+.table-bordered {
+ border: 1px solid #dddddd;
+ border-collapse: separate;
+ *border-collapse: collapse;
+ border-left: 0;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+
+.table-bordered th,
+.table-bordered td {
+ border-left: 1px solid #dddddd;
+}
+
+.table-bordered caption + thead tr:first-child th,
+.table-bordered caption + tbody tr:first-child th,
+.table-bordered caption + tbody tr:first-child td,
+.table-bordered colgroup + thead tr:first-child th,
+.table-bordered colgroup + tbody tr:first-child th,
+.table-bordered colgroup + tbody tr:first-child td,
+.table-bordered thead:first-child tr:first-child th,
+.table-bordered tbody:first-child tr:first-child th,
+.table-bordered tbody:first-child tr:first-child td {
+ border-top: 0;
+}
+
+.table-bordered thead:first-child tr:first-child th:first-child,
+.table-bordered tbody:first-child tr:first-child td:first-child {
+ -webkit-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
+ -moz-border-radius-topleft: 4px;
+}
+
+.table-bordered thead:first-child tr:first-child th:last-child,
+.table-bordered tbody:first-child tr:first-child td:last-child {
+ -webkit-border-top-right-radius: 4px;
+ border-top-right-radius: 4px;
+ -moz-border-radius-topright: 4px;
+}
+
+.table-bordered thead:last-child tr:last-child th:first-child,
+.table-bordered tbody:last-child tr:last-child td:first-child,
+.table-bordered tfoot:last-child tr:last-child td:first-child {
+ -webkit-border-radius: 0 0 0 4px;
+ -moz-border-radius: 0 0 0 4px;
+ border-radius: 0 0 0 4px;
+ -webkit-border-bottom-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+ -moz-border-radius-bottomleft: 4px;
+}
+
+.table-bordered thead:last-child tr:last-child th:last-child,
+.table-bordered tbody:last-child tr:last-child td:last-child,
+.table-bordered tfoot:last-child tr:last-child td:last-child {
+ -webkit-border-bottom-right-radius: 4px;
+ border-bottom-right-radius: 4px;
+ -moz-border-radius-bottomright: 4px;
+}
+
+.table-bordered caption + thead tr:first-child th:first-child,
+.table-bordered caption + tbody tr:first-child td:first-child,
+.table-bordered colgroup + thead tr:first-child th:first-child,
+.table-bordered colgroup + tbody tr:first-child td:first-child {
+ -webkit-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
+ -moz-border-radius-topleft: 4px;
+}
+
+.table-bordered caption + thead tr:first-child th:last-child,
+.table-bordered caption + tbody tr:first-child td:last-child,
+.table-bordered colgroup + thead tr:first-child th:last-child,
+.table-bordered colgroup + tbody tr:first-child td:last-child {
+ -webkit-border-top-right-radius: 4px;
+ border-top-right-radius: 4px;
+ -moz-border-radius-topleft: 4px;
+}
+
+.table-striped tbody tr:nth-child(odd) td,
+.table-striped tbody tr:nth-child(odd) th {
+ background-color: #f9f9f9;
+}
+
+.table-hover tbody tr:hover td,
+.table-hover tbody tr:hover th {
+ background-color: #f5f5f5;
+}
+
+table [class*=span],
+.row-fluid table [class*=span] {
+ display: table-cell;
+ float: none;
+ margin-left: 0;
+}
+
+.table .span1 {
+ float: none;
+ width: 44px;
+ margin-left: 0;
+}
+
+.table .span2 {
+ float: none;
+ width: 124px;
+ margin-left: 0;
+}
+
+.table .span3 {
+ float: none;
+ width: 204px;
+ margin-left: 0;
+}
+
+.table .span4 {
+ float: none;
+ width: 284px;
+ margin-left: 0;
+}
+
+.table .span5 {
+ float: none;
+ width: 364px;
+ margin-left: 0;
+}
+
+.table .span6 {
+ float: none;
+ width: 444px;
+ margin-left: 0;
+}
+
+.table .span7 {
+ float: none;
+ width: 524px;
+ margin-left: 0;
+}
+
+.table .span8 {
+ float: none;
+ width: 604px;
+ margin-left: 0;
+}
+
+.table .span9 {
+ float: none;
+ width: 684px;
+ margin-left: 0;
+}
+
+.table .span10 {
+ float: none;
+ width: 764px;
+ margin-left: 0;
+}
+
+.table .span11 {
+ float: none;
+ width: 844px;
+ margin-left: 0;
+}
+
+.table .span12 {
+ float: none;
+ width: 924px;
+ margin-left: 0;
+}
+
+.table .span13 {
+ float: none;
+ width: 1004px;
+ margin-left: 0;
+}
+
+.table .span14 {
+ float: none;
+ width: 1084px;
+ margin-left: 0;
+}
+
+.table .span15 {
+ float: none;
+ width: 1164px;
+ margin-left: 0;
+}
+
+.table .span16 {
+ float: none;
+ width: 1244px;
+ margin-left: 0;
+}
+
+.table .span17 {
+ float: none;
+ width: 1324px;
+ margin-left: 0;
+}
+
+.table .span18 {
+ float: none;
+ width: 1404px;
+ margin-left: 0;
+}
+
+.table .span19 {
+ float: none;
+ width: 1484px;
+ margin-left: 0;
+}
+
+.table .span20 {
+ float: none;
+ width: 1564px;
+ margin-left: 0;
+}
+
+.table .span21 {
+ float: none;
+ width: 1644px;
+ margin-left: 0;
+}
+
+.table .span22 {
+ float: none;
+ width: 1724px;
+ margin-left: 0;
+}
+
+.table .span23 {
+ float: none;
+ width: 1804px;
+ margin-left: 0;
+}
+
+.table .span24 {
+ float: none;
+ width: 1884px;
+ margin-left: 0;
+}
+
+.table tbody tr.success td {
+ background-color: #dff0d8;
+}
+
+.table tbody tr.error td {
+ background-color: #f2dede;
+}
+
+.table tbody tr.warning td {
+ background-color: #fcf8e3;
+}
+
+.table tbody tr.info td {
+ background-color: #d9edf7;
+}
+
+.table-hover tbody tr.success:hover td {
+ background-color: #d0e9c6;
+}
+
+.table-hover tbody tr.error:hover td {
+ background-color: #ebcccc;
+}
+
+.table-hover tbody tr.warning:hover td {
+ background-color: #faf2cc;
+}
+
+.table-hover tbody tr.info:hover td {
+ background-color: #c4e3f3;
+}
+
+[class^="icon-"],
+[class*=" icon-"] {
+ display: inline-block;
+ width: 14px;
+ height: 14px;
+ margin-top: 1px;
+ *margin-right: .3em;
+ line-height: 14px;
+ vertical-align: text-top;
+ background-image: url("../img/glyphicons-halflings.png");
+ background-position: 14px 14px;
+ background-repeat: no-repeat;
+}
+
+/* White icons with optional class, or on hover/active states of certain elements */
+
+.icon-white,
+.nav-tabs > .active > a > [class^="icon-"],
+.nav-tabs > .active > a > [class*=" icon-"],
+.nav-pills > .active > a > [class^="icon-"],
+.nav-pills > .active > a > [class*=" icon-"],
+.nav-list > .active > a > [class^="icon-"],
+.nav-list > .active > a > [class*=" icon-"],
+.navbar-inverse .nav > .active > a > [class^="icon-"],
+.navbar-inverse .nav > .active > a > [class*=" icon-"],
+.dropdown-menu > li > a:hover > [class^="icon-"],
+.dropdown-menu > li > a:hover > [class*=" icon-"],
+.dropdown-menu > .active > a > [class^="icon-"],
+.dropdown-menu > .active > a > [class*=" icon-"] {
+ background-image: url("../img/glyphicons-halflings-white.png");
+}
+
+.icon-glass {
+ background-position: 0 0;
+}
+
+.icon-music {
+ background-position: -24px 0;
+}
+
+.icon-search {
+ background-position: -48px 0;
+}
+
+.icon-envelope {
+ background-position: -72px 0;
+}
+
+.icon-heart {
+ background-position: -96px 0;
+}
+
+.icon-star {
+ background-position: -120px 0;
+}
+
+.icon-star-empty {
+ background-position: -144px 0;
+}
+
+.icon-user {
+ background-position: -168px 0;
+}
+
+.icon-film {
+ background-position: -192px 0;
+}
+
+.icon-th-large {
+ background-position: -216px 0;
+}
+
+.icon-th {
+ background-position: -240px 0;
+}
+
+.icon-th-list {
+ background-position: -264px 0;
+}
+
+.icon-ok {
+ background-position: -288px 0;
+}
+
+.icon-remove {
+ background-position: -312px 0;
+}
+
+.icon-zoom-in {
+ background-position: -336px 0;
+}
+
+.icon-zoom-out {
+ background-position: -360px 0;
+}
+
+.icon-off {
+ background-position: -384px 0;
+}
+
+.icon-signal {
+ background-position: -408px 0;
+}
+
+.icon-cog {
+ background-position: -432px 0;
+}
+
+.icon-trash {
+ background-position: -456px 0;
+}
+
+.icon-home {
+ background-position: 0 -24px;
+}
+
+.icon-file {
+ background-position: -24px -24px;
+}
+
+.icon-time {
+ background-position: -48px -24px;
+}
+
+.icon-road {
+ background-position: -72px -24px;
+}
+
+.icon-download-alt {
+ background-position: -96px -24px;
+}
+
+.icon-download {
+ background-position: -120px -24px;
+}
+
+.icon-upload {
+ background-position: -144px -24px;
+}
+
+.icon-inbox {
+ background-position: -168px -24px;
+}
+
+.icon-play-circle {
+ background-position: -192px -24px;
+}
+
+.icon-repeat {
+ background-position: -216px -24px;
+}
+
+.icon-refresh {
+ background-position: -240px -24px;
+}
+
+.icon-list-alt {
+ background-position: -264px -24px;
+}
+
+.icon-lock {
+ background-position: -287px -24px;
+}
+
+.icon-flag {
+ background-position: -312px -24px;
+}
+
+.icon-headphones {
+ background-position: -336px -24px;
+}
+
+.icon-volume-off {
+ background-position: -360px -24px;
+}
+
+.icon-volume-down {
+ background-position: -384px -24px;
+}
+
+.icon-volume-up {
+ background-position: -408px -24px;
+}
+
+.icon-qrcode {
+ background-position: -432px -24px;
+}
+
+.icon-barcode {
+ background-position: -456px -24px;
+}
+
+.icon-tag {
+ background-position: 0 -48px;
+}
+
+.icon-tags {
+ background-position: -25px -48px;
+}
+
+.icon-book {
+ background-position: -48px -48px;
+}
+
+.icon-bookmark {
+ background-position: -72px -48px;
+}
+
+.icon-print {
+ background-position: -96px -48px;
+}
+
+.icon-camera {
+ background-position: -120px -48px;
+}
+
+.icon-font {
+ background-position: -144px -48px;
+}
+
+.icon-bold {
+ background-position: -167px -48px;
+}
+
+.icon-italic {
+ background-position: -192px -48px;
+}
+
+.icon-text-height {
+ background-position: -216px -48px;
+}
+
+.icon-text-width {
+ background-position: -240px -48px;
+}
+
+.icon-align-left {
+ background-position: -264px -48px;
+}
+
+.icon-align-center {
+ background-position: -288px -48px;
+}
+
+.icon-align-right {
+ background-position: -312px -48px;
+}
+
+.icon-align-justify {
+ background-position: -336px -48px;
+}
+
+.icon-list {
+ background-position: -360px -48px;
+}
+
+.icon-indent-left {
+ background-position: -384px -48px;
+}
+
+.icon-indent-right {
+ background-position: -408px -48px;
+}
+
+.icon-facetime-video {
+ background-position: -432px -48px;
+}
+
+.icon-picture {
+ background-position: -456px -48px;
+}
+
+.icon-pencil {
+ background-position: 0 -72px;
+}
+
+.icon-map-marker {
+ background-position: -24px -72px;
+}
+
+.icon-adjust {
+ background-position: -48px -72px;
+}
+
+.icon-tint {
+ background-position: -72px -72px;
+}
+
+.icon-edit {
+ background-position: -96px -72px;
+}
+
+.icon-share {
+ background-position: -120px -72px;
+}
+
+.icon-check {
+ background-position: -144px -72px;
+}
+
+.icon-move {
+ background-position: -168px -72px;
+}
+
+.icon-step-backward {
+ background-position: -192px -72px;
+}
+
+.icon-fast-backward {
+ background-position: -216px -72px;
+}
+
+.icon-backward {
+ background-position: -240px -72px;
+}
+
+.icon-play {
+ background-position: -264px -72px;
+}
+
+.icon-pause {
+ background-position: -288px -72px;
+}
+
+.icon-stop {
+ background-position: -312px -72px;
+}
+
+.icon-forward {
+ background-position: -336px -72px;
+}
+
+.icon-fast-forward {
+ background-position: -360px -72px;
+}
+
+.icon-step-forward {
+ background-position: -384px -72px;
+}
+
+.icon-eject {
+ background-position: -408px -72px;
+}
+
+.icon-chevron-left {
+ background-position: -432px -72px;
+}
+
+.icon-chevron-right {
+ background-position: -456px -72px;
+}
+
+.icon-plus-sign {
+ background-position: 0 -96px;
+}
+
+.icon-minus-sign {
+ background-position: -24px -96px;
+}
+
+.icon-remove-sign {
+ background-position: -48px -96px;
+}
+
+.icon-ok-sign {
+ background-position: -72px -96px;
+}
+
+.icon-question-sign {
+ background-position: -96px -96px;
+}
+
+.icon-info-sign {
+ background-position: -120px -96px;
+}
+
+.icon-screenshot {
+ background-position: -144px -96px;
+}
+
+.icon-remove-circle {
+ background-position: -168px -96px;
+}
+
+.icon-ok-circle {
+ background-position: -192px -96px;
+}
+
+.icon-ban-circle {
+ background-position: -216px -96px;
+}
+
+.icon-arrow-left {
+ background-position: -240px -96px;
+}
+
+.icon-arrow-right {
+ background-position: -264px -96px;
+}
+
+.icon-arrow-up {
+ background-position: -289px -96px;
+}
+
+.icon-arrow-down {
+ background-position: -312px -96px;
+}
+
+.icon-share-alt {
+ background-position: -336px -96px;
+}
+
+.icon-resize-full {
+ background-position: -360px -96px;
+}
+
+.icon-resize-small {
+ background-position: -384px -96px;
+}
+
+.icon-plus {
+ background-position: -408px -96px;
+}
+
+.icon-minus {
+ background-position: -433px -96px;
+}
+
+.icon-asterisk {
+ background-position: -456px -96px;
+}
+
+.icon-exclamation-sign {
+ background-position: 0 -120px;
+}
+
+.icon-gift {
+ background-position: -24px -120px;
+}
+
+.icon-leaf {
+ background-position: -48px -120px;
+}
+
+.icon-fire {
+ background-position: -72px -120px;
+}
+
+.icon-eye-open {
+ background-position: -96px -120px;
+}
+
+.icon-eye-close {
+ background-position: -120px -120px;
+}
+
+.icon-warning-sign {
+ background-position: -144px -120px;
+}
+
+.icon-plane {
+ background-position: -168px -120px;
+}
+
+.icon-calendar {
+ background-position: -192px -120px;
+}
+
+.icon-random {
+ width: 16px;
+ background-position: -216px -120px;
+}
+
+.icon-comment {
+ background-position: -240px -120px;
+}
+
+.icon-magnet {
+ background-position: -264px -120px;
+}
+
+.icon-chevron-up {
+ background-position: -288px -120px;
+}
+
+.icon-chevron-down {
+ background-position: -313px -119px;
+}
+
+.icon-retweet {
+ background-position: -336px -120px;
+}
+
+.icon-shopping-cart {
+ background-position: -360px -120px;
+}
+
+.icon-folder-close {
+ background-position: -384px -120px;
+}
+
+.icon-folder-open {
+ width: 16px;
+ background-position: -408px -120px;
+}
+
+.icon-resize-vertical {
+ background-position: -432px -119px;
+}
+
+.icon-resize-horizontal {
+ background-position: -456px -118px;
+}
+
+.icon-hdd {
+ background-position: 0 -144px;
+}
+
+.icon-bullhorn {
+ background-position: -24px -144px;
+}
+
+.icon-bell {
+ background-position: -48px -144px;
+}
+
+.icon-certificate {
+ background-position: -72px -144px;
+}
+
+.icon-thumbs-up {
+ background-position: -96px -144px;
+}
+
+.icon-thumbs-down {
+ background-position: -120px -144px;
+}
+
+.icon-hand-right {
+ background-position: -144px -144px;
+}
+
+.icon-hand-left {
+ background-position: -168px -144px;
+}
+
+.icon-hand-up {
+ background-position: -192px -144px;
+}
+
+.icon-hand-down {
+ background-position: -216px -144px;
+}
+
+.icon-circle-arrow-right {
+ background-position: -240px -144px;
+}
+
+.icon-circle-arrow-left {
+ background-position: -264px -144px;
+}
+
+.icon-circle-arrow-up {
+ background-position: -288px -144px;
+}
+
+.icon-circle-arrow-down {
+ background-position: -312px -144px;
+}
+
+.icon-globe {
+ background-position: -336px -144px;
+}
+
+.icon-wrench {
+ background-position: -360px -144px;
+}
+
+.icon-tasks {
+ background-position: -384px -144px;
+}
+
+.icon-filter {
+ background-position: -408px -144px;
+}
+
+.icon-briefcase {
+ background-position: -432px -144px;
+}
+
+.icon-fullscreen {
+ background-position: -456px -144px;
+}
+
+.dropup,
+.dropdown {
+ position: relative;
+}
+
+.dropdown-toggle {
+ *margin-bottom: -3px;
+}
+
+.dropdown-toggle:active,
+.open .dropdown-toggle {
+ outline: 0;
+}
+
+.caret {
+ display: inline-block;
+ width: 0;
+ height: 0;
+ vertical-align: top;
+ border-top: 4px solid #000000;
+ border-right: 4px solid transparent;
+ border-left: 4px solid transparent;
+ content: "";
+}
+
+.dropdown .caret {
+ margin-top: 8px;
+ margin-left: 2px;
+}
+
+.dropdown-menu {
+ position: absolute;
+ top: 100%;
+ left: 0;
+ z-index: 1000;
+ display: none;
+ float: left;
+ min-width: 160px;
+ padding: 5px 0;
+ margin: 2px 0 0;
+ list-style: none;
+ background-color: #ffffff;
+ border: 1px solid #ccc;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ *border-right-width: 2px;
+ *border-bottom-width: 2px;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+ -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ -webkit-background-clip: padding-box;
+ -moz-background-clip: padding;
+ background-clip: padding-box;
+}
+
+.dropdown-menu.pull-right {
+ right: 0;
+ left: auto;
+}
+
+.dropdown-menu .divider {
+ *width: 100%;
+ height: 1px;
+ margin: 9px 1px;
+ *margin: -5px 0 5px;
+ overflow: hidden;
+ background-color: #e5e5e5;
+ border-bottom: 1px solid #ffffff;
+}
+
+.dropdown-menu a {
+ display: block;
+ padding: 3px 20px;
+ clear: both;
+ font-weight: normal;
+ line-height: 20px;
+ color: #333333;
+ white-space: nowrap;
+}
+
+.dropdown-menu li > a:hover,
+.dropdown-menu li > a:focus,
+.dropdown-submenu:hover > a {
+ color: #ffffff;
+ text-decoration: none;
+ background-color: #0088cc;
+ background-color: #0081c2;
+ background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
+ background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
+ background-image: -o-linear-gradient(top, #0088cc, #0077b3);
+ background-image: linear-gradient(to bottom, #0088cc, #0077b3);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0);
+}
+
+.dropdown-menu .active > a,
+.dropdown-menu .active > a:hover {
+ color: #ffffff;
+ text-decoration: none;
+ background-color: #0088cc;
+ background-color: #0081c2;
+ background-image: linear-gradient(to bottom, #0088cc, #0077b3);
+ background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
+ background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
+ background-image: -o-linear-gradient(top, #0088cc, #0077b3);
+ background-repeat: repeat-x;
+ outline: 0;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0);
+}
+
+.dropdown-menu .disabled > a,
+.dropdown-menu .disabled > a:hover {
+ color: #999999;
+}
+
+.dropdown-menu .disabled > a:hover {
+ text-decoration: none;
+ cursor: default;
+ background-color: transparent;
+}
+
+.open {
+ *z-index: 1000;
+}
+
+.open > .dropdown-menu {
+ display: block;
+}
+
+.pull-right > .dropdown-menu {
+ right: 0;
+ left: auto;
+}
+
+.dropup .caret,
+.navbar-fixed-bottom .dropdown .caret {
+ border-top: 0;
+ border-bottom: 4px solid #000000;
+ content: "";
+}
+
+.dropup .dropdown-menu,
+.navbar-fixed-bottom .dropdown .dropdown-menu {
+ top: auto;
+ bottom: 100%;
+ margin-bottom: 1px;
+}
+
+.dropdown-submenu {
+ position: relative;
+}
+
+.dropdown-submenu > .dropdown-menu {
+ top: 0;
+ left: 100%;
+ margin-top: -6px;
+ margin-left: -1px;
+ -webkit-border-radius: 0 6px 6px 6px;
+ -moz-border-radius: 0 6px 6px 6px;
+ border-radius: 0 6px 6px 6px;
+}
+
+.dropdown-submenu:hover > .dropdown-menu {
+ display: block;
+}
+
+.dropdown-submenu > a:after {
+ display: block;
+ float: right;
+ width: 0;
+ height: 0;
+ margin-top: 5px;
+ margin-right: -10px;
+ border-color: transparent;
+ border-left-color: #cccccc;
+ border-style: solid;
+ border-width: 5px 0 5px 5px;
+ content: " ";
+}
+
+.dropdown-submenu:hover > a:after {
+ border-left-color: #ffffff;
+}
+
+.dropdown .dropdown-menu .nav-header {
+ padding-right: 20px;
+ padding-left: 20px;
+}
+
+.typeahead {
+ margin-top: 2px;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+
+.well {
+ min-height: 20px;
+ padding: 19px;
+ margin-bottom: 20px;
+ background-color: #f5f5f5;
+ border: 1px solid #e3e3e3;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+}
+
+.well blockquote {
+ border-color: #ddd;
+ border-color: rgba(0, 0, 0, 0.15);
+}
+
+.well-large {
+ padding: 24px;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+}
+
+.well-small {
+ padding: 9px;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+}
+
+.fade {
+ opacity: 0;
+ -webkit-transition: opacity 0.15s linear;
+ -moz-transition: opacity 0.15s linear;
+ -o-transition: opacity 0.15s linear;
+ transition: opacity 0.15s linear;
+}
+
+.fade.in {
+ opacity: 1;
+}
+
+.collapse {
+ position: relative;
+ height: 0;
+ overflow: hidden;
+ -webkit-transition: height 0.35s ease;
+ -moz-transition: height 0.35s ease;
+ -o-transition: height 0.35s ease;
+ transition: height 0.35s ease;
+}
+
+.collapse.in {
+ height: auto;
+}
+
+.close {
+ float: right;
+ font-size: 20px;
+ font-weight: bold;
+ line-height: 20px;
+ color: #000000;
+ text-shadow: 0 1px 0 #ffffff;
+ opacity: 0.2;
+ filter: alpha(opacity=20);
+}
+
+.close:hover {
+ color: #000000;
+ text-decoration: none;
+ cursor: pointer;
+ opacity: 0.4;
+ filter: alpha(opacity=40);
+}
+
+button.close {
+ padding: 0;
+ cursor: pointer;
+ background: transparent;
+ border: 0;
+ -webkit-appearance: none;
+}
+
+.btn {
+ display: inline-block;
+ *display: inline;
+ padding: 4px 14px;
+ margin-bottom: 0;
+ *margin-left: .3em;
+ font-size: 14px;
+ line-height: 20px;
+ *line-height: 20px;
+ color: #333333;
+ text-align: center;
+ text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
+ vertical-align: middle;
+ cursor: pointer;
+ background-color: #f5f5f5;
+ *background-color: #e6e6e6;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
+ background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
+ background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
+ background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
+ background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
+ background-repeat: repeat-x;
+ border: 1px solid #bbbbbb;
+ *border: 0;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ border-color: #e6e6e6 #e6e6e6 #bfbfbf;
+ border-bottom-color: #a2a2a2;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+ *zoom: 1;
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+}
+
+.btn:hover,
+.btn:active,
+.btn.active,
+.btn.disabled,
+.btn[disabled] {
+ color: #333333;
+ background-color: #e6e6e6;
+ *background-color: #d9d9d9;
+}
+
+.btn:active,
+.btn.active {
+ background-color: #cccccc \9;
+}
+
+.btn:first-child {
+ *margin-left: 0;
+}
+
+.btn:hover {
+ color: #333333;
+ text-decoration: none;
+ background-color: #e6e6e6;
+ *background-color: #d9d9d9;
+ /* Buttons in IE7 don't get borders, so darken on hover */
+
+ background-position: 0 -15px;
+ -webkit-transition: background-position 0.1s linear;
+ -moz-transition: background-position 0.1s linear;
+ -o-transition: background-position 0.1s linear;
+ transition: background-position 0.1s linear;
+}
+
+.btn:focus {
+ outline: thin dotted #333;
+ outline: 5px auto -webkit-focus-ring-color;
+ outline-offset: -2px;
+}
+
+.btn.active,
+.btn:active {
+ background-color: #e6e6e6;
+ background-color: #d9d9d9 \9;
+ background-image: none;
+ outline: 0;
+ -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+}
+
+.btn.disabled,
+.btn[disabled] {
+ cursor: default;
+ background-color: #e6e6e6;
+ background-image: none;
+ opacity: 0.65;
+ filter: alpha(opacity=65);
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ box-shadow: none;
+}
+
+.btn-large {
+ padding: 9px 14px;
+ font-size: 16px;
+ line-height: normal;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+}
+
+.btn-large [class^="icon-"] {
+ margin-top: 2px;
+}
+
+.btn-small {
+ padding: 3px 9px;
+ font-size: 12px;
+ line-height: 18px;
+}
+
+.btn-small [class^="icon-"] {
+ margin-top: 0;
+}
+
+.btn-mini {
+ padding: 2px 6px;
+ font-size: 11px;
+ line-height: 17px;
+}
+
+.btn-block {
+ display: block;
+ width: 100%;
+ padding-right: 0;
+ padding-left: 0;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+.btn-block + .btn-block {
+ margin-top: 5px;
+}
+
+input[type="submit"].btn-block,
+input[type="reset"].btn-block,
+input[type="button"].btn-block {
+ width: 100%;
+}
+
+.btn-primary.active,
+.btn-warning.active,
+.btn-danger.active,
+.btn-success.active,
+.btn-info.active,
+.btn-inverse.active {
+ color: rgba(255, 255, 255, 0.75);
+}
+
+.btn {
+ border-color: #c5c5c5;
+ border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25);
+}
+
+.btn-primary {
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #006dcc;
+ *background-color: #0044cc;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
+ background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
+ background-image: -o-linear-gradient(top, #0088cc, #0044cc);
+ background-image: linear-gradient(to bottom, #0088cc, #0044cc);
+ background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
+ background-repeat: repeat-x;
+ border-color: #0044cc #0044cc #002a80;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+}
+
+.btn-primary:hover,
+.btn-primary:active,
+.btn-primary.active,
+.btn-primary.disabled,
+.btn-primary[disabled] {
+ color: #ffffff;
+ background-color: #0044cc;
+ *background-color: #003bb3;
+}
+
+.btn-primary:active,
+.btn-primary.active {
+ background-color: #003399 \9;
+}
+
+.btn-warning {
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #faa732;
+ *background-color: #f89406;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
+ background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
+ background-image: -o-linear-gradient(top, #fbb450, #f89406);
+ background-image: linear-gradient(to bottom, #fbb450, #f89406);
+ background-image: -moz-linear-gradient(top, #fbb450, #f89406);
+ background-repeat: repeat-x;
+ border-color: #f89406 #f89406 #ad6704;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+}
+
+.btn-warning:hover,
+.btn-warning:active,
+.btn-warning.active,
+.btn-warning.disabled,
+.btn-warning[disabled] {
+ color: #ffffff;
+ background-color: #f89406;
+ *background-color: #df8505;
+}
+
+.btn-warning:active,
+.btn-warning.active {
+ background-color: #c67605 \9;
+}
+
+.btn-danger {
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #da4f49;
+ *background-color: #bd362f;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));
+ background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f);
+ background-image: -o-linear-gradient(top, #ee5f5b, #bd362f);
+ background-image: linear-gradient(to bottom, #ee5f5b, #bd362f);
+ background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f);
+ background-repeat: repeat-x;
+ border-color: #bd362f #bd362f #802420;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffbd362f', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+}
+
+.btn-danger:hover,
+.btn-danger:active,
+.btn-danger.active,
+.btn-danger.disabled,
+.btn-danger[disabled] {
+ color: #ffffff;
+ background-color: #bd362f;
+ *background-color: #a9302a;
+}
+
+.btn-danger:active,
+.btn-danger.active {
+ background-color: #942a25 \9;
+}
+
+.btn-success {
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #5bb75b;
+ *background-color: #51a351;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));
+ background-image: -webkit-linear-gradient(top, #62c462, #51a351);
+ background-image: -o-linear-gradient(top, #62c462, #51a351);
+ background-image: linear-gradient(to bottom, #62c462, #51a351);
+ background-image: -moz-linear-gradient(top, #62c462, #51a351);
+ background-repeat: repeat-x;
+ border-color: #51a351 #51a351 #387038;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff51a351', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+}
+
+.btn-success:hover,
+.btn-success:active,
+.btn-success.active,
+.btn-success.disabled,
+.btn-success[disabled] {
+ color: #ffffff;
+ background-color: #51a351;
+ *background-color: #499249;
+}
+
+.btn-success:active,
+.btn-success.active {
+ background-color: #408140 \9;
+}
+
+.btn-info {
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #49afcd;
+ *background-color: #2f96b4;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));
+ background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4);
+ background-image: -o-linear-gradient(top, #5bc0de, #2f96b4);
+ background-image: linear-gradient(to bottom, #5bc0de, #2f96b4);
+ background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4);
+ background-repeat: repeat-x;
+ border-color: #2f96b4 #2f96b4 #1f6377;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2f96b4', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+}
+
+.btn-info:hover,
+.btn-info:active,
+.btn-info.active,
+.btn-info.disabled,
+.btn-info[disabled] {
+ color: #ffffff;
+ background-color: #2f96b4;
+ *background-color: #2a85a0;
+}
+
+.btn-info:active,
+.btn-info.active {
+ background-color: #24748c \9;
+}
+
+.btn-inverse {
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #363636;
+ *background-color: #222222;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#444444), to(#222222));
+ background-image: -webkit-linear-gradient(top, #444444, #222222);
+ background-image: -o-linear-gradient(top, #444444, #222222);
+ background-image: linear-gradient(to bottom, #444444, #222222);
+ background-image: -moz-linear-gradient(top, #444444, #222222);
+ background-repeat: repeat-x;
+ border-color: #222222 #222222 #000000;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff444444', endColorstr='#ff222222', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+}
+
+.btn-inverse:hover,
+.btn-inverse:active,
+.btn-inverse.active,
+.btn-inverse.disabled,
+.btn-inverse[disabled] {
+ color: #ffffff;
+ background-color: #222222;
+ *background-color: #151515;
+}
+
+.btn-inverse:active,
+.btn-inverse.active {
+ background-color: #080808 \9;
+}
+
+button.btn,
+input[type="submit"].btn {
+ *padding-top: 3px;
+ *padding-bottom: 3px;
+}
+
+button.btn::-moz-focus-inner,
+input[type="submit"].btn::-moz-focus-inner {
+ padding: 0;
+ border: 0;
+}
+
+button.btn.btn-large,
+input[type="submit"].btn.btn-large {
+ *padding-top: 7px;
+ *padding-bottom: 7px;
+}
+
+button.btn.btn-small,
+input[type="submit"].btn.btn-small {
+ *padding-top: 3px;
+ *padding-bottom: 3px;
+}
+
+button.btn.btn-mini,
+input[type="submit"].btn.btn-mini {
+ *padding-top: 1px;
+ *padding-bottom: 1px;
+}
+
+.btn-link,
+.btn-link:active,
+.btn-link[disabled] {
+ background-color: transparent;
+ background-image: none;
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ box-shadow: none;
+}
+
+.btn-link {
+ color: #0088cc;
+ cursor: pointer;
+ border-color: transparent;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+}
+
+.btn-link:hover {
+ color: #005580;
+ text-decoration: underline;
+ background-color: transparent;
+}
+
+.btn-link[disabled]:hover {
+ color: #333333;
+ text-decoration: none;
+}
+
+.btn-group {
+ position: relative;
+ *margin-left: .3em;
+ font-size: 0;
+ white-space: nowrap;
+ vertical-align: middle;
+}
+
+.btn-group:first-child {
+ *margin-left: 0;
+}
+
+.btn-group + .btn-group {
+ margin-left: 5px;
+}
+
+.btn-toolbar {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 0;
+}
+
+.btn-toolbar .btn-group {
+ display: inline-block;
+ *display: inline;
+ /* IE7 inline-block hack */
+
+ *zoom: 1;
+}
+
+.btn-toolbar .btn + .btn,
+.btn-toolbar .btn-group + .btn,
+.btn-toolbar .btn + .btn-group {
+ margin-left: 5px;
+}
+
+.btn-group > .btn {
+ position: relative;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+}
+
+.btn-group > .btn + .btn {
+ margin-left: -1px;
+}
+
+.btn-group > .btn,
+.btn-group > .dropdown-menu {
+ font-size: 14px;
+}
+
+.btn-group > .btn-mini {
+ font-size: 11px;
+}
+
+.btn-group > .btn-small {
+ font-size: 12px;
+}
+
+.btn-group > .btn-large {
+ font-size: 16px;
+}
+
+.btn-group > .btn:first-child {
+ margin-left: 0;
+ -webkit-border-bottom-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+ -webkit-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
+ -moz-border-radius-bottomleft: 4px;
+ -moz-border-radius-topleft: 4px;
+}
+
+.btn-group > .btn:last-child,
+.btn-group > .dropdown-toggle {
+ -webkit-border-top-right-radius: 4px;
+ border-top-right-radius: 4px;
+ -webkit-border-bottom-right-radius: 4px;
+ border-bottom-right-radius: 4px;
+ -moz-border-radius-topright: 4px;
+ -moz-border-radius-bottomright: 4px;
+}
+
+.btn-group > .btn.large:first-child {
+ margin-left: 0;
+ -webkit-border-bottom-left-radius: 6px;
+ border-bottom-left-radius: 6px;
+ -webkit-border-top-left-radius: 6px;
+ border-top-left-radius: 6px;
+ -moz-border-radius-bottomleft: 6px;
+ -moz-border-radius-topleft: 6px;
+}
+
+.btn-group > .btn.large:last-child,
+.btn-group > .large.dropdown-toggle {
+ -webkit-border-top-right-radius: 6px;
+ border-top-right-radius: 6px;
+ -webkit-border-bottom-right-radius: 6px;
+ border-bottom-right-radius: 6px;
+ -moz-border-radius-topright: 6px;
+ -moz-border-radius-bottomright: 6px;
+}
+
+.btn-group > .btn:hover,
+.btn-group > .btn:focus,
+.btn-group > .btn:active,
+.btn-group > .btn.active {
+ z-index: 2;
+}
+
+.btn-group .dropdown-toggle:active,
+.btn-group.open .dropdown-toggle {
+ outline: 0;
+}
+
+.btn-group > .btn + .dropdown-toggle {
+ *padding-top: 5px;
+ padding-right: 8px;
+ *padding-bottom: 5px;
+ padding-left: 8px;
+ -webkit-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+}
+
+.btn-group > .btn-mini + .dropdown-toggle {
+ *padding-top: 2px;
+ padding-right: 5px;
+ *padding-bottom: 2px;
+ padding-left: 5px;
+}
+
+.btn-group > .btn-small + .dropdown-toggle {
+ *padding-top: 5px;
+ *padding-bottom: 4px;
+}
+
+.btn-group > .btn-large + .dropdown-toggle {
+ *padding-top: 7px;
+ padding-right: 12px;
+ *padding-bottom: 7px;
+ padding-left: 12px;
+}
+
+.btn-group.open .dropdown-toggle {
+ background-image: none;
+ -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+}
+
+.btn-group.open .btn.dropdown-toggle {
+ background-color: #e6e6e6;
+}
+
+.btn-group.open .btn-primary.dropdown-toggle {
+ background-color: #0044cc;
+}
+
+.btn-group.open .btn-warning.dropdown-toggle {
+ background-color: #f89406;
+}
+
+.btn-group.open .btn-danger.dropdown-toggle {
+ background-color: #bd362f;
+}
+
+.btn-group.open .btn-success.dropdown-toggle {
+ background-color: #51a351;
+}
+
+.btn-group.open .btn-info.dropdown-toggle {
+ background-color: #2f96b4;
+}
+
+.btn-group.open .btn-inverse.dropdown-toggle {
+ background-color: #222222;
+}
+
+.btn .caret {
+ margin-top: 8px;
+ margin-left: 0;
+}
+
+.btn-mini .caret,
+.btn-small .caret,
+.btn-large .caret {
+ margin-top: 6px;
+}
+
+.btn-large .caret {
+ border-top-width: 5px;
+ border-right-width: 5px;
+ border-left-width: 5px;
+}
+
+.dropup .btn-large .caret {
+ border-top: 0;
+ border-bottom: 5px solid #000000;
+}
+
+.btn-primary .caret,
+.btn-warning .caret,
+.btn-danger .caret,
+.btn-info .caret,
+.btn-success .caret,
+.btn-inverse .caret {
+ border-top-color: #ffffff;
+ border-bottom-color: #ffffff;
+}
+
+.btn-group-vertical {
+ display: inline-block;
+ *display: inline;
+ /* IE7 inline-block hack */
+
+ *zoom: 1;
+}
+
+.btn-group-vertical .btn {
+ display: block;
+ float: none;
+ width: 100%;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+}
+
+.btn-group-vertical .btn + .btn {
+ margin-top: -1px;
+ margin-left: 0;
+}
+
+.btn-group-vertical .btn:first-child {
+ -webkit-border-radius: 4px 4px 0 0;
+ -moz-border-radius: 4px 4px 0 0;
+ border-radius: 4px 4px 0 0;
+}
+
+.btn-group-vertical .btn:last-child {
+ -webkit-border-radius: 0 0 4px 4px;
+ -moz-border-radius: 0 0 4px 4px;
+ border-radius: 0 0 4px 4px;
+}
+
+.btn-group-vertical .btn-large:first-child {
+ -webkit-border-radius: 6px 6px 0 0;
+ -moz-border-radius: 6px 6px 0 0;
+ border-radius: 6px 6px 0 0;
+}
+
+.btn-group-vertical .btn-large:last-child {
+ -webkit-border-radius: 0 0 6px 6px;
+ -moz-border-radius: 0 0 6px 6px;
+ border-radius: 0 0 6px 6px;
+}
+
+.alert {
+ padding: 8px 35px 8px 14px;
+ margin-bottom: 20px;
+ color: #c09853;
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
+ background-color: #fcf8e3;
+ border: 1px solid #fbeed5;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+
+.alert h4 {
+ margin: 0;
+}
+
+.alert .close {
+ position: relative;
+ top: -2px;
+ right: -21px;
+ line-height: 20px;
+}
+
+.alert-success {
+ color: #468847;
+ background-color: #dff0d8;
+ border-color: #d6e9c6;
+}
+
+.alert-danger,
+.alert-error {
+ color: #b94a48;
+ background-color: #f2dede;
+ border-color: #eed3d7;
+}
+
+.alert-info {
+ color: #3a87ad;
+ background-color: #d9edf7;
+ border-color: #bce8f1;
+}
+
+.alert-block {
+ padding-top: 14px;
+ padding-bottom: 14px;
+}
+
+.alert-block > p,
+.alert-block > ul {
+ margin-bottom: 0;
+}
+
+.alert-block p + p {
+ margin-top: 5px;
+}
+
+.nav {
+ margin-bottom: 20px;
+ margin-left: 0;
+ list-style: none;
+}
+
+.nav > li > a {
+ display: block;
+}
+
+.nav > li > a:hover {
+ text-decoration: none;
+ background-color: #eeeeee;
+}
+
+.nav > .pull-right {
+ float: right;
+}
+
+.nav-header {
+ display: block;
+ padding: 3px 15px;
+ font-size: 11px;
+ font-weight: bold;
+ line-height: 20px;
+ color: #999999;
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
+ text-transform: uppercase;
+}
+
+.nav li + .nav-header {
+ margin-top: 9px;
+}
+
+.nav-list {
+ padding-right: 15px;
+ padding-left: 15px;
+ margin-bottom: 0;
+}
+
+.nav-list > li > a,
+.nav-list .nav-header {
+ margin-right: -15px;
+ margin-left: -15px;
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
+}
+
+.nav-list > li > a {
+ padding: 3px 15px;
+}
+
+.nav-list > .active > a,
+.nav-list > .active > a:hover {
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
+ background-color: #0088cc;
+}
+
+.nav-list [class^="icon-"] {
+ margin-right: 2px;
+}
+
+.nav-list .divider {
+ *width: 100%;
+ height: 1px;
+ margin: 9px 1px;
+ *margin: -5px 0 5px;
+ overflow: hidden;
+ background-color: #e5e5e5;
+ border-bottom: 1px solid #ffffff;
+}
+
+.nav-tabs,
+.nav-pills {
+ *zoom: 1;
+}
+
+.nav-tabs:before,
+.nav-pills:before,
+.nav-tabs:after,
+.nav-pills:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.nav-tabs:after,
+.nav-pills:after {
+ clear: both;
+}
+
+.nav-tabs > li,
+.nav-pills > li {
+ float: left;
+}
+
+.nav-tabs > li > a,
+.nav-pills > li > a {
+ padding-right: 12px;
+ padding-left: 12px;
+ margin-right: 2px;
+ line-height: 14px;
+}
+
+.nav-tabs {
+ border-bottom: 1px solid #ddd;
+}
+
+.nav-tabs > li {
+ margin-bottom: -1px;
+}
+
+.nav-tabs > li > a {
+ padding-top: 8px;
+ padding-bottom: 8px;
+ line-height: 20px;
+ border: 1px solid transparent;
+ -webkit-border-radius: 4px 4px 0 0;
+ -moz-border-radius: 4px 4px 0 0;
+ border-radius: 4px 4px 0 0;
+}
+
+.nav-tabs > li > a:hover {
+ border-color: #eeeeee #eeeeee #dddddd;
+}
+
+.nav-tabs > .active > a,
+.nav-tabs > .active > a:hover {
+ color: #555555;
+ cursor: default;
+ background-color: #ffffff;
+ border: 1px solid #ddd;
+ border-bottom-color: transparent;
+}
+
+.nav-pills > li > a {
+ padding-top: 8px;
+ padding-bottom: 8px;
+ margin-top: 2px;
+ margin-bottom: 2px;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+}
+
+.nav-pills > .active > a,
+.nav-pills > .active > a:hover {
+ color: #ffffff;
+ background-color: #0088cc;
+}
+
+.nav-stacked > li {
+ float: none;
+}
+
+.nav-stacked > li > a {
+ margin-right: 0;
+}
+
+.nav-tabs.nav-stacked {
+ border-bottom: 0;
+}
+
+.nav-tabs.nav-stacked > li > a {
+ border: 1px solid #ddd;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+}
+
+.nav-tabs.nav-stacked > li:first-child > a {
+ -webkit-border-top-right-radius: 4px;
+ border-top-right-radius: 4px;
+ -webkit-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
+ -moz-border-radius-topright: 4px;
+ -moz-border-radius-topleft: 4px;
+}
+
+.nav-tabs.nav-stacked > li:last-child > a {
+ -webkit-border-bottom-right-radius: 4px;
+ border-bottom-right-radius: 4px;
+ -webkit-border-bottom-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+ -moz-border-radius-bottomright: 4px;
+ -moz-border-radius-bottomleft: 4px;
+}
+
+.nav-tabs.nav-stacked > li > a:hover {
+ z-index: 2;
+ border-color: #ddd;
+}
+
+.nav-pills.nav-stacked > li > a {
+ margin-bottom: 3px;
+}
+
+.nav-pills.nav-stacked > li:last-child > a {
+ margin-bottom: 1px;
+}
+
+.nav-tabs .dropdown-menu {
+ -webkit-border-radius: 0 0 6px 6px;
+ -moz-border-radius: 0 0 6px 6px;
+ border-radius: 0 0 6px 6px;
+}
+
+.nav-pills .dropdown-menu {
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+}
+
+.nav .dropdown-toggle .caret {
+ margin-top: 6px;
+ border-top-color: #0088cc;
+ border-bottom-color: #0088cc;
+}
+
+.nav .dropdown-toggle:hover .caret {
+ border-top-color: #005580;
+ border-bottom-color: #005580;
+}
+
+/* move down carets for tabs */
+
+.nav-tabs .dropdown-toggle .caret {
+ margin-top: 8px;
+}
+
+.nav .active .dropdown-toggle .caret {
+ border-top-color: #fff;
+ border-bottom-color: #fff;
+}
+
+.nav-tabs .active .dropdown-toggle .caret {
+ border-top-color: #555555;
+ border-bottom-color: #555555;
+}
+
+.nav > .dropdown.active > a:hover {
+ cursor: pointer;
+}
+
+.nav-tabs .open .dropdown-toggle,
+.nav-pills .open .dropdown-toggle,
+.nav > li.dropdown.open.active > a:hover {
+ color: #ffffff;
+ background-color: #999999;
+ border-color: #999999;
+}
+
+.nav li.dropdown.open .caret,
+.nav li.dropdown.open.active .caret,
+.nav li.dropdown.open a:hover .caret {
+ border-top-color: #ffffff;
+ border-bottom-color: #ffffff;
+ opacity: 1;
+ filter: alpha(opacity=100);
+}
+
+.tabs-stacked .open > a:hover {
+ border-color: #999999;
+}
+
+.tabbable {
+ *zoom: 1;
+}
+
+.tabbable:before,
+.tabbable:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.tabbable:after {
+ clear: both;
+}
+
+.tab-content {
+ overflow: auto;
+}
+
+.tabs-below > .nav-tabs,
+.tabs-right > .nav-tabs,
+.tabs-left > .nav-tabs {
+ border-bottom: 0;
+}
+
+.tab-content > .tab-pane,
+.pill-content > .pill-pane {
+ display: none;
+}
+
+.tab-content > .active,
+.pill-content > .active {
+ display: block;
+}
+
+.tabs-below > .nav-tabs {
+ border-top: 1px solid #ddd;
+}
+
+.tabs-below > .nav-tabs > li {
+ margin-top: -1px;
+ margin-bottom: 0;
+}
+
+.tabs-below > .nav-tabs > li > a {
+ -webkit-border-radius: 0 0 4px 4px;
+ -moz-border-radius: 0 0 4px 4px;
+ border-radius: 0 0 4px 4px;
+}
+
+.tabs-below > .nav-tabs > li > a:hover {
+ border-top-color: #ddd;
+ border-bottom-color: transparent;
+}
+
+.tabs-below > .nav-tabs > .active > a,
+.tabs-below > .nav-tabs > .active > a:hover {
+ border-color: transparent #ddd #ddd #ddd;
+}
+
+.tabs-left > .nav-tabs > li,
+.tabs-right > .nav-tabs > li {
+ float: none;
+}
+
+.tabs-left > .nav-tabs > li > a,
+.tabs-right > .nav-tabs > li > a {
+ min-width: 74px;
+ margin-right: 0;
+ margin-bottom: 3px;
+}
+
+.tabs-left > .nav-tabs {
+ float: left;
+ margin-right: 19px;
+ border-right: 1px solid #ddd;
+}
+
+.tabs-left > .nav-tabs > li > a {
+ margin-right: -1px;
+ -webkit-border-radius: 4px 0 0 4px;
+ -moz-border-radius: 4px 0 0 4px;
+ border-radius: 4px 0 0 4px;
+}
+
+.tabs-left > .nav-tabs > li > a:hover {
+ border-color: #eeeeee #dddddd #eeeeee #eeeeee;
+}
+
+.tabs-left > .nav-tabs .active > a,
+.tabs-left > .nav-tabs .active > a:hover {
+ border-color: #ddd transparent #ddd #ddd;
+ *border-right-color: #ffffff;
+}
+
+.tabs-right > .nav-tabs {
+ float: right;
+ margin-left: 19px;
+ border-left: 1px solid #ddd;
+}
+
+.tabs-right > .nav-tabs > li > a {
+ margin-left: -1px;
+ -webkit-border-radius: 0 4px 4px 0;
+ -moz-border-radius: 0 4px 4px 0;
+ border-radius: 0 4px 4px 0;
+}
+
+.tabs-right > .nav-tabs > li > a:hover {
+ border-color: #eeeeee #eeeeee #eeeeee #dddddd;
+}
+
+.tabs-right > .nav-tabs .active > a,
+.tabs-right > .nav-tabs .active > a:hover {
+ border-color: #ddd #ddd #ddd transparent;
+ *border-left-color: #ffffff;
+}
+
+.nav > .disabled > a {
+ color: #999999;
+}
+
+.nav > .disabled > a:hover {
+ text-decoration: none;
+ cursor: default;
+ background-color: transparent;
+}
+
+.navbar {
+ *position: relative;
+ *z-index: 2;
+ margin-bottom: 20px;
+ overflow: visible;
+ color: #777777;
+}
+
+.navbar-inner {
+ min-height: 40px;
+ padding-right: 20px;
+ padding-left: 20px;
+ background-color: #fafafa;
+ background-image: -moz-linear-gradient(top, #ffffff, #f2f2f2);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#f2f2f2));
+ background-image: -webkit-linear-gradient(top, #ffffff, #f2f2f2);
+ background-image: -o-linear-gradient(top, #ffffff, #f2f2f2);
+ background-image: linear-gradient(to bottom, #ffffff, #f2f2f2);
+ background-repeat: repeat-x;
+ border: 1px solid #d4d4d4;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff2f2f2', GradientType=0);
+ *zoom: 1;
+ -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
+ -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
+}
+
+.navbar-inner:before,
+.navbar-inner:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.navbar-inner:after {
+ clear: both;
+}
+
+.navbar .container {
+ width: auto;
+}
+
+.nav-collapse.collapse {
+ height: auto;
+}
+
+.navbar .brand {
+ display: block;
+ float: left;
+ padding: 10px 20px 10px;
+ margin-left: -20px;
+ font-size: 20px;
+ font-weight: 200;
+ color: #777777;
+ text-shadow: 0 1px 0 #ffffff;
+}
+
+.navbar .brand:hover {
+ text-decoration: none;
+}
+
+.navbar-text {
+ margin-bottom: 0;
+ line-height: 40px;
+}
+
+.navbar-link {
+ color: #777777;
+}
+
+.navbar-link:hover {
+ color: #333333;
+}
+
+.navbar .divider-vertical {
+ height: 40px;
+ margin: 0 9px;
+ border-right: 1px solid #ffffff;
+ border-left: 1px solid #f2f2f2;
+}
+
+.navbar .btn,
+.navbar .btn-group {
+ margin-top: 5px;
+}
+
+.navbar .btn-group .btn,
+.navbar .input-prepend .btn,
+.navbar .input-append .btn {
+ margin-top: 0;
+}
+
+.navbar-form {
+ margin-bottom: 0;
+ *zoom: 1;
+}
+
+.navbar-form:before,
+.navbar-form:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.navbar-form:after {
+ clear: both;
+}
+
+.navbar-form input,
+.navbar-form select,
+.navbar-form .radio,
+.navbar-form .checkbox {
+ margin-top: 5px;
+}
+
+.navbar-form input,
+.navbar-form select,
+.navbar-form .btn {
+ display: inline-block;
+ margin-bottom: 0;
+}
+
+.navbar-form input[type="image"],
+.navbar-form input[type="checkbox"],
+.navbar-form input[type="radio"] {
+ margin-top: 3px;
+}
+
+.navbar-form .input-append,
+.navbar-form .input-prepend {
+ margin-top: 6px;
+ white-space: nowrap;
+}
+
+.navbar-form .input-append input,
+.navbar-form .input-prepend input {
+ margin-top: 0;
+}
+
+.navbar-search {
+ position: relative;
+ float: left;
+ margin-top: 5px;
+ margin-bottom: 0;
+}
+
+.navbar-search .search-query {
+ padding: 4px 14px;
+ margin-bottom: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 13px;
+ font-weight: normal;
+ line-height: 1;
+ -webkit-border-radius: 15px;
+ -moz-border-radius: 15px;
+ border-radius: 15px;
+}
+
+.navbar-static-top {
+ position: static;
+ width: 100%;
+ margin-bottom: 0;
+}
+
+.navbar-static-top .navbar-inner {
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+}
+
+.navbar-fixed-top,
+.navbar-fixed-bottom {
+ position: fixed;
+ right: 0;
+ left: 0;
+ z-index: 1030;
+ margin-bottom: 0;
+}
+
+.navbar-fixed-top .navbar-inner,
+.navbar-static-top .navbar-inner {
+ border-width: 0 0 1px;
+}
+
+.navbar-fixed-bottom .navbar-inner {
+ border-width: 1px 0 0;
+}
+
+.navbar-fixed-top .navbar-inner,
+.navbar-fixed-bottom .navbar-inner {
+ padding-right: 0;
+ padding-left: 0;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0;
+}
+
+.navbar-static-top .container,
+.navbar-fixed-top .container,
+.navbar-fixed-bottom .container {
+ width: 940px;
+}
+
+.navbar-fixed-top {
+ top: 0;
+}
+
+.navbar-fixed-top .navbar-inner,
+.navbar-static-top .navbar-inner {
+ -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.1);
+ -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.1);
+ box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.1);
+}
+
+.navbar-fixed-bottom {
+ bottom: 0;
+}
+
+.navbar-fixed-bottom .navbar-inner {
+ -webkit-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), 0 -1px 10px rgba(0, 0, 0, 0.1);
+ -moz-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), 0 -1px 10px rgba(0, 0, 0, 0.1);
+ box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), 0 -1px 10px rgba(0, 0, 0, 0.1);
+}
+
+.navbar .nav {
+ position: relative;
+ left: 0;
+ display: block;
+ float: left;
+ margin: 0 10px 0 0;
+}
+
+.navbar .nav.pull-right {
+ float: right;
+ margin-right: 0;
+}
+
+.navbar .nav > li {
+ float: left;
+}
+
+.navbar .nav > li > a {
+ float: none;
+ padding: 10px 15px 10px;
+ color: #777777;
+ text-decoration: none;
+ text-shadow: 0 1px 0 #ffffff;
+}
+
+.navbar .nav .dropdown-toggle .caret {
+ margin-top: 8px;
+}
+
+.navbar .nav > li > a:focus,
+.navbar .nav > li > a:hover {
+ color: #333333;
+ text-decoration: none;
+ background-color: transparent;
+}
+
+.navbar .nav > .active > a,
+.navbar .nav > .active > a:hover,
+.navbar .nav > .active > a:focus {
+ color: #555555;
+ text-decoration: none;
+ background-color: #e5e5e5;
+ -webkit-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
+ -moz-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
+ box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
+}
+
+.navbar .btn-navbar {
+ display: none;
+ float: right;
+ padding: 7px 10px;
+ margin-right: 5px;
+ margin-left: 5px;
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #ededed;
+ *background-color: #e5e5e5;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f2f2f2), to(#e5e5e5));
+ background-image: -webkit-linear-gradient(top, #f2f2f2, #e5e5e5);
+ background-image: -o-linear-gradient(top, #f2f2f2, #e5e5e5);
+ background-image: linear-gradient(to bottom, #f2f2f2, #e5e5e5);
+ background-image: -moz-linear-gradient(top, #f2f2f2, #e5e5e5);
+ background-repeat: repeat-x;
+ border-color: #e5e5e5 #e5e5e5 #bfbfbf;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffe5e5e5', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
+ -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
+}
+
+.navbar .btn-navbar:hover,
+.navbar .btn-navbar:active,
+.navbar .btn-navbar.active,
+.navbar .btn-navbar.disabled,
+.navbar .btn-navbar[disabled] {
+ color: #ffffff;
+ background-color: #e5e5e5;
+ *background-color: #d9d9d9;
+}
+
+.navbar .btn-navbar:active,
+.navbar .btn-navbar.active {
+ background-color: #cccccc \9;
+}
+
+.navbar .btn-navbar .icon-bar {
+ display: block;
+ width: 18px;
+ height: 2px;
+ background-color: #f5f5f5;
+ -webkit-border-radius: 1px;
+ -moz-border-radius: 1px;
+ border-radius: 1px;
+ -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
+ -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
+ box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
+}
+
+.btn-navbar .icon-bar + .icon-bar {
+ margin-top: 3px;
+}
+
+.navbar .nav > li > .dropdown-menu:before {
+ position: absolute;
+ top: -7px;
+ left: 9px;
+ display: inline-block;
+ border-right: 7px solid transparent;
+ border-bottom: 7px solid #ccc;
+ border-left: 7px solid transparent;
+ border-bottom-color: rgba(0, 0, 0, 0.2);
+ content: '';
+}
+
+.navbar .nav > li > .dropdown-menu:after {
+ position: absolute;
+ top: -6px;
+ left: 10px;
+ display: inline-block;
+ border-right: 6px solid transparent;
+ border-bottom: 6px solid #ffffff;
+ border-left: 6px solid transparent;
+ content: '';
+}
+
+.navbar-fixed-bottom .nav > li > .dropdown-menu:before {
+ top: auto;
+ bottom: -7px;
+ border-top: 7px solid #ccc;
+ border-bottom: 0;
+ border-top-color: rgba(0, 0, 0, 0.2);
+}
+
+.navbar-fixed-bottom .nav > li > .dropdown-menu:after {
+ top: auto;
+ bottom: -6px;
+ border-top: 6px solid #ffffff;
+ border-bottom: 0;
+}
+
+.navbar .nav li.dropdown.open > .dropdown-toggle,
+.navbar .nav li.dropdown.active > .dropdown-toggle,
+.navbar .nav li.dropdown.open.active > .dropdown-toggle {
+ color: #555555;
+ background-color: #e5e5e5;
+}
+
+.navbar .nav li.dropdown > .dropdown-toggle .caret {
+ border-top-color: #777777;
+ border-bottom-color: #777777;
+}
+
+.navbar .nav li.dropdown.open > .dropdown-toggle .caret,
+.navbar .nav li.dropdown.active > .dropdown-toggle .caret,
+.navbar .nav li.dropdown.open.active > .dropdown-toggle .caret {
+ border-top-color: #555555;
+ border-bottom-color: #555555;
+}
+
+.navbar .pull-right > li > .dropdown-menu,
+.navbar .nav > li > .dropdown-menu.pull-right {
+ right: 0;
+ left: auto;
+}
+
+.navbar .pull-right > li > .dropdown-menu:before,
+.navbar .nav > li > .dropdown-menu.pull-right:before {
+ right: 12px;
+ left: auto;
+}
+
+.navbar .pull-right > li > .dropdown-menu:after,
+.navbar .nav > li > .dropdown-menu.pull-right:after {
+ right: 13px;
+ left: auto;
+}
+
+.navbar .pull-right > li > .dropdown-menu .dropdown-menu,
+.navbar .nav > li > .dropdown-menu.pull-right .dropdown-menu {
+ right: 100%;
+ left: auto;
+ margin-right: -1px;
+ margin-left: 0;
+ -webkit-border-radius: 6px 0 6px 6px;
+ -moz-border-radius: 6px 0 6px 6px;
+ border-radius: 6px 0 6px 6px;
+}
+
+.navbar-inverse {
+ color: #999999;
+}
+
+.navbar-inverse .navbar-inner {
+ background-color: #1b1b1b;
+ background-image: -moz-linear-gradient(top, #222222, #111111);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#222222), to(#111111));
+ background-image: -webkit-linear-gradient(top, #222222, #111111);
+ background-image: -o-linear-gradient(top, #222222, #111111);
+ background-image: linear-gradient(to bottom, #222222, #111111);
+ background-repeat: repeat-x;
+ border-color: #252525;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff222222', endColorstr='#ff111111', GradientType=0);
+}
+
+.navbar-inverse .brand,
+.navbar-inverse .nav > li > a {
+ color: #999999;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+}
+
+.navbar-inverse .brand:hover,
+.navbar-inverse .nav > li > a:hover {
+ color: #ffffff;
+}
+
+.navbar-inverse .nav > li > a:focus,
+.navbar-inverse .nav > li > a:hover {
+ color: #ffffff;
+ background-color: transparent;
+}
+
+.navbar-inverse .nav .active > a,
+.navbar-inverse .nav .active > a:hover,
+.navbar-inverse .nav .active > a:focus {
+ color: #ffffff;
+ background-color: #111111;
+}
+
+.navbar-inverse .navbar-link {
+ color: #999999;
+}
+
+.navbar-inverse .navbar-link:hover {
+ color: #ffffff;
+}
+
+.navbar-inverse .divider-vertical {
+ border-right-color: #222222;
+ border-left-color: #111111;
+}
+
+.navbar-inverse .nav li.dropdown.open > .dropdown-toggle,
+.navbar-inverse .nav li.dropdown.active > .dropdown-toggle,
+.navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle {
+ color: #ffffff;
+ background-color: #111111;
+}
+
+.navbar-inverse .nav li.dropdown > .dropdown-toggle .caret {
+ border-top-color: #999999;
+ border-bottom-color: #999999;
+}
+
+.navbar-inverse .nav li.dropdown.open > .dropdown-toggle .caret,
+.navbar-inverse .nav li.dropdown.active > .dropdown-toggle .caret,
+.navbar-inverse .nav li.dropdown.open.active > .dropdown-toggle .caret {
+ border-top-color: #ffffff;
+ border-bottom-color: #ffffff;
+}
+
+.navbar-inverse .navbar-search .search-query {
+ color: #ffffff;
+ background-color: #515151;
+ border-color: #111111;
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);
+ -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);
+ -webkit-transition: none;
+ -moz-transition: none;
+ -o-transition: none;
+ transition: none;
+}
+
+.navbar-inverse .navbar-search .search-query:-moz-placeholder {
+ color: #cccccc;
+}
+
+.navbar-inverse .navbar-search .search-query:-ms-input-placeholder {
+ color: #cccccc;
+}
+
+.navbar-inverse .navbar-search .search-query::-webkit-input-placeholder {
+ color: #cccccc;
+}
+
+.navbar-inverse .navbar-search .search-query:focus,
+.navbar-inverse .navbar-search .search-query.focused {
+ padding: 5px 15px;
+ color: #333333;
+ text-shadow: 0 1px 0 #ffffff;
+ background-color: #ffffff;
+ border: 0;
+ outline: 0;
+ -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
+ -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
+}
+
+.navbar-inverse .btn-navbar {
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #0e0e0e;
+ *background-color: #040404;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#151515), to(#040404));
+ background-image: -webkit-linear-gradient(top, #151515, #040404);
+ background-image: -o-linear-gradient(top, #151515, #040404);
+ background-image: linear-gradient(to bottom, #151515, #040404);
+ background-image: -moz-linear-gradient(top, #151515, #040404);
+ background-repeat: repeat-x;
+ border-color: #040404 #040404 #000000;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff151515', endColorstr='#ff040404', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+}
+
+.navbar-inverse .btn-navbar:hover,
+.navbar-inverse .btn-navbar:active,
+.navbar-inverse .btn-navbar.active,
+.navbar-inverse .btn-navbar.disabled,
+.navbar-inverse .btn-navbar[disabled] {
+ color: #ffffff;
+ background-color: #040404;
+ *background-color: #000000;
+}
+
+.navbar-inverse .btn-navbar:active,
+.navbar-inverse .btn-navbar.active {
+ background-color: #000000 \9;
+}
+
+.breadcrumb {
+ padding: 8px 15px;
+ margin: 0 0 20px;
+ list-style: none;
+ background-color: #f5f5f5;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+
+.breadcrumb li {
+ display: inline-block;
+ *display: inline;
+ text-shadow: 0 1px 0 #ffffff;
+ *zoom: 1;
+}
+
+.breadcrumb .divider {
+ padding: 0 5px;
+ color: #ccc;
+}
+
+.breadcrumb .active {
+ color: #999999;
+}
+
+.pagination {
+ height: 40px;
+ margin: 20px 0;
+}
+
+.pagination ul {
+ display: inline-block;
+ *display: inline;
+ margin-bottom: 0;
+ margin-left: 0;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+ *zoom: 1;
+ -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+}
+
+.pagination ul > li {
+ display: inline;
+}
+
+.pagination ul > li > a,
+.pagination ul > li > span {
+ float: left;
+ padding: 0 14px;
+ line-height: 38px;
+ text-decoration: none;
+ background-color: #ffffff;
+ border: 1px solid #dddddd;
+ border-left-width: 0;
+}
+
+.pagination ul > li > a:hover,
+.pagination ul > .active > a,
+.pagination ul > .active > span {
+ background-color: #f5f5f5;
+}
+
+.pagination ul > .active > a,
+.pagination ul > .active > span {
+ color: #999999;
+ cursor: default;
+}
+
+.pagination ul > .disabled > span,
+.pagination ul > .disabled > a,
+.pagination ul > .disabled > a:hover {
+ color: #999999;
+ cursor: default;
+ background-color: transparent;
+}
+
+.pagination ul > li:first-child > a,
+.pagination ul > li:first-child > span {
+ border-left-width: 1px;
+ -webkit-border-radius: 3px 0 0 3px;
+ -moz-border-radius: 3px 0 0 3px;
+ border-radius: 3px 0 0 3px;
+}
+
+.pagination ul > li:last-child > a,
+.pagination ul > li:last-child > span {
+ -webkit-border-radius: 0 3px 3px 0;
+ -moz-border-radius: 0 3px 3px 0;
+ border-radius: 0 3px 3px 0;
+}
+
+.pagination-centered {
+ text-align: center;
+}
+
+.pagination-right {
+ text-align: right;
+}
+
+.pager {
+ margin: 20px 0;
+ text-align: center;
+ list-style: none;
+ *zoom: 1;
+}
+
+.pager:before,
+.pager:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.pager:after {
+ clear: both;
+}
+
+.pager li {
+ display: inline;
+}
+
+.pager a,
+.pager span {
+ display: inline-block;
+ padding: 5px 14px;
+ background-color: #fff;
+ border: 1px solid #ddd;
+ -webkit-border-radius: 15px;
+ -moz-border-radius: 15px;
+ border-radius: 15px;
+}
+
+.pager a:hover {
+ text-decoration: none;
+ background-color: #f5f5f5;
+}
+
+.pager .next a,
+.pager .next span {
+ float: right;
+}
+
+.pager .previous a {
+ float: left;
+}
+
+.pager .disabled a,
+.pager .disabled a:hover,
+.pager .disabled span {
+ color: #999999;
+ cursor: default;
+ background-color: #fff;
+}
+
+.modal-open .modal .dropdown-menu {
+ z-index: 2050;
+}
+
+.modal-open .modal .dropdown.open {
+ *z-index: 2050;
+}
+
+.modal-open .modal .popover {
+ z-index: 2060;
+}
+
+.modal-open .modal .tooltip {
+ z-index: 2080;
+}
+
+.modal-backdrop {
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ z-index: 1040;
+ background-color: #000000;
+}
+
+.modal-backdrop.fade {
+ opacity: 0;
+}
+
+.modal-backdrop,
+.modal-backdrop.fade.in {
+ opacity: 0.8;
+ filter: alpha(opacity=80);
+}
+
+.modal {
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ z-index: 1050;
+ width: 560px;
+ margin: -250px 0 0 -280px;
+ overflow: auto;
+ background-color: #ffffff;
+ border: 1px solid #999;
+ border: 1px solid rgba(0, 0, 0, 0.3);
+ *border: 1px solid #999;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+ -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+ -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+ box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+ -webkit-background-clip: padding-box;
+ -moz-background-clip: padding-box;
+ background-clip: padding-box;
+}
+
+.modal.fade {
+ top: -25%;
+ -webkit-transition: opacity 0.3s linear, top 0.3s ease-out;
+ -moz-transition: opacity 0.3s linear, top 0.3s ease-out;
+ -o-transition: opacity 0.3s linear, top 0.3s ease-out;
+ transition: opacity 0.3s linear, top 0.3s ease-out;
+}
+
+.modal.fade.in {
+ top: 50%;
+}
+
+.modal-header {
+ padding: 9px 15px;
+ border-bottom: 1px solid #eee;
+}
+
+.modal-header .close {
+ margin-top: 2px;
+}
+
+.modal-header h3 {
+ margin: 0;
+ line-height: 30px;
+}
+
+.modal-body {
+ max-height: 400px;
+ padding: 15px;
+ overflow-y: auto;
+}
+
+.modal-form {
+ margin-bottom: 0;
+}
+
+.modal-footer {
+ padding: 14px 15px 15px;
+ margin-bottom: 0;
+ text-align: right;
+ background-color: #f5f5f5;
+ border-top: 1px solid #ddd;
+ -webkit-border-radius: 0 0 6px 6px;
+ -moz-border-radius: 0 0 6px 6px;
+ border-radius: 0 0 6px 6px;
+ *zoom: 1;
+ -webkit-box-shadow: inset 0 1px 0 #ffffff;
+ -moz-box-shadow: inset 0 1px 0 #ffffff;
+ box-shadow: inset 0 1px 0 #ffffff;
+}
+
+.modal-footer:before,
+.modal-footer:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.modal-footer:after {
+ clear: both;
+}
+
+.modal-footer .btn + .btn {
+ margin-bottom: 0;
+ margin-left: 5px;
+}
+
+.modal-footer .btn-group .btn + .btn {
+ margin-left: -1px;
+}
+
+.tooltip {
+ position: absolute;
+ z-index: 1030;
+ display: block;
+ padding: 5px;
+ font-size: 11px;
+ opacity: 0;
+ filter: alpha(opacity=0);
+ visibility: visible;
+}
+
+.tooltip.in {
+ opacity: 0.8;
+ filter: alpha(opacity=80);
+}
+
+.tooltip.top {
+ margin-top: -3px;
+}
+
+.tooltip.right {
+ margin-left: 3px;
+}
+
+.tooltip.bottom {
+ margin-top: 3px;
+}
+
+.tooltip.left {
+ margin-left: -3px;
+}
+
+.tooltip-inner {
+ max-width: 200px;
+ padding: 3px 8px;
+ color: #ffffff;
+ text-align: center;
+ text-decoration: none;
+ background-color: #000000;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+
+.tooltip-arrow {
+ position: absolute;
+ width: 0;
+ height: 0;
+ border-color: transparent;
+ border-style: solid;
+}
+
+.tooltip.top .tooltip-arrow {
+ bottom: 0;
+ left: 50%;
+ margin-left: -5px;
+ border-top-color: #000000;
+ border-width: 5px 5px 0;
+}
+
+.tooltip.right .tooltip-arrow {
+ top: 50%;
+ left: 0;
+ margin-top: -5px;
+ border-right-color: #000000;
+ border-width: 5px 5px 5px 0;
+}
+
+.tooltip.left .tooltip-arrow {
+ top: 50%;
+ right: 0;
+ margin-top: -5px;
+ border-left-color: #000000;
+ border-width: 5px 0 5px 5px;
+}
+
+.tooltip.bottom .tooltip-arrow {
+ top: 0;
+ left: 50%;
+ margin-left: -5px;
+ border-bottom-color: #000000;
+ border-width: 0 5px 5px;
+}
+
+.popover {
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 1010;
+ display: none;
+ width: 236px;
+ padding: 1px;
+ background-color: #ffffff;
+ border: 1px solid #ccc;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+ -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ -webkit-background-clip: padding-box;
+ -moz-background-clip: padding;
+ background-clip: padding-box;
+}
+
+.popover.top {
+ margin-bottom: 10px;
+}
+
+.popover.right {
+ margin-left: 10px;
+}
+
+.popover.bottom {
+ margin-top: 10px;
+}
+
+.popover.left {
+ margin-right: 10px;
+}
+
+.popover-title {
+ padding: 8px 14px;
+ margin: 0;
+ font-size: 14px;
+ font-weight: normal;
+ line-height: 18px;
+ background-color: #f7f7f7;
+ border-bottom: 1px solid #ebebeb;
+ -webkit-border-radius: 5px 5px 0 0;
+ -moz-border-radius: 5px 5px 0 0;
+ border-radius: 5px 5px 0 0;
+}
+
+.popover-content {
+ padding: 9px 14px;
+}
+
+.popover-content p,
+.popover-content ul,
+.popover-content ol {
+ margin-bottom: 0;
+}
+
+.popover .arrow,
+.popover .arrow:after {
+ position: absolute;
+ display: inline-block;
+ width: 0;
+ height: 0;
+ border-color: transparent;
+ border-style: solid;
+}
+
+.popover .arrow:after {
+ z-index: -1;
+ content: "";
+}
+
+.popover.top .arrow {
+ bottom: -10px;
+ left: 50%;
+ margin-left: -10px;
+ border-top-color: #ffffff;
+ border-width: 10px 10px 0;
+}
+
+.popover.top .arrow:after {
+ bottom: -1px;
+ left: -11px;
+ border-top-color: rgba(0, 0, 0, 0.25);
+ border-width: 11px 11px 0;
+}
+
+.popover.right .arrow {
+ top: 50%;
+ left: -10px;
+ margin-top: -10px;
+ border-right-color: #ffffff;
+ border-width: 10px 10px 10px 0;
+}
+
+.popover.right .arrow:after {
+ bottom: -11px;
+ left: -1px;
+ border-right-color: rgba(0, 0, 0, 0.25);
+ border-width: 11px 11px 11px 0;
+}
+
+.popover.bottom .arrow {
+ top: -10px;
+ left: 50%;
+ margin-left: -10px;
+ border-bottom-color: #ffffff;
+ border-width: 0 10px 10px;
+}
+
+.popover.bottom .arrow:after {
+ top: -1px;
+ left: -11px;
+ border-bottom-color: rgba(0, 0, 0, 0.25);
+ border-width: 0 11px 11px;
+}
+
+.popover.left .arrow {
+ top: 50%;
+ right: -10px;
+ margin-top: -10px;
+ border-left-color: #ffffff;
+ border-width: 10px 0 10px 10px;
+}
+
+.popover.left .arrow:after {
+ right: -1px;
+ bottom: -11px;
+ border-left-color: rgba(0, 0, 0, 0.25);
+ border-width: 11px 0 11px 11px;
+}
+
+.thumbnails {
+ margin-left: -20px;
+ list-style: none;
+ *zoom: 1;
+}
+
+.thumbnails:before,
+.thumbnails:after {
+ display: table;
+ line-height: 0;
+ content: "";
+}
+
+.thumbnails:after {
+ clear: both;
+}
+
+.row-fluid .thumbnails {
+ margin-left: 0;
+}
+
+.thumbnails > li {
+ float: left;
+ margin-bottom: 20px;
+ margin-left: 20px;
+}
+
+.thumbnail {
+ display: block;
+ padding: 4px;
+ line-height: 20px;
+ border: 1px solid #ddd;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055);
+ -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055);
+ -webkit-transition: all 0.2s ease-in-out;
+ -moz-transition: all 0.2s ease-in-out;
+ -o-transition: all 0.2s ease-in-out;
+ transition: all 0.2s ease-in-out;
+}
+
+a.thumbnail:hover {
+ border-color: #0088cc;
+ -webkit-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
+ -moz-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
+ box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
+}
+
+.thumbnail > img {
+ display: block;
+ max-width: 100%;
+ margin-right: auto;
+ margin-left: auto;
+}
+
+.thumbnail .caption {
+ padding: 9px;
+ color: #555555;
+}
+
+.label,
+.badge {
+ font-size: 11.844px;
+ font-weight: bold;
+ line-height: 14px;
+ color: #ffffff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ white-space: nowrap;
+ vertical-align: baseline;
+ background-color: #999999;
+}
+
+.label {
+ padding: 1px 4px 2px;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+}
+
+.badge {
+ padding: 1px 9px 2px;
+ -webkit-border-radius: 9px;
+ -moz-border-radius: 9px;
+ border-radius: 9px;
+}
+
+a.label:hover,
+a.badge:hover {
+ color: #ffffff;
+ text-decoration: none;
+ cursor: pointer;
+}
+
+.label-important,
+.badge-important {
+ background-color: #b94a48;
+}
+
+.label-important[href],
+.badge-important[href] {
+ background-color: #953b39;
+}
+
+.label-warning,
+.badge-warning {
+ background-color: #f89406;
+}
+
+.label-warning[href],
+.badge-warning[href] {
+ background-color: #c67605;
+}
+
+.label-success,
+.badge-success {
+ background-color: #468847;
+}
+
+.label-success[href],
+.badge-success[href] {
+ background-color: #356635;
+}
+
+.label-info,
+.badge-info {
+ background-color: #3a87ad;
+}
+
+.label-info[href],
+.badge-info[href] {
+ background-color: #2d6987;
+}
+
+.label-inverse,
+.badge-inverse {
+ background-color: #333333;
+}
+
+.label-inverse[href],
+.badge-inverse[href] {
+ background-color: #1a1a1a;
+}
+
+.btn .label,
+.btn .badge {
+ position: relative;
+ top: -1px;
+}
+
+.btn-mini .label,
+.btn-mini .badge {
+ top: 0;
+}
+
+@-webkit-keyframes progress-bar-stripes {
+ from {
+ background-position: 40px 0;
+ }
+ to {
+ background-position: 0 0;
+ }
+}
+
+@-moz-keyframes progress-bar-stripes {
+ from {
+ background-position: 40px 0;
+ }
+ to {
+ background-position: 0 0;
+ }
+}
+
+@-ms-keyframes progress-bar-stripes {
+ from {
+ background-position: 40px 0;
+ }
+ to {
+ background-position: 0 0;
+ }
+}
+
+@-o-keyframes progress-bar-stripes {
+ from {
+ background-position: 0 0;
+ }
+ to {
+ background-position: 40px 0;
+ }
+}
+
+@keyframes progress-bar-stripes {
+ from {
+ background-position: 40px 0;
+ }
+ to {
+ background-position: 0 0;
+ }
+}
+
+.progress {
+ height: 20px;
+ margin-bottom: 20px;
+ overflow: hidden;
+ background-color: #f7f7f7;
+ background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));
+ background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9);
+ background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9);
+ background-image: linear-gradient(to bottom, #f5f5f5, #f9f9f9);
+ background-repeat: repeat-x;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0);
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
+ -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
+}
+
+.progress .bar {
+ float: left;
+ width: 0;
+ height: 100%;
+ font-size: 12px;
+ color: #ffffff;
+ text-align: center;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #0e90d2;
+ background-image: -moz-linear-gradient(top, #149bdf, #0480be);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be));
+ background-image: -webkit-linear-gradient(top, #149bdf, #0480be);
+ background-image: -o-linear-gradient(top, #149bdf, #0480be);
+ background-image: linear-gradient(to bottom, #149bdf, #0480be);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff149bdf', endColorstr='#ff0480be', GradientType=0);
+ -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ -webkit-transition: width 0.6s ease;
+ -moz-transition: width 0.6s ease;
+ -o-transition: width 0.6s ease;
+ transition: width 0.6s ease;
+}
+
+.progress .bar + .bar {
+ -webkit-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ -moz-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+}
+
+.progress-striped .bar {
+ background-color: #149bdf;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ -webkit-background-size: 40px 40px;
+ -moz-background-size: 40px 40px;
+ -o-background-size: 40px 40px;
+ background-size: 40px 40px;
+}
+
+.progress.active .bar {
+ -webkit-animation: progress-bar-stripes 2s linear infinite;
+ -moz-animation: progress-bar-stripes 2s linear infinite;
+ -ms-animation: progress-bar-stripes 2s linear infinite;
+ -o-animation: progress-bar-stripes 2s linear infinite;
+ animation: progress-bar-stripes 2s linear infinite;
+}
+
+.progress-danger .bar,
+.progress .bar-danger {
+ background-color: #dd514c;
+ background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35));
+ background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35);
+ background-image: -o-linear-gradient(top, #ee5f5b, #c43c35);
+ background-image: linear-gradient(to bottom, #ee5f5b, #c43c35);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffc43c35', GradientType=0);
+}
+
+.progress-danger.progress-striped .bar,
+.progress-striped .bar-danger {
+ background-color: #ee5f5b;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+}
+
+.progress-success .bar,
+.progress .bar-success {
+ background-color: #5eb95e;
+ background-image: -moz-linear-gradient(top, #62c462, #57a957);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957));
+ background-image: -webkit-linear-gradient(top, #62c462, #57a957);
+ background-image: -o-linear-gradient(top, #62c462, #57a957);
+ background-image: linear-gradient(to bottom, #62c462, #57a957);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff57a957', GradientType=0);
+}
+
+.progress-success.progress-striped .bar,
+.progress-striped .bar-success {
+ background-color: #62c462;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+}
+
+.progress-info .bar,
+.progress .bar-info {
+ background-color: #4bb1cf;
+ background-image: -moz-linear-gradient(top, #5bc0de, #339bb9);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9));
+ background-image: -webkit-linear-gradient(top, #5bc0de, #339bb9);
+ background-image: -o-linear-gradient(top, #5bc0de, #339bb9);
+ background-image: linear-gradient(to bottom, #5bc0de, #339bb9);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff339bb9', GradientType=0);
+}
+
+.progress-info.progress-striped .bar,
+.progress-striped .bar-info {
+ background-color: #5bc0de;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+}
+
+.progress-warning .bar,
+.progress .bar-warning {
+ background-color: #faa732;
+ background-image: -moz-linear-gradient(top, #fbb450, #f89406);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
+ background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
+ background-image: -o-linear-gradient(top, #fbb450, #f89406);
+ background-image: linear-gradient(to bottom, #fbb450, #f89406);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);
+}
+
+.progress-warning.progress-striped .bar,
+.progress-striped .bar-warning {
+ background-color: #fbb450;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+}
+
+.accordion {
+ margin-bottom: 20px;
+}
+
+.accordion-group {
+ margin-bottom: 2px;
+ border: 1px solid #e5e5e5;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+}
+
+.accordion-heading {
+ border-bottom: 0;
+}
+
+.accordion-heading .accordion-toggle {
+ display: block;
+ padding: 8px 15px;
+}
+
+.accordion-toggle {
+ cursor: pointer;
+}
+
+.accordion-inner {
+ padding: 9px 15px;
+ border-top: 1px solid #e5e5e5;
+}
+
+.carousel {
+ position: relative;
+ margin-bottom: 20px;
+ line-height: 1;
+}
+
+.carousel-inner {
+ position: relative;
+ width: 100%;
+ overflow: hidden;
+}
+
+.carousel .item {
+ position: relative;
+ display: none;
+ -webkit-transition: 0.6s ease-in-out left;
+ -moz-transition: 0.6s ease-in-out left;
+ -o-transition: 0.6s ease-in-out left;
+ transition: 0.6s ease-in-out left;
+}
+
+.carousel .item > img {
+ display: block;
+ line-height: 1;
+}
+
+.carousel .active,
+.carousel .next,
+.carousel .prev {
+ display: block;
+}
+
+.carousel .active {
+ left: 0;
+}
+
+.carousel .next,
+.carousel .prev {
+ position: absolute;
+ top: 0;
+ width: 100%;
+}
+
+.carousel .next {
+ left: 100%;
+}
+
+.carousel .prev {
+ left: -100%;
+}
+
+.carousel .next.left,
+.carousel .prev.right {
+ left: 0;
+}
+
+.carousel .active.left {
+ left: -100%;
+}
+
+.carousel .active.right {
+ left: 100%;
+}
+
+.carousel-control {
+ position: absolute;
+ top: 40%;
+ left: 15px;
+ width: 40px;
+ height: 40px;
+ margin-top: -20px;
+ font-size: 60px;
+ font-weight: 100;
+ line-height: 30px;
+ color: #ffffff;
+ text-align: center;
+ background: #222222;
+ border: 3px solid #ffffff;
+ -webkit-border-radius: 23px;
+ -moz-border-radius: 23px;
+ border-radius: 23px;
+ opacity: 0.5;
+ filter: alpha(opacity=50);
+}
+
+.carousel-control.right {
+ right: 15px;
+ left: auto;
+}
+
+.carousel-control:hover {
+ color: #ffffff;
+ text-decoration: none;
+ opacity: 0.9;
+ filter: alpha(opacity=90);
+}
+
+.carousel-caption {
+ position: absolute;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ padding: 15px;
+ background: #333333;
+ background: rgba(0, 0, 0, 0.75);
+}
+
+.carousel-caption h4,
+.carousel-caption p {
+ line-height: 20px;
+ color: #ffffff;
+}
+
+.carousel-caption h4 {
+ margin: 0 0 5px;
+}
+
+.carousel-caption p {
+ margin-bottom: 0;
+}
+
+.hero-unit {
+ padding: 60px;
+ margin-bottom: 30px;
+ background-color: #eeeeee;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+}
+
+.hero-unit h1 {
+ margin-bottom: 0;
+ font-size: 60px;
+ line-height: 1;
+ letter-spacing: -1px;
+ color: inherit;
+}
+
+.hero-unit p {
+ font-size: 18px;
+ font-weight: 200;
+ line-height: 30px;
+ color: inherit;
+}
+
+.pull-right {
+ float: right;
+}
+
+.pull-left {
+ float: left;
+}
+
+.hide {
+ display: none;
+}
+
+.show {
+ display: block;
+}
+
+.invisible {
+ visibility: hidden;
+}
+
+.affix {
+ position: fixed;
+}
diff --git a/content/examples/moviefun/src/main/webapp/assets/css/bootstrap.min.css b/content/examples/moviefun/src/main/webapp/assets/css/bootstrap.min.css
new file mode 100755
index 0000000..f2af09e
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/assets/css/bootstrap.min.css
@@ -0,0 +1,5215 @@
+/*!
+ * Bootstrap v2.1.1
+ *
+ * Copyright 2012 Twitter, Inc
+ * Licensed under the Apache License v2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Designed and built with all the love in the world @twitter by @mdo and @fat.
+ */
+article, aside, details, figcaption, figure, footer, header, hgroup, nav, section {
+ display: block
+}
+
+audio, canvas, video {
+ display: inline-block;
+ *display: inline;
+ *zoom: 1
+}
+
+audio:not([controls]) {
+ display: none
+}
+
+html {
+ font-size: 100%;
+ -webkit-text-size-adjust: 100%;
+ -ms-text-size-adjust: 100%
+}
+
+a:focus {
+ outline: thin dotted #333;
+ outline: 5px auto -webkit-focus-ring-color;
+ outline-offset: -2px
+}
+
+a:hover, a:active {
+ outline: 0
+}
+
+sub, sup {
+ position: relative;
+ font-size: 75%;
+ line-height: 0;
+ vertical-align: baseline
+}
+
+sup {
+ top: -0.5em
+}
+
+sub {
+ bottom: -0.25em
+}
+
+img {
+ width: auto\9;
+ height: auto;
+ max-width: 100%;
+ vertical-align: middle;
+ border: 0;
+ -ms-interpolation-mode: bicubic
+}
+
+#map_canvas img {
+ max-width: none
+}
+
+button, input, select, textarea {
+ margin: 0;
+ font-size: 100%;
+ vertical-align: middle
+}
+
+button, input {
+ *overflow: visible;
+ line-height: normal
+}
+
+button::-moz-focus-inner, input::-moz-focus-inner {
+ padding: 0;
+ border: 0
+}
+
+button, input[type="button"], input[type="reset"], input[type="submit"] {
+ cursor: pointer;
+ -webkit-appearance: button
+}
+
+input[type="search"] {
+ -webkit-box-sizing: content-box;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+ -webkit-appearance: textfield
+}
+
+input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button {
+ -webkit-appearance: none
+}
+
+textarea {
+ overflow: auto;
+ vertical-align: top
+}
+
+.clearfix {
+ *zoom: 1
+}
+
+.clearfix:before, .clearfix:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.clearfix:after {
+ clear: both
+}
+
+.hide-text {
+ font: 0/0 a;
+ color: transparent;
+ text-shadow: none;
+ background-color: transparent;
+ border: 0
+}
+
+.input-block-level {
+ display: block;
+ width: 100%;
+ min-height: 30px;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box
+}
+
+body {
+ margin: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 14px;
+ line-height: 20px;
+ color: #333;
+ background-color: #fff
+}
+
+a {
+ color: #08c;
+ text-decoration: none
+}
+
+a:hover {
+ color: #005580;
+ text-decoration: underline
+}
+
+.img-rounded {
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px
+}
+
+.img-polaroid {
+ padding: 4px;
+ background-color: #fff;
+ border: 1px solid #ccc;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
+ -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1)
+}
+
+.img-circle {
+ -webkit-border-radius: 500px;
+ -moz-border-radius: 500px;
+ border-radius: 500px
+}
+
+.row {
+ margin-left: -20px;
+ *zoom: 1
+}
+
+.row:before, .row:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.row:after {
+ clear: both
+}
+
+[class*="span"] {
+ float: left;
+ min-height: 1px;
+ margin-left: 20px
+}
+
+.container, .navbar-static-top .container, .navbar-fixed-top .container, .navbar-fixed-bottom .container {
+ width: 940px
+}
+
+.span12 {
+ width: 940px
+}
+
+.span11 {
+ width: 860px
+}
+
+.span10 {
+ width: 780px
+}
+
+.span9 {
+ width: 700px
+}
+
+.span8 {
+ width: 620px
+}
+
+.span7 {
+ width: 540px
+}
+
+.span6 {
+ width: 460px
+}
+
+.span5 {
+ width: 380px
+}
+
+.span4 {
+ width: 300px
+}
+
+.span3 {
+ width: 220px
+}
+
+.span2 {
+ width: 140px
+}
+
+.span1 {
+ width: 60px
+}
+
+.offset12 {
+ margin-left: 980px
+}
+
+.offset11 {
+ margin-left: 900px
+}
+
+.offset10 {
+ margin-left: 820px
+}
+
+.offset9 {
+ margin-left: 740px
+}
+
+.offset8 {
+ margin-left: 660px
+}
+
+.offset7 {
+ margin-left: 580px
+}
+
+.offset6 {
+ margin-left: 500px
+}
+
+.offset5 {
+ margin-left: 420px
+}
+
+.offset4 {
+ margin-left: 340px
+}
+
+.offset3 {
+ margin-left: 260px
+}
+
+.offset2 {
+ margin-left: 180px
+}
+
+.offset1 {
+ margin-left: 100px
+}
+
+.row-fluid {
+ width: 100%;
+ *zoom: 1
+}
+
+.row-fluid:before, .row-fluid:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.row-fluid:after {
+ clear: both
+}
+
+.row-fluid [class*="span"] {
+ display: block;
+ float: left;
+ width: 100%;
+ min-height: 30px;
+ margin-left: 2.127659574468085%;
+ *margin-left: 2.074468085106383%;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box
+}
+
+.row-fluid [class*="span"]:first-child {
+ margin-left: 0
+}
+
+.row-fluid .span12 {
+ width: 100%;
+ *width: 99.94680851063829%
+}
+
+.row-fluid .span11 {
+ width: 91.48936170212765%;
+ *width: 91.43617021276594%
+}
+
+.row-fluid .span10 {
+ width: 82.97872340425532%;
+ *width: 82.92553191489361%
+}
+
+.row-fluid .span9 {
+ width: 74.46808510638297%;
+ *width: 74.41489361702126%
+}
+
+.row-fluid .span8 {
+ width: 65.95744680851064%;
+ *width: 65.90425531914893%
+}
+
+.row-fluid .span7 {
+ width: 57.44680851063829%;
+ *width: 57.39361702127659%
+}
+
+.row-fluid .span6 {
+ width: 48.93617021276595%;
+ *width: 48.88297872340425%
+}
+
+.row-fluid .span5 {
+ width: 40.42553191489362%;
+ *width: 40.37234042553192%
+}
+
+.row-fluid .span4 {
+ width: 31.914893617021278%;
+ *width: 31.861702127659576%
+}
+
+.row-fluid .span3 {
+ width: 23.404255319148934%;
+ *width: 23.351063829787233%
+}
+
+.row-fluid .span2 {
+ width: 14.893617021276595%;
+ *width: 14.840425531914894%
+}
+
+.row-fluid .span1 {
+ width: 6.382978723404255%;
+ *width: 6.329787234042553%
+}
+
+.row-fluid .offset12 {
+ margin-left: 104.25531914893617%;
+ *margin-left: 104.14893617021275%
+}
+
+.row-fluid .offset12:first-child {
+ margin-left: 102.12765957446808%;
+ *margin-left: 102.02127659574467%
+}
+
+.row-fluid .offset11 {
+ margin-left: 95.74468085106382%;
+ *margin-left: 95.6382978723404%
+}
+
+.row-fluid .offset11:first-child {
+ margin-left: 93.61702127659574%;
+ *margin-left: 93.51063829787232%
+}
+
+.row-fluid .offset10 {
+ margin-left: 87.23404255319149%;
+ *margin-left: 87.12765957446807%
+}
+
+.row-fluid .offset10:first-child {
+ margin-left: 85.1063829787234%;
+ *margin-left: 84.99999999999999%
+}
+
+.row-fluid .offset9 {
+ margin-left: 78.72340425531914%;
+ *margin-left: 78.61702127659572%
+}
+
+.row-fluid .offset9:first-child {
+ margin-left: 76.59574468085106%;
+ *margin-left: 76.48936170212764%
+}
+
+.row-fluid .offset8 {
+ margin-left: 70.2127659574468%;
+ *margin-left: 70.10638297872339%
+}
+
+.row-fluid .offset8:first-child {
+ margin-left: 68.08510638297872%;
+ *margin-left: 67.9787234042553%
+}
+
+.row-fluid .offset7 {
+ margin-left: 61.70212765957446%;
+ *margin-left: 61.59574468085106%
+}
+
+.row-fluid .offset7:first-child {
+ margin-left: 59.574468085106375%;
+ *margin-left: 59.46808510638297%
+}
+
+.row-fluid .offset6 {
+ margin-left: 53.191489361702125%;
+ *margin-left: 53.085106382978715%
+}
+
+.row-fluid .offset6:first-child {
+ margin-left: 51.063829787234035%;
+ *margin-left: 50.95744680851063%
+}
+
+.row-fluid .offset5 {
+ margin-left: 44.68085106382979%;
+ *margin-left: 44.57446808510638%
+}
+
+.row-fluid .offset5:first-child {
+ margin-left: 42.5531914893617%;
+ *margin-left: 42.4468085106383%
+}
+
+.row-fluid .offset4 {
+ margin-left: 36.170212765957444%;
+ *margin-left: 36.06382978723405%
+}
+
+.row-fluid .offset4:first-child {
+ margin-left: 34.04255319148936%;
+ *margin-left: 33.93617021276596%
+}
+
+.row-fluid .offset3 {
+ margin-left: 27.659574468085104%;
+ *margin-left: 27.5531914893617%
+}
+
+.row-fluid .offset3:first-child {
+ margin-left: 25.53191489361702%;
+ *margin-left: 25.425531914893618%
+}
+
+.row-fluid .offset2 {
+ margin-left: 19.148936170212764%;
+ *margin-left: 19.04255319148936%
+}
+
+.row-fluid .offset2:first-child {
+ margin-left: 17.02127659574468%;
+ *margin-left: 16.914893617021278%
+}
+
+.row-fluid .offset1 {
+ margin-left: 10.638297872340425%;
+ *margin-left: 10.53191489361702%
+}
+
+.row-fluid .offset1:first-child {
+ margin-left: 8.51063829787234%;
+ *margin-left: 8.404255319148938%
+}
+
+[class*="span"].hide, .row-fluid [class*="span"].hide {
+ display: none
+}
+
+[class*="span"].pull-right, .row-fluid [class*="span"].pull-right {
+ float: right
+}
+
+.container {
+ margin-right: auto;
+ margin-left: auto;
+ *zoom: 1
+}
+
+.container:before, .container:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.container:after {
+ clear: both
+}
+
+.container-fluid {
+ padding-right: 20px;
+ padding-left: 20px;
+ *zoom: 1
+}
+
+.container-fluid:before, .container-fluid:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.container-fluid:after {
+ clear: both
+}
+
+p {
+ margin: 0 0 10px
+}
+
+.lead {
+ margin-bottom: 20px;
+ font-size: 21px;
+ font-weight: 200;
+ line-height: 30px
+}
+
+small {
+ font-size: 85%
+}
+
+strong {
+ font-weight: bold
+}
+
+em {
+ font-style: italic
+}
+
+cite {
+ font-style: normal
+}
+
+.muted {
+ color: #999
+}
+
+.text-warning {
+ color: #c09853
+}
+
+.text-error {
+ color: #b94a48
+}
+
+.text-info {
+ color: #3a87ad
+}
+
+.text-success {
+ color: #468847
+}
+
+h1, h2, h3, h4, h5, h6 {
+ margin: 10px 0;
+ font-family: inherit;
+ font-weight: bold;
+ line-height: 1;
+ color: inherit;
+ text-rendering: optimizelegibility
+}
+
+h1 small, h2 small, h3 small, h4 small, h5 small, h6 small {
+ font-weight: normal;
+ line-height: 1;
+ color: #999
+}
+
+h1 {
+ font-size: 36px;
+ line-height: 40px
+}
+
+h2 {
+ font-size: 30px;
+ line-height: 40px
+}
+
+h3 {
+ font-size: 24px;
+ line-height: 40px
+}
+
+h4 {
+ font-size: 18px;
+ line-height: 20px
+}
+
+h5 {
+ font-size: 14px;
+ line-height: 20px
+}
+
+h6 {
+ font-size: 12px;
+ line-height: 20px
+}
+
+h1 small {
+ font-size: 24px
+}
+
+h2 small {
+ font-size: 18px
+}
+
+h3 small {
+ font-size: 14px
+}
+
+h4 small {
+ font-size: 14px
+}
+
+.page-header {
+ padding-bottom: 9px;
+ margin: 20px 0 30px;
+ border-bottom: 1px solid #eee
+}
+
+ul, ol {
+ padding: 0;
+ margin: 0 0 10px 25px
+}
+
+ul ul, ul ol, ol ol, ol ul {
+ margin-bottom: 0
+}
+
+li {
+ line-height: 20px
+}
+
+ul.unstyled, ol.unstyled {
+ margin-left: 0;
+ list-style: none
+}
+
+dl {
+ margin-bottom: 20px
+}
+
+dt, dd {
+ line-height: 20px
+}
+
+dt {
+ font-weight: bold
+}
+
+dd {
+ margin-left: 10px
+}
+
+.dl-horizontal {
+ *zoom: 1
+}
+
+.dl-horizontal:before, .dl-horizontal:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.dl-horizontal:after {
+ clear: both
+}
+
+.dl-horizontal dt {
+ float: left;
+ width: 160px;
+ overflow: hidden;
+ clear: left;
+ text-align: right;
+ text-overflow: ellipsis;
+ white-space: nowrap
+}
+
+.dl-horizontal dd {
+ margin-left: 180px
+}
+
+hr {
+ margin: 20px 0;
+ border: 0;
+ border-top: 1px solid #eee;
+ border-bottom: 1px solid #fff
+}
+
+abbr[title] {
+ cursor: help;
+ border-bottom: 1px dotted #999
+}
+
+abbr.initialism {
+ font-size: 90%;
+ text-transform: uppercase
+}
+
+blockquote {
+ padding: 0 0 0 15px;
+ margin: 0 0 20px;
+ border-left: 5px solid #eee
+}
+
+blockquote p {
+ margin-bottom: 0;
+ font-size: 16px;
+ font-weight: 300;
+ line-height: 25px
+}
+
+blockquote small {
+ display: block;
+ line-height: 20px;
+ color: #999
+}
+
+blockquote small:before {
+ content: '\2014 \00A0'
+}
+
+blockquote.pull-right {
+ float: right;
+ padding-right: 15px;
+ padding-left: 0;
+ border-right: 5px solid #eee;
+ border-left: 0
+}
+
+blockquote.pull-right p, blockquote.pull-right small {
+ text-align: right
+}
+
+blockquote.pull-right small:before {
+ content: ''
+}
+
+blockquote.pull-right small:after {
+ content: '\00A0 \2014'
+}
+
+q:before, q:after, blockquote:before, blockquote:after {
+ content: ""
+}
+
+address {
+ display: block;
+ margin-bottom: 20px;
+ font-style: normal;
+ line-height: 20px
+}
+
+code, pre {
+ padding: 0 3px 2px;
+ font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
+ font-size: 12px;
+ color: #333;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px
+}
+
+code {
+ padding: 2px 4px;
+ color: #d14;
+ background-color: #f7f7f9;
+ border: 1px solid #e1e1e8
+}
+
+pre {
+ display: block;
+ padding: 9.5px;
+ margin: 0 0 10px;
+ font-size: 13px;
+ line-height: 20px;
+ word-break: break-all;
+ word-wrap: break-word;
+ white-space: pre;
+ white-space: pre-wrap;
+ background-color: #f5f5f5;
+ border: 1px solid #ccc;
+ border: 1px solid rgba(0, 0, 0, 0.15);
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px
+}
+
+pre.prettyprint {
+ margin-bottom: 20px
+}
+
+pre code {
+ padding: 0;
+ color: inherit;
+ background-color: transparent;
+ border: 0
+}
+
+.pre-scrollable {
+ max-height: 340px;
+ overflow-y: scroll
+}
+
+form {
+ margin: 0 0 20px
+}
+
+fieldset {
+ padding: 0;
+ margin: 0;
+ border: 0
+}
+
+legend {
+ display: block;
+ width: 100%;
+ padding: 0;
+ margin-bottom: 20px;
+ font-size: 21px;
+ line-height: 40px;
+ color: #333;
+ border: 0;
+ border-bottom: 1px solid #e5e5e5
+}
+
+legend small {
+ font-size: 15px;
+ color: #999
+}
+
+label, input, button, select, textarea {
+ font-size: 14px;
+ font-weight: normal;
+ line-height: 20px
+}
+
+input, button, select, textarea {
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif
+}
+
+label {
+ display: block;
+ margin-bottom: 5px
+}
+
+select, textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input {
+ display: inline-block;
+ height: 20px;
+ padding: 4px 6px;
+ margin-bottom: 9px;
+ font-size: 14px;
+ line-height: 20px;
+ color: #555;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px
+}
+
+input, textarea, .uneditable-input {
+ width: 206px
+}
+
+textarea {
+ height: auto
+}
+
+textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input {
+ background-color: #fff;
+ border: 1px solid #ccc;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -webkit-transition: border linear .2s, box-shadow linear .2s;
+ -moz-transition: border linear .2s, box-shadow linear .2s;
+ -o-transition: border linear .2s, box-shadow linear .2s;
+ transition: border linear .2s, box-shadow linear .2s
+}
+
+textarea:focus, input[type="text"]:focus, input[type="password"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="date"]:focus, input[type="month"]:focus, input[type="time"]:focus, input[type="week"]:focus, input[type="number"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="color"]:focus, .uneditable-input:focus {
+ border-color: rgba(82, 168, 236, 0.8);
+ outline: 0;
+ outline: thin dotted \9;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6)
+}
+
+input[type="radio"], input[type="checkbox"] {
+ margin: 4px 0 0;
+ margin-top: 1px \9;
+ *margin-top: 0;
+ line-height: normal;
+ cursor: pointer
+}
+
+input[type="file"], input[type="image"], input[type="submit"], input[type="reset"], input[type="button"], input[type="radio"], input[type="checkbox"] {
+ width: auto
+}
+
+select, input[type="file"] {
+ height: 30px;
+ *margin-top: 4px;
+ line-height: 30px
+}
+
+select {
+ width: 220px;
+ background-color: #fff;
+ border: 1px solid #ccc
+}
+
+select[multiple], select[size] {
+ height: auto
+}
+
+select:focus, input[type="file"]:focus, input[type="radio"]:focus, input[type="checkbox"]:focus {
+ outline: thin dotted #333;
+ outline: 5px auto -webkit-focus-ring-color;
+ outline-offset: -2px
+}
+
+.uneditable-input, .uneditable-textarea {
+ color: #999;
+ cursor: not-allowed;
+ background-color: #fcfcfc;
+ border-color: #ccc;
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
+ -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025)
+}
+
+.uneditable-input {
+ overflow: hidden;
+ white-space: nowrap
+}
+
+.uneditable-textarea {
+ width: auto;
+ height: auto
+}
+
+input:-moz-placeholder, textarea:-moz-placeholder {
+ color: #999
+}
+
+input:-ms-input-placeholder, textarea:-ms-input-placeholder {
+ color: #999
+}
+
+input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
+ color: #999
+}
+
+.radio, .checkbox {
+ min-height: 18px;
+ padding-left: 18px
+}
+
+.radio input[type="radio"], .checkbox input[type="checkbox"] {
+ float: left;
+ margin-left: -18px
+}
+
+.controls>.radio:first-child, .controls>.checkbox:first-child {
+ padding-top: 5px
+}
+
+.radio.inline, .checkbox.inline {
+ display: inline-block;
+ padding-top: 5px;
+ margin-bottom: 0;
+ vertical-align: middle
+}
+
+.radio.inline+.radio.inline, .checkbox.inline+.checkbox.inline {
+ margin-left: 10px
+}
+
+.input-mini {
+ width: 60px
+}
+
+.input-small {
+ width: 90px
+}
+
+.input-medium {
+ width: 150px
+}
+
+.input-large {
+ width: 210px
+}
+
+.input-xlarge {
+ width: 270px
+}
+
+.input-xxlarge {
+ width: 530px
+}
+
+input[class*="span"], select[class*="span"], textarea[class*="span"], .uneditable-input[class*="span"], .row-fluid input[class*="span"], .row-fluid select[class*="span"], .row-fluid textarea[class*="span"], .row-fluid .uneditable-input[class*="span"] {
+ float: none;
+ margin-left: 0
+}
+
+.input-append input[class*="span"], .input-append .uneditable-input[class*="span"], .input-prepend input[class*="span"], .input-prepend .uneditable-input[class*="span"], .row-fluid input[class*="span"], .row-fluid select[class*="span"], .row-fluid textarea[class*="span"], .row-fluid .uneditable-input[class*="span"], .row-fluid .input-prepend [class*="span"], .row-fluid .input-append [class*="span"] {
+ display: inline-block
+}
+
+input, textarea, .uneditable-input {
+ margin-left: 0
+}
+
+.controls-row [class*="span"]+[class*="span"] {
+ margin-left: 20px
+}
+
+input.span12, textarea.span12, .uneditable-input.span12 {
+ width: 926px
+}
+
+input.span11, textarea.span11, .uneditable-input.span11 {
+ width: 846px
+}
+
+input.span10, textarea.span10, .uneditable-input.span10 {
+ width: 766px
+}
+
+input.span9, textarea.span9, .uneditable-input.span9 {
+ width: 686px
+}
+
+input.span8, textarea.span8, .uneditable-input.span8 {
+ width: 606px
+}
+
+input.span7, textarea.span7, .uneditable-input.span7 {
+ width: 526px
+}
+
+input.span6, textarea.span6, .uneditable-input.span6 {
+ width: 446px
+}
+
+input.span5, textarea.span5, .uneditable-input.span5 {
+ width: 366px
+}
+
+input.span4, textarea.span4, .uneditable-input.span4 {
+ width: 286px
+}
+
+input.span3, textarea.span3, .uneditable-input.span3 {
+ width: 206px
+}
+
+input.span2, textarea.span2, .uneditable-input.span2 {
+ width: 126px
+}
+
+input.span1, textarea.span1, .uneditable-input.span1 {
+ width: 46px
+}
+
+.controls-row {
+ *zoom: 1
+}
+
+.controls-row:before, .controls-row:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.controls-row:after {
+ clear: both
+}
+
+.controls-row [class*="span"] {
+ float: left
+}
+
+input[disabled], select[disabled], textarea[disabled], input[readonly], select[readonly], textarea[readonly] {
+ cursor: not-allowed;
+ background-color: #eee
+}
+
+input[type="radio"][disabled], input[type="checkbox"][disabled], input[type="radio"][readonly], input[type="checkbox"][readonly] {
+ background-color: transparent
+}
+
+.control-group.warning>label, .control-group.warning .help-block, .control-group.warning .help-inline {
+ color: #c09853
+}
+
+.control-group.warning .checkbox, .control-group.warning .radio, .control-group.warning input, .control-group.warning select, .control-group.warning textarea {
+ color: #c09853
+}
+
+.control-group.warning input, .control-group.warning select, .control-group.warning textarea {
+ border-color: #c09853;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075)
+}
+
+.control-group.warning input:focus, .control-group.warning select:focus, .control-group.warning textarea:focus {
+ border-color: #a47e3c;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e;
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #dbc59e
+}
+
+.control-group.warning .input-prepend .add-on, .control-group.warning .input-append .add-on {
+ color: #c09853;
+ background-color: #fcf8e3;
+ border-color: #c09853
+}
+
+.control-group.error>label, .control-group.error .help-block, .control-group.error .help-inline {
+ color: #b94a48
+}
+
+.control-group.error .checkbox, .control-group.error .radio, .control-group.error input, .control-group.error select, .control-group.error textarea {
+ color: #b94a48
+}
+
+.control-group.error input, .control-group.error select, .control-group.error textarea {
+ border-color: #b94a48;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075)
+}
+
+.control-group.error input:focus, .control-group.error select:focus, .control-group.error textarea:focus {
+ border-color: #953b39;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392
+}
+
+.control-group.error .input-prepend .add-on, .control-group.error .input-append .add-on {
+ color: #b94a48;
+ background-color: #f2dede;
+ border-color: #b94a48
+}
+
+.control-group.success>label, .control-group.success .help-block, .control-group.success .help-inline {
+ color: #468847
+}
+
+.control-group.success .checkbox, .control-group.success .radio, .control-group.success input, .control-group.success select, .control-group.success textarea {
+ color: #468847
+}
+
+.control-group.success input, .control-group.success select, .control-group.success textarea {
+ border-color: #468847;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075)
+}
+
+.control-group.success input:focus, .control-group.success select:focus, .control-group.success textarea:focus {
+ border-color: #356635;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b;
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7aba7b
+}
+
+.control-group.success .input-prepend .add-on, .control-group.success .input-append .add-on {
+ color: #468847;
+ background-color: #dff0d8;
+ border-color: #468847
+}
+
+.control-group.info>label, .control-group.info .help-block, .control-group.info .help-inline {
+ color: #3a87ad
+}
+
+.control-group.info .checkbox, .control-group.info .radio, .control-group.info input, .control-group.info select, .control-group.info textarea {
+ color: #3a87ad
+}
+
+.control-group.info input, .control-group.info select, .control-group.info textarea {
+ border-color: #3a87ad;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075)
+}
+
+.control-group.info input:focus, .control-group.info select:focus, .control-group.info textarea:focus {
+ border-color: #2d6987;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3;
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3;
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #7ab5d3
+}
+
+.control-group.info .input-prepend .add-on, .control-group.info .input-append .add-on {
+ color: #3a87ad;
+ background-color: #d9edf7;
+ border-color: #3a87ad
+}
+
+input:focus:required:invalid, textarea:focus:required:invalid, select:focus:required:invalid {
+ color: #b94a48;
+ border-color: #ee5f5b
+}
+
+input:focus:required:invalid:focus, textarea:focus:required:invalid:focus, select:focus:required:invalid:focus {
+ border-color: #e9322d;
+ -webkit-box-shadow: 0 0 6px #f8b9b7;
+ -moz-box-shadow: 0 0 6px #f8b9b7;
+ box-shadow: 0 0 6px #f8b9b7
+}
+
+.form-actions {
+ padding: 19px 20px 20px;
+ margin-top: 20px;
+ margin-bottom: 20px;
+ background-color: #f5f5f5;
+ border-top: 1px solid #e5e5e5;
+ *zoom: 1
+}
+
+.form-actions:before, .form-actions:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.form-actions:after {
+ clear: both
+}
+
+.help-block, .help-inline {
+ color: #595959
+}
+
+.help-block {
+ display: block;
+ margin-bottom: 10px
+}
+
+.help-inline {
+ display: inline-block;
+ *display: inline;
+ padding-left: 5px;
+ vertical-align: middle;
+ *zoom: 1
+}
+
+.input-append, .input-prepend {
+ margin-bottom: 5px;
+ font-size: 0;
+ white-space: nowrap
+}
+
+.input-append input, .input-prepend input, .input-append select, .input-prepend select, .input-append .uneditable-input, .input-prepend .uneditable-input {
+ position: relative;
+ margin-bottom: 0;
+ *margin-left: 0;
+ font-size: 14px;
+ vertical-align: top;
+ -webkit-border-radius: 0 3px 3px 0;
+ -moz-border-radius: 0 3px 3px 0;
+ border-radius: 0 3px 3px 0
+}
+
+.input-append input:focus, .input-prepend input:focus, .input-append select:focus, .input-prepend select:focus, .input-append .uneditable-input:focus, .input-prepend .uneditable-input:focus {
+ z-index: 2
+}
+
+.input-append .add-on, .input-prepend .add-on {
+ display: inline-block;
+ width: auto;
+ height: 20px;
+ min-width: 16px;
+ padding: 4px 5px;
+ font-size: 14px;
+ font-weight: normal;
+ line-height: 20px;
+ text-align: center;
+ text-shadow: 0 1px 0 #fff;
+ background-color: #eee;
+ border: 1px solid #ccc
+}
+
+.input-append .add-on, .input-prepend .add-on, .input-append .btn, .input-prepend .btn {
+ vertical-align: top;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0
+}
+
+.input-append .active, .input-prepend .active {
+ background-color: #a9dba9;
+ border-color: #46a546
+}
+
+.input-prepend .add-on, .input-prepend .btn {
+ margin-right: -1px
+}
+
+.input-prepend .add-on:first-child, .input-prepend .btn:first-child {
+ -webkit-border-radius: 3px 0 0 3px;
+ -moz-border-radius: 3px 0 0 3px;
+ border-radius: 3px 0 0 3px
+}
+
+.input-append input, .input-append select, .input-append .uneditable-input {
+ -webkit-border-radius: 3px 0 0 3px;
+ -moz-border-radius: 3px 0 0 3px;
+ border-radius: 3px 0 0 3px
+}
+
+.input-append .add-on, .input-append .btn {
+ margin-left: -1px
+}
+
+.input-append .add-on:last-child, .input-append .btn:last-child {
+ -webkit-border-radius: 0 3px 3px 0;
+ -moz-border-radius: 0 3px 3px 0;
+ border-radius: 0 3px 3px 0
+}
+
+.input-prepend.input-append input, .input-prepend.input-append select, .input-prepend.input-append .uneditable-input {
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0
+}
+
+.input-prepend.input-append .add-on:first-child, .input-prepend.input-append .btn:first-child {
+ margin-right: -1px;
+ -webkit-border-radius: 3px 0 0 3px;
+ -moz-border-radius: 3px 0 0 3px;
+ border-radius: 3px 0 0 3px
+}
+
+.input-prepend.input-append .add-on:last-child, .input-prepend.input-append .btn:last-child {
+ margin-left: -1px;
+ -webkit-border-radius: 0 3px 3px 0;
+ -moz-border-radius: 0 3px 3px 0;
+ border-radius: 0 3px 3px 0
+}
+
+input.search-query {
+ padding-right: 14px;
+ padding-right: 4px \9;
+ padding-left: 14px;
+ padding-left: 4px \9;
+ margin-bottom: 0;
+ -webkit-border-radius: 15px;
+ -moz-border-radius: 15px;
+ border-radius: 15px
+}
+
+.form-search .input-append .search-query, .form-search .input-prepend .search-query {
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0
+}
+
+.form-search .input-append .search-query {
+ -webkit-border-radius: 14px 0 0 14px;
+ -moz-border-radius: 14px 0 0 14px;
+ border-radius: 14px 0 0 14px
+}
+
+.form-search .input-append .btn {
+ -webkit-border-radius: 0 14px 14px 0;
+ -moz-border-radius: 0 14px 14px 0;
+ border-radius: 0 14px 14px 0
+}
+
+.form-search .input-prepend .search-query {
+ -webkit-border-radius: 0 14px 14px 0;
+ -moz-border-radius: 0 14px 14px 0;
+ border-radius: 0 14px 14px 0
+}
+
+.form-search .input-prepend .btn {
+ -webkit-border-radius: 14px 0 0 14px;
+ -moz-border-radius: 14px 0 0 14px;
+ border-radius: 14px 0 0 14px
+}
+
+.form-search input, .form-inline input, .form-horizontal input, .form-search textarea, .form-inline textarea, .form-horizontal textarea, .form-search select, .form-inline select, .form-horizontal select, .form-search .help-inline, .form-inline .help-inline, .form-horizontal .help-inline, .form-search .uneditable-input, .form-inline .uneditable-input, .form-horizontal .uneditable-input, .form-search .input-prepend, .form-inline .input-prepend, .form-horizontal .input-prepend, .form-search .input-append, .form-inline .input-append, .form-horizontal .input-append {
+ display: inline-block;
+ *display: inline;
+ margin-bottom: 0;
+ vertical-align: middle;
+ *zoom: 1
+}
+
+.form-search .hide, .form-inline .hide, .form-horizontal .hide {
+ display: none
+}
+
+.form-search label, .form-inline label, .form-search .btn-group, .form-inline .btn-group {
+ display: inline-block
+}
+
+.form-search .input-append, .form-inline .input-append, .form-search .input-prepend, .form-inline .input-prepend {
+ margin-bottom: 0
+}
+
+.form-search .radio, .form-search .checkbox, .form-inline .radio, .form-inline .checkbox {
+ padding-left: 0;
+ margin-bottom: 0;
+ vertical-align: middle
+}
+
+.form-search .radio input[type="radio"], .form-search .checkbox input[type="checkbox"], .form-inline .radio input[type="radio"], .form-inline .checkbox input[type="checkbox"] {
+ float: left;
+ margin-right: 3px;
+ margin-left: 0
+}
+
+.control-group {
+ margin-bottom: 10px
+}
+
+legend+.control-group {
+ margin-top: 20px;
+ -webkit-margin-top-collapse: separate
+}
+
+.form-horizontal .control-group {
+ margin-bottom: 20px;
+ *zoom: 1
+}
+
+.form-horizontal .control-group:before, .form-horizontal .control-group:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.form-horizontal .control-group:after {
+ clear: both
+}
+
+.form-horizontal .control-label {
+ float: left;
+ width: 160px;
+ padding-top: 5px;
+ text-align: right
+}
+
+.form-horizontal .controls {
+ *display: inline-block;
+ *padding-left: 20px;
+ margin-left: 180px;
+ *margin-left: 0
+}
+
+.form-horizontal .controls:first-child {
+ *padding-left: 180px
+}
+
+.form-horizontal .help-block {
+ margin-bottom: 0
+}
+
+.form-horizontal input+.help-block, .form-horizontal select+.help-block, .form-horizontal textarea+.help-block {
+ margin-top: 10px
+}
+
+.form-horizontal .form-actions {
+ padding-left: 180px
+}
+
+table {
+ max-width: 100%;
+ background-color: transparent;
+ border-collapse: collapse;
+ border-spacing: 0
+}
+
+.table {
+ width: 100%;
+ margin-bottom: 20px
+}
+
+.table th, .table td {
+ padding: 8px;
+ line-height: 20px;
+ text-align: left;
+ vertical-align: top;
+ border-top: 1px solid #ddd
+}
+
+.table th {
+ font-weight: bold
+}
+
+.table thead th {
+ vertical-align: bottom
+}
+
+.table caption+thead tr:first-child th, .table caption+thead tr:first-child td, .table colgroup+thead tr:first-child th, .table colgroup+thead tr:first-child td, .table thead:first-child tr:first-child th, .table thead:first-child tr:first-child td {
+ border-top: 0
+}
+
+.table tbody+tbody {
+ border-top: 2px solid #ddd
+}
+
+.table-condensed th, .table-condensed td {
+ padding: 4px 5px
+}
+
+.table-bordered {
+ border: 1px solid #ddd;
+ border-collapse: separate;
+ *border-collapse: collapse;
+ border-left: 0;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px
+}
+
+.table-bordered th, .table-bordered td {
+ border-left: 1px solid #ddd
+}
+
+.table-bordered caption+thead tr:first-child th, .table-bordered caption+tbody tr:first-child th, .table-bordered caption+tbody tr:first-child td, .table-bordered colgroup+thead tr:first-child th, .table-bordered colgroup+tbody tr:first-child th, .table-bordered colgroup+tbody tr:first-child td, .table-bordered thead:first-child tr:first-child th, .table-bordered tbody:first-child tr:first-child th, .table-bordered tbody:first-child tr:first-child td {
+ border-top: 0
+}
+
+.table-bordered thead:first-child tr:first-child th:first-child, .table-bordered tbody:first-child tr:first-child td:first-child {
+ -webkit-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
+ -moz-border-radius-topleft: 4px
+}
+
+.table-bordered thead:first-child tr:first-child th:last-child, .table-bordered tbody:first-child tr:first-child td:last-child {
+ -webkit-border-top-right-radius: 4px;
+ border-top-right-radius: 4px;
+ -moz-border-radius-topright: 4px
+}
+
+.table-bordered thead:last-child tr:last-child th:first-child, .table-bordered tbody:last-child tr:last-child td:first-child, .table-bordered tfoot:last-child tr:last-child td:first-child {
+ -webkit-border-radius: 0 0 0 4px;
+ -moz-border-radius: 0 0 0 4px;
+ border-radius: 0 0 0 4px;
+ -webkit-border-bottom-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+ -moz-border-radius-bottomleft: 4px
+}
+
+.table-bordered thead:last-child tr:last-child th:last-child, .table-bordered tbody:last-child tr:last-child td:last-child, .table-bordered tfoot:last-child tr:last-child td:last-child {
+ -webkit-border-bottom-right-radius: 4px;
+ border-bottom-right-radius: 4px;
+ -moz-border-radius-bottomright: 4px
+}
+
+.table-bordered caption+thead tr:first-child th:first-child, .table-bordered caption+tbody tr:first-child td:first-child, .table-bordered colgroup+thead tr:first-child th:first-child, .table-bordered colgroup+tbody tr:first-child td:first-child {
+ -webkit-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
+ -moz-border-radius-topleft: 4px
+}
+
+.table-bordered caption+thead tr:first-child th:last-child, .table-bordered caption+tbody tr:first-child td:last-child, .table-bordered colgroup+thead tr:first-child th:last-child, .table-bordered colgroup+tbody tr:first-child td:last-child {
+ -webkit-border-top-right-radius: 4px;
+ border-top-right-radius: 4px;
+ -moz-border-radius-topleft: 4px
+}
+
+.table-striped tbody tr:nth-child(odd) td, .table-striped tbody tr:nth-child(odd) th {
+ background-color: #f9f9f9
+}
+
+.table-hover tbody tr:hover td, .table-hover tbody tr:hover th {
+ background-color: #f5f5f5
+}
+
+table [class*=span], .row-fluid table [class*=span] {
+ display: table-cell;
+ float: none;
+ margin-left: 0
+}
+
+.table .span1 {
+ float: none;
+ width: 44px;
+ margin-left: 0
+}
+
+.table .span2 {
+ float: none;
+ width: 124px;
+ margin-left: 0
+}
+
+.table .span3 {
+ float: none;
+ width: 204px;
+ margin-left: 0
+}
+
+.table .span4 {
+ float: none;
+ width: 284px;
+ margin-left: 0
+}
+
+.table .span5 {
+ float: none;
+ width: 364px;
+ margin-left: 0
+}
+
+.table .span6 {
+ float: none;
+ width: 444px;
+ margin-left: 0
+}
+
+.table .span7 {
+ float: none;
+ width: 524px;
+ margin-left: 0
+}
+
+.table .span8 {
+ float: none;
+ width: 604px;
+ margin-left: 0
+}
+
+.table .span9 {
+ float: none;
+ width: 684px;
+ margin-left: 0
+}
+
+.table .span10 {
+ float: none;
+ width: 764px;
+ margin-left: 0
+}
+
+.table .span11 {
+ float: none;
+ width: 844px;
+ margin-left: 0
+}
+
+.table .span12 {
+ float: none;
+ width: 924px;
+ margin-left: 0
+}
+
+.table .span13 {
+ float: none;
+ width: 1004px;
+ margin-left: 0
+}
+
+.table .span14 {
+ float: none;
+ width: 1084px;
+ margin-left: 0
+}
+
+.table .span15 {
+ float: none;
+ width: 1164px;
+ margin-left: 0
+}
+
+.table .span16 {
+ float: none;
+ width: 1244px;
+ margin-left: 0
+}
+
+.table .span17 {
+ float: none;
+ width: 1324px;
+ margin-left: 0
+}
+
+.table .span18 {
+ float: none;
+ width: 1404px;
+ margin-left: 0
+}
+
+.table .span19 {
+ float: none;
+ width: 1484px;
+ margin-left: 0
+}
+
+.table .span20 {
+ float: none;
+ width: 1564px;
+ margin-left: 0
+}
+
+.table .span21 {
+ float: none;
+ width: 1644px;
+ margin-left: 0
+}
+
+.table .span22 {
+ float: none;
+ width: 1724px;
+ margin-left: 0
+}
+
+.table .span23 {
+ float: none;
+ width: 1804px;
+ margin-left: 0
+}
+
+.table .span24 {
+ float: none;
+ width: 1884px;
+ margin-left: 0
+}
+
+.table tbody tr.success td {
+ background-color: #dff0d8
+}
+
+.table tbody tr.error td {
+ background-color: #f2dede
+}
+
+.table tbody tr.warning td {
+ background-color: #fcf8e3
+}
+
+.table tbody tr.info td {
+ background-color: #d9edf7
+}
+
+.table-hover tbody tr.success:hover td {
+ background-color: #d0e9c6
+}
+
+.table-hover tbody tr.error:hover td {
+ background-color: #ebcccc
+}
+
+.table-hover tbody tr.warning:hover td {
+ background-color: #faf2cc
+}
+
+.table-hover tbody tr.info:hover td {
+ background-color: #c4e3f3
+}
+
+[class^="icon-"], [class*=" icon-"] {
+ display: inline-block;
+ width: 14px;
+ height: 14px;
+ margin-top: 1px;
+ *margin-right: .3em;
+ line-height: 14px;
+ vertical-align: text-top;
+ background-image: url("../img/glyphicons-halflings.png");
+ background-position: 14px 14px;
+ background-repeat: no-repeat
+}
+
+.icon-white, .nav-tabs>.active>a>[class^="icon-"], .nav-tabs>.active>a>[class*=" icon-"], .nav-pills>.active>a>[class^="icon-"], .nav-pills>.active>a>[class*=" icon-"], .nav-list>.active>a>[class^="icon-"], .nav-list>.active>a>[class*=" icon-"], .navbar-inverse .nav>.active>a>[class^="icon-"], .navbar-inverse .nav>.active>a>[class*=" icon-"], .dropdown-menu>li>a:hover>[class^="icon-"], .dropdown-menu>li>a:hover>[class*=" icon-"], .dropdown-menu>.active>a>[class^="icon-"], .dropdown-menu>.active>a>[class*=" icon-"] {
+ background-image: url("../img/glyphicons-halflings-white.png")
+}
+
+.icon-glass {
+ background-position: 0 0
+}
+
+.icon-music {
+ background-position: -24px 0
+}
+
+.icon-search {
+ background-position: -48px 0
+}
+
+.icon-envelope {
+ background-position: -72px 0
+}
+
+.icon-heart {
+ background-position: -96px 0
+}
+
+.icon-star {
+ background-position: -120px 0
+}
+
+.icon-star-empty {
+ background-position: -144px 0
+}
+
+.icon-user {
+ background-position: -168px 0
+}
+
+.icon-film {
+ background-position: -192px 0
+}
+
+.icon-th-large {
+ background-position: -216px 0
+}
+
+.icon-th {
+ background-position: -240px 0
+}
+
+.icon-th-list {
+ background-position: -264px 0
+}
+
+.icon-ok {
+ background-position: -288px 0
+}
+
+.icon-remove {
+ background-position: -312px 0
+}
+
+.icon-zoom-in {
+ background-position: -336px 0
+}
+
+.icon-zoom-out {
+ background-position: -360px 0
+}
+
+.icon-off {
+ background-position: -384px 0
+}
+
+.icon-signal {
+ background-position: -408px 0
+}
+
+.icon-cog {
+ background-position: -432px 0
+}
+
+.icon-trash {
+ background-position: -456px 0
+}
+
+.icon-home {
+ background-position: 0 -24px
+}
+
+.icon-file {
+ background-position: -24px -24px
+}
+
+.icon-time {
+ background-position: -48px -24px
+}
+
+.icon-road {
+ background-position: -72px -24px
+}
+
+.icon-download-alt {
+ background-position: -96px -24px
+}
+
+.icon-download {
+ background-position: -120px -24px
+}
+
+.icon-upload {
+ background-position: -144px -24px
+}
+
+.icon-inbox {
+ background-position: -168px -24px
+}
+
+.icon-play-circle {
+ background-position: -192px -24px
+}
+
+.icon-repeat {
+ background-position: -216px -24px
+}
+
+.icon-refresh {
+ background-position: -240px -24px
+}
+
+.icon-list-alt {
+ background-position: -264px -24px
+}
+
+.icon-lock {
+ background-position: -287px -24px
+}
+
+.icon-flag {
+ background-position: -312px -24px
+}
+
+.icon-headphones {
+ background-position: -336px -24px
+}
+
+.icon-volume-off {
+ background-position: -360px -24px
+}
+
+.icon-volume-down {
+ background-position: -384px -24px
+}
+
+.icon-volume-up {
+ background-position: -408px -24px
+}
+
+.icon-qrcode {
+ background-position: -432px -24px
+}
+
+.icon-barcode {
+ background-position: -456px -24px
+}
+
+.icon-tag {
+ background-position: 0 -48px
+}
+
+.icon-tags {
+ background-position: -25px -48px
+}
+
+.icon-book {
+ background-position: -48px -48px
+}
+
+.icon-bookmark {
+ background-position: -72px -48px
+}
+
+.icon-print {
+ background-position: -96px -48px
+}
+
+.icon-camera {
+ background-position: -120px -48px
+}
+
+.icon-font {
+ background-position: -144px -48px
+}
+
+.icon-bold {
+ background-position: -167px -48px
+}
+
+.icon-italic {
+ background-position: -192px -48px
+}
+
+.icon-text-height {
+ background-position: -216px -48px
+}
+
+.icon-text-width {
+ background-position: -240px -48px
+}
+
+.icon-align-left {
+ background-position: -264px -48px
+}
+
+.icon-align-center {
+ background-position: -288px -48px
+}
+
+.icon-align-right {
+ background-position: -312px -48px
+}
+
+.icon-align-justify {
+ background-position: -336px -48px
+}
+
+.icon-list {
+ background-position: -360px -48px
+}
+
+.icon-indent-left {
+ background-position: -384px -48px
+}
+
+.icon-indent-right {
+ background-position: -408px -48px
+}
+
+.icon-facetime-video {
+ background-position: -432px -48px
+}
+
+.icon-picture {
+ background-position: -456px -48px
+}
+
+.icon-pencil {
+ background-position: 0 -72px
+}
+
+.icon-map-marker {
+ background-position: -24px -72px
+}
+
+.icon-adjust {
+ background-position: -48px -72px
+}
+
+.icon-tint {
+ background-position: -72px -72px
+}
+
+.icon-edit {
+ background-position: -96px -72px
+}
+
+.icon-share {
+ background-position: -120px -72px
+}
+
+.icon-check {
+ background-position: -144px -72px
+}
+
+.icon-move {
+ background-position: -168px -72px
+}
+
+.icon-step-backward {
+ background-position: -192px -72px
+}
+
+.icon-fast-backward {
+ background-position: -216px -72px
+}
+
+.icon-backward {
+ background-position: -240px -72px
+}
+
+.icon-play {
+ background-position: -264px -72px
+}
+
+.icon-pause {
+ background-position: -288px -72px
+}
+
+.icon-stop {
+ background-position: -312px -72px
+}
+
+.icon-forward {
+ background-position: -336px -72px
+}
+
+.icon-fast-forward {
+ background-position: -360px -72px
+}
+
+.icon-step-forward {
+ background-position: -384px -72px
+}
+
+.icon-eject {
+ background-position: -408px -72px
+}
+
+.icon-chevron-left {
+ background-position: -432px -72px
+}
+
+.icon-chevron-right {
+ background-position: -456px -72px
+}
+
+.icon-plus-sign {
+ background-position: 0 -96px
+}
+
+.icon-minus-sign {
+ background-position: -24px -96px
+}
+
+.icon-remove-sign {
+ background-position: -48px -96px
+}
+
+.icon-ok-sign {
+ background-position: -72px -96px
+}
+
+.icon-question-sign {
+ background-position: -96px -96px
+}
+
+.icon-info-sign {
+ background-position: -120px -96px
+}
+
+.icon-screenshot {
+ background-position: -144px -96px
+}
+
+.icon-remove-circle {
+ background-position: -168px -96px
+}
+
+.icon-ok-circle {
+ background-position: -192px -96px
+}
+
+.icon-ban-circle {
+ background-position: -216px -96px
+}
+
+.icon-arrow-left {
+ background-position: -240px -96px
+}
+
+.icon-arrow-right {
+ background-position: -264px -96px
+}
+
+.icon-arrow-up {
+ background-position: -289px -96px
+}
+
+.icon-arrow-down {
+ background-position: -312px -96px
+}
+
+.icon-share-alt {
+ background-position: -336px -96px
+}
+
+.icon-resize-full {
+ background-position: -360px -96px
+}
+
+.icon-resize-small {
+ background-position: -384px -96px
+}
+
+.icon-plus {
+ background-position: -408px -96px
+}
+
+.icon-minus {
+ background-position: -433px -96px
+}
+
+.icon-asterisk {
+ background-position: -456px -96px
+}
+
+.icon-exclamation-sign {
+ background-position: 0 -120px
+}
+
+.icon-gift {
+ background-position: -24px -120px
+}
+
+.icon-leaf {
+ background-position: -48px -120px
+}
+
+.icon-fire {
+ background-position: -72px -120px
+}
+
+.icon-eye-open {
+ background-position: -96px -120px
+}
+
+.icon-eye-close {
+ background-position: -120px -120px
+}
+
+.icon-warning-sign {
+ background-position: -144px -120px
+}
+
+.icon-plane {
+ background-position: -168px -120px
+}
+
+.icon-calendar {
+ background-position: -192px -120px
+}
+
+.icon-random {
+ width: 16px;
+ background-position: -216px -120px
+}
+
+.icon-comment {
+ background-position: -240px -120px
+}
+
+.icon-magnet {
+ background-position: -264px -120px
+}
+
+.icon-chevron-up {
+ background-position: -288px -120px
+}
+
+.icon-chevron-down {
+ background-position: -313px -119px
+}
+
+.icon-retweet {
+ background-position: -336px -120px
+}
+
+.icon-shopping-cart {
+ background-position: -360px -120px
+}
+
+.icon-folder-close {
+ background-position: -384px -120px
+}
+
+.icon-folder-open {
+ width: 16px;
+ background-position: -408px -120px
+}
+
+.icon-resize-vertical {
+ background-position: -432px -119px
+}
+
+.icon-resize-horizontal {
+ background-position: -456px -118px
+}
+
+.icon-hdd {
+ background-position: 0 -144px
+}
+
+.icon-bullhorn {
+ background-position: -24px -144px
+}
+
+.icon-bell {
+ background-position: -48px -144px
+}
+
+.icon-certificate {
+ background-position: -72px -144px
+}
+
+.icon-thumbs-up {
+ background-position: -96px -144px
+}
+
+.icon-thumbs-down {
+ background-position: -120px -144px
+}
+
+.icon-hand-right {
+ background-position: -144px -144px
+}
+
+.icon-hand-left {
+ background-position: -168px -144px
+}
+
+.icon-hand-up {
+ background-position: -192px -144px
+}
+
+.icon-hand-down {
+ background-position: -216px -144px
+}
+
+.icon-circle-arrow-right {
+ background-position: -240px -144px
+}
+
+.icon-circle-arrow-left {
+ background-position: -264px -144px
+}
+
+.icon-circle-arrow-up {
+ background-position: -288px -144px
+}
+
+.icon-circle-arrow-down {
+ background-position: -312px -144px
+}
+
+.icon-globe {
+ background-position: -336px -144px
+}
+
+.icon-wrench {
+ background-position: -360px -144px
+}
+
+.icon-tasks {
+ background-position: -384px -144px
+}
+
+.icon-filter {
+ background-position: -408px -144px
+}
+
+.icon-briefcase {
+ background-position: -432px -144px
+}
+
+.icon-fullscreen {
+ background-position: -456px -144px
+}
+
+.dropup, .dropdown {
+ position: relative
+}
+
+.dropdown-toggle {
+ *margin-bottom: -3px
+}
+
+.dropdown-toggle:active, .open .dropdown-toggle {
+ outline: 0
+}
+
+.caret {
+ display: inline-block;
+ width: 0;
+ height: 0;
+ vertical-align: top;
+ border-top: 4px solid #000;
+ border-right: 4px solid transparent;
+ border-left: 4px solid transparent;
+ content: ""
+}
+
+.dropdown .caret {
+ margin-top: 8px;
+ margin-left: 2px
+}
+
+.dropdown-menu {
+ position: absolute;
+ top: 100%;
+ left: 0;
+ z-index: 1000;
+ display: none;
+ float: left;
+ min-width: 160px;
+ padding: 5px 0;
+ margin: 2px 0 0;
+ list-style: none;
+ background-color: #fff;
+ border: 1px solid #ccc;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ *border-right-width: 2px;
+ *border-bottom-width: 2px;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+ -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ -webkit-background-clip: padding-box;
+ -moz-background-clip: padding;
+ background-clip: padding-box
+}
+
+.dropdown-menu.pull-right {
+ right: 0;
+ left: auto
+}
+
+.dropdown-menu .divider {
+ *width: 100%;
+ height: 1px;
+ margin: 9px 1px;
+ *margin: -5px 0 5px;
+ overflow: hidden;
+ background-color: #e5e5e5;
+ border-bottom: 1px solid #fff
+}
+
+.dropdown-menu a {
+ display: block;
+ padding: 3px 20px;
+ clear: both;
+ font-weight: normal;
+ line-height: 20px;
+ color: #333;
+ white-space: nowrap
+}
+
+.dropdown-menu li>a:hover, .dropdown-menu li>a:focus, .dropdown-submenu:hover>a {
+ color: #fff;
+ text-decoration: none;
+ background-color: #08c;
+ background-color: #0081c2;
+ background-image: -moz-linear-gradient(top, #08c, #0077b3);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#0077b3));
+ background-image: -webkit-linear-gradient(top, #08c, #0077b3);
+ background-image: -o-linear-gradient(top, #08c, #0077b3);
+ background-image: linear-gradient(to bottom, #08c, #0077b3);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
+}
+
+.dropdown-menu .active>a, .dropdown-menu .active>a:hover {
+ color: #fff;
+ text-decoration: none;
+ background-color: #08c;
+ background-color: #0081c2;
+ background-image: linear-gradient(to bottom, #08c, #0077b3);
+ background-image: -moz-linear-gradient(top, #08c, #0077b3);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#0077b3));
+ background-image: -webkit-linear-gradient(top, #08c, #0077b3);
+ background-image: -o-linear-gradient(top, #08c, #0077b3);
+ background-repeat: repeat-x;
+ outline: 0;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
+}
+
+.dropdown-menu .disabled>a, .dropdown-menu .disabled>a:hover {
+ color: #999
+}
+
+.dropdown-menu .disabled>a:hover {
+ text-decoration: none;
+ cursor: default;
+ background-color: transparent
+}
+
+.open {
+ *z-index: 1000
+}
+
+.open>.dropdown-menu {
+ display: block
+}
+
+.pull-right>.dropdown-menu {
+ right: 0;
+ left: auto
+}
+
+.dropup .caret, .navbar-fixed-bottom .dropdown .caret {
+ border-top: 0;
+ border-bottom: 4px solid #000;
+ content: ""
+}
+
+.dropup .dropdown-menu, .navbar-fixed-bottom .dropdown .dropdown-menu {
+ top: auto;
+ bottom: 100%;
+ margin-bottom: 1px
+}
+
+.dropdown-submenu {
+ position: relative
+}
+
+.dropdown-submenu>.dropdown-menu {
+ top: 0;
+ left: 100%;
+ margin-top: -6px;
+ margin-left: -1px;
+ -webkit-border-radius: 0 6px 6px 6px;
+ -moz-border-radius: 0 6px 6px 6px;
+ border-radius: 0 6px 6px 6px
+}
+
+.dropdown-submenu:hover>.dropdown-menu {
+ display: block
+}
+
+.dropdown-submenu>a:after {
+ display: block;
+ float: right;
+ width: 0;
+ height: 0;
+ margin-top: 5px;
+ margin-right: -10px;
+ border-color: transparent;
+ border-left-color: #ccc;
+ border-style: solid;
+ border-width: 5px 0 5px 5px;
+ content: " "
+}
+
+.dropdown-submenu:hover>a:after {
+ border-left-color: #fff
+}
+
+.dropdown .dropdown-menu .nav-header {
+ padding-right: 20px;
+ padding-left: 20px
+}
+
+.typeahead {
+ margin-top: 2px;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px
+}
+
+.well {
+ min-height: 20px;
+ padding: 19px;
+ margin-bottom: 20px;
+ background-color: #f5f5f5;
+ border: 1px solid #e3e3e3;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05)
+}
+
+.well blockquote {
+ border-color: #ddd;
+ border-color: rgba(0, 0, 0, 0.15)
+}
+
+.well-large {
+ padding: 24px;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px
+}
+
+.well-small {
+ padding: 9px;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px
+}
+
+.fade {
+ opacity: 0;
+ -webkit-transition: opacity .15s linear;
+ -moz-transition: opacity .15s linear;
+ -o-transition: opacity .15s linear;
+ transition: opacity .15s linear
+}
+
+.fade.in {
+ opacity: 1
+}
+
+.collapse {
+ position: relative;
+ height: 0;
+ overflow: hidden;
+ -webkit-transition: height .35s ease;
+ -moz-transition: height .35s ease;
+ -o-transition: height .35s ease;
+ transition: height .35s ease
+}
+
+.collapse.in {
+ height: auto
+}
+
+.close {
+ float: right;
+ font-size: 20px;
+ font-weight: bold;
+ line-height: 20px;
+ color: #000;
+ text-shadow: 0 1px 0 #fff;
+ opacity: .2;
+ filter: alpha(opacity=20)
+}
+
+.close:hover {
+ color: #000;
+ text-decoration: none;
+ cursor: pointer;
+ opacity: .4;
+ filter: alpha(opacity=40)
+}
+
+button.close {
+ padding: 0;
+ cursor: pointer;
+ background: transparent;
+ border: 0;
+ -webkit-appearance: none
+}
+
+.btn {
+ display: inline-block;
+ *display: inline;
+ padding: 4px 14px;
+ margin-bottom: 0;
+ *margin-left: .3em;
+ font-size: 14px;
+ line-height: 20px;
+ *line-height: 20px;
+ color: #333;
+ text-align: center;
+ text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
+ vertical-align: middle;
+ cursor: pointer;
+ background-color: #f5f5f5;
+ *background-color: #e6e6e6;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#e6e6e6));
+ background-image: -webkit-linear-gradient(top, #fff, #e6e6e6);
+ background-image: -o-linear-gradient(top, #fff, #e6e6e6);
+ background-image: linear-gradient(to bottom, #fff, #e6e6e6);
+ background-image: -moz-linear-gradient(top, #fff, #e6e6e6);
+ background-repeat: repeat-x;
+ border: 1px solid #bbb;
+ *border: 0;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ border-color: #e6e6e6 #e6e6e6 #bfbfbf;
+ border-bottom-color: #a2a2a2;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+ *zoom: 1;
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05)
+}
+
+.btn:hover, .btn:active, .btn.active, .btn.disabled, .btn[disabled] {
+ color: #333;
+ background-color: #e6e6e6;
+ *background-color: #d9d9d9
+}
+
+.btn:active, .btn.active {
+ background-color: #ccc \9
+}
+
+.btn:first-child {
+ *margin-left: 0
+}
+
+.btn:hover {
+ color: #333;
+ text-decoration: none;
+ background-color: #e6e6e6;
+ *background-color: #d9d9d9;
+ background-position: 0 -15px;
+ -webkit-transition: background-position .1s linear;
+ -moz-transition: background-position .1s linear;
+ -o-transition: background-position .1s linear;
+ transition: background-position .1s linear
+}
+
+.btn:focus {
+ outline: thin dotted #333;
+ outline: 5px auto -webkit-focus-ring-color;
+ outline-offset: -2px
+}
+
+.btn.active, .btn:active {
+ background-color: #e6e6e6;
+ background-color: #d9d9d9 \9;
+ background-image: none;
+ outline: 0;
+ -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05)
+}
+
+.btn.disabled, .btn[disabled] {
+ cursor: default;
+ background-color: #e6e6e6;
+ background-image: none;
+ opacity: .65;
+ filter: alpha(opacity=65);
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ box-shadow: none
+}
+
+.btn-large {
+ padding: 9px 14px;
+ font-size: 16px;
+ line-height: normal;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px
+}
+
+.btn-large [class^="icon-"] {
+ margin-top: 2px
+}
+
+.btn-small {
+ padding: 3px 9px;
+ font-size: 12px;
+ line-height: 18px
+}
+
+.btn-small [class^="icon-"] {
+ margin-top: 0
+}
+
+.btn-mini {
+ padding: 2px 6px;
+ font-size: 11px;
+ line-height: 17px
+}
+
+.btn-block {
+ display: block;
+ width: 100%;
+ padding-right: 0;
+ padding-left: 0;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box
+}
+
+.btn-block+.btn-block {
+ margin-top: 5px
+}
+
+input[type="submit"].btn-block, input[type="reset"].btn-block, input[type="button"].btn-block {
+ width: 100%
+}
+
+.btn-primary.active, .btn-warning.active, .btn-danger.active, .btn-success.active, .btn-info.active, .btn-inverse.active {
+ color: rgba(255, 255, 255, 0.75)
+}
+
+.btn {
+ border-color: #c5c5c5;
+ border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25)
+}
+
+.btn-primary {
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #006dcc;
+ *background-color: #04c;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#04c));
+ background-image: -webkit-linear-gradient(top, #08c, #04c);
+ background-image: -o-linear-gradient(top, #08c, #04c);
+ background-image: linear-gradient(to bottom, #08c, #04c);
+ background-image: -moz-linear-gradient(top, #08c, #04c);
+ background-repeat: repeat-x;
+ border-color: #04c #04c #002a80;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false)
+}
+
+.btn-primary:hover, .btn-primary:active, .btn-primary.active, .btn-primary.disabled, .btn-primary[disabled] {
+ color: #fff;
+ background-color: #04c;
+ *background-color: #003bb3
+}
+
+.btn-primary:active, .btn-primary.active {
+ background-color: #039 \9
+}
+
+.btn-warning {
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #faa732;
+ *background-color: #f89406;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
+ background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
+ background-image: -o-linear-gradient(top, #fbb450, #f89406);
+ background-image: linear-gradient(to bottom, #fbb450, #f89406);
+ background-image: -moz-linear-gradient(top, #fbb450, #f89406);
+ background-repeat: repeat-x;
+ border-color: #f89406 #f89406 #ad6704;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false)
+}
+
+.btn-warning:hover, .btn-warning:active, .btn-warning.active, .btn-warning.disabled, .btn-warning[disabled] {
+ color: #fff;
+ background-color: #f89406;
+ *background-color: #df8505
+}
+
+.btn-warning:active, .btn-warning.active {
+ background-color: #c67605 \9
+}
+
+.btn-danger {
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #da4f49;
+ *background-color: #bd362f;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));
+ background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f);
+ background-image: -o-linear-gradient(top, #ee5f5b, #bd362f);
+ background-image: linear-gradient(to bottom, #ee5f5b, #bd362f);
+ background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f);
+ background-repeat: repeat-x;
+ border-color: #bd362f #bd362f #802420;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffbd362f', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false)
+}
+
+.btn-danger:hover, .btn-danger:active, .btn-danger.active, .btn-danger.disabled, .btn-danger[disabled] {
+ color: #fff;
+ background-color: #bd362f;
+ *background-color: #a9302a
+}
+
+.btn-danger:active, .btn-danger.active {
+ background-color: #942a25 \9
+}
+
+.btn-success {
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #5bb75b;
+ *background-color: #51a351;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));
+ background-image: -webkit-linear-gradient(top, #62c462, #51a351);
+ background-image: -o-linear-gradient(top, #62c462, #51a351);
+ background-image: linear-gradient(to bottom, #62c462, #51a351);
+ background-image: -moz-linear-gradient(top, #62c462, #51a351);
+ background-repeat: repeat-x;
+ border-color: #51a351 #51a351 #387038;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff51a351', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false)
+}
+
+.btn-success:hover, .btn-success:active, .btn-success.active, .btn-success.disabled, .btn-success[disabled] {
+ color: #fff;
+ background-color: #51a351;
+ *background-color: #499249
+}
+
+.btn-success:active, .btn-success.active {
+ background-color: #408140 \9
+}
+
+.btn-info {
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #49afcd;
+ *background-color: #2f96b4;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));
+ background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4);
+ background-image: -o-linear-gradient(top, #5bc0de, #2f96b4);
+ background-image: linear-gradient(to bottom, #5bc0de, #2f96b4);
+ background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4);
+ background-repeat: repeat-x;
+ border-color: #2f96b4 #2f96b4 #1f6377;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2f96b4', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false)
+}
+
+.btn-info:hover, .btn-info:active, .btn-info.active, .btn-info.disabled, .btn-info[disabled] {
+ color: #fff;
+ background-color: #2f96b4;
+ *background-color: #2a85a0
+}
+
+.btn-info:active, .btn-info.active {
+ background-color: #24748c \9
+}
+
+.btn-inverse {
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #363636;
+ *background-color: #222;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#444), to(#222));
+ background-image: -webkit-linear-gradient(top, #444, #222);
+ background-image: -o-linear-gradient(top, #444, #222);
+ background-image: linear-gradient(to bottom, #444, #222);
+ background-image: -moz-linear-gradient(top, #444, #222);
+ background-repeat: repeat-x;
+ border-color: #222 #222 #000;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff444444', endColorstr='#ff222222', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false)
+}
+
+.btn-inverse:hover, .btn-inverse:active, .btn-inverse.active, .btn-inverse.disabled, .btn-inverse[disabled] {
+ color: #fff;
+ background-color: #222;
+ *background-color: #151515
+}
+
+.btn-inverse:active, .btn-inverse.active {
+ background-color: #080808 \9
+}
+
+button.btn, input[type="submit"].btn {
+ *padding-top: 3px;
+ *padding-bottom: 3px
+}
+
+button.btn::-moz-focus-inner, input[type="submit"].btn::-moz-focus-inner {
+ padding: 0;
+ border: 0
+}
+
+button.btn.btn-large, input[type="submit"].btn.btn-large {
+ *padding-top: 7px;
+ *padding-bottom: 7px
+}
+
+button.btn.btn-small, input[type="submit"].btn.btn-small {
+ *padding-top: 3px;
+ *padding-bottom: 3px
+}
+
+button.btn.btn-mini, input[type="submit"].btn.btn-mini {
+ *padding-top: 1px;
+ *padding-bottom: 1px
+}
+
+.btn-link, .btn-link:active, .btn-link[disabled] {
+ background-color: transparent;
+ background-image: none;
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ box-shadow: none
+}
+
+.btn-link {
+ color: #08c;
+ cursor: pointer;
+ border-color: transparent;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0
+}
+
+.btn-link:hover {
+ color: #005580;
+ text-decoration: underline;
+ background-color: transparent
+}
+
+.btn-link[disabled]:hover {
+ color: #333;
+ text-decoration: none
+}
+
+.btn-group {
+ position: relative;
+ *margin-left: .3em;
+ font-size: 0;
+ white-space: nowrap;
+ vertical-align: middle
+}
+
+.btn-group:first-child {
+ *margin-left: 0
+}
+
+.btn-group+.btn-group {
+ margin-left: 5px
+}
+
+.btn-toolbar {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 0
+}
+
+.btn-toolbar .btn-group {
+ display: inline-block;
+ *display: inline;
+ *zoom: 1
+}
+
+.btn-toolbar .btn+.btn, .btn-toolbar .btn-group+.btn, .btn-toolbar .btn+.btn-group {
+ margin-left: 5px
+}
+
+.btn-group>.btn {
+ position: relative;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0
+}
+
+.btn-group>.btn+.btn {
+ margin-left: -1px
+}
+
+.btn-group>.btn, .btn-group>.dropdown-menu {
+ font-size: 14px
+}
+
+.btn-group>.btn-mini {
+ font-size: 11px
+}
+
+.btn-group>.btn-small {
+ font-size: 12px
+}
+
+.btn-group>.btn-large {
+ font-size: 16px
+}
+
+.btn-group>.btn:first-child {
+ margin-left: 0;
+ -webkit-border-bottom-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+ -webkit-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
+ -moz-border-radius-bottomleft: 4px;
+ -moz-border-radius-topleft: 4px
+}
+
+.btn-group>.btn:last-child, .btn-group>.dropdown-toggle {
+ -webkit-border-top-right-radius: 4px;
+ border-top-right-radius: 4px;
+ -webkit-border-bottom-right-radius: 4px;
+ border-bottom-right-radius: 4px;
+ -moz-border-radius-topright: 4px;
+ -moz-border-radius-bottomright: 4px
+}
+
+.btn-group>.btn.large:first-child {
+ margin-left: 0;
+ -webkit-border-bottom-left-radius: 6px;
+ border-bottom-left-radius: 6px;
+ -webkit-border-top-left-radius: 6px;
+ border-top-left-radius: 6px;
+ -moz-border-radius-bottomleft: 6px;
+ -moz-border-radius-topleft: 6px
+}
+
+.btn-group>.btn.large:last-child, .btn-group>.large.dropdown-toggle {
+ -webkit-border-top-right-radius: 6px;
+ border-top-right-radius: 6px;
+ -webkit-border-bottom-right-radius: 6px;
+ border-bottom-right-radius: 6px;
+ -moz-border-radius-topright: 6px;
+ -moz-border-radius-bottomright: 6px
+}
+
+.btn-group>.btn:hover, .btn-group>.btn:focus, .btn-group>.btn:active, .btn-group>.btn.active {
+ z-index: 2
+}
+
+.btn-group .dropdown-toggle:active, .btn-group.open .dropdown-toggle {
+ outline: 0
+}
+
+.btn-group>.btn+.dropdown-toggle {
+ *padding-top: 5px;
+ padding-right: 8px;
+ *padding-bottom: 5px;
+ padding-left: 8px;
+ -webkit-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05)
+}
+
+.btn-group>.btn-mini+.dropdown-toggle {
+ *padding-top: 2px;
+ padding-right: 5px;
+ *padding-bottom: 2px;
+ padding-left: 5px
+}
+
+.btn-group>.btn-small+.dropdown-toggle {
+ *padding-top: 5px;
+ *padding-bottom: 4px
+}
+
+.btn-group>.btn-large+.dropdown-toggle {
+ *padding-top: 7px;
+ padding-right: 12px;
+ *padding-bottom: 7px;
+ padding-left: 12px
+}
+
+.btn-group.open .dropdown-toggle {
+ background-image: none;
+ -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05)
+}
+
+.btn-group.open .btn.dropdown-toggle {
+ background-color: #e6e6e6
+}
+
+.btn-group.open .btn-primary.dropdown-toggle {
+ background-color: #04c
+}
+
+.btn-group.open .btn-warning.dropdown-toggle {
+ background-color: #f89406
+}
+
+.btn-group.open .btn-danger.dropdown-toggle {
+ background-color: #bd362f
+}
+
+.btn-group.open .btn-success.dropdown-toggle {
+ background-color: #51a351
+}
+
+.btn-group.open .btn-info.dropdown-toggle {
+ background-color: #2f96b4
+}
+
+.btn-group.open .btn-inverse.dropdown-toggle {
+ background-color: #222
+}
+
+.btn .caret {
+ margin-top: 8px;
+ margin-left: 0
+}
+
+.btn-mini .caret, .btn-small .caret, .btn-large .caret {
+ margin-top: 6px
+}
+
+.btn-large .caret {
+ border-top-width: 5px;
+ border-right-width: 5px;
+ border-left-width: 5px
+}
+
+.dropup .btn-large .caret {
+ border-top: 0;
+ border-bottom: 5px solid #000
+}
+
+.btn-primary .caret, .btn-warning .caret, .btn-danger .caret, .btn-info .caret, .btn-success .caret, .btn-inverse .caret {
+ border-top-color: #fff;
+ border-bottom-color: #fff
+}
+
+.btn-group-vertical {
+ display: inline-block;
+ *display: inline;
+ *zoom: 1
+}
+
+.btn-group-vertical .btn {
+ display: block;
+ float: none;
+ width: 100%;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0
+}
+
+.btn-group-vertical .btn+.btn {
+ margin-top: -1px;
+ margin-left: 0
+}
+
+.btn-group-vertical .btn:first-child {
+ -webkit-border-radius: 4px 4px 0 0;
+ -moz-border-radius: 4px 4px 0 0;
+ border-radius: 4px 4px 0 0
+}
+
+.btn-group-vertical .btn:last-child {
+ -webkit-border-radius: 0 0 4px 4px;
+ -moz-border-radius: 0 0 4px 4px;
+ border-radius: 0 0 4px 4px
+}
+
+.btn-group-vertical .btn-large:first-child {
+ -webkit-border-radius: 6px 6px 0 0;
+ -moz-border-radius: 6px 6px 0 0;
+ border-radius: 6px 6px 0 0
+}
+
+.btn-group-vertical .btn-large:last-child {
+ -webkit-border-radius: 0 0 6px 6px;
+ -moz-border-radius: 0 0 6px 6px;
+ border-radius: 0 0 6px 6px
+}
+
+.alert {
+ padding: 8px 35px 8px 14px;
+ margin-bottom: 20px;
+ color: #c09853;
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
+ background-color: #fcf8e3;
+ border: 1px solid #fbeed5;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px
+}
+
+.alert h4 {
+ margin: 0
+}
+
+.alert .close {
+ position: relative;
+ top: -2px;
+ right: -21px;
+ line-height: 20px
+}
+
+.alert-success {
+ color: #468847;
+ background-color: #dff0d8;
+ border-color: #d6e9c6
+}
+
+.alert-danger, .alert-error {
+ color: #b94a48;
+ background-color: #f2dede;
+ border-color: #eed3d7
+}
+
+.alert-info {
+ color: #3a87ad;
+ background-color: #d9edf7;
+ border-color: #bce8f1
+}
+
+.alert-block {
+ padding-top: 14px;
+ padding-bottom: 14px
+}
+
+.alert-block>p, .alert-block>ul {
+ margin-bottom: 0
+}
+
+.alert-block p+p {
+ margin-top: 5px
+}
+
+.nav {
+ margin-bottom: 20px;
+ margin-left: 0;
+ list-style: none
+}
+
+.nav>li>a {
+ display: block
+}
+
+.nav>li>a:hover {
+ text-decoration: none;
+ background-color: #eee
+}
+
+.nav>.pull-right {
+ float: right
+}
+
+.nav-header {
+ display: block;
+ padding: 3px 15px;
+ font-size: 11px;
+ font-weight: bold;
+ line-height: 20px;
+ color: #999;
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
+ text-transform: uppercase
+}
+
+.nav li+.nav-header {
+ margin-top: 9px
+}
+
+.nav-list {
+ padding-right: 15px;
+ padding-left: 15px;
+ margin-bottom: 0
+}
+
+.nav-list>li>a, .nav-list .nav-header {
+ margin-right: -15px;
+ margin-left: -15px;
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5)
+}
+
+.nav-list>li>a {
+ padding: 3px 15px
+}
+
+.nav-list>.active>a, .nav-list>.active>a:hover {
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
+ background-color: #08c
+}
+
+.nav-list [class^="icon-"] {
+ margin-right: 2px
+}
+
+.nav-list .divider {
+ *width: 100%;
+ height: 1px;
+ margin: 9px 1px;
+ *margin: -5px 0 5px;
+ overflow: hidden;
+ background-color: #e5e5e5;
+ border-bottom: 1px solid #fff
+}
+
+.nav-tabs, .nav-pills {
+ *zoom: 1
+}
+
+.nav-tabs:before, .nav-pills:before, .nav-tabs:after, .nav-pills:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.nav-tabs:after, .nav-pills:after {
+ clear: both
+}
+
+.nav-tabs>li, .nav-pills>li {
+ float: left
+}
+
+.nav-tabs>li>a, .nav-pills>li>a {
+ padding-right: 12px;
+ padding-left: 12px;
+ margin-right: 2px;
+ line-height: 14px
+}
+
+.nav-tabs {
+ border-bottom: 1px solid #ddd
+}
+
+.nav-tabs>li {
+ margin-bottom: -1px
+}
+
+.nav-tabs>li>a {
+ padding-top: 8px;
+ padding-bottom: 8px;
+ line-height: 20px;
+ border: 1px solid transparent;
+ -webkit-border-radius: 4px 4px 0 0;
+ -moz-border-radius: 4px 4px 0 0;
+ border-radius: 4px 4px 0 0
+}
+
+.nav-tabs>li>a:hover {
+ border-color: #eee #eee #ddd
+}
+
+.nav-tabs>.active>a, .nav-tabs>.active>a:hover {
+ color: #555;
+ cursor: default;
+ background-color: #fff;
+ border: 1px solid #ddd;
+ border-bottom-color: transparent
+}
+
+.nav-pills>li>a {
+ padding-top: 8px;
+ padding-bottom: 8px;
+ margin-top: 2px;
+ margin-bottom: 2px;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px
+}
+
+.nav-pills>.active>a, .nav-pills>.active>a:hover {
+ color: #fff;
+ background-color: #08c
+}
+
+.nav-stacked>li {
+ float: none
+}
+
+.nav-stacked>li>a {
+ margin-right: 0
+}
+
+.nav-tabs.nav-stacked {
+ border-bottom: 0
+}
+
+.nav-tabs.nav-stacked>li>a {
+ border: 1px solid #ddd;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0
+}
+
+.nav-tabs.nav-stacked>li:first-child>a {
+ -webkit-border-top-right-radius: 4px;
+ border-top-right-radius: 4px;
+ -webkit-border-top-left-radius: 4px;
+ border-top-left-radius: 4px;
+ -moz-border-radius-topright: 4px;
+ -moz-border-radius-topleft: 4px
+}
+
+.nav-tabs.nav-stacked>li:last-child>a {
+ -webkit-border-bottom-right-radius: 4px;
+ border-bottom-right-radius: 4px;
+ -webkit-border-bottom-left-radius: 4px;
+ border-bottom-left-radius: 4px;
+ -moz-border-radius-bottomright: 4px;
+ -moz-border-radius-bottomleft: 4px
+}
+
+.nav-tabs.nav-stacked>li>a:hover {
+ z-index: 2;
+ border-color: #ddd
+}
+
+.nav-pills.nav-stacked>li>a {
+ margin-bottom: 3px
+}
+
+.nav-pills.nav-stacked>li:last-child>a {
+ margin-bottom: 1px
+}
+
+.nav-tabs .dropdown-menu {
+ -webkit-border-radius: 0 0 6px 6px;
+ -moz-border-radius: 0 0 6px 6px;
+ border-radius: 0 0 6px 6px
+}
+
+.nav-pills .dropdown-menu {
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px
+}
+
+.nav .dropdown-toggle .caret {
+ margin-top: 6px;
+ border-top-color: #08c;
+ border-bottom-color: #08c
+}
+
+.nav .dropdown-toggle:hover .caret {
+ border-top-color: #005580;
+ border-bottom-color: #005580
+}
+
+.nav-tabs .dropdown-toggle .caret {
+ margin-top: 8px
+}
+
+.nav .active .dropdown-toggle .caret {
+ border-top-color: #fff;
+ border-bottom-color: #fff
+}
+
+.nav-tabs .active .dropdown-toggle .caret {
+ border-top-color: #555;
+ border-bottom-color: #555
+}
+
+.nav>.dropdown.active>a:hover {
+ cursor: pointer
+}
+
+.nav-tabs .open .dropdown-toggle, .nav-pills .open .dropdown-toggle, .nav>li.dropdown.open.active>a:hover {
+ color: #fff;
+ background-color: #999;
+ border-color: #999
+}
+
+.nav li.dropdown.open .caret, .nav li.dropdown.open.active .caret, .nav li.dropdown.open a:hover .caret {
+ border-top-color: #fff;
+ border-bottom-color: #fff;
+ opacity: 1;
+ filter: alpha(opacity=100)
+}
+
+.tabs-stacked .open>a:hover {
+ border-color: #999
+}
+
+.tabbable {
+ *zoom: 1
+}
+
+.tabbable:before, .tabbable:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.tabbable:after {
+ clear: both
+}
+
+.tab-content {
+ overflow: auto
+}
+
+.tabs-below>.nav-tabs, .tabs-right>.nav-tabs, .tabs-left>.nav-tabs {
+ border-bottom: 0
+}
+
+.tab-content>.tab-pane, .pill-content>.pill-pane {
+ display: none
+}
+
+.tab-content>.active, .pill-content>.active {
+ display: block
+}
+
+.tabs-below>.nav-tabs {
+ border-top: 1px solid #ddd
+}
+
+.tabs-below>.nav-tabs>li {
+ margin-top: -1px;
+ margin-bottom: 0
+}
+
+.tabs-below>.nav-tabs>li>a {
+ -webkit-border-radius: 0 0 4px 4px;
+ -moz-border-radius: 0 0 4px 4px;
+ border-radius: 0 0 4px 4px
+}
+
+.tabs-below>.nav-tabs>li>a:hover {
+ border-top-color: #ddd;
+ border-bottom-color: transparent
+}
+
+.tabs-below>.nav-tabs>.active>a, .tabs-below>.nav-tabs>.active>a:hover {
+ border-color: transparent #ddd #ddd #ddd
+}
+
+.tabs-left>.nav-tabs>li, .tabs-right>.nav-tabs>li {
+ float: none
+}
+
+.tabs-left>.nav-tabs>li>a, .tabs-right>.nav-tabs>li>a {
+ min-width: 74px;
+ margin-right: 0;
+ margin-bottom: 3px
+}
+
+.tabs-left>.nav-tabs {
+ float: left;
+ margin-right: 19px;
+ border-right: 1px solid #ddd
+}
+
+.tabs-left>.nav-tabs>li>a {
+ margin-right: -1px;
+ -webkit-border-radius: 4px 0 0 4px;
+ -moz-border-radius: 4px 0 0 4px;
+ border-radius: 4px 0 0 4px
+}
+
+.tabs-left>.nav-tabs>li>a:hover {
+ border-color: #eee #ddd #eee #eee
+}
+
+.tabs-left>.nav-tabs .active>a, .tabs-left>.nav-tabs .active>a:hover {
+ border-color: #ddd transparent #ddd #ddd;
+ *border-right-color: #fff
+}
+
+.tabs-right>.nav-tabs {
+ float: right;
+ margin-left: 19px;
+ border-left: 1px solid #ddd
+}
+
+.tabs-right>.nav-tabs>li>a {
+ margin-left: -1px;
+ -webkit-border-radius: 0 4px 4px 0;
+ -moz-border-radius: 0 4px 4px 0;
+ border-radius: 0 4px 4px 0
+}
+
+.tabs-right>.nav-tabs>li>a:hover {
+ border-color: #eee #eee #eee #ddd
+}
+
+.tabs-right>.nav-tabs .active>a, .tabs-right>.nav-tabs .active>a:hover {
+ border-color: #ddd #ddd #ddd transparent;
+ *border-left-color: #fff
+}
+
+.nav>.disabled>a {
+ color: #999
+}
+
+.nav>.disabled>a:hover {
+ text-decoration: none;
+ cursor: default;
+ background-color: transparent
+}
+
+.navbar {
+ *position: relative;
+ *z-index: 2;
+ margin-bottom: 20px;
+ overflow: visible;
+ color: #777
+}
+
+.navbar-inner {
+ min-height: 40px;
+ padding-right: 20px;
+ padding-left: 20px;
+ background-color: #fafafa;
+ background-image: -moz-linear-gradient(top, #fff, #f2f2f2);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#f2f2f2));
+ background-image: -webkit-linear-gradient(top, #fff, #f2f2f2);
+ background-image: -o-linear-gradient(top, #fff, #f2f2f2);
+ background-image: linear-gradient(to bottom, #fff, #f2f2f2);
+ background-repeat: repeat-x;
+ border: 1px solid #d4d4d4;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff2f2f2', GradientType=0);
+ *zoom: 1;
+ -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
+ -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065)
+}
+
+.navbar-inner:before, .navbar-inner:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.navbar-inner:after {
+ clear: both
+}
+
+.navbar .container {
+ width: auto
+}
+
+.nav-collapse.collapse {
+ height: auto
+}
+
+.navbar .brand {
+ display: block;
+ float: left;
+ padding: 10px 20px 10px;
+ margin-left: -20px;
+ font-size: 20px;
+ font-weight: 200;
+ color: #777;
+ text-shadow: 0 1px 0 #fff
+}
+
+.navbar .brand:hover {
+ text-decoration: none
+}
+
+.navbar-text {
+ margin-bottom: 0;
+ line-height: 40px
+}
+
+.navbar-link {
+ color: #777
+}
+
+.navbar-link:hover {
+ color: #333
+}
+
+.navbar .divider-vertical {
+ height: 40px;
+ margin: 0 9px;
+ border-right: 1px solid #fff;
+ border-left: 1px solid #f2f2f2
+}
+
+.navbar .btn, .navbar .btn-group {
+ margin-top: 5px
+}
+
+.navbar .btn-group .btn, .navbar .input-prepend .btn, .navbar .input-append .btn {
+ margin-top: 0
+}
+
+.navbar-form {
+ margin-bottom: 0;
+ *zoom: 1
+}
+
+.navbar-form:before, .navbar-form:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.navbar-form:after {
+ clear: both
+}
+
+.navbar-form input, .navbar-form select, .navbar-form .radio, .navbar-form .checkbox {
+ margin-top: 5px
+}
+
+.navbar-form input, .navbar-form select, .navbar-form .btn {
+ display: inline-block;
+ margin-bottom: 0
+}
+
+.navbar-form input[type="image"], .navbar-form input[type="checkbox"], .navbar-form input[type="radio"] {
+ margin-top: 3px
+}
+
+.navbar-form .input-append, .navbar-form .input-prepend {
+ margin-top: 6px;
+ white-space: nowrap
+}
+
+.navbar-form .input-append input, .navbar-form .input-prepend input {
+ margin-top: 0
+}
+
+.navbar-search {
+ position: relative;
+ float: left;
+ margin-top: 5px;
+ margin-bottom: 0
+}
+
+.navbar-search .search-query {
+ padding: 4px 14px;
+ margin-bottom: 0;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 13px;
+ font-weight: normal;
+ line-height: 1;
+ -webkit-border-radius: 15px;
+ -moz-border-radius: 15px;
+ border-radius: 15px
+}
+
+.navbar-static-top {
+ position: static;
+ width: 100%;
+ margin-bottom: 0
+}
+
+.navbar-static-top .navbar-inner {
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0
+}
+
+.navbar-fixed-top, .navbar-fixed-bottom {
+ position: fixed;
+ right: 0;
+ left: 0;
+ z-index: 1030;
+ margin-bottom: 0
+}
+
+.navbar-fixed-top .navbar-inner, .navbar-static-top .navbar-inner {
+ border-width: 0 0 1px
+}
+
+.navbar-fixed-bottom .navbar-inner {
+ border-width: 1px 0 0
+}
+
+.navbar-fixed-top .navbar-inner, .navbar-fixed-bottom .navbar-inner {
+ padding-right: 0;
+ padding-left: 0;
+ -webkit-border-radius: 0;
+ -moz-border-radius: 0;
+ border-radius: 0
+}
+
+.navbar-static-top .container, .navbar-fixed-top .container, .navbar-fixed-bottom .container {
+ width: 940px
+}
+
+.navbar-fixed-top {
+ top: 0
+}
+
+.navbar-fixed-top .navbar-inner, .navbar-static-top .navbar-inner {
+ -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.1);
+ -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.1);
+ box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.1)
+}
+
+.navbar-fixed-bottom {
+ bottom: 0
+}
+
+.navbar-fixed-bottom .navbar-inner {
+ -webkit-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), 0 -1px 10px rgba(0, 0, 0, 0.1);
+ -moz-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), 0 -1px 10px rgba(0, 0, 0, 0.1);
+ box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.1), 0 -1px 10px rgba(0, 0, 0, 0.1)
+}
+
+.navbar .nav {
+ position: relative;
+ left: 0;
+ display: block;
+ float: left;
+ margin: 0 10px 0 0
+}
+
+.navbar .nav.pull-right {
+ float: right;
+ margin-right: 0
+}
+
+.navbar .nav>li {
+ float: left
+}
+
+.navbar .nav>li>a {
+ float: none;
+ padding: 10px 15px 10px;
+ color: #777;
+ text-decoration: none;
+ text-shadow: 0 1px 0 #fff
+}
+
+.navbar .nav .dropdown-toggle .caret {
+ margin-top: 8px
+}
+
+.navbar .nav>li>a:focus, .navbar .nav>li>a:hover {
+ color: #333;
+ text-decoration: none;
+ background-color: transparent
+}
+
+.navbar .nav>.active>a, .navbar .nav>.active>a:hover, .navbar .nav>.active>a:focus {
+ color: #555;
+ text-decoration: none;
+ background-color: #e5e5e5;
+ -webkit-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
+ -moz-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
+ box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125)
+}
+
+.navbar .btn-navbar {
+ display: none;
+ float: right;
+ padding: 7px 10px;
+ margin-right: 5px;
+ margin-left: 5px;
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #ededed;
+ *background-color: #e5e5e5;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f2f2f2), to(#e5e5e5));
+ background-image: -webkit-linear-gradient(top, #f2f2f2, #e5e5e5);
+ background-image: -o-linear-gradient(top, #f2f2f2, #e5e5e5);
+ background-image: linear-gradient(to bottom, #f2f2f2, #e5e5e5);
+ background-image: -moz-linear-gradient(top, #f2f2f2, #e5e5e5);
+ background-repeat: repeat-x;
+ border-color: #e5e5e5 #e5e5e5 #bfbfbf;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffe5e5e5', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false);
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
+ -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075)
+}
+
+.navbar .btn-navbar:hover, .navbar .btn-navbar:active, .navbar .btn-navbar.active, .navbar .btn-navbar.disabled, .navbar .btn-navbar[disabled] {
+ color: #fff;
+ background-color: #e5e5e5;
+ *background-color: #d9d9d9
+}
+
+.navbar .btn-navbar:active, .navbar .btn-navbar.active {
+ background-color: #ccc \9
+}
+
+.navbar .btn-navbar .icon-bar {
+ display: block;
+ width: 18px;
+ height: 2px;
+ background-color: #f5f5f5;
+ -webkit-border-radius: 1px;
+ -moz-border-radius: 1px;
+ border-radius: 1px;
+ -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
+ -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
+ box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25)
+}
+
+.btn-navbar .icon-bar+.icon-bar {
+ margin-top: 3px
+}
+
+.navbar .nav>li>.dropdown-menu:before {
+ position: absolute;
+ top: -7px;
+ left: 9px;
+ display: inline-block;
+ border-right: 7px solid transparent;
+ border-bottom: 7px solid #ccc;
+ border-left: 7px solid transparent;
+ border-bottom-color: rgba(0, 0, 0, 0.2);
+ content: ''
+}
+
+.navbar .nav>li>.dropdown-menu:after {
+ position: absolute;
+ top: -6px;
+ left: 10px;
+ display: inline-block;
+ border-right: 6px solid transparent;
+ border-bottom: 6px solid #fff;
+ border-left: 6px solid transparent;
+ content: ''
+}
+
+.navbar-fixed-bottom .nav>li>.dropdown-menu:before {
+ top: auto;
+ bottom: -7px;
+ border-top: 7px solid #ccc;
+ border-bottom: 0;
+ border-top-color: rgba(0, 0, 0, 0.2)
+}
+
+.navbar-fixed-bottom .nav>li>.dropdown-menu:after {
+ top: auto;
+ bottom: -6px;
+ border-top: 6px solid #fff;
+ border-bottom: 0
+}
+
+.navbar .nav li.dropdown.open>.dropdown-toggle, .navbar .nav li.dropdown.active>.dropdown-toggle, .navbar .nav li.dropdown.open.active>.dropdown-toggle {
+ color: #555;
+ background-color: #e5e5e5
+}
+
+.navbar .nav li.dropdown>.dropdown-toggle .caret {
+ border-top-color: #777;
+ border-bottom-color: #777
+}
+
+.navbar .nav li.dropdown.open>.dropdown-toggle .caret, .navbar .nav li.dropdown.active>.dropdown-toggle .caret, .navbar .nav li.dropdown.open.active>.dropdown-toggle .caret {
+ border-top-color: #555;
+ border-bottom-color: #555
+}
+
+.navbar .pull-right>li>.dropdown-menu, .navbar .nav>li>.dropdown-menu.pull-right {
+ right: 0;
+ left: auto
+}
+
+.navbar .pull-right>li>.dropdown-menu:before, .navbar .nav>li>.dropdown-menu.pull-right:before {
+ right: 12px;
+ left: auto
+}
+
+.navbar .pull-right>li>.dropdown-menu:after, .navbar .nav>li>.dropdown-menu.pull-right:after {
+ right: 13px;
+ left: auto
+}
+
+.navbar .pull-right>li>.dropdown-menu .dropdown-menu, .navbar .nav>li>.dropdown-menu.pull-right .dropdown-menu {
+ right: 100%;
+ left: auto;
+ margin-right: -1px;
+ margin-left: 0;
+ -webkit-border-radius: 6px 0 6px 6px;
+ -moz-border-radius: 6px 0 6px 6px;
+ border-radius: 6px 0 6px 6px
+}
+
+.navbar-inverse {
+ color: #999
+}
+
+.navbar-inverse .navbar-inner {
+ background-color: #1b1b1b;
+ background-image: -moz-linear-gradient(top, #222, #111);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#222), to(#111));
+ background-image: -webkit-linear-gradient(top, #222, #111);
+ background-image: -o-linear-gradient(top, #222, #111);
+ background-image: linear-gradient(to bottom, #222, #111);
+ background-repeat: repeat-x;
+ border-color: #252525;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff222222', endColorstr='#ff111111', GradientType=0)
+}
+
+.navbar-inverse .brand, .navbar-inverse .nav>li>a {
+ color: #999;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25)
+}
+
+.navbar-inverse .brand:hover, .navbar-inverse .nav>li>a:hover {
+ color: #fff
+}
+
+.navbar-inverse .nav>li>a:focus, .navbar-inverse .nav>li>a:hover {
+ color: #fff;
+ background-color: transparent
+}
+
+.navbar-inverse .nav .active>a, .navbar-inverse .nav .active>a:hover, .navbar-inverse .nav .active>a:focus {
+ color: #fff;
+ background-color: #111
+}
+
+.navbar-inverse .navbar-link {
+ color: #999
+}
+
+.navbar-inverse .navbar-link:hover {
+ color: #fff
+}
+
+.navbar-inverse .divider-vertical {
+ border-right-color: #222;
+ border-left-color: #111
+}
+
+.navbar-inverse .nav li.dropdown.open>.dropdown-toggle, .navbar-inverse .nav li.dropdown.active>.dropdown-toggle, .navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle {
+ color: #fff;
+ background-color: #111
+}
+
+.navbar-inverse .nav li.dropdown>.dropdown-toggle .caret {
+ border-top-color: #999;
+ border-bottom-color: #999
+}
+
+.navbar-inverse .nav li.dropdown.open>.dropdown-toggle .caret, .navbar-inverse .nav li.dropdown.active>.dropdown-toggle .caret, .navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle .caret {
+ border-top-color: #fff;
+ border-bottom-color: #fff
+}
+
+.navbar-inverse .navbar-search .search-query {
+ color: #fff;
+ background-color: #515151;
+ border-color: #111;
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);
+ -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);
+ -webkit-transition: none;
+ -moz-transition: none;
+ -o-transition: none;
+ transition: none
+}
+
+.navbar-inverse .navbar-search .search-query:-moz-placeholder {
+ color: #ccc
+}
+
+.navbar-inverse .navbar-search .search-query:-ms-input-placeholder {
+ color: #ccc
+}
+
+.navbar-inverse .navbar-search .search-query::-webkit-input-placeholder {
+ color: #ccc
+}
+
+.navbar-inverse .navbar-search .search-query:focus, .navbar-inverse .navbar-search .search-query.focused {
+ padding: 5px 15px;
+ color: #333;
+ text-shadow: 0 1px 0 #fff;
+ background-color: #fff;
+ border: 0;
+ outline: 0;
+ -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
+ -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.15)
+}
+
+.navbar-inverse .btn-navbar {
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #0e0e0e;
+ *background-color: #040404;
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#151515), to(#040404));
+ background-image: -webkit-linear-gradient(top, #151515, #040404);
+ background-image: -o-linear-gradient(top, #151515, #040404);
+ background-image: linear-gradient(to bottom, #151515, #040404);
+ background-image: -moz-linear-gradient(top, #151515, #040404);
+ background-repeat: repeat-x;
+ border-color: #040404 #040404 #000;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff151515', endColorstr='#ff040404', GradientType=0);
+ filter: progid:dximagetransform.microsoft.gradient(enabled=false)
+}
+
+.navbar-inverse .btn-navbar:hover, .navbar-inverse .btn-navbar:active, .navbar-inverse .btn-navbar.active, .navbar-inverse .btn-navbar.disabled, .navbar-inverse .btn-navbar[disabled] {
+ color: #fff;
+ background-color: #040404;
+ *background-color: #000
+}
+
+.navbar-inverse .btn-navbar:active, .navbar-inverse .btn-navbar.active {
+ background-color: #000 \9
+}
+
+.breadcrumb {
+ padding: 8px 15px;
+ margin: 0 0 20px;
+ list-style: none;
+ background-color: #f5f5f5;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px
+}
+
+.breadcrumb li {
+ display: inline-block;
+ *display: inline;
+ text-shadow: 0 1px 0 #fff;
+ *zoom: 1
+}
+
+.breadcrumb .divider {
+ padding: 0 5px;
+ color: #ccc
+}
+
+.breadcrumb .active {
+ color: #999
+}
+
+.pagination {
+ height: 40px;
+ margin: 20px 0
+}
+
+.pagination ul {
+ display: inline-block;
+ *display: inline;
+ margin-bottom: 0;
+ margin-left: 0;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+ *zoom: 1;
+ -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05)
+}
+
+.pagination ul>li {
+ display: inline
+}
+
+.pagination ul>li>a, .pagination ul>li>span {
+ float: left;
+ padding: 0 14px;
+ line-height: 38px;
+ text-decoration: none;
+ background-color: #fff;
+ border: 1px solid #ddd;
+ border-left-width: 0
+}
+
+.pagination ul>li>a:hover, .pagination ul>.active>a, .pagination ul>.active>span {
+ background-color: #f5f5f5
+}
+
+.pagination ul>.active>a, .pagination ul>.active>span {
+ color: #999;
+ cursor: default
+}
+
+.pagination ul>.disabled>span, .pagination ul>.disabled>a, .pagination ul>.disabled>a:hover {
+ color: #999;
+ cursor: default;
+ background-color: transparent
+}
+
+.pagination ul>li:first-child>a, .pagination ul>li:first-child>span {
+ border-left-width: 1px;
+ -webkit-border-radius: 3px 0 0 3px;
+ -moz-border-radius: 3px 0 0 3px;
+ border-radius: 3px 0 0 3px
+}
+
+.pagination ul>li:last-child>a, .pagination ul>li:last-child>span {
+ -webkit-border-radius: 0 3px 3px 0;
+ -moz-border-radius: 0 3px 3px 0;
+ border-radius: 0 3px 3px 0
+}
+
+.pagination-centered {
+ text-align: center
+}
+
+.pagination-right {
+ text-align: right
+}
+
+.pager {
+ margin: 20px 0;
+ text-align: center;
+ list-style: none;
+ *zoom: 1
+}
+
+.pager:before, .pager:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.pager:after {
+ clear: both
+}
+
+.pager li {
+ display: inline
+}
+
+.pager a, .pager span {
+ display: inline-block;
+ padding: 5px 14px;
+ background-color: #fff;
+ border: 1px solid #ddd;
+ -webkit-border-radius: 15px;
+ -moz-border-radius: 15px;
+ border-radius: 15px
+}
+
+.pager a:hover {
+ text-decoration: none;
+ background-color: #f5f5f5
+}
+
+.pager .next a, .pager .next span {
+ float: right
+}
+
+.pager .previous a {
+ float: left
+}
+
+.pager .disabled a, .pager .disabled a:hover, .pager .disabled span {
+ color: #999;
+ cursor: default;
+ background-color: #fff
+}
+
+.modal-open .modal .dropdown-menu {
+ z-index: 2050
+}
+
+.modal-open .modal .dropdown.open {
+ *z-index: 2050
+}
+
+.modal-open .modal .popover {
+ z-index: 2060
+}
+
+.modal-open .modal .tooltip {
+ z-index: 2080
+}
+
+.modal-backdrop {
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ z-index: 1040;
+ background-color: #000
+}
+
+.modal-backdrop.fade {
+ opacity: 0
+}
+
+.modal-backdrop, .modal-backdrop.fade.in {
+ opacity: .8;
+ filter: alpha(opacity=80)
+}
+
+.modal {
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ z-index: 1050;
+ width: 560px;
+ margin: -250px 0 0 -280px;
+ overflow: auto;
+ background-color: #fff;
+ border: 1px solid #999;
+ border: 1px solid rgba(0, 0, 0, 0.3);
+ *border: 1px solid #999;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+ -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+ -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+ box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+ -webkit-background-clip: padding-box;
+ -moz-background-clip: padding-box;
+ background-clip: padding-box
+}
+
+.modal.fade {
+ top: -25%;
+ -webkit-transition: opacity .3s linear, top .3s ease-out;
+ -moz-transition: opacity .3s linear, top .3s ease-out;
+ -o-transition: opacity .3s linear, top .3s ease-out;
+ transition: opacity .3s linear, top .3s ease-out
+}
+
+.modal.fade.in {
+ top: 50%
+}
+
+.modal-header {
+ padding: 9px 15px;
+ border-bottom: 1px solid #eee
+}
+
+.modal-header .close {
+ margin-top: 2px
+}
+
+.modal-header h3 {
+ margin: 0;
+ line-height: 30px
+}
+
+.modal-body {
+ max-height: 400px;
+ padding: 15px;
+ overflow-y: auto
+}
+
+.modal-form {
+ margin-bottom: 0
+}
+
+.modal-footer {
+ padding: 14px 15px 15px;
+ margin-bottom: 0;
+ text-align: right;
+ background-color: #f5f5f5;
+ border-top: 1px solid #ddd;
+ -webkit-border-radius: 0 0 6px 6px;
+ -moz-border-radius: 0 0 6px 6px;
+ border-radius: 0 0 6px 6px;
+ *zoom: 1;
+ -webkit-box-shadow: inset 0 1px 0 #fff;
+ -moz-box-shadow: inset 0 1px 0 #fff;
+ box-shadow: inset 0 1px 0 #fff
+}
+
+.modal-footer:before, .modal-footer:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.modal-footer:after {
+ clear: both
+}
+
+.modal-footer .btn+.btn {
+ margin-bottom: 0;
+ margin-left: 5px
+}
+
+.modal-footer .btn-group .btn+.btn {
+ margin-left: -1px
+}
+
+.tooltip {
+ position: absolute;
+ z-index: 1030;
+ display: block;
+ padding: 5px;
+ font-size: 11px;
+ opacity: 0;
+ filter: alpha(opacity=0);
+ visibility: visible
+}
+
+.tooltip.in {
+ opacity: .8;
+ filter: alpha(opacity=80)
+}
+
+.tooltip.top {
+ margin-top: -3px
+}
+
+.tooltip.right {
+ margin-left: 3px
+}
+
+.tooltip.bottom {
+ margin-top: 3px
+}
+
+.tooltip.left {
+ margin-left: -3px
+}
+
+.tooltip-inner {
+ max-width: 200px;
+ padding: 3px 8px;
+ color: #fff;
+ text-align: center;
+ text-decoration: none;
+ background-color: #000;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px
+}
+
+.tooltip-arrow {
+ position: absolute;
+ width: 0;
+ height: 0;
+ border-color: transparent;
+ border-style: solid
+}
+
+.tooltip.top .tooltip-arrow {
+ bottom: 0;
+ left: 50%;
+ margin-left: -5px;
+ border-top-color: #000;
+ border-width: 5px 5px 0
+}
+
+.tooltip.right .tooltip-arrow {
+ top: 50%;
+ left: 0;
+ margin-top: -5px;
+ border-right-color: #000;
+ border-width: 5px 5px 5px 0
+}
+
+.tooltip.left .tooltip-arrow {
+ top: 50%;
+ right: 0;
+ margin-top: -5px;
+ border-left-color: #000;
+ border-width: 5px 0 5px 5px
+}
+
+.tooltip.bottom .tooltip-arrow {
+ top: 0;
+ left: 50%;
+ margin-left: -5px;
+ border-bottom-color: #000;
+ border-width: 0 5px 5px
+}
+
+.popover {
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 1010;
+ display: none;
+ width: 236px;
+ padding: 1px;
+ background-color: #fff;
+ border: 1px solid #ccc;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+ -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ -webkit-background-clip: padding-box;
+ -moz-background-clip: padding;
+ background-clip: padding-box
+}
+
+.popover.top {
+ margin-bottom: 10px
+}
+
+.popover.right {
+ margin-left: 10px
+}
+
+.popover.bottom {
+ margin-top: 10px
+}
+
+.popover.left {
+ margin-right: 10px
+}
+
+.popover-title {
+ padding: 8px 14px;
+ margin: 0;
+ font-size: 14px;
+ font-weight: normal;
+ line-height: 18px;
+ background-color: #f7f7f7;
+ border-bottom: 1px solid #ebebeb;
+ -webkit-border-radius: 5px 5px 0 0;
+ -moz-border-radius: 5px 5px 0 0;
+ border-radius: 5px 5px 0 0
+}
+
+.popover-content {
+ padding: 9px 14px
+}
+
+.popover-content p, .popover-content ul, .popover-content ol {
+ margin-bottom: 0
+}
+
+.popover .arrow, .popover .arrow:after {
+ position: absolute;
+ display: inline-block;
+ width: 0;
+ height: 0;
+ border-color: transparent;
+ border-style: solid
+}
+
+.popover .arrow:after {
+ z-index: -1;
+ content: ""
+}
+
+.popover.top .arrow {
+ bottom: -10px;
+ left: 50%;
+ margin-left: -10px;
+ border-top-color: #fff;
+ border-width: 10px 10px 0
+}
+
+.popover.top .arrow:after {
+ bottom: -1px;
+ left: -11px;
+ border-top-color: rgba(0, 0, 0, 0.25);
+ border-width: 11px 11px 0
+}
+
+.popover.right .arrow {
+ top: 50%;
+ left: -10px;
+ margin-top: -10px;
+ border-right-color: #fff;
+ border-width: 10px 10px 10px 0
+}
+
+.popover.right .arrow:after {
+ bottom: -11px;
+ left: -1px;
+ border-right-color: rgba(0, 0, 0, 0.25);
+ border-width: 11px 11px 11px 0
+}
+
+.popover.bottom .arrow {
+ top: -10px;
+ left: 50%;
+ margin-left: -10px;
+ border-bottom-color: #fff;
+ border-width: 0 10px 10px
+}
+
+.popover.bottom .arrow:after {
+ top: -1px;
+ left: -11px;
+ border-bottom-color: rgba(0, 0, 0, 0.25);
+ border-width: 0 11px 11px
+}
+
+.popover.left .arrow {
+ top: 50%;
+ right: -10px;
+ margin-top: -10px;
+ border-left-color: #fff;
+ border-width: 10px 0 10px 10px
+}
+
+.popover.left .arrow:after {
+ right: -1px;
+ bottom: -11px;
+ border-left-color: rgba(0, 0, 0, 0.25);
+ border-width: 11px 0 11px 11px
+}
+
+.thumbnails {
+ margin-left: -20px;
+ list-style: none;
+ *zoom: 1
+}
+
+.thumbnails:before, .thumbnails:after {
+ display: table;
+ line-height: 0;
+ content: ""
+}
+
+.thumbnails:after {
+ clear: both
+}
+
+.row-fluid .thumbnails {
+ margin-left: 0
+}
+
+.thumbnails>li {
+ float: left;
+ margin-bottom: 20px;
+ margin-left: 20px
+}
+
+.thumbnail {
+ display: block;
+ padding: 4px;
+ line-height: 20px;
+ border: 1px solid #ddd;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055);
+ -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.055);
+ -webkit-transition: all .2s ease-in-out;
+ -moz-transition: all .2s ease-in-out;
+ -o-transition: all .2s ease-in-out;
+ transition: all .2s ease-in-out
+}
+
+a.thumbnail:hover {
+ border-color: #08c;
+ -webkit-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
+ -moz-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
+ box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25)
+}
+
+.thumbnail>img {
+ display: block;
+ max-width: 100%;
+ margin-right: auto;
+ margin-left: auto
+}
+
+.thumbnail .caption {
+ padding: 9px;
+ color: #555
+}
+
+.label, .badge {
+ font-size: 11.844px;
+ font-weight: bold;
+ line-height: 14px;
+ color: #fff;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ white-space: nowrap;
+ vertical-align: baseline;
+ background-color: #999
+}
+
+.label {
+ padding: 1px 4px 2px;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px
+}
+
+.badge {
+ padding: 1px 9px 2px;
+ -webkit-border-radius: 9px;
+ -moz-border-radius: 9px;
+ border-radius: 9px
+}
+
+a.label:hover, a.badge:hover {
+ color: #fff;
+ text-decoration: none;
+ cursor: pointer
+}
+
+.label-important, .badge-important {
+ background-color: #b94a48
+}
+
+.label-important[href], .badge-important[href] {
+ background-color: #953b39
+}
+
+.label-warning, .badge-warning {
+ background-color: #f89406
+}
+
+.label-warning[href], .badge-warning[href] {
+ background-color: #c67605
+}
+
+.label-success, .badge-success {
+ background-color: #468847
+}
+
+.label-success[href], .badge-success[href] {
+ background-color: #356635
+}
+
+.label-info, .badge-info {
+ background-color: #3a87ad
+}
+
+.label-info[href], .badge-info[href] {
+ background-color: #2d6987
+}
+
+.label-inverse, .badge-inverse {
+ background-color: #333
+}
+
+.label-inverse[href], .badge-inverse[href] {
+ background-color: #1a1a1a
+}
+
+.btn .label, .btn .badge {
+ position: relative;
+ top: -1px
+}
+
+.btn-mini .label, .btn-mini .badge {
+ top: 0
+}
+
+@-webkit-keyframes progress-bar-stripes {
+ from {
+ background-position: 40px 0
+ }
+ to {
+ background-position: 0 0
+ }
+}
+
+@-moz-keyframes progress-bar-stripes {
+ from {
+ background-position: 40px 0
+ }
+ to {
+ background-position: 0 0
+ }
+}
+
+@-ms-keyframes progress-bar-stripes {
+ from {
+ background-position: 40px 0
+ }
+ to {
+ background-position: 0 0
+ }
+}
+
+@-o-keyframes progress-bar-stripes {
+ from {
+ background-position: 0 0
+ }
+ to {
+ background-position: 40px 0
+ }
+}
+
+@keyframes progress-bar-stripes {
+ from {
+ background-position: 40px 0
+ }
+ to {
+ background-position: 0 0
+ }
+}
+
+.progress {
+ height: 20px;
+ margin-bottom: 20px;
+ overflow: hidden;
+ background-color: #f7f7f7;
+ background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));
+ background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9);
+ background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9);
+ background-image: linear-gradient(to bottom, #f5f5f5, #f9f9f9);
+ background-repeat: repeat-x;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0);
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
+ -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1)
+}
+
+.progress .bar {
+ float: left;
+ width: 0;
+ height: 100%;
+ font-size: 12px;
+ color: #fff;
+ text-align: center;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ background-color: #0e90d2;
+ background-image: -moz-linear-gradient(top, #149bdf, #0480be);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be));
+ background-image: -webkit-linear-gradient(top, #149bdf, #0480be);
+ background-image: -o-linear-gradient(top, #149bdf, #0480be);
+ background-image: linear-gradient(to bottom, #149bdf, #0480be);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff149bdf', endColorstr='#ff0480be', GradientType=0);
+ -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ -webkit-transition: width .6s ease;
+ -moz-transition: width .6s ease;
+ -o-transition: width .6s ease;
+ transition: width .6s ease
+}
+
+.progress .bar+.bar {
+ -webkit-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ -moz-box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
+ box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15)
+}
+
+.progress-striped .bar {
+ background-color: #149bdf;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ -webkit-background-size: 40px 40px;
+ -moz-background-size: 40px 40px;
+ -o-background-size: 40px 40px;
+ background-size: 40px 40px
+}
+
+.progress.active .bar {
+ -webkit-animation: progress-bar-stripes 2s linear infinite;
+ -moz-animation: progress-bar-stripes 2s linear infinite;
+ -ms-animation: progress-bar-stripes 2s linear infinite;
+ -o-animation: progress-bar-stripes 2s linear infinite;
+ animation: progress-bar-stripes 2s linear infinite
+}
+
+.progress-danger .bar, .progress .bar-danger {
+ background-color: #dd514c;
+ background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35));
+ background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35);
+ background-image: -o-linear-gradient(top, #ee5f5b, #c43c35);
+ background-image: linear-gradient(to bottom, #ee5f5b, #c43c35);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffee5f5b', endColorstr='#ffc43c35', GradientType=0)
+}
+
+.progress-danger.progress-striped .bar, .progress-striped .bar-danger {
+ background-color: #ee5f5b;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent)
+}
+
+.progress-success .bar, .progress .bar-success {
+ background-color: #5eb95e;
+ background-image: -moz-linear-gradient(top, #62c462, #57a957);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957));
+ background-image: -webkit-linear-gradient(top, #62c462, #57a957);
+ background-image: -o-linear-gradient(top, #62c462, #57a957);
+ background-image: linear-gradient(to bottom, #62c462, #57a957);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff62c462', endColorstr='#ff57a957', GradientType=0)
+}
+
+.progress-success.progress-striped .bar, .progress-striped .bar-success {
+ background-color: #62c462;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent)
+}
+
+.progress-info .bar, .progress .bar-info {
+ background-color: #4bb1cf;
+ background-image: -moz-linear-gradient(top, #5bc0de, #339bb9);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9));
+ background-image: -webkit-linear-gradient(top, #5bc0de, #339bb9);
+ background-image: -o-linear-gradient(top, #5bc0de, #339bb9);
+ background-image: linear-gradient(to bottom, #5bc0de, #339bb9);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff339bb9', GradientType=0)
+}
+
+.progress-info.progress-striped .bar, .progress-striped .bar-info {
+ background-color: #5bc0de;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent)
+}
+
+.progress-warning .bar, .progress .bar-warning {
+ background-color: #faa732;
+ background-image: -moz-linear-gradient(top, #fbb450, #f89406);
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
+ background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
+ background-image: -o-linear-gradient(top, #fbb450, #f89406);
+ background-image: linear-gradient(to bottom, #fbb450, #f89406);
+ background-repeat: repeat-x;
+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0)
+}
+
+.progress-warning.progress-striped .bar, .progress-striped .bar-warning {
+ background-color: #fbb450;
+ background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
+ background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+ background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent)
+}
+
+.accordion {
+ margin-bottom: 20px
+}
+
+.accordion-group {
+ margin-bottom: 2px;
+ border: 1px solid #e5e5e5;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px
+}
+
+.accordion-heading {
+ border-bottom: 0
+}
+
+.accordion-heading .accordion-toggle {
+ display: block;
+ padding: 8px 15px
+}
+
+.accordion-toggle {
+ cursor: pointer
+}
+
+.accordion-inner {
+ padding: 9px 15px;
+ border-top: 1px solid #e5e5e5
+}
+
+.carousel {
+ position: relative;
+ margin-bottom: 20px;
+ line-height: 1
+}
+
+.carousel-inner {
+ position: relative;
+ width: 100%;
+ overflow: hidden
+}
+
+.carousel .item {
+ position: relative;
+ display: none;
+ -webkit-transition: .6s ease-in-out left;
+ -moz-transition: .6s ease-in-out left;
+ -o-transition: .6s ease-in-out left;
+ transition: .6s ease-in-out left
+}
+
+.carousel .item>img {
+ display: block;
+ line-height: 1
+}
+
+.carousel .active, .carousel .next, .carousel .prev {
+ display: block
+}
+
+.carousel .active {
+ left: 0
+}
+
+.carousel .next, .carousel .prev {
+ position: absolute;
+ top: 0;
+ width: 100%
+}
+
+.carousel .next {
+ left: 100%
+}
+
+.carousel .prev {
+ left: -100%
+}
+
+.carousel .next.left, .carousel .prev.right {
+ left: 0
+}
+
+.carousel .active.left {
+ left: -100%
+}
+
+.carousel .active.right {
+ left: 100%
+}
+
+.carousel-control {
+ position: absolute;
+ top: 40%;
+ left: 15px;
+ width: 40px;
+ height: 40px;
+ margin-top: -20px;
+ font-size: 60px;
+ font-weight: 100;
+ line-height: 30px;
+ color: #fff;
+ text-align: center;
+ background: #222;
+ border: 3px solid #fff;
+ -webkit-border-radius: 23px;
+ -moz-border-radius: 23px;
+ border-radius: 23px;
+ opacity: .5;
+ filter: alpha(opacity=50)
+}
+
+.carousel-control.right {
+ right: 15px;
+ left: auto
+}
+
+.carousel-control:hover {
+ color: #fff;
+ text-decoration: none;
+ opacity: .9;
+ filter: alpha(opacity=90)
+}
+
+.carousel-caption {
+ position: absolute;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ padding: 15px;
+ background: #333;
+ background: rgba(0, 0, 0, 0.75)
+}
+
+.carousel-caption h4, .carousel-caption p {
+ line-height: 20px;
+ color: #fff
+}
+
+.carousel-caption h4 {
+ margin: 0 0 5px
+}
+
+.carousel-caption p {
+ margin-bottom: 0
+}
+
+.hero-unit {
+ padding: 60px;
+ margin-bottom: 30px;
+ background-color: #eee;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px
+}
+
+.hero-unit h1 {
+ margin-bottom: 0;
+ font-size: 60px;
+ line-height: 1;
+ letter-spacing: -1px;
+ color: inherit
+}
+
+.hero-unit p {
+ font-size: 18px;
+ font-weight: 200;
+ line-height: 30px;
+ color: inherit
+}
+
+.pull-right {
+ float: right
+}
+
+.pull-left {
+ float: left
+}
+
+.hide {
+ display: none
+}
+
+.show {
+ display: block
+}
+
+.invisible {
+ visibility: hidden
+}
+
+.affix {
+ position: fixed
+}
diff --git a/content/examples/moviefun/src/main/webapp/assets/css/movie.css b/content/examples/moviefun/src/main/webapp/assets/css/movie.css
new file mode 100755
index 0000000..51293d8
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/assets/css/movie.css
@@ -0,0 +1,24 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.movie-input-form {
+ padding: 20px;
+ background-color: #EEE;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+}
diff --git a/content/examples/moviefun/src/main/webapp/assets/img/glyphicons-halflings-white.png b/content/examples/moviefun/src/main/webapp/assets/img/glyphicons-halflings-white.png
new file mode 100755
index 0000000..3bf6484
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/assets/img/glyphicons-halflings-white.png
Binary files differ
diff --git a/content/examples/moviefun/src/main/webapp/assets/img/glyphicons-halflings.png b/content/examples/moviefun/src/main/webapp/assets/img/glyphicons-halflings.png
new file mode 100755
index 0000000..a996999
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/assets/img/glyphicons-halflings.png
Binary files differ
diff --git a/content/examples/moviefun/src/main/webapp/assets/js/bootstrap.js b/content/examples/moviefun/src/main/webapp/assets/js/bootstrap.js
new file mode 100755
index 0000000..5998e90
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/assets/js/bootstrap.js
@@ -0,0 +1,1885 @@
+/* ===================================================
+ * bootstrap-transition.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#transitions
+ * ===================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function ($) {
+
+ $(function () {
+
+ "use strict"; // jshint ;_;
+
+
+ /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
+ * ======================================================= */
+
+ $.support.transition = (function () {
+
+ var transitionEnd = (function () {
+
+ var el = document.createElement('bootstrap')
+ , transEndEventNames = {
+ 'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd otransitionend', 'transition': 'transitionend'
+ }
+ , name
+
+ for (name in transEndEventNames) {
+ if (el.style[name] !== undefined) {
+ return transEndEventNames[name]
+ }
+ }
+
+ }())
+
+ return transitionEnd && {
+ end: transitionEnd
+ }
+
+ })()
+
+ })
+
+}(window.jQuery);
+/* ==========================================================
+ * bootstrap-alert.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#alerts
+ * ==========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* ALERT CLASS DEFINITION
+ * ====================== */
+
+ var dismiss = '[data-dismiss="alert"]'
+ , Alert = function (el) {
+ $(el).on('click', dismiss, this.close)
+ }
+
+ Alert.prototype.close = function (e) {
+ var $this = $(this)
+ , selector = $this.attr('data-target')
+ , $parent
+
+ if (!selector) {
+ selector = $this.attr('href')
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
+ }
+
+ $parent = $(selector)
+
+ e && e.preventDefault()
+
+ $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
+
+ $parent.trigger(e = $.Event('close'))
+
+ if (e.isDefaultPrevented()) return
+
+ $parent.removeClass('in')
+
+ function removeElement() {
+ $parent
+ .trigger('closed')
+ .remove()
+ }
+
+ $.support.transition && $parent.hasClass('fade') ?
+ $parent.on($.support.transition.end, removeElement) :
+ removeElement()
+ }
+
+
+ /* ALERT PLUGIN DEFINITION
+ * ======================= */
+
+ $.fn.alert = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('alert')
+ if (!data) $this.data('alert', (data = new Alert(this)))
+ if (typeof option == 'string') data[option].call($this)
+ })
+ }
+
+ $.fn.alert.Constructor = Alert
+
+
+ /* ALERT DATA-API
+ * ============== */
+
+ $(function () {
+ $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
+ })
+
+}(window.jQuery);
+/* ============================================================
+ * bootstrap-button.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#buttons
+ * ============================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================================================ */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* BUTTON PUBLIC CLASS DEFINITION
+ * ============================== */
+
+ var Button = function (element, options) {
+ this.$element = $(element)
+ this.options = $.extend({}, $.fn.button.defaults, options)
+ }
+
+ Button.prototype.setState = function (state) {
+ var d = 'disabled'
+ , $el = this.$element
+ , data = $el.data()
+ , val = $el.is('input') ? 'val' : 'html'
+
+ state = state + 'Text'
+ data.resetText || $el.data('resetText', $el[val]())
+
+ $el[val](data[state] || this.options[state])
+
+ // push to event loop to allow forms to submit
+ setTimeout(function () {
+ state == 'loadingText' ?
+ $el.addClass(d).attr(d, d) :
+ $el.removeClass(d).removeAttr(d)
+ }, 0)
+ }
+
+ Button.prototype.toggle = function () {
+ var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
+
+ $parent && $parent
+ .find('.active')
+ .removeClass('active')
+
+ this.$element.toggleClass('active')
+ }
+
+
+ /* BUTTON PLUGIN DEFINITION
+ * ======================== */
+
+ $.fn.button = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('button')
+ , options = typeof option == 'object' && option
+ if (!data) $this.data('button', (data = new Button(this, options)))
+ if (option == 'toggle') data.toggle()
+ else if (option) data.setState(option)
+ })
+ }
+
+ $.fn.button.defaults = {
+ loadingText: 'loading...'
+ }
+
+ $.fn.button.Constructor = Button
+
+
+ /* BUTTON DATA-API
+ * =============== */
+
+ $(function () {
+ $('body').on('click.button.data-api', '[data-toggle^=button]', function (e) {
+ var $btn = $(e.target)
+ if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
+ $btn.button('toggle')
+ })
+ })
+
+}(window.jQuery);
+/* ==========================================================
+ * bootstrap-carousel.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#carousel
+ * ==========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* CAROUSEL CLASS DEFINITION
+ * ========================= */
+
+ var Carousel = function (element, options) {
+ this.$element = $(element)
+ this.options = options
+ this.options.slide && this.slide(this.options.slide)
+ this.options.pause == 'hover' && this.$element
+ .on('mouseenter', $.proxy(this.pause, this))
+ .on('mouseleave', $.proxy(this.cycle, this))
+ }
+
+ Carousel.prototype = {
+
+ cycle: function (e) {
+ if (!e) this.paused = false
+ this.options.interval
+ && !this.paused
+ && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
+ return this
+ }, to: function (pos) {
+ var $active = this.$element.find('.item.active')
+ , children = $active.parent().children()
+ , activePos = children.index($active)
+ , that = this
+
+ if (pos > (children.length - 1) || pos < 0) return
+
+ if (this.sliding) {
+ return this.$element.one('slid', function () {
+ that.to(pos)
+ })
+ }
+
+ if (activePos == pos) {
+ return this.pause().cycle()
+ }
+
+ return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
+ }, pause: function (e) {
+ if (!e) this.paused = true
+ if (this.$element.find('.next, .prev').length && $.support.transition.end) {
+ this.$element.trigger($.support.transition.end)
+ this.cycle()
+ }
+ clearInterval(this.interval)
+ this.interval = null
+ return this
+ }, next: function () {
+ if (this.sliding) return
+ return this.slide('next')
+ }, prev: function () {
+ if (this.sliding) return
+ return this.slide('prev')
+ }, slide: function (type, next) {
+ var $active = this.$element.find('.item.active')
+ , $next = next || $active[type]()
+ , isCycling = this.interval
+ , direction = type == 'next' ? 'left' : 'right'
+ , fallback = type == 'next' ? 'first' : 'last'
+ , that = this
+ , e = $.Event('slide', {
+ relatedTarget: $next[0]
+ })
+
+ this.sliding = true
+
+ isCycling && this.pause()
+
+ $next = $next.length ? $next : this.$element.find('.item')[fallback]()
+
+ if ($next.hasClass('active')) return
+
+ if ($.support.transition && this.$element.hasClass('slide')) {
+ this.$element.trigger(e)
+ if (e.isDefaultPrevented()) return
+ $next.addClass(type)
+ $next[0].offsetWidth // force reflow
+ $active.addClass(direction)
+ $next.addClass(direction)
+ this.$element.one($.support.transition.end, function () {
+ $next.removeClass([type, direction].join(' ')).addClass('active')
+ $active.removeClass(['active', direction].join(' '))
+ that.sliding = false
+ setTimeout(function () {
+ that.$element.trigger('slid')
+ }, 0)
+ })
+ } else {
+ this.$element.trigger(e)
+ if (e.isDefaultPrevented()) return
+ $active.removeClass('active')
+ $next.addClass('active')
+ this.sliding = false
+ this.$element.trigger('slid')
+ }
+
+ isCycling && this.cycle()
+
+ return this
+ }
+
+ }
+
+
+ /* CAROUSEL PLUGIN DEFINITION
+ * ========================== */
+
+ $.fn.carousel = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('carousel')
+ , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
+ , action = typeof option == 'string' ? option : options.slide
+ if (!data) $this.data('carousel', (data = new Carousel(this, options)))
+ if (typeof option == 'number') data.to(option)
+ else if (action) data[action]()
+ else if (options.interval) data.cycle()
+ })
+ }
+
+ $.fn.carousel.defaults = {
+ interval: 5000, pause: 'hover'
+ }
+
+ $.fn.carousel.Constructor = Carousel
+
+
+ /* CAROUSEL DATA-API
+ * ================= */
+
+ $(function () {
+ $('body').on('click.carousel.data-api', '[data-slide]', function (e) {
+ var $this = $(this), href
+ , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
+ , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
+ $target.carousel(options)
+ e.preventDefault()
+ })
+ })
+
+}(window.jQuery);
+/* =============================================================
+ * bootstrap-collapse.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#collapse
+ * =============================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================================================ */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* COLLAPSE PUBLIC CLASS DEFINITION
+ * ================================ */
+
+ var Collapse = function (element, options) {
+ this.$element = $(element)
+ this.options = $.extend({}, $.fn.collapse.defaults, options)
+
+ if (this.options.parent) {
+ this.$parent = $(this.options.parent)
+ }
+
+ this.options.toggle && this.toggle()
+ }
+
+ Collapse.prototype = {
+
+ constructor: Collapse, dimension: function () {
+ var hasWidth = this.$element.hasClass('width')
+ return hasWidth ? 'width' : 'height'
+ }, show: function () {
+ var dimension
+ , scroll
+ , actives
+ , hasData
+
+ if (this.transitioning) return
+
+ dimension = this.dimension()
+ scroll = $.camelCase(['scroll', dimension].join('-'))
+ actives = this.$parent && this.$parent.find('> .accordion-group > .in')
+
+ if (actives && actives.length) {
+ hasData = actives.data('collapse')
+ if (hasData && hasData.transitioning) return
+ actives.collapse('hide')
+ hasData || actives.data('collapse', null)
+ }
+
+ this.$element[dimension](0)
+ this.transition('addClass', $.Event('show'), 'shown')
+ $.support.transition && this.$element[dimension](this.$element[0][scroll])
+ }, hide: function () {
+ var dimension
+ if (this.transitioning) return
+ dimension = this.dimension()
+ this.reset(this.$element[dimension]())
+ this.transition('removeClass', $.Event('hide'), 'hidden')
+ this.$element[dimension](0)
+ }, reset: function (size) {
+ var dimension = this.dimension()
+
+ this.$element
+ .removeClass('collapse')
+ [dimension](size || 'auto')
+ [0].offsetWidth
+
+ this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
+
+ return this
+ }, transition: function (method, startEvent, completeEvent) {
+ var that = this
+ , complete = function () {
+ if (startEvent.type == 'show') that.reset()
+ that.transitioning = 0
+ that.$element.trigger(completeEvent)
+ }
+
+ this.$element.trigger(startEvent)
+
+ if (startEvent.isDefaultPrevented()) return
+
+ this.transitioning = 1
+
+ this.$element[method]('in')
+
+ $.support.transition && this.$element.hasClass('collapse') ?
+ this.$element.one($.support.transition.end, complete) :
+ complete()
+ }, toggle: function () {
+ this[this.$element.hasClass('in') ? 'hide' : 'show']()
+ }
+
+ }
+
+
+ /* COLLAPSIBLE PLUGIN DEFINITION
+ * ============================== */
+
+ $.fn.collapse = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('collapse')
+ , options = typeof option == 'object' && option
+ if (!data) $this.data('collapse', (data = new Collapse(this, options)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.collapse.defaults = {
+ toggle: true
+ }
+
+ $.fn.collapse.Constructor = Collapse
+
+
+ /* COLLAPSIBLE DATA-API
+ * ==================== */
+
+ $(function () {
+ $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
+ var $this = $(this), href
+ , target = $this.attr('data-target')
+ || e.preventDefault()
+ || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
+ , option = $(target).data('collapse') ? 'toggle' : $this.data()
+ $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
+ $(target).collapse(option)
+ })
+ })
+
+}(window.jQuery);
+/* ============================================================
+ * bootstrap-dropdown.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#dropdowns
+ * ============================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================================================ */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* DROPDOWN CLASS DEFINITION
+ * ========================= */
+
+ var toggle = '[data-toggle=dropdown]'
+ , Dropdown = function (element) {
+ var $el = $(element).on('click.dropdown.data-api', this.toggle)
+ $('html').on('click.dropdown.data-api', function () {
+ $el.parent().removeClass('open')
+ })
+ }
+
+ Dropdown.prototype = {
+
+ constructor: Dropdown, toggle: function (e) {
+ var $this = $(this)
+ , $parent
+ , isActive
+
+ if ($this.is('.disabled, :disabled')) return
+
+ $parent = getParent($this)
+
+ isActive = $parent.hasClass('open')
+
+ clearMenus()
+
+ if (!isActive) {
+ $parent.toggleClass('open')
+ $this.focus()
+ }
+
+ return false
+ }, keydown: function (e) {
+ var $this
+ , $items
+ , $active
+ , $parent
+ , isActive
+ , index
+
+ if (!/(38|40|27)/.test(e.keyCode)) return
+
+ $this = $(this)
+
+ e.preventDefault()
+ e.stopPropagation()
+
+ if ($this.is('.disabled, :disabled')) return
+
+ $parent = getParent($this)
+
+ isActive = $parent.hasClass('open')
+
+ if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
+
+ $items = $('[role=menu] li:not(.divider) a', $parent)
+
+ if (!$items.length) return
+
+ index = $items.index($items.filter(':focus'))
+
+ if (e.keyCode == 38 && index > 0) index-- // up
+ if (e.keyCode == 40 && index < $items.length - 1) index++ // down
+ if (!~index) index = 0
+
+ $items
+ .eq(index)
+ .focus()
+ }
+
+ }
+
+ function clearMenus() {
+ getParent($(toggle))
+ .removeClass('open')
+ }
+
+ function getParent($this) {
+ var selector = $this.attr('data-target')
+ , $parent
+
+ if (!selector) {
+ selector = $this.attr('href')
+ selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
+ }
+
+ $parent = $(selector)
+ $parent.length || ($parent = $this.parent())
+
+ return $parent
+ }
+
+
+ /* DROPDOWN PLUGIN DEFINITION
+ * ========================== */
+
+ $.fn.dropdown = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('dropdown')
+ if (!data) $this.data('dropdown', (data = new Dropdown(this)))
+ if (typeof option == 'string') data[option].call($this)
+ })
+ }
+
+ $.fn.dropdown.Constructor = Dropdown
+
+
+ /* APPLY TO STANDARD DROPDOWN ELEMENTS
+ * =================================== */
+
+ $(function () {
+ $('html')
+ .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
+ $('body')
+ .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) {
+ e.stopPropagation()
+ })
+ .on('click.dropdown.data-api touchstart.dropdown.data-api', toggle, Dropdown.prototype.toggle)
+ .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]', Dropdown.prototype.keydown)
+ })
+
+}(window.jQuery);
+/* =========================================================
+ * bootstrap-modal.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#modals
+ * =========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================= */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* MODAL CLASS DEFINITION
+ * ====================== */
+
+ var Modal = function (element, options) {
+ this.options = options
+ this.$element = $(element)
+ .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
+ this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
+ }
+
+ Modal.prototype = {
+
+ constructor: Modal, toggle: function () {
+ return this[!this.isShown ? 'show' : 'hide']()
+ }, show: function () {
+ var that = this
+ , e = $.Event('show')
+
+ this.$element.trigger(e)
+
+ if (this.isShown || e.isDefaultPrevented()) return
+
+ $('body').addClass('modal-open')
+
+ this.isShown = true
+
+ this.escape()
+
+ this.backdrop(function () {
+ var transition = $.support.transition && that.$element.hasClass('fade')
+
+ if (!that.$element.parent().length) {
+ that.$element.appendTo(document.body) //don't move modals dom position
+ }
+
+ that.$element
+ .show()
+
+ if (transition) {
+ that.$element[0].offsetWidth // force reflow
+ }
+
+ that.$element
+ .addClass('in')
+ .attr('aria-hidden', false)
+ .focus()
+
+ that.enforceFocus()
+
+ transition ?
+ that.$element.one($.support.transition.end, function () {
+ that.$element.trigger('shown')
+ }) :
+ that.$element.trigger('shown')
+
+ })
+ }, hide: function (e) {
+ e && e.preventDefault()
+
+ var that = this
+
+ e = $.Event('hide')
+
+ this.$element.trigger(e)
+
+ if (!this.isShown || e.isDefaultPrevented()) return
+
+ this.isShown = false
+
+ $('body').removeClass('modal-open')
+
+ this.escape()
+
+ $(document).off('focusin.modal')
+
+ this.$element
+ .removeClass('in')
+ .attr('aria-hidden', true)
+
+ $.support.transition && this.$element.hasClass('fade') ?
+ this.hideWithTransition() :
+ this.hideModal()
+ }, enforceFocus: function () {
+ var that = this
+ $(document).on('focusin.modal', function (e) {
+ if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
+ that.$element.focus()
+ }
+ })
+ }, escape: function () {
+ var that = this
+ if (this.isShown && this.options.keyboard) {
+ this.$element.on('keyup.dismiss.modal', function (e) {
+ e.which == 27 && that.hide()
+ })
+ } else if (!this.isShown) {
+ this.$element.off('keyup.dismiss.modal')
+ }
+ }, hideWithTransition: function () {
+ var that = this
+ , timeout = setTimeout(function () {
+ that.$element.off($.support.transition.end)
+ that.hideModal()
+ }, 500)
+
+ this.$element.one($.support.transition.end, function () {
+ clearTimeout(timeout)
+ that.hideModal()
+ })
+ }, hideModal: function (that) {
+ this.$element
+ .hide()
+ .trigger('hidden')
+
+ this.backdrop()
+ }, removeBackdrop: function () {
+ this.$backdrop.remove()
+ this.$backdrop = null
+ }, backdrop: function (callback) {
+ var that = this
+ , animate = this.$element.hasClass('fade') ? 'fade' : ''
+
+ if (this.isShown && this.options.backdrop) {
+ var doAnimate = $.support.transition && animate
+
+ this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
+ .appendTo(document.body)
+
+ if (this.options.backdrop != 'static') {
+ this.$backdrop.click($.proxy(this.hide, this))
+ }
+
+ if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
+
+ this.$backdrop.addClass('in')
+
+ doAnimate ?
+ this.$backdrop.one($.support.transition.end, callback) :
+ callback()
+
+ } else if (!this.isShown && this.$backdrop) {
+ this.$backdrop.removeClass('in')
+
+ $.support.transition && this.$element.hasClass('fade') ?
+ this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
+ this.removeBackdrop()
+
+ } else if (callback) {
+ callback()
+ }
+ }
+ }
+
+
+ /* MODAL PLUGIN DEFINITION
+ * ======================= */
+
+ $.fn.modal = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('modal')
+ , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
+ if (!data) $this.data('modal', (data = new Modal(this, options)))
+ if (typeof option == 'string') data[option]()
+ else if (options.show) data.show()
+ })
+ }
+
+ $.fn.modal.defaults = {
+ backdrop: true, keyboard: true, show: true
+ }
+
+ $.fn.modal.Constructor = Modal
+
+
+ /* MODAL DATA-API
+ * ============== */
+
+ $(function () {
+ $('body').on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
+ var $this = $(this)
+ , href = $this.attr('href')
+ , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
+ , option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
+
+ e.preventDefault()
+
+ $target
+ .modal(option)
+ .one('hide', function () {
+ $this.focus()
+ })
+ })
+ })
+
+}(window.jQuery);
+/* ===========================================================
+ * bootstrap-tooltip.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#tooltips
+ * Inspired by the original jQuery.tipsy by Jason Frame
+ * ===========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* TOOLTIP PUBLIC CLASS DEFINITION
+ * =============================== */
+
+ var Tooltip = function (element, options) {
+ this.init('tooltip', element, options)
+ }
+
+ Tooltip.prototype = {
+
+ constructor: Tooltip, init: function (type, element, options) {
+ var eventIn
+ , eventOut
+
+ this.type = type
+ this.$element = $(element)
+ this.options = this.getOptions(options)
+ this.enabled = true
+
+ if (this.options.trigger == 'click') {
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
+ } else if (this.options.trigger != 'manual') {
+ eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
+ eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
+ }
+
+ this.options.selector ?
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
+ this.fixTitle()
+ }, getOptions: function (options) {
+ options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
+
+ if (options.delay && typeof options.delay == 'number') {
+ options.delay = {
+ show: options.delay, hide: options.delay
+ }
+ }
+
+ return options
+ }, enter: function (e) {
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
+
+ if (!self.options.delay || !self.options.delay.show) return self.show()
+
+ clearTimeout(this.timeout)
+ self.hoverState = 'in'
+ this.timeout = setTimeout(function () {
+ if (self.hoverState == 'in') self.show()
+ }, self.options.delay.show)
+ }, leave: function (e) {
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
+
+ if (this.timeout) clearTimeout(this.timeout)
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
+
+ self.hoverState = 'out'
+ this.timeout = setTimeout(function () {
+ if (self.hoverState == 'out') self.hide()
+ }, self.options.delay.hide)
+ }, show: function () {
+ var $tip
+ , inside
+ , pos
+ , actualWidth
+ , actualHeight
+ , placement
+ , tp
+
+ if (this.hasContent() && this.enabled) {
+ $tip = this.tip()
+ this.setContent()
+
+ if (this.options.animation) {
+ $tip.addClass('fade')
+ }
+
+ placement = typeof this.options.placement == 'function' ?
+ this.options.placement.call(this, $tip[0], this.$element[0]) :
+ this.options.placement
+
+ inside = /in/.test(placement)
+
+ $tip
+ .remove()
+ .css({ top: 0, left: 0, display: 'block' })
+ .appendTo(inside ? this.$element : document.body)
+
+ pos = this.getPosition(inside)
+
+ actualWidth = $tip[0].offsetWidth
+ actualHeight = $tip[0].offsetHeight
+
+ switch (inside ? placement.split(' ')[1] : placement) {
+ case 'bottom':
+ tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
+ break
+ case 'top':
+ tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
+ break
+ case 'left':
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
+ break
+ case 'right':
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
+ break
+ }
+
+ $tip
+ .css(tp)
+ .addClass(placement)
+ .addClass('in')
+ }
+ }, setContent: function () {
+ var $tip = this.tip()
+ , title = this.getTitle()
+
+ $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
+ $tip.removeClass('fade in top bottom left right')
+ }, hide: function () {
+ var that = this
+ , $tip = this.tip()
+
+ $tip.removeClass('in')
+
+ function removeWithAnimation() {
+ var timeout = setTimeout(function () {
+ $tip.off($.support.transition.end).remove()
+ }, 500)
+
+ $tip.one($.support.transition.end, function () {
+ clearTimeout(timeout)
+ $tip.remove()
+ })
+ }
+
+ $.support.transition && this.$tip.hasClass('fade') ?
+ removeWithAnimation() :
+ $tip.remove()
+
+ return this
+ }, fixTitle: function () {
+ var $e = this.$element
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
+ $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
+ }
+ }, hasContent: function () {
+ return this.getTitle()
+ }, getPosition: function (inside) {
+ return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
+ width: this.$element[0].offsetWidth, height: this.$element[0].offsetHeight
+ })
+ }, getTitle: function () {
+ var title
+ , $e = this.$element
+ , o = this.options
+
+ title = $e.attr('data-original-title')
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
+
+ return title
+ }, tip: function () {
+ return this.$tip = this.$tip || $(this.options.template)
+ }, validate: function () {
+ if (!this.$element[0].parentNode) {
+ this.hide()
+ this.$element = null
+ this.options = null
+ }
+ }, enable: function () {
+ this.enabled = true
+ }, disable: function () {
+ this.enabled = false
+ }, toggleEnabled: function () {
+ this.enabled = !this.enabled
+ }, toggle: function () {
+ this[this.tip().hasClass('in') ? 'hide' : 'show']()
+ }, destroy: function () {
+ this.hide().$element.off('.' + this.type).removeData(this.type)
+ }
+
+ }
+
+
+ /* TOOLTIP PLUGIN DEFINITION
+ * ========================= */
+
+ $.fn.tooltip = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('tooltip')
+ , options = typeof option == 'object' && option
+ if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.tooltip.Constructor = Tooltip
+
+ $.fn.tooltip.defaults = {
+ animation: true, placement: 'top', selector: false, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', trigger: 'hover', title: '', delay: 0, html: true
+ }
+
+}(window.jQuery);
+/* ===========================================================
+ * bootstrap-popover.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#popovers
+ * ===========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =========================================================== */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* POPOVER PUBLIC CLASS DEFINITION
+ * =============================== */
+
+ var Popover = function (element, options) {
+ this.init('popover', element, options)
+ }
+
+
+ /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
+ ========================================== */
+
+ Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
+
+ constructor: Popover, setContent: function () {
+ var $tip = this.tip()
+ , title = this.getTitle()
+ , content = this.getContent()
+
+ $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
+ $tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content)
+
+ $tip.removeClass('fade top bottom left right in')
+ }, hasContent: function () {
+ return this.getTitle() || this.getContent()
+ }, getContent: function () {
+ var content
+ , $e = this.$element
+ , o = this.options
+
+ content = $e.attr('data-content')
+ || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
+
+ return content
+ }, tip: function () {
+ if (!this.$tip) {
+ this.$tip = $(this.options.template)
+ }
+ return this.$tip
+ }, destroy: function () {
+ this.hide().$element.off('.' + this.type).removeData(this.type)
+ }
+
+ })
+
+
+ /* POPOVER PLUGIN DEFINITION
+ * ======================= */
+
+ $.fn.popover = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('popover')
+ , options = typeof option == 'object' && option
+ if (!data) $this.data('popover', (data = new Popover(this, options)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.popover.Constructor = Popover
+
+ $.fn.popover.defaults = $.extend({}, $.fn.tooltip.defaults, {
+ placement: 'right', trigger: 'click', content: '', template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
+ })
+
+}(window.jQuery);
+/* =============================================================
+ * bootstrap-scrollspy.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#scrollspy
+ * =============================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================================================== */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* SCROLLSPY CLASS DEFINITION
+ * ========================== */
+
+ function ScrollSpy(element, options) {
+ var process = $.proxy(this.process, this)
+ , $element = $(element).is('body') ? $(window) : $(element)
+ , href
+ this.options = $.extend({}, $.fn.scrollspy.defaults, options)
+ this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
+ this.selector = (this.options.target
+ || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
+ || '') + ' .nav li > a'
+ this.$body = $('body')
+ this.refresh()
+ this.process()
+ }
+
+ ScrollSpy.prototype = {
+
+ constructor: ScrollSpy, refresh: function () {
+ var self = this
+ , $targets
+
+ this.offsets = $([])
+ this.targets = $([])
+
+ $targets = this.$body
+ .find(this.selector)
+ .map(function () {
+ var $el = $(this)
+ , href = $el.data('target') || $el.attr('href')
+ , $href = /^#\w/.test(href) && $(href)
+ return ( $href
+ && $href.length
+ && [
+ [ $href.position().top, href ]
+ ] ) || null
+ })
+ .sort(function (a, b) {
+ return a[0] - b[0]
+ })
+ .each(function () {
+ self.offsets.push(this[0])
+ self.targets.push(this[1])
+ })
+ }, process: function () {
+ var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
+ , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
+ , maxScroll = scrollHeight - this.$scrollElement.height()
+ , offsets = this.offsets
+ , targets = this.targets
+ , activeTarget = this.activeTarget
+ , i
+
+ if (scrollTop >= maxScroll) {
+ return activeTarget != (i = targets.last()[0])
+ && this.activate(i)
+ }
+
+ for (i = offsets.length; i--;) {
+ activeTarget != targets[i]
+ && scrollTop >= offsets[i]
+ && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
+ && this.activate(targets[i])
+ }
+ }, activate: function (target) {
+ var active
+ , selector
+
+ this.activeTarget = target
+
+ $(this.selector)
+ .parent('.active')
+ .removeClass('active')
+
+ selector = this.selector
+ + '[data-target="' + target + '"],'
+ + this.selector + '[href="' + target + '"]'
+
+ active = $(selector)
+ .parent('li')
+ .addClass('active')
+
+ if (active.parent('.dropdown-menu').length) {
+ active = active.closest('li.dropdown').addClass('active')
+ }
+
+ active.trigger('activate')
+ }
+
+ }
+
+
+ /* SCROLLSPY PLUGIN DEFINITION
+ * =========================== */
+
+ $.fn.scrollspy = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('scrollspy')
+ , options = typeof option == 'object' && option
+ if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.scrollspy.Constructor = ScrollSpy
+
+ $.fn.scrollspy.defaults = {
+ offset: 10
+ }
+
+
+ /* SCROLLSPY DATA-API
+ * ================== */
+
+ $(window).on('load', function () {
+ $('[data-spy="scroll"]').each(function () {
+ var $spy = $(this)
+ $spy.scrollspy($spy.data())
+ })
+ })
+
+}(window.jQuery);
+/* ========================================================
+ * bootstrap-tab.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#tabs
+ * ========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ======================================================== */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* TAB CLASS DEFINITION
+ * ==================== */
+
+ var Tab = function (element) {
+ this.element = $(element)
+ }
+
+ Tab.prototype = {
+
+ constructor: Tab, show: function () {
+ var $this = this.element
+ , $ul = $this.closest('ul:not(.dropdown-menu)')
+ , selector = $this.attr('data-target')
+ , previous
+ , $target
+ , e
+
+ if (!selector) {
+ selector = $this.attr('href')
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
+ }
+
+ if ($this.parent('li').hasClass('active')) return
+
+ previous = $ul.find('.active a').last()[0]
+
+ e = $.Event('show', {
+ relatedTarget: previous
+ })
+
+ $this.trigger(e)
+
+ if (e.isDefaultPrevented()) return
+
+ $target = $(selector)
+
+ this.activate($this.parent('li'), $ul)
+ this.activate($target, $target.parent(), function () {
+ $this.trigger({
+ type: 'shown', relatedTarget: previous
+ })
+ })
+ }, activate: function (element, container, callback) {
+ var $active = container.find('> .active')
+ , transition = callback
+ && $.support.transition
+ && $active.hasClass('fade')
+
+ function next() {
+ $active
+ .removeClass('active')
+ .find('> .dropdown-menu > .active')
+ .removeClass('active')
+
+ element.addClass('active')
+
+ if (transition) {
+ element[0].offsetWidth // reflow for transition
+ element.addClass('in')
+ } else {
+ element.removeClass('fade')
+ }
+
+ if (element.parent('.dropdown-menu')) {
+ element.closest('li.dropdown').addClass('active')
+ }
+
+ callback && callback()
+ }
+
+ transition ?
+ $active.one($.support.transition.end, next) :
+ next()
+
+ $active.removeClass('in')
+ }
+ }
+
+
+ /* TAB PLUGIN DEFINITION
+ * ===================== */
+
+ $.fn.tab = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('tab')
+ if (!data) $this.data('tab', (data = new Tab(this)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.tab.Constructor = Tab
+
+
+ /* TAB DATA-API
+ * ============ */
+
+ $(function () {
+ $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
+ e.preventDefault()
+ $(this).tab('show')
+ })
+ })
+
+}(window.jQuery);
+/* =============================================================
+ * bootstrap-typeahead.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#typeahead
+ * =============================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================================================ */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* TYPEAHEAD PUBLIC CLASS DEFINITION
+ * ================================= */
+
+ var Typeahead = function (element, options) {
+ this.$element = $(element)
+ this.options = $.extend({}, $.fn.typeahead.defaults, options)
+ this.matcher = this.options.matcher || this.matcher
+ this.sorter = this.options.sorter || this.sorter
+ this.highlighter = this.options.highlighter || this.highlighter
+ this.updater = this.options.updater || this.updater
+ this.$menu = $(this.options.menu).appendTo('body')
+ this.source = this.options.source
+ this.shown = false
+ this.listen()
+ }
+
+ Typeahead.prototype = {
+
+ constructor: Typeahead, select: function () {
+ var val = this.$menu.find('.active').attr('data-value')
+ this.$element
+ .val(this.updater(val))
+ .change()
+ return this.hide()
+ }, updater: function (item) {
+ return item
+ }, show: function () {
+ var pos = $.extend({}, this.$element.offset(), {
+ height: this.$element[0].offsetHeight
+ })
+
+ this.$menu.css({
+ top: pos.top + pos.height, left: pos.left
+ })
+
+ this.$menu.show()
+ this.shown = true
+ return this
+ }, hide: function () {
+ this.$menu.hide()
+ this.shown = false
+ return this
+ }, lookup: function (event) {
+ var items
+
+ this.query = this.$element.val()
+
+ if (!this.query || this.query.length < this.options.minLength) {
+ return this.shown ? this.hide() : this
+ }
+
+ items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
+
+ return items ? this.process(items) : this
+ }, process: function (items) {
+ var that = this
+
+ items = $.grep(items, function (item) {
+ return that.matcher(item)
+ })
+
+ items = this.sorter(items)
+
+ if (!items.length) {
+ return this.shown ? this.hide() : this
+ }
+
+ return this.render(items.slice(0, this.options.items)).show()
+ }, matcher: function (item) {
+ return ~item.toLowerCase().indexOf(this.query.toLowerCase())
+ }, sorter: function (items) {
+ var beginswith = []
+ , caseSensitive = []
+ , caseInsensitive = []
+ , item
+
+ while (item = items.shift()) {
+ if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
+ else if (~item.indexOf(this.query)) caseSensitive.push(item)
+ else caseInsensitive.push(item)
+ }
+
+ return beginswith.concat(caseSensitive, caseInsensitive)
+ }, highlighter: function (item) {
+ var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
+ return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
+ return '<strong>' + match + '</strong>'
+ })
+ }, render: function (items) {
+ var that = this
+
+ items = $(items).map(function (i, item) {
+ i = $(that.options.item).attr('data-value', item)
+ i.find('a').html(that.highlighter(item))
+ return i[0]
+ })
+
+ items.first().addClass('active')
+ this.$menu.html(items)
+ return this
+ }, next: function (event) {
+ var active = this.$menu.find('.active').removeClass('active')
+ , next = active.next()
+
+ if (!next.length) {
+ next = $(this.$menu.find('li')[0])
+ }
+
+ next.addClass('active')
+ }, prev: function (event) {
+ var active = this.$menu.find('.active').removeClass('active')
+ , prev = active.prev()
+
+ if (!prev.length) {
+ prev = this.$menu.find('li').last()
+ }
+
+ prev.addClass('active')
+ }, listen: function () {
+ this.$element
+ .on('blur', $.proxy(this.blur, this))
+ .on('keypress', $.proxy(this.keypress, this))
+ .on('keyup', $.proxy(this.keyup, this))
+
+ if ($.browser.chrome || $.browser.webkit || $.browser.msie) {
+ this.$element.on('keydown', $.proxy(this.keydown, this))
+ }
+
+ this.$menu
+ .on('click', $.proxy(this.click, this))
+ .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
+ }, move: function (e) {
+ if (!this.shown) return
+
+ switch (e.keyCode) {
+ case 9: // tab
+ case 13: // enter
+ case 27: // escape
+ e.preventDefault()
+ break
+
+ case 38: // up arrow
+ e.preventDefault()
+ this.prev()
+ break
+
+ case 40: // down arrow
+ e.preventDefault()
+ this.next()
+ break
+ }
+
+ e.stopPropagation()
+ }, keydown: function (e) {
+ this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40, 38, 9, 13, 27])
+ this.move(e)
+ }, keypress: function (e) {
+ if (this.suppressKeyPressRepeat) return
+ this.move(e)
+ }, keyup: function (e) {
+ switch (e.keyCode) {
+ case 40: // down arrow
+ case 38: // up arrow
+ break
+
+ case 9: // tab
+ case 13: // enter
+ if (!this.shown) return
+ this.select()
+ break
+
+ case 27: // escape
+ if (!this.shown) return
+ this.hide()
+ break
+
+ default:
+ this.lookup()
+ }
+
+ e.stopPropagation()
+ e.preventDefault()
+ }, blur: function (e) {
+ var that = this
+ setTimeout(function () {
+ that.hide()
+ }, 150)
+ }, click: function (e) {
+ e.stopPropagation()
+ e.preventDefault()
+ this.select()
+ }, mouseenter: function (e) {
+ this.$menu.find('.active').removeClass('active')
+ $(e.currentTarget).addClass('active')
+ }
+
+ }
+
+
+ /* TYPEAHEAD PLUGIN DEFINITION
+ * =========================== */
+
+ $.fn.typeahead = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('typeahead')
+ , options = typeof option == 'object' && option
+ if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.typeahead.defaults = {
+ source: [], items: 8, menu: '<ul class="typeahead dropdown-menu"></ul>', item: '<li><a href="#"></a></li>', minLength: 1
+ }
+
+ $.fn.typeahead.Constructor = Typeahead
+
+
+ /* TYPEAHEAD DATA-API
+ * ================== */
+
+ $(function () {
+ $('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
+ var $this = $(this)
+ if ($this.data('typeahead')) return
+ e.preventDefault()
+ $this.typeahead($this.data())
+ })
+ })
+
+}(window.jQuery);
+/* ==========================================================
+ * bootstrap-affix.js v2.1.1
+ * http://twitter.github.com/bootstrap/javascript.html#affix
+ * ==========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* AFFIX CLASS DEFINITION
+ * ====================== */
+
+ var Affix = function (element, options) {
+ this.options = $.extend({}, $.fn.affix.defaults, options)
+ this.$window = $(window).on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
+ this.$element = $(element)
+ this.checkPosition()
+ }
+
+ Affix.prototype.checkPosition = function () {
+ if (!this.$element.is(':visible')) return
+
+ var scrollHeight = $(document).height()
+ , scrollTop = this.$window.scrollTop()
+ , position = this.$element.offset()
+ , offset = this.options.offset
+ , offsetBottom = offset.bottom
+ , offsetTop = offset.top
+ , reset = 'affix affix-top affix-bottom'
+ , affix
+
+ if (typeof offset != 'object') offsetBottom = offsetTop = offset
+ if (typeof offsetTop == 'function') offsetTop = offset.top()
+ if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
+
+ affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
+ false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
+ 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
+ 'top' : false
+
+ if (this.affixed === affix) return
+
+ this.affixed = affix
+ this.unpin = affix == 'bottom' ? position.top - scrollTop : null
+
+ this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
+ }
+
+
+ /* AFFIX PLUGIN DEFINITION
+ * ======================= */
+
+ $.fn.affix = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('affix')
+ , options = typeof option == 'object' && option
+ if (!data) $this.data('affix', (data = new Affix(this, options)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.affix.Constructor = Affix
+
+ $.fn.affix.defaults = {
+ offset: 0
+ }
+
+
+ /* AFFIX DATA-API
+ * ============== */
+
+ $(window).on('load', function () {
+ $('[data-spy="affix"]').each(function () {
+ var $spy = $(this)
+ , data = $spy.data()
+
+ data.offset = data.offset || {}
+
+ data.offsetBottom && (data.offset.bottom = data.offsetBottom)
+ data.offsetTop && (data.offset.top = data.offsetTop)
+
+ $spy.affix(data)
+ })
+ })
+
+
+}(window.jQuery);
\ No newline at end of file
diff --git a/content/examples/moviefun/src/main/webapp/assets/js/bootstrap.min.js b/content/examples/moviefun/src/main/webapp/assets/js/bootstrap.min.js
new file mode 100755
index 0000000..3b91223
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/assets/js/bootstrap.min.js
@@ -0,0 +1,568 @@
+/*!
+ * Bootstrap.js by @fat & @mdo
+ * Copyright 2012 Twitter, Inc.
+ * http://www.apache.org/licenses/LICENSE-2.0.txt
+ */
+!function (e) {
+ e(function () {
+ "use strict";
+ e.support.transition = function () {
+ var e = function () {
+ var e = document.createElement("bootstrap"), t = {WebkitTransition: "webkitTransitionEnd", MozTransition: "transitionend", OTransition: "oTransitionEnd otransitionend", transition: "transitionend"}, n;
+ for (n in t)if (e.style[n] !== undefined)return t[n]
+ }();
+ return e && {end: e}
+ }()
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = '[data-dismiss="alert"]', n = function (n) {
+ e(n).on("click", t, this.close)
+ };
+ n.prototype.close = function (t) {
+ function s() {
+ i.trigger("closed").remove()
+ }
+
+ var n = e(this), r = n.attr("data-target"), i;
+ r || (r = n.attr("href"), r = r && r.replace(/.*(?=#[^\s]*$)/, "")), i = e(r), t && t.preventDefault(), i.length || (i = n.hasClass("alert") ? n : n.parent()), i.trigger(t = e.Event("close"));
+ if (t.isDefaultPrevented())return;
+ i.removeClass("in"), e.support.transition && i.hasClass("fade") ? i.on(e.support.transition.end, s) : s()
+ }, e.fn.alert = function (t) {
+ return this.each(function () {
+ var r = e(this), i = r.data("alert");
+ i || r.data("alert", i = new n(this)), typeof t == "string" && i[t].call(r)
+ })
+ }, e.fn.alert.Constructor = n, e(function () {
+ e("body").on("click.alert.data-api", t, n.prototype.close)
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = function (t, n) {
+ this.$element = e(t), this.options = e.extend({}, e.fn.button.defaults, n)
+ };
+ t.prototype.setState = function (e) {
+ var t = "disabled", n = this.$element, r = n.data(), i = n.is("input") ? "val" : "html";
+ e += "Text", r.resetText || n.data("resetText", n[i]()), n[i](r[e] || this.options[e]), setTimeout(function () {
+ e == "loadingText" ? n.addClass(t).attr(t, t) : n.removeClass(t).removeAttr(t)
+ }, 0)
+ }, t.prototype.toggle = function () {
+ var e = this.$element.closest('[data-toggle="buttons-radio"]');
+ e && e.find(".active").removeClass("active"), this.$element.toggleClass("active")
+ }, e.fn.button = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("button"), s = typeof n == "object" && n;
+ i || r.data("button", i = new t(this, s)), n == "toggle" ? i.toggle() : n && i.setState(n)
+ })
+ }, e.fn.button.defaults = {loadingText: "loading..."}, e.fn.button.Constructor = t, e(function () {
+ e("body").on("click.button.data-api", "[data-toggle^=button]", function (t) {
+ var n = e(t.target);
+ n.hasClass("btn") || (n = n.closest(".btn")), n.button("toggle")
+ })
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = function (t, n) {
+ this.$element = e(t), this.options = n, this.options.slide && this.slide(this.options.slide), this.options.pause == "hover" && this.$element.on("mouseenter", e.proxy(this.pause, this)).on("mouseleave", e.proxy(this.cycle, this))
+ };
+ t.prototype = {cycle: function (t) {
+ return t || (this.paused = !1), this.options.interval && !this.paused && (this.interval = setInterval(e.proxy(this.next, this), this.options.interval)), this
+ }, to: function (t) {
+ var n = this.$element.find(".item.active"), r = n.parent().children(), i = r.index(n), s = this;
+ if (t > r.length - 1 || t < 0)return;
+ return this.sliding ? this.$element.one("slid", function () {
+ s.to(t)
+ }) : i == t ? this.pause().cycle() : this.slide(t > i ? "next" : "prev", e(r[t]))
+ }, pause: function (t) {
+ return t || (this.paused = !0), this.$element.find(".next, .prev").length && e.support.transition.end && (this.$element.trigger(e.support.transition.end), this.cycle()), clearInterval(this.interval), this.interval = null, this
+ }, next: function () {
+ if (this.sliding)return;
+ return this.slide("next")
+ }, prev: function () {
+ if (this.sliding)return;
+ return this.slide("prev")
+ }, slide: function (t, n) {
+ var r = this.$element.find(".item.active"), i = n || r[t](), s = this.interval, o = t == "next" ? "left" : "right", u = t == "next" ? "first" : "last", a = this, f = e.Event("slide", {relatedTarget: i[0]});
+ this.sliding = !0, s && this.pause(), i = i.length ? i : this.$element.find(".item")[u]();
+ if (i.hasClass("active"))return;
+ if (e.support.transition && this.$element.hasClass("slide")) {
+ this.$element.trigger(f);
+ if (f.isDefaultPrevented())return;
+ i.addClass(t), i[0].offsetWidth, r.addClass(o), i.addClass(o), this.$element.one(e.support.transition.end, function () {
+ i.removeClass([t, o].join(" ")).addClass("active"), r.removeClass(["active", o].join(" ")), a.sliding = !1, setTimeout(function () {
+ a.$element.trigger("slid")
+ }, 0)
+ })
+ } else {
+ this.$element.trigger(f);
+ if (f.isDefaultPrevented())return;
+ r.removeClass("active"), i.addClass("active"), this.sliding = !1, this.$element.trigger("slid")
+ }
+ return s && this.cycle(), this
+ }}, e.fn.carousel = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("carousel"), s = e.extend({}, e.fn.carousel.defaults, typeof n == "object" && n), o = typeof n == "string" ? n : s.slide;
+ i || r.data("carousel", i = new t(this, s)), typeof n == "number" ? i.to(n) : o ? i[o]() : s.interval && i.cycle()
+ })
+ }, e.fn.carousel.defaults = {interval: 5e3, pause: "hover"}, e.fn.carousel.Constructor = t, e(function () {
+ e("body").on("click.carousel.data-api", "[data-slide]", function (t) {
+ var n = e(this), r, i = e(n.attr("data-target") || (r = n.attr("href")) && r.replace(/.*(?=#[^\s]+$)/, "")), s = !i.data("modal") && e.extend({}, i.data(), n.data());
+ i.carousel(s), t.preventDefault()
+ })
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = function (t, n) {
+ this.$element = e(t), this.options = e.extend({}, e.fn.collapse.defaults, n), this.options.parent && (this.$parent = e(this.options.parent)), this.options.toggle && this.toggle()
+ };
+ t.prototype = {constructor: t, dimension: function () {
+ var e = this.$element.hasClass("width");
+ return e ? "width" : "height"
+ }, show: function () {
+ var t, n, r, i;
+ if (this.transitioning)return;
+ t = this.dimension(), n = e.camelCase(["scroll", t].join("-")), r = this.$parent && this.$parent.find("> .accordion-group > .in");
+ if (r && r.length) {
+ i = r.data("collapse");
+ if (i && i.transitioning)return;
+ r.collapse("hide"), i || r.data("collapse", null)
+ }
+ this.$element[t](0), this.transition("addClass", e.Event("show"), "shown"), e.support.transition && this.$element[t](this.$element[0][n])
+ }, hide: function () {
+ var t;
+ if (this.transitioning)return;
+ t = this.dimension(), this.reset(this.$element[t]()), this.transition("removeClass", e.Event("hide"), "hidden"), this.$element[t](0)
+ }, reset: function (e) {
+ var t = this.dimension();
+ return this.$element.removeClass("collapse")[t](e || "auto")[0].offsetWidth, this.$element[e !== null ? "addClass" : "removeClass"]("collapse"), this
+ }, transition: function (t, n, r) {
+ var i = this, s = function () {
+ n.type == "show" && i.reset(), i.transitioning = 0, i.$element.trigger(r)
+ };
+ this.$element.trigger(n);
+ if (n.isDefaultPrevented())return;
+ this.transitioning = 1, this.$element[t]("in"), e.support.transition && this.$element.hasClass("collapse") ? this.$element.one(e.support.transition.end, s) : s()
+ }, toggle: function () {
+ this[this.$element.hasClass("in") ? "hide" : "show"]()
+ }}, e.fn.collapse = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("collapse"), s = typeof n == "object" && n;
+ i || r.data("collapse", i = new t(this, s)), typeof n == "string" && i[n]()
+ })
+ }, e.fn.collapse.defaults = {toggle: !0}, e.fn.collapse.Constructor = t, e(function () {
+ e("body").on("click.collapse.data-api", "[data-toggle=collapse]", function (t) {
+ var n = e(this), r, i = n.attr("data-target") || t.preventDefault() || (r = n.attr("href")) && r.replace(/.*(?=#[^\s]+$)/, ""), s = e(i).data("collapse") ? "toggle" : n.data();
+ n[e(i).hasClass("in") ? "addClass" : "removeClass"]("collapsed"), e(i).collapse(s)
+ })
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ function r() {
+ i(e(t)).removeClass("open")
+ }
+
+ function i(t) {
+ var n = t.attr("data-target"), r;
+ return n || (n = t.attr("href"), n = n && /#/.test(n) && n.replace(/.*(?=#[^\s]*$)/, "")), r = e(n), r.length || (r = t.parent()), r
+ }
+
+ var t = "[data-toggle=dropdown]", n = function (t) {
+ var n = e(t).on("click.dropdown.data-api", this.toggle);
+ e("html").on("click.dropdown.data-api", function () {
+ n.parent().removeClass("open")
+ })
+ };
+ n.prototype = {constructor: n, toggle: function (t) {
+ var n = e(this), s, o;
+ if (n.is(".disabled, :disabled"))return;
+ return s = i(n), o = s.hasClass("open"), r(), o || (s.toggleClass("open"), n.focus()), !1
+ }, keydown: function (t) {
+ var n, r, s, o, u, a;
+ if (!/(38|40|27)/.test(t.keyCode))return;
+ n = e(this), t.preventDefault(), t.stopPropagation();
+ if (n.is(".disabled, :disabled"))return;
+ o = i(n), u = o.hasClass("open");
+ if (!u || u && t.keyCode == 27)return n.click();
+ r = e("[role=menu] li:not(.divider) a", o);
+ if (!r.length)return;
+ a = r.index(r.filter(":focus")), t.keyCode == 38 && a > 0 && a--, t.keyCode == 40 && a < r.length - 1 && a++, ~a || (a = 0), r.eq(a).focus()
+ }}, e.fn.dropdown = function (t) {
+ return this.each(function () {
+ var r = e(this), i = r.data("dropdown");
+ i || r.data("dropdown", i = new n(this)), typeof t == "string" && i[t].call(r)
+ })
+ }, e.fn.dropdown.Constructor = n, e(function () {
+ e("html").on("click.dropdown.data-api touchstart.dropdown.data-api", r), e("body").on("click.dropdown touchstart.dropdown.data-api", ".dropdown form",function (e) {
+ e.stopPropagation()
+ }).on("click.dropdown.data-api touchstart.dropdown.data-api", t, n.prototype.toggle).on("keydown.dropdown.data-api touchstart.dropdown.data-api", t + ", [role=menu]", n.prototype.keydown)
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = function (t, n) {
+ this.options = n, this.$element = e(t).delegate('[data-dismiss="modal"]', "click.dismiss.modal", e.proxy(this.hide, this)), this.options.remote && this.$element.find(".modal-body").load(this.options.remote)
+ };
+ t.prototype = {constructor: t, toggle: function () {
+ return this[this.isShown ? "hide" : "show"]()
+ }, show: function () {
+ var t = this, n = e.Event("show");
+ this.$element.trigger(n);
+ if (this.isShown || n.isDefaultPrevented())return;
+ e("body").addClass("modal-open"), this.isShown = !0, this.escape(), this.backdrop(function () {
+ var n = e.support.transition && t.$element.hasClass("fade");
+ t.$element.parent().length || t.$element.appendTo(document.body), t.$element.show(), n && t.$element[0].offsetWidth, t.$element.addClass("in").attr("aria-hidden", !1).focus(), t.enforceFocus(), n ? t.$element.one(e.support.transition.end, function () {
+ t.$element.trigger("shown")
+ }) : t.$element.trigger("shown")
+ })
+ }, hide: function (t) {
+ t && t.preventDefault();
+ var n = this;
+ t = e.Event("hide"), this.$element.trigger(t);
+ if (!this.isShown || t.isDefaultPrevented())return;
+ this.isShown = !1, e("body").removeClass("modal-open"), this.escape(), e(document).off("focusin.modal"), this.$element.removeClass("in").attr("aria-hidden", !0), e.support.transition && this.$element.hasClass("fade") ? this.hideWithTransition() : this.hideModal()
+ }, enforceFocus: function () {
+ var t = this;
+ e(document).on("focusin.modal", function (e) {
+ t.$element[0] !== e.target && !t.$element.has(e.target).length && t.$element.focus()
+ })
+ }, escape: function () {
+ var e = this;
+ this.isShown && this.options.keyboard ? this.$element.on("keyup.dismiss.modal", function (t) {
+ t.which == 27 && e.hide()
+ }) : this.isShown || this.$element.off("keyup.dismiss.modal")
+ }, hideWithTransition: function () {
+ var t = this, n = setTimeout(function () {
+ t.$element.off(e.support.transition.end), t.hideModal()
+ }, 500);
+ this.$element.one(e.support.transition.end, function () {
+ clearTimeout(n), t.hideModal()
+ })
+ }, hideModal: function (e) {
+ this.$element.hide().trigger("hidden"), this.backdrop()
+ }, removeBackdrop: function () {
+ this.$backdrop.remove(), this.$backdrop = null
+ }, backdrop: function (t) {
+ var n = this, r = this.$element.hasClass("fade") ? "fade" : "";
+ if (this.isShown && this.options.backdrop) {
+ var i = e.support.transition && r;
+ this.$backdrop = e('<div class="modal-backdrop ' + r + '" />').appendTo(document.body), this.options.backdrop != "static" && this.$backdrop.click(e.proxy(this.hide, this)), i && this.$backdrop[0].offsetWidth, this.$backdrop.addClass("in"), i ? this.$backdrop.one(e.support.transition.end, t) : t()
+ } else!this.isShown && this.$backdrop ? (this.$backdrop.removeClass("in"), e.support.transition && this.$element.hasClass("fade") ? this.$backdrop.one(e.support.transition.end, e.proxy(this.removeBackdrop, this)) : this.removeBackdrop()) : t && t()
+ }}, e.fn.modal = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("modal"), s = e.extend({}, e.fn.modal.defaults, r.data(), typeof n == "object" && n);
+ i || r.data("modal", i = new t(this, s)), typeof n == "string" ? i[n]() : s.show && i.show()
+ })
+ }, e.fn.modal.defaults = {backdrop: !0, keyboard: !0, show: !0}, e.fn.modal.Constructor = t, e(function () {
+ e("body").on("click.modal.data-api", '[data-toggle="modal"]', function (t) {
+ var n = e(this), r = n.attr("href"), i = e(n.attr("data-target") || r && r.replace(/.*(?=#[^\s]+$)/, "")), s = i.data("modal") ? "toggle" : e.extend({remote: !/#/.test(r) && r}, i.data(), n.data());
+ t.preventDefault(), i.modal(s).one("hide", function () {
+ n.focus()
+ })
+ })
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = function (e, t) {
+ this.init("tooltip", e, t)
+ };
+ t.prototype = {constructor: t, init: function (t, n, r) {
+ var i, s;
+ this.type = t, this.$element = e(n), this.options = this.getOptions(r), this.enabled = !0, this.options.trigger == "click" ? this.$element.on("click." + this.type, this.options.selector, e.proxy(this.toggle, this)) : this.options.trigger != "manual" && (i = this.options.trigger == "hover" ? "mouseenter" : "focus", s = this.options.trigger == "hover" ? "mouseleave" : "blur", this.$element.on(i + "." + this.type, this.options.selector, e.proxy(this.enter, this)), this.$element.on(s + "." + this.type, this.options.selector, e.proxy(this.leave, this))), this.options.selector ? this._options = e.extend({}, this.options, {trigger: "manual", selector: ""}) : this.fixTitle()
+ }, getOptions: function (t) {
+ return t = e.extend({}, e.fn[this.type].defaults, t, this.$element.data()), t.delay && typeof t.delay == "number" && (t.delay = {show: t.delay, hide: t.delay}), t
+ }, enter: function (t) {
+ var n = e(t.currentTarget)[this.type](this._options).data(this.type);
+ if (!n.options.delay || !n.options.delay.show)return n.show();
+ clearTimeout(this.timeout), n.hoverState = "in", this.timeout = setTimeout(function () {
+ n.hoverState == "in" && n.show()
+ }, n.options.delay.show)
+ }, leave: function (t) {
+ var n = e(t.currentTarget)[this.type](this._options).data(this.type);
+ this.timeout && clearTimeout(this.timeout);
+ if (!n.options.delay || !n.options.delay.hide)return n.hide();
+ n.hoverState = "out", this.timeout = setTimeout(function () {
+ n.hoverState == "out" && n.hide()
+ }, n.options.delay.hide)
+ }, show: function () {
+ var e, t, n, r, i, s, o;
+ if (this.hasContent() && this.enabled) {
+ e = this.tip(), this.setContent(), this.options.animation && e.addClass("fade"), s = typeof this.options.placement == "function" ? this.options.placement.call(this, e[0], this.$element[0]) : this.options.placement, t = /in/.test(s), e.remove().css({top: 0, left: 0, display: "block"}).appendTo(t ? this.$element : document.body), n = this.getPosition(t), r = e[0].offsetWidth, i = e[0].offsetHeight;
+ switch (t ? s.split(" ")[1] : s) {
+ case"bottom":
+ o = {top: n.top + n.height, left: n.left + n.width / 2 - r / 2};
+ break;
+ case"top":
+ o = {top: n.top - i, left: n.left + n.width / 2 - r / 2};
+ break;
+ case"left":
+ o = {top: n.top + n.height / 2 - i / 2, left: n.left - r};
+ break;
+ case"right":
+ o = {top: n.top + n.height / 2 - i / 2, left: n.left + n.width}
+ }
+ e.css(o).addClass(s).addClass("in")
+ }
+ }, setContent: function () {
+ var e = this.tip(), t = this.getTitle();
+ e.find(".tooltip-inner")[this.options.html ? "html" : "text"](t), e.removeClass("fade in top bottom left right")
+ }, hide: function () {
+ function r() {
+ var t = setTimeout(function () {
+ n.off(e.support.transition.end).remove()
+ }, 500);
+ n.one(e.support.transition.end, function () {
+ clearTimeout(t), n.remove()
+ })
+ }
+
+ var t = this, n = this.tip();
+ return n.removeClass("in"), e.support.transition && this.$tip.hasClass("fade") ? r() : n.remove(), this
+ }, fixTitle: function () {
+ var e = this.$element;
+ (e.attr("title") || typeof e.attr("data-original-title") != "string") && e.attr("data-original-title", e.attr("title") || "").removeAttr("title")
+ }, hasContent: function () {
+ return this.getTitle()
+ }, getPosition: function (t) {
+ return e.extend({}, t ? {top: 0, left: 0} : this.$element.offset(), {width: this.$element[0].offsetWidth, height: this.$element[0].offsetHeight})
+ }, getTitle: function () {
+ var e, t = this.$element, n = this.options;
+ return e = t.attr("data-original-title") || (typeof n.title == "function" ? n.title.call(t[0]) : n.title), e
+ }, tip: function () {
+ return this.$tip = this.$tip || e(this.options.template)
+ }, validate: function () {
+ this.$element[0].parentNode || (this.hide(), this.$element = null, this.options = null)
+ }, enable: function () {
+ this.enabled = !0
+ }, disable: function () {
+ this.enabled = !1
+ }, toggleEnabled: function () {
+ this.enabled = !this.enabled
+ }, toggle: function () {
+ this[this.tip().hasClass("in") ? "hide" : "show"]()
+ }, destroy: function () {
+ this.hide().$element.off("." + this.type).removeData(this.type)
+ }}, e.fn.tooltip = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("tooltip"), s = typeof n == "object" && n;
+ i || r.data("tooltip", i = new t(this, s)), typeof n == "string" && i[n]()
+ })
+ }, e.fn.tooltip.Constructor = t, e.fn.tooltip.defaults = {animation: !0, placement: "top", selector: !1, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', trigger: "hover", title: "", delay: 0, html: !0}
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = function (e, t) {
+ this.init("popover", e, t)
+ };
+ t.prototype = e.extend({}, e.fn.tooltip.Constructor.prototype, {constructor: t, setContent: function () {
+ var e = this.tip(), t = this.getTitle(), n = this.getContent();
+ e.find(".popover-title")[this.options.html ? "html" : "text"](t), e.find(".popover-content > *")[this.options.html ? "html" : "text"](n), e.removeClass("fade top bottom left right in")
+ }, hasContent: function () {
+ return this.getTitle() || this.getContent()
+ }, getContent: function () {
+ var e, t = this.$element, n = this.options;
+ return e = t.attr("data-content") || (typeof n.content == "function" ? n.content.call(t[0]) : n.content), e
+ }, tip: function () {
+ return this.$tip || (this.$tip = e(this.options.template)), this.$tip
+ }, destroy: function () {
+ this.hide().$element.off("." + this.type).removeData(this.type)
+ }}), e.fn.popover = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("popover"), s = typeof n == "object" && n;
+ i || r.data("popover", i = new t(this, s)), typeof n == "string" && i[n]()
+ })
+ }, e.fn.popover.Constructor = t, e.fn.popover.defaults = e.extend({}, e.fn.tooltip.defaults, {placement: "right", trigger: "click", content: "", template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'})
+}(window.jQuery), !function (e) {
+ "use strict";
+ function t(t, n) {
+ var r = e.proxy(this.process, this), i = e(t).is("body") ? e(window) : e(t), s;
+ this.options = e.extend({}, e.fn.scrollspy.defaults, n), this.$scrollElement = i.on("scroll.scroll-spy.data-api", r), this.selector = (this.options.target || (s = e(t).attr("href")) && s.replace(/.*(?=#[^\s]+$)/, "") || "") + " .nav li > a", this.$body = e("body"), this.refresh(), this.process()
+ }
+
+ t.prototype = {constructor: t, refresh: function () {
+ var t = this, n;
+ this.offsets = e([]), this.targets = e([]), n = this.$body.find(this.selector).map(function () {
+ var t = e(this), n = t.data("target") || t.attr("href"), r = /^#\w/.test(n) && e(n);
+ return r && r.length && [
+ [r.position().top, n]
+ ] || null
+ }).sort(function (e, t) {
+ return e[0] - t[0]
+ }).each(function () {
+ t.offsets.push(this[0]), t.targets.push(this[1])
+ })
+ }, process: function () {
+ var e = this.$scrollElement.scrollTop() + this.options.offset, t = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight, n = t - this.$scrollElement.height(), r = this.offsets, i = this.targets, s = this.activeTarget, o;
+ if (e >= n)return s != (o = i.last()[0]) && this.activate(o);
+ for (o = r.length; o--;)s != i[o] && e >= r[o] && (!r[o + 1] || e <= r[o + 1]) && this.activate(i[o])
+ }, activate: function (t) {
+ var n, r;
+ this.activeTarget = t, e(this.selector).parent(".active").removeClass("active"), r = this.selector + '[data-target="' + t + '"],' + this.selector + '[href="' + t + '"]', n = e(r).parent("li").addClass("active"), n.parent(".dropdown-menu").length && (n = n.closest("li.dropdown").addClass("active")), n.trigger("activate")
+ }}, e.fn.scrollspy = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("scrollspy"), s = typeof n == "object" && n;
+ i || r.data("scrollspy", i = new t(this, s)), typeof n == "string" && i[n]()
+ })
+ }, e.fn.scrollspy.Constructor = t, e.fn.scrollspy.defaults = {offset: 10}, e(window).on("load", function () {
+ e('[data-spy="scroll"]').each(function () {
+ var t = e(this);
+ t.scrollspy(t.data())
+ })
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = function (t) {
+ this.element = e(t)
+ };
+ t.prototype = {constructor: t, show: function () {
+ var t = this.element, n = t.closest("ul:not(.dropdown-menu)"), r = t.attr("data-target"), i, s, o;
+ r || (r = t.attr("href"), r = r && r.replace(/.*(?=#[^\s]*$)/, ""));
+ if (t.parent("li").hasClass("active"))return;
+ i = n.find(".active a").last()[0], o = e.Event("show", {relatedTarget: i}), t.trigger(o);
+ if (o.isDefaultPrevented())return;
+ s = e(r), this.activate(t.parent("li"), n), this.activate(s, s.parent(), function () {
+ t.trigger({type: "shown", relatedTarget: i})
+ })
+ }, activate: function (t, n, r) {
+ function o() {
+ i.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"), t.addClass("active"), s ? (t[0].offsetWidth, t.addClass("in")) : t.removeClass("fade"), t.parent(".dropdown-menu") && t.closest("li.dropdown").addClass("active"), r && r()
+ }
+
+ var i = n.find("> .active"), s = r && e.support.transition && i.hasClass("fade");
+ s ? i.one(e.support.transition.end, o) : o(), i.removeClass("in")
+ }}, e.fn.tab = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("tab");
+ i || r.data("tab", i = new t(this)), typeof n == "string" && i[n]()
+ })
+ }, e.fn.tab.Constructor = t, e(function () {
+ e("body").on("click.tab.data-api", '[data-toggle="tab"], [data-toggle="pill"]', function (t) {
+ t.preventDefault(), e(this).tab("show")
+ })
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = function (t, n) {
+ this.$element = e(t), this.options = e.extend({}, e.fn.typeahead.defaults, n), this.matcher = this.options.matcher || this.matcher, this.sorter = this.options.sorter || this.sorter, this.highlighter = this.options.highlighter || this.highlighter, this.updater = this.options.updater || this.updater, this.$menu = e(this.options.menu).appendTo("body"), this.source = this.options.source, this.shown = !1, this.listen()
+ };
+ t.prototype = {constructor: t, select: function () {
+ var e = this.$menu.find(".active").attr("data-value");
+ return this.$element.val(this.updater(e)).change(), this.hide()
+ }, updater: function (e) {
+ return e
+ }, show: function () {
+ var t = e.extend({}, this.$element.offset(), {height: this.$element[0].offsetHeight});
+ return this.$menu.css({top: t.top + t.height, left: t.left}), this.$menu.show(), this.shown = !0, this
+ }, hide: function () {
+ return this.$menu.hide(), this.shown = !1, this
+ }, lookup: function (t) {
+ var n;
+ return this.query = this.$element.val(), !this.query || this.query.length < this.options.minLength ? this.shown ? this.hide() : this : (n = e.isFunction(this.source) ? this.source(this.query, e.proxy(this.process, this)) : this.source, n ? this.process(n) : this)
+ }, process: function (t) {
+ var n = this;
+ return t = e.grep(t, function (e) {
+ return n.matcher(e)
+ }), t = this.sorter(t), t.length ? this.render(t.slice(0, this.options.items)).show() : this.shown ? this.hide() : this
+ }, matcher: function (e) {
+ return~e.toLowerCase().indexOf(this.query.toLowerCase())
+ }, sorter: function (e) {
+ var t = [], n = [], r = [], i;
+ while (i = e.shift())i.toLowerCase().indexOf(this.query.toLowerCase()) ? ~i.indexOf(this.query) ? n.push(i) : r.push(i) : t.push(i);
+ return t.concat(n, r)
+ }, highlighter: function (e) {
+ var t = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
+ return e.replace(new RegExp("(" + t + ")", "ig"), function (e, t) {
+ return"<strong>" + t + "</strong>"
+ })
+ }, render: function (t) {
+ var n = this;
+ return t = e(t).map(function (t, r) {
+ return t = e(n.options.item).attr("data-value", r), t.find("a").html(n.highlighter(r)), t[0]
+ }), t.first().addClass("active"), this.$menu.html(t), this
+ }, next: function (t) {
+ var n = this.$menu.find(".active").removeClass("active"), r = n.next();
+ r.length || (r = e(this.$menu.find("li")[0])), r.addClass("active")
+ }, prev: function (e) {
+ var t = this.$menu.find(".active").removeClass("active"), n = t.prev();
+ n.length || (n = this.$menu.find("li").last()), n.addClass("active")
+ }, listen: function () {
+ this.$element.on("blur", e.proxy(this.blur, this)).on("keypress", e.proxy(this.keypress, this)).on("keyup", e.proxy(this.keyup, this)), (e.browser.chrome || e.browser.webkit || e.browser.msie) && this.$element.on("keydown", e.proxy(this.keydown, this)), this.$menu.on("click", e.proxy(this.click, this)).on("mouseenter", "li", e.proxy(this.mouseenter, this))
+ }, move: function (e) {
+ if (!this.shown)return;
+ switch (e.keyCode) {
+ case 9:
+ case 13:
+ case 27:
+ e.preventDefault();
+ break;
+ case 38:
+ e.preventDefault(), this.prev();
+ break;
+ case 40:
+ e.preventDefault(), this.next()
+ }
+ e.stopPropagation()
+ }, keydown: function (t) {
+ this.suppressKeyPressRepeat = !~e.inArray(t.keyCode, [40, 38, 9, 13, 27]), this.move(t)
+ }, keypress: function (e) {
+ if (this.suppressKeyPressRepeat)return;
+ this.move(e)
+ }, keyup: function (e) {
+ switch (e.keyCode) {
+ case 40:
+ case 38:
+ break;
+ case 9:
+ case 13:
+ if (!this.shown)return;
+ this.select();
+ break;
+ case 27:
+ if (!this.shown)return;
+ this.hide();
+ break;
+ default:
+ this.lookup()
+ }
+ e.stopPropagation(), e.preventDefault()
+ }, blur: function (e) {
+ var t = this;
+ setTimeout(function () {
+ t.hide()
+ }, 150)
+ }, click: function (e) {
+ e.stopPropagation(), e.preventDefault(), this.select()
+ }, mouseenter: function (t) {
+ this.$menu.find(".active").removeClass("active"), e(t.currentTarget).addClass("active")
+ }}, e.fn.typeahead = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("typeahead"), s = typeof n == "object" && n;
+ i || r.data("typeahead", i = new t(this, s)), typeof n == "string" && i[n]()
+ })
+ }, e.fn.typeahead.defaults = {source: [], items: 8, menu: '<ul class="typeahead dropdown-menu"></ul>', item: '<li><a href="#"></a></li>', minLength: 1}, e.fn.typeahead.Constructor = t, e(function () {
+ e("body").on("focus.typeahead.data-api", '[data-provide="typeahead"]', function (t) {
+ var n = e(this);
+ if (n.data("typeahead"))return;
+ t.preventDefault(), n.typeahead(n.data())
+ })
+ })
+}(window.jQuery), !function (e) {
+ "use strict";
+ var t = function (t, n) {
+ this.options = e.extend({}, e.fn.affix.defaults, n), this.$window = e(window).on("scroll.affix.data-api", e.proxy(this.checkPosition, this)), this.$element = e(t), this.checkPosition()
+ };
+ t.prototype.checkPosition = function () {
+ if (!this.$element.is(":visible"))return;
+ var t = e(document).height(), n = this.$window.scrollTop(), r = this.$element.offset(), i = this.options.offset, s = i.bottom, o = i.top, u = "affix affix-top affix-bottom", a;
+ typeof i != "object" && (s = o = i), typeof o == "function" && (o = i.top()), typeof s == "function" && (s = i.bottom()), a = this.unpin != null && n + this.unpin <= r.top ? !1 : s != null && r.top + this.$element.height() >= t - s ? "bottom" : o != null && n <= o ? "top" : !1;
+ if (this.affixed === a)return;
+ this.affixed = a, this.unpin = a == "bottom" ? r.top - n : null, this.$element.removeClass(u).addClass("affix" + (a ? "-" + a : ""))
+ }, e.fn.affix = function (n) {
+ return this.each(function () {
+ var r = e(this), i = r.data("affix"), s = typeof n == "object" && n;
+ i || r.data("affix", i = new t(this, s)), typeof n == "string" && i[n]()
+ })
+ }, e.fn.affix.Constructor = t, e.fn.affix.defaults = {offset: 0}, e(window).on("load", function () {
+ e('[data-spy="affix"]').each(function () {
+ var t = e(this), n = t.data();
+ n.offset = n.offset || {}, n.offsetBottom && (n.offset.bottom = n.offsetBottom), n.offsetTop && (n.offset.top = n.offsetTop), t.affix(n)
+ })
+ })
+}(window.jQuery);
\ No newline at end of file
diff --git a/content/examples/moviefun/src/main/webapp/default.css b/content/examples/moviefun/src/main/webapp/default.css
new file mode 100755
index 0000000..cc1946f
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/default.css
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+body, p, td, table, tr, .bodytext, .stepfield {
+ font-family: Verdana, arial, sans-serif;
+ font-size: 11px;
+ line-height: 16px;
+ color: #000000;
+ font-weight: normal;
+}
+
+body {
+ margin: 0px;
+ padding: 0px;
+ text-align: center;
+ background-color: #f0f0f0;
+}
+
+#Content {
+ text-align: left;
+ background-color: #fff;
+ padding: 0px;
+ margin: 0px;
+}
+
+HR {
+ color: 3 c78b5;
+ height: 1;
+}
+
+A:link, A:visited, A:active, A:hover {
+ color: #003366;
+}
+
+h1 A:link, h1 A:visited, h1 A:active {
+ text-decoration: none;
+}
+
+h1 A:hover {
+ border-bottom: 1px dotted #003366;
+}
+
+input {
+ font-family: verdana, geneva, arial, sans-serif;
+ font-size: 11px;
+ color: #000000;
+}
+
+h1 {
+ font-size: 24px;
+ line-height: normal;
+ font-weight: bold;
+ background-color: #f0f0f0;
+ color: #003366;
+ border-bottom: 1px solid #3c78b5;
+ padding: 2px;
+ margin: 36px 0px 4px 0px;
+}
+
+h2 {
+ font-size: 18px;
+ line-height: normal;
+ font-weight: bold;
+ background-color: #f0f0f0;
+ border-bottom: 1px solid #3c78b5;
+ padding: 2px;
+ margin: 27px 0px 4px 0px;
+}
+
+h3 {
+ font-size: 14px;
+ line-height: normal;
+ font-weight: bold;
+ background-color: #f0f0f0;
+ padding: 2px;
+ margin: 21px 0px 4px 0px;
+}
+
+h4 {
+ font-size: 12px;
+ line-height: normal;
+ font-weight: bold;
+ background-color: #f0f0f0;
+ padding: 2px;
+ margin: 18px 0px 4px 0px;
+}
+
+h4.search {
+ font-size: 12px;
+ line-height: normal;
+ font-weight: normal;
+ background-color: #f0f0f0;
+ padding: 4px;
+ margin: 18px 0px 4px 0px;
+}
+
+h5 {
+ font-size: 10px;
+ line-height: normal;
+ font-weight: bold;
+ background-color: #f0f0f0;
+ padding: 2px;
+ margin: 14px 0px 4px 0px;
+}
+
+h6 {
+ font-size: 8px;
+ line-height: normal;
+ font-weight: bold;
+ background-color: #f0f0f0;
+ padding: 2px;
+ margin: 14px 0px 4px 0px;
+}
+
+.smalltext {
+ color: #666666;
+ font-size: 10px;
+}
+
+.smalltext a {
+ color: #666666;
+}
+
+.tableview table {
+ margin: 0;
+}
+
+.tableview th {
+ text-align: left;
+ color: #003366;
+ font-size: 12px;
+ padding: 5px 0px 0px 5px;
+ border-bottom: 2px solid #3c78b5;
+}
+
+.tableview td {
+ text-align: left;
+ border-color: #ccc;
+ border-width: 0px 0px 1px 0px;
+ border-style: solid;
+ margin: 0;
+ padding: 4px 10px 4px 5px;
+}
+
+.bottomshadow {
+ height: 12px;
+ background-image: url("/images/border/border_bottom.gif");
+ background-repeat: repeat-x;
+}
+
+.topBarDiv a:link {
+ color: white;
+}
+
+.topBarDiv a:visited {
+ color: white;
+}
+
+.topBarDiv a:active {
+ color: white;
+}
+
+.topBarDiv a:hover {
+ color: white;
+}
+
+.topBarDiv {
+ color: white;
+}
+
+.topBar td {
+ background-color: #003366;
+}
+
+.basicPanelContainer {
+ border: 1px solid #3c78b5;
+ margin-top: 2px;
+ margin-bottom: 8px;
+ width: 100%
+}
+
+.basicPanelTitle {
+ padding: 5px;
+ margin: 0px;
+ background-color: #f0f0f0;
+ color: black;
+ font-weight: bold;
+}
+
+.basicPanelBody {
+ padding: 5px;
+ margin: 0px
+}
diff --git a/content/examples/moviefun/src/main/webapp/index.jsp b/content/examples/moviefun/src/main/webapp/index.jsp
new file mode 100755
index 0000000..2e4f7c2
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/index.jsp
@@ -0,0 +1,75 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<c:set var="language" value="${pageContext.request.locale}"/>
+<fmt:setLocale value="${language}"/>
+
+<!DOCTYPE html>
+<html lang="${language}">
+<head>
+ <meta charset="utf-8">
+ <title>Moviefun</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <!-- Le styles -->
+ <link href="assets/css/bootstrap.css" rel="stylesheet">
+ <link href="assets/css/movie.css" rel="stylesheet">
+ <style>
+ body {
+ padding-top: 60px;
+ /* 60px to make the container go all the way to the bottom of the topbar */
+ }
+ </style>
+ <link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
+
+ <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+</head>
+
+<body>
+
+<div class="navbar navbar-inverse navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse"
+ data-target=".nav-collapse"> <span class="icon-bar"></span> <span
+ class="icon-bar"></span> <span class="icon-bar"></span>
+ </a> <a class="brand" href="#">Moviefun</a>
+ <!--/.nav-collapse -->
+ </div>
+ </div>
+</div>
+
+<div class="container">
+
+ <h1>Moviefun</h1>
+
+ <p>Please select one of the following links:</p>
+ <a href="setup.jsp">Setup</a> - Sets up the application with some sample data<br/>
+ <a href="moviefun">Index</a> - Start the application<br/>
+
+</div>
+<!-- /container -->
+</body>
+</html>
diff --git a/content/examples/moviefun/src/main/webapp/setup.jsp b/content/examples/moviefun/src/main/webapp/setup.jsp
new file mode 100755
index 0000000..4184b28
--- /dev/null
+++ b/content/examples/moviefun/src/main/webapp/setup.jsp
@@ -0,0 +1,115 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--%>
+<%@ page import=" org.superbiz.moviefun.Movie" %>
+<%@ page import="org.superbiz.moviefun.MoviesBean" %>
+<%@ page import="javax.naming.InitialContext" %>
+<%@ page import="java.util.Iterator" %>
+<%@ page import="java.util.List" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%
+ InitialContext initialContext = new InitialContext();
+ MoviesBean moviesBean = (MoviesBean) initialContext.lookup("java:comp/env/org.superbiz.moviefun.ActionServlet/moviesBean");
+
+ moviesBean.addMovie(new Movie("Wedding Crashers", "David Dobkin", "Comedy", 7, 2005));
+ moviesBean.addMovie(new Movie("Starsky & Hutch", "Todd Phillips", "Action", 6, 2004));
+ moviesBean.addMovie(new Movie("Shanghai Knights", "David Dobkin", "Action", 6, 2003));
+ moviesBean.addMovie(new Movie("I-Spy", "Betty Thomas", "Adventure", 5, 2002));
+ moviesBean.addMovie(new Movie("The Royal Tenenbaums", "Wes Anderson", "Comedy", 8, 2001));
+ moviesBean.addMovie(new Movie("Zoolander", "Ben Stiller", "Comedy", 6, 2001));
+ moviesBean.addMovie(new Movie("Shanghai Noon", "Tom Dey", "Comedy", 7, 2000));
+%>
+<c:set var="language" value="${pageContext.request.locale}"/>
+<fmt:setLocale value="${language}"/>
+
+<!DOCTYPE html>
+<html lang="${language}">
+<head>
+ <meta charset="utf-8">
+ <title>Moviefun</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <!-- Le styles -->
+ <link href="assets/css/bootstrap.css" rel="stylesheet">
+ <link href="assets/css/movie.css" rel="stylesheet">
+ <style>
+ body {
+ padding-top: 60px;
+ /* 60px to make the container go all the way to the bottom of the topbar */
+ }
+ </style>
+ <link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
+
+ <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
+ <!--[if lt IE 9]>
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+</head>
+
+<body>
+
+<div class="navbar navbar-inverse navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="collapse"
+ data-target=".nav-collapse"> <span class="icon-bar"></span> <span
+ class="icon-bar"></span> <span class="icon-bar"></span>
+ </a> <a class="brand" href="#">Moviefun</a>
+ <!--/.nav-collapse -->
+ </div>
+ </div>
+</div>
+
+<div class="container">
+
+ <h1>Moviefun</h1>
+
+ <h2>Seeded Database with the Following movies</h2>
+ <table width="500">
+ <tr>
+ <td><b>Title</b></td>
+ <td><b>Director</b></td>
+ <td><b>Genre</b></td>
+ </tr>
+ <%
+ List<Movie> movies = moviesBean.getMovies();
+ for (Iterator<Movie> iterator = movies.iterator(); iterator.hasNext(); ) {
+ Movie movie = (Movie) iterator.next();
+ %>
+ <tr>
+ <td><%=movie.getTitle()%>
+ </td>
+ <td><%=movie.getDirector()%>
+ </td>
+ <td><%=movie.getGenre()%>
+ </td>
+ </tr>
+
+ <%
+ }
+ %>
+ </table>
+
+ <h2>Continue</h2>
+ <a href="moviefun">Go to main app</a>
+</div>
+<!-- /container -->
+</body>
+</html>
diff --git a/content/examples/moviefun/src/test/java/org/superbiz/moviefun/Basedir.java b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/Basedir.java
new file mode 100755
index 0000000..aaabf36
--- /dev/null
+++ b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/Basedir.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import org.apache.ziplock.JarLocation;
+
+import java.io.File;
+
+/**
+* @version $Revision$ $Date$
+*/
+public class Basedir {
+
+ public static File basedir(final String s) {
+ final File classes = JarLocation.jarLocation(MoviesArquillianHtmlUnitTest.class);
+ final File target = classes.getParentFile();
+ final File basedir = target.getParentFile();
+ return new File(basedir, s);
+ }
+}
diff --git a/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesArquillianHtmlUnitTest.java b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesArquillianHtmlUnitTest.java
new file mode 100755
index 0000000..42fe599
--- /dev/null
+++ b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesArquillianHtmlUnitTest.java
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Filters;
+import org.jboss.shrinkwrap.api.GenericArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.importer.ExplodedImporter;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.EJB;
+import java.io.File;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class MoviesArquillianHtmlUnitTest {
+
+ private static final String WEBAPP_SRC = "src/main/webapp";
+
+ @Deployment
+ public static WebArchive createDeployment() {
+
+ Collection<String> dependencies = Arrays.asList(new String[]{
+ "javax.servlet:jstl",
+ "taglibs:standard",
+ "commons-lang:commons-lang"
+ });
+
+ File[] libs = Maven.resolver()
+ .loadPomFromFile(Basedir.basedir("pom.xml")).resolve(dependencies)
+ .withTransitivity().asFile();
+
+ WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(Movie.class, MoviesBean.class, MoviesArquillianHtmlUnitTest.class, ActionServlet.class)
+ .addAsResource(new ClassLoaderAsset("META-INF/ejb-jar.xml"), "META-INF/ejb-jar.xml")
+ .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml")
+ .addAsLibraries(libs);
+
+ war.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
+ .importDirectory(Basedir.basedir(WEBAPP_SRC)).as(GenericArchive.class),
+ "/", Filters.includeAll());
+
+ return war;
+ }
+
+ @EJB
+ private MoviesBean movies;
+
+ @ArquillianResource
+ private URL deploymentUrl;
+
+ @Before
+ @After
+ public void clean() {
+ movies.clean();
+ }
+
+ @Test
+ public void testShouldMakeSureWebappIsWorking() throws Exception {
+ WebClient webClient = new WebClient();
+ HtmlPage page = webClient.getPage(deploymentUrl + "/setup.jsp");
+
+ assertMoviesPresent(page);
+
+ page = webClient.getPage(deploymentUrl + "/moviefun");
+
+ assertMoviesPresent(page);
+ webClient.closeAllWindows();
+ }
+
+ private void assertMoviesPresent(HtmlPage page) {
+ String pageAsText = page.asText();
+ assertTrue(pageAsText.contains("Wedding Crashers"));
+ assertTrue(pageAsText.contains("Starsky & Hutch"));
+ assertTrue(pageAsText.contains("Shanghai Knights"));
+ assertTrue(pageAsText.contains("I-Spy"));
+ assertTrue(pageAsText.contains("The Royal Tenenbaums"));
+ }
+
+}
diff --git a/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java
new file mode 100755
index 0000000..37f4699
--- /dev/null
+++ b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesEJBTest.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ejb.EJB;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class MoviesEJBTest {
+
+ @Deployment
+ public static WebArchive createDeployment() {
+ return ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(Movie.class, MoviesBean.class, MoviesEJBTest.class)
+ .addAsResource(new ClassLoaderAsset("META-INF/ejb-jar.xml"), "META-INF/ejb-jar.xml")
+ .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");
+ }
+
+ @EJB
+ private MoviesBean movies;
+
+ @Before
+ @After
+ public void clean() {
+ movies.clean();
+ }
+
+ @Test
+ public void shouldBeAbleToAddAMovie() throws Exception {
+ assertNotNull("Verify that the ejb was injected", movies);
+
+ Movie movie = new Movie();
+ movie.setDirector("Michael Bay");
+ movie.setGenre("Action");
+ movie.setRating(9);
+ movie.setTitle("Bad Boys");
+ movie.setYear(1995);
+ movies.addMovie(movie);
+
+ assertEquals(1, movies.countAll());
+ List<Movie> moviesFound = movies.findRange("title", "Bad Boys", 0, 5);
+
+ assertEquals(1, moviesFound.size());
+ assertEquals("Michael Bay", moviesFound.get(0).getDirector());
+ assertEquals("Action", moviesFound.get(0).getGenre());
+ assertEquals(9, moviesFound.get(0).getRating());
+ assertEquals("Bad Boys", moviesFound.get(0).getTitle());
+ assertEquals(1995, moviesFound.get(0).getYear());
+ }
+
+}
diff --git a/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java
new file mode 100755
index 0000000..71af57a
--- /dev/null
+++ b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesEmbeddedEJBTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+
+public class MoviesEmbeddedEJBTest {
+
+ private static EJBContainer ejbContainer;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ if (ejbContainer != null) {
+ ejbContainer.close();
+ }
+ }
+
+ @Before
+ @After
+ public void clean() throws Exception {
+ MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun/MoviesBean!org.superbiz.moviefun.MoviesBean");
+ movies.clean();
+ }
+
+ @Test
+ public void testShouldAddAMovie() throws Exception {
+ MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun/MoviesBean!org.superbiz.moviefun.MoviesBean");
+
+ Movie movie = new Movie();
+ movie.setDirector("Michael Bay");
+ movie.setGenre("Action");
+ movie.setRating(9);
+ movie.setTitle("Bad Boys");
+ movie.setYear(1995);
+ movies.addMovie(movie);
+
+ Assert.assertEquals(1, movies.countAll());
+ List<Movie> moviesFound = movies.findRange("title", "Bad Boys", 0, 10);
+
+ Assert.assertEquals(1, moviesFound.size());
+ Assert.assertEquals("Michael Bay", moviesFound.get(0).getDirector());
+ Assert.assertEquals("Action", moviesFound.get(0).getGenre());
+ Assert.assertEquals(9, moviesFound.get(0).getRating());
+ Assert.assertEquals("Bad Boys", moviesFound.get(0).getTitle());
+ Assert.assertEquals(1995, moviesFound.get(0).getYear());
+ }
+
+}
\ No newline at end of file
diff --git a/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java
new file mode 100755
index 0000000..6c7e364
--- /dev/null
+++ b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesHtmlUnitTest.java
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import org.apache.commons.io.FileUtils;
+import org.apache.tomee.embedded.EmbeddedTomEEContainer;
+import org.apache.ziplock.Archive;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import java.io.File;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+import static org.superbiz.moviefun.Basedir.basedir;
+
+public class MoviesHtmlUnitTest {
+
+ private static EJBContainer container;
+ private static File webApp;
+ private static int port;
+
+ @BeforeClass
+ public static void start() throws IOException {
+
+ // get a random unused port to use for http requests
+ ServerSocket server = new ServerSocket(0);
+ port = server.getLocalPort();
+ server.close();
+
+ webApp = createWebApp();
+ Properties p = new Properties();
+ p.setProperty(EJBContainer.APP_NAME, "moviefun");
+ p.setProperty(EJBContainer.PROVIDER, "tomee-embedded"); // need web feature
+ p.setProperty(EJBContainer.MODULES, webApp.getAbsolutePath());
+ p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, String.valueOf(port));
+ container = EJBContainer.createEJBContainer(p);
+ }
+
+ @AfterClass
+ public static void stop() {
+ if (container != null) {
+ container.close();
+ }
+ if (webApp != null) {
+ try {
+ FileUtils.forceDelete(webApp);
+ } catch (IOException e) {
+ FileUtils.deleteQuietly(webApp);
+ }
+ }
+ }
+
+ private static File createWebApp() throws IOException {
+ return Archive.archive()
+ .copyTo("WEB-INF/classes", basedir("target/classes"))
+ .copyTo("WEB-INF/lib", basedir("target/test-libs"))
+ .copyTo("", basedir("src/main/webapp"))
+ .asDir();
+ }
+
+ @Test
+ public void testShouldMakeSureWebappIsWorking() throws Exception {
+ WebClient webClient = new WebClient();
+ HtmlPage page = webClient.getPage("http://localhost:" + port + "/moviefun/setup.jsp");
+
+ assertMoviesPresent(page);
+
+ page = webClient.getPage("http://localhost:" + port + "/moviefun/moviefun");
+
+ assertMoviesPresent(page);
+ webClient.closeAllWindows();
+ }
+
+ private void assertMoviesPresent(HtmlPage page) {
+ String pageAsText = page.asText();
+ assertTrue(pageAsText.contains("Wedding Crashers"));
+ assertTrue(pageAsText.contains("Starsky & Hutch"));
+ assertTrue(pageAsText.contains("Shanghai Knights"));
+ assertTrue(pageAsText.contains("I-Spy"));
+ assertTrue(pageAsText.contains("The Royal Tenenbaums"));
+ }
+}
diff --git a/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesTest.java b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesTest.java
new file mode 100755
index 0000000..af611e9
--- /dev/null
+++ b/content/examples/moviefun/src/test/java/org/superbiz/moviefun/MoviesTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.moviefun;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+
+public class MoviesTest {
+
+ private static EJBContainer ejbContainer;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ if (ejbContainer != null) {
+ ejbContainer.close();
+ }
+ }
+
+ @Before
+ @After
+ public void clean() throws Exception {
+ MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun/MoviesBean!org.superbiz.moviefun.MoviesBean");
+ movies.clean();
+ }
+
+ @Test
+ public void testShouldAddAMovie() throws Exception {
+ MoviesBean movies = (MoviesBean) ejbContainer.getContext().lookup("java:global/moviefun/MoviesBean!org.superbiz.moviefun.MoviesBean");
+
+ Movie movie = new Movie();
+ movie.setDirector("Michael Bay");
+ movie.setGenre("Action");
+ movie.setRating(9);
+ movie.setTitle("Bad Boys");
+ movie.setYear(1995);
+ movies.addMovie(movie);
+
+ Assert.assertEquals(1, movies.countAll());
+ List<Movie> moviesFound = movies.findRange("title", "Bad Boys", 0, 10);
+
+ Assert.assertEquals(1, moviesFound.size());
+ Assert.assertEquals("Michael Bay", moviesFound.get(0).getDirector());
+ Assert.assertEquals("Action", moviesFound.get(0).getGenre());
+ Assert.assertEquals(9, moviesFound.get(0).getRating());
+ Assert.assertEquals("Bad Boys", moviesFound.get(0).getTitle());
+ Assert.assertEquals(1995, moviesFound.get(0).getYear());
+ }
+
+}
\ No newline at end of file
diff --git a/content/examples/moviefun/src/test/resources/META-INF/application-client.xml b/content/examples/moviefun/src/test/resources/META-INF/application-client.xml
new file mode 100755
index 0000000..1e91dca
--- /dev/null
+++ b/content/examples/moviefun/src/test/resources/META-INF/application-client.xml
@@ -0,0 +1 @@
+<application-client/>
\ No newline at end of file
diff --git a/content/examples/moviefun/src/test/resources/arquillian.xml b/content/examples/moviefun/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..4a2f32f
--- /dev/null
+++ b/content/examples/moviefun/src/test/resources/arquillian.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+
+ <container qualifier="tomee" default="true">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="tomcatVersion"></property>
+ <property name="openejbVersion">${tomee.version}</property>
+ <property name="dir">target/apache-tomee-remote</property>
+ <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+ </configuration>
+ </container>
+</arquillian>
\ No newline at end of file
diff --git a/content/examples/movies-complete-meta.html b/content/examples/movies-complete-meta.html
new file mode 100644
index 0000000..8f78867
--- /dev/null
+++ b/content/examples/movies-complete-meta.html
@@ -0,0 +1,694 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/movies-complete-meta.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Movies Complete Meta</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example movies-complete-meta can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/movies-complete-meta" class="bare">https://github.com/apache/tomee/tree/master/examples/movies-complete-meta</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_addinterceptor">AddInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AddInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Add
+ return context.proceed();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_add">Add</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx.api;
+
+import org.superbiz.injection.tx.AddInterceptor;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.interceptor.Interceptors;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+public @interface Add {
+ public interface $ {
+
+ @Add
+ @RolesAllowed({"Employee", "Manager"})
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ @Interceptors(AddInterceptor.class)
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_delete">Delete</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx.api;
+
+import org.superbiz.injection.tx.DeleteInterceptor;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.interceptor.Interceptors;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+public @interface Delete {
+ public interface $ {
+
+ @Delete
+ @RolesAllowed({"Manager"})
+ @TransactionAttribute(TransactionAttributeType.MANDATORY)
+ @Interceptors(DeleteInterceptor.class)
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_metatype">Metatype</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface Metatype {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movieunit">MovieUnit</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx.api;
+
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Metatype
+@Target({ElementType.METHOD, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+
+@PersistenceContext(name = "movie-unit", unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+public @interface MovieUnit {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_read">Read</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx.api;
+
+import javax.annotation.security.PermitAll;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+public @interface Read {
+ public interface $ {
+
+ @Read
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_deleteinterceptor">DeleteInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class DeleteInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import org.superbiz.injection.tx.api.Add;
+import org.superbiz.injection.tx.api.Delete;
+import org.superbiz.injection.tx.api.MovieUnit;
+import org.superbiz.injection.tx.api.Read;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.List;
+
+//END SNIPPET: code
+
+//START SNIPPET: code
+@Stateful
+public class Movies {
+
+ @MovieUnit
+ private EntityManager entityManager;
+
+ @Add
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @Delete
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @Read
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import junit.framework.TestCase;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+/**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "TransactionBean")
+ private Caller transactionalCaller;
+
+ @EJB(beanName = "NoTransactionBean")
+ private Caller nonTransactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ nonTransactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public static class NoTransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.tx.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/movies-complete-meta
+INFO - openejb.base = /Users/dblevins/examples/movies-complete-meta
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete-meta/target/test-classes
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete-meta/target/classes
+INFO - Beginning load: /Users/dblevins/examples/movies-complete-meta/target/test-classes
+INFO - Beginning load: /Users/dblevins/examples/movies-complete-meta/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/movies-complete-meta
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/movies-complete-meta" loaded.
+INFO - Assembling app: /Users/dblevins/examples/movies-complete-meta
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 408ms
+INFO - Jndi(name="java:global/movies-complete-meta/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+INFO - Jndi(name="java:global/movies-complete-meta/TransactionBean")
+INFO - Jndi(name="java:global/movies-complete-meta/NoTransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+INFO - Jndi(name="java:global/movies-complete-meta/NoTransactionBean")
+INFO - Jndi(name="java:global/movies-complete-meta/Movies!org.superbiz.injection.tx.Movies")
+INFO - Jndi(name="java:global/movies-complete-meta/Movies")
+INFO - Jndi(name="java:global/EjbModule1861413442/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1861413442/org.superbiz.injection.tx.MoviesTest")
+INFO - Created Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/movies-complete-meta)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.869 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/movies-complete-meta.pdf b/content/examples/movies-complete-meta.pdf
new file mode 100644
index 0000000..60c6c84
--- /dev/null
+++ b/content/examples/movies-complete-meta.pdf
Binary files differ
diff --git a/content/examples/movies-complete-meta/README.md b/content/examples/movies-complete-meta/README.md
new file mode 100755
index 0000000..8b94ae2
--- /dev/null
+++ b/content/examples/movies-complete-meta/README.md
@@ -0,0 +1,435 @@
+Title: Movies Complete Meta
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## AddInterceptor
+
+ package org.superbiz.injection.tx;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class AddInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Add
+ return context.proceed();
+ }
+ }
+
+## Add
+
+ package org.superbiz.injection.tx.api;
+
+ import org.superbiz.injection.tx.AddInterceptor;
+
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.interceptor.Interceptors;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+
+ public @interface Add {
+ public interface $ {
+
+ @Add
+ @RolesAllowed({"Employee", "Manager"})
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ @Interceptors(AddInterceptor.class)
+ public void method();
+ }
+ }
+
+## Delete
+
+ package org.superbiz.injection.tx.api;
+
+ import org.superbiz.injection.tx.DeleteInterceptor;
+
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.interceptor.Interceptors;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+
+ public @interface Delete {
+ public interface $ {
+
+ @Delete
+ @RolesAllowed({"Manager"})
+ @TransactionAttribute(TransactionAttributeType.MANDATORY)
+ @Interceptors(DeleteInterceptor.class)
+ public void method();
+ }
+ }
+
+## Metatype
+
+ package org.superbiz.injection.tx.api;
+
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.ANNOTATION_TYPE)
+ public @interface Metatype {
+ }
+
+## MovieUnit
+
+ package org.superbiz.injection.tx.api;
+
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+
+ @Metatype
+ @Target({ElementType.METHOD, ElementType.FIELD})
+ @Retention(RetentionPolicy.RUNTIME)
+
+ @PersistenceContext(name = "movie-unit", unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ public @interface MovieUnit {
+ }
+
+## Read
+
+ package org.superbiz.injection.tx.api;
+
+ import javax.annotation.security.PermitAll;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+
+ public @interface Read {
+ public interface $ {
+
+ @Read
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void method();
+ }
+ }
+
+## DeleteInterceptor
+
+ package org.superbiz.injection.tx;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class DeleteInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+ }
+
+## Movie
+
+ package org.superbiz.injection.tx;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection.tx;
+
+ import org.superbiz.injection.tx.api.Add;
+ import org.superbiz.injection.tx.api.Delete;
+ import org.superbiz.injection.tx.api.MovieUnit;
+ import org.superbiz.injection.tx.api.Read;
+
+ import javax.ejb.Stateful;
+ import javax.persistence.EntityManager;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ //END SNIPPET: code
+
+ //START SNIPPET: code
+ @Stateful
+ public class Movies {
+
+ @MovieUnit
+ private EntityManager entityManager;
+
+ @Add
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @Delete
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @Read
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MoviesTest
+
+ package org.superbiz.injection.tx;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.security.RunAs;
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.ejb.embeddable.EJBContainer;
+ import java.util.List;
+ import java.util.Properties;
+ import java.util.concurrent.Callable;
+
+ import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+ /**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+ //START SNIPPET: code
+ public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "TransactionBean")
+ private Caller transactionalCaller;
+
+ @EJB(beanName = "NoTransactionBean")
+ private Caller nonTransactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ nonTransactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public static class NoTransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.tx.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/movies-complete-meta
+ INFO - openejb.base = /Users/dblevins/examples/movies-complete-meta
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete-meta/target/test-classes
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete-meta/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/movies-complete-meta/target/test-classes
+ INFO - Beginning load: /Users/dblevins/examples/movies-complete-meta/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/movies-complete-meta
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/movies-complete-meta" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/movies-complete-meta
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 408ms
+ INFO - Jndi(name="java:global/movies-complete-meta/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+ INFO - Jndi(name="java:global/movies-complete-meta/TransactionBean")
+ INFO - Jndi(name="java:global/movies-complete-meta/NoTransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+ INFO - Jndi(name="java:global/movies-complete-meta/NoTransactionBean")
+ INFO - Jndi(name="java:global/movies-complete-meta/Movies!org.superbiz.injection.tx.Movies")
+ INFO - Jndi(name="java:global/movies-complete-meta/Movies")
+ INFO - Jndi(name="java:global/EjbModule1861413442/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1861413442/org.superbiz.injection.tx.MoviesTest")
+ INFO - Created Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/movies-complete-meta)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.869 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/movies-complete-meta/build.xml b/content/examples/movies-complete-meta/build.xml
new file mode 100755
index 0000000..4f29800
--- /dev/null
+++ b/content/examples/movies-complete-meta/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/movies-complete-meta/pom.xml b/content/examples/movies-complete-meta/pom.xml
new file mode 100755
index 0000000..fb8cee7
--- /dev/null
+++ b/content/examples/movies-complete-meta/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>movies-complete-meta</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Movies Complete (Meta)</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/AddInterceptor.java b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/AddInterceptor.java
new file mode 100755
index 0000000..c9f9cef
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/AddInterceptor.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AddInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Add
+ return context.proceed();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/DeleteInterceptor.java b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/DeleteInterceptor.java
new file mode 100755
index 0000000..a20fc75
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/DeleteInterceptor.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class DeleteInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+}
diff --git a/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/Movie.java b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/Movie.java
new file mode 100755
index 0000000..1d0c359
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/Movies.java b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/Movies.java
new file mode 100755
index 0000000..6ed16d0
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/Movies.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import org.superbiz.injection.tx.api.Add;
+import org.superbiz.injection.tx.api.Delete;
+import org.superbiz.injection.tx.api.MovieUnit;
+import org.superbiz.injection.tx.api.Read;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.List;
+
+//END SNIPPET: code
+
+//START SNIPPET: code
+@Stateful
+public class Movies {
+
+ @MovieUnit
+ private EntityManager entityManager;
+
+ @Add
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @Delete
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @Read
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Add.java b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Add.java
new file mode 100755
index 0000000..2507d5b
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Add.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx.api;
+
+import org.superbiz.injection.tx.AddInterceptor;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.interceptor.Interceptors;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+public @interface Add {
+
+ public interface $ {
+
+ @Add
+ @RolesAllowed({"Employee", "Manager"})
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ @Interceptors(AddInterceptor.class)
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Delete.java b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Delete.java
new file mode 100755
index 0000000..8565d27
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Delete.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx.api;
+
+import org.superbiz.injection.tx.DeleteInterceptor;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.interceptor.Interceptors;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+public @interface Delete {
+
+ public interface $ {
+
+ @Delete
+ @RolesAllowed({"Manager"})
+ @TransactionAttribute(TransactionAttributeType.MANDATORY)
+ @Interceptors(DeleteInterceptor.class)
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Metatype.java b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Metatype.java
new file mode 100755
index 0000000..0bf8570
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Metatype.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface Metatype {
+
+}
diff --git a/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/MovieUnit.java b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/MovieUnit.java
new file mode 100755
index 0000000..b6f6ffc
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/MovieUnit.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx.api;
+
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target({ElementType.METHOD, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+
+@PersistenceContext(name = "movie-unit", unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+public @interface MovieUnit {
+
+}
diff --git a/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Read.java b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Read.java
new file mode 100755
index 0000000..f3d7f5a
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/java/org/superbiz/injection/tx/api/Read.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx.api;
+
+import javax.annotation.security.PermitAll;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+
+public @interface Read {
+
+ public interface $ {
+
+ @Read
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void method();
+ }
+}
diff --git a/content/examples/movies-complete-meta/src/main/resources/META-INF/persistence.xml b/content/examples/movies-complete-meta/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..029144e
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/movies-complete-meta/src/test/java/org/superbiz/injection/tx/MoviesTest.java b/content/examples/movies-complete-meta/src/test/java/org/superbiz/injection/tx/MoviesTest.java
new file mode 100755
index 0000000..fcd5826
--- /dev/null
+++ b/content/examples/movies-complete-meta/src/test/java/org/superbiz/injection/tx/MoviesTest.java
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import junit.framework.TestCase;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+/**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "TransactionBean")
+ private Caller transactionalCaller;
+
+ @EJB(beanName = "NoTransactionBean")
+ private Caller nonTransactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ transactionalCaller.call(new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ for (final Movie m : movies.getMovies()) {
+ movies.deleteMovie(m);
+ }
+ return null;
+ }
+ });
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ nonTransactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+ public static interface Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public static class NoTransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/movies-complete.html b/content/examples/movies-complete.html
new file mode 100644
index 0000000..f64d671
--- /dev/null
+++ b/content/examples/movies-complete.html
@@ -0,0 +1,573 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/movies-complete.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Movies Complete</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example movies-complete can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/movies-complete" class="bare">https://github.com/apache/tomee/tree/master/examples/movies-complete</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_addinterceptor">AddInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AddInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Add
+ return context.proceed();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_deleteinterceptor">DeleteInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class DeleteInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.interceptor.Interceptors;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+//START SNIPPET: code
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ @Interceptors(AddInterceptor.class)
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ @TransactionAttribute(TransactionAttributeType.MANDATORY)
+ @Interceptors(DeleteInterceptor.class)
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_readinterceptor">ReadInterceptor</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class ReadInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import junit.framework.TestCase;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+/**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "TransactionBean")
+ private Caller transactionalCaller;
+
+ @EJB(beanName = "NoTransactionBean")
+ private Caller nonTransactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ nonTransactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public static class NoTransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.tx.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/movies-complete
+INFO - openejb.base = /Users/dblevins/examples/movies-complete
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/classes
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/test-classes
+INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/classes
+INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/test-classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/movies-complete
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/movies-complete" loaded.
+INFO - Assembling app: /Users/dblevins/examples/movies-complete
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 402ms
+INFO - Jndi(name="java:global/movies-complete/Movies!org.superbiz.injection.tx.Movies")
+INFO - Jndi(name="java:global/movies-complete/Movies")
+INFO - Jndi(name="java:global/movies-complete/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+INFO - Jndi(name="java:global/movies-complete/TransactionBean")
+INFO - Jndi(name="java:global/movies-complete/NoTransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+INFO - Jndi(name="java:global/movies-complete/NoTransactionBean")
+INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/movies-complete)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.418 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/movies-complete.pdf b/content/examples/movies-complete.pdf
new file mode 100644
index 0000000..4484fca
--- /dev/null
+++ b/content/examples/movies-complete.pdf
Binary files differ
diff --git a/content/examples/movies-complete/README.md b/content/examples/movies-complete/README.md
new file mode 100755
index 0000000..990258a
--- /dev/null
+++ b/content/examples/movies-complete/README.md
@@ -0,0 +1,338 @@
+Title: Movies Complete
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## AddInterceptor
+
+ package org.superbiz.injection.tx;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class AddInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Add
+ return context.proceed();
+ }
+ }
+
+## DeleteInterceptor
+
+ package org.superbiz.injection.tx;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class DeleteInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+ }
+
+## Movie
+
+ package org.superbiz.injection.tx;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection.tx;
+
+ import javax.annotation.security.PermitAll;
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.Stateful;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.interceptor.Interceptors;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ //START SNIPPET: code
+ @Stateful
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ @Interceptors(AddInterceptor.class)
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ @TransactionAttribute(TransactionAttributeType.MANDATORY)
+ @Interceptors(DeleteInterceptor.class)
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## ReadInterceptor
+
+ package org.superbiz.injection.tx;
+
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class ReadInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MoviesTest
+
+ package org.superbiz.injection.tx;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.security.RunAs;
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.ejb.embeddable.EJBContainer;
+ import java.util.List;
+ import java.util.Properties;
+ import java.util.concurrent.Callable;
+
+ import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+ /**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+ //START SNIPPET: code
+ public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "TransactionBean")
+ private Caller transactionalCaller;
+
+ @EJB(beanName = "NoTransactionBean")
+ private Caller nonTransactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ nonTransactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public static class NoTransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.tx.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/movies-complete
+ INFO - openejb.base = /Users/dblevins/examples/movies-complete
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/classes
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/test-classes
+ INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/test-classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/movies-complete
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/movies-complete" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/movies-complete
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 402ms
+ INFO - Jndi(name="java:global/movies-complete/Movies!org.superbiz.injection.tx.Movies")
+ INFO - Jndi(name="java:global/movies-complete/Movies")
+ INFO - Jndi(name="java:global/movies-complete/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+ INFO - Jndi(name="java:global/movies-complete/TransactionBean")
+ INFO - Jndi(name="java:global/movies-complete/NoTransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+ INFO - Jndi(name="java:global/movies-complete/NoTransactionBean")
+ INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/movies-complete)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.418 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/movies-complete/build.xml b/content/examples/movies-complete/build.xml
new file mode 100755
index 0000000..4f29800
--- /dev/null
+++ b/content/examples/movies-complete/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/movies-complete/pom.xml b/content/examples/movies-complete/pom.xml
new file mode 100755
index 0000000..00ee975
--- /dev/null
+++ b/content/examples/movies-complete/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>movies-complete</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Movies Complete</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/AddInterceptor.java b/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/AddInterceptor.java
new file mode 100755
index 0000000..c9f9cef
--- /dev/null
+++ b/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/AddInterceptor.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AddInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Add
+ return context.proceed();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/DeleteInterceptor.java b/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/DeleteInterceptor.java
new file mode 100755
index 0000000..a20fc75
--- /dev/null
+++ b/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/DeleteInterceptor.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class DeleteInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+}
diff --git a/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/Movie.java b/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/Movie.java
new file mode 100755
index 0000000..1d0c359
--- /dev/null
+++ b/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/Movies.java b/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/Movies.java
new file mode 100755
index 0000000..73f9e04
--- /dev/null
+++ b/content/examples/movies-complete/src/main/java/org/superbiz/injection/tx/Movies.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.interceptor.Interceptors;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+//START SNIPPET: code
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ @Interceptors(AddInterceptor.class)
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ @TransactionAttribute(TransactionAttributeType.MANDATORY)
+ @Interceptors(DeleteInterceptor.class)
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/movies-complete/src/main/resources/META-INF/persistence.xml b/content/examples/movies-complete/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..029144e
--- /dev/null
+++ b/content/examples/movies-complete/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/movies-complete/src/test/java/org/superbiz/injection/tx/MoviesTest.java b/content/examples/movies-complete/src/test/java/org/superbiz/injection/tx/MoviesTest.java
new file mode 100755
index 0000000..fcd5826
--- /dev/null
+++ b/content/examples/movies-complete/src/test/java/org/superbiz/injection/tx/MoviesTest.java
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import junit.framework.TestCase;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+/**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "TransactionBean")
+ private Caller transactionalCaller;
+
+ @EJB(beanName = "NoTransactionBean")
+ private Caller nonTransactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ transactionalCaller.call(new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ for (final Movie m : movies.getMovies()) {
+ movies.deleteMovie(m);
+ }
+ return null;
+ }
+ });
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ nonTransactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+ public static interface Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+
+ }
+
+ @Stateless
+ @RunAs("Manager")
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public static class NoTransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/mtom.html b/content/examples/mtom.html
new file mode 100644
index 0000000..cdc4070
--- /dev/null
+++ b/content/examples/mtom.html
@@ -0,0 +1,189 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/mtom.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>mtom</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example mtom can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/mtom" class="bare">https://github.com/apache/tomee/tree/master/examples/mtom</a></p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/mtom.pdf b/content/examples/mtom.pdf
new file mode 100644
index 0000000..c89129c
--- /dev/null
+++ b/content/examples/mtom.pdf
Binary files differ
diff --git a/content/examples/mtom/README.md b/content/examples/mtom/README.md
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/content/examples/mtom/README.md
diff --git a/content/examples/mtom/pom.xml b/content/examples/mtom/pom.xml
new file mode 100755
index 0000000..769068a
--- /dev/null
+++ b/content/examples/mtom/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>mtom</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: MTOM</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <version.openejb>4.7.1</version.openejb>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>snapshots-apache</id>
+ <url>http://repository.apache.org/content/groups/snapshots/</url>
+ </repository>
+ </repositories>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>${version.openejb}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-junit</artifactId>
+ <version>${version.openejb}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-mockito</artifactId>
+ <version>${version.openejb}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/mtom/src/main/java/org/superbiz/mtom/AbstractService.java b/content/examples/mtom/src/main/java/org/superbiz/mtom/AbstractService.java
new file mode 100755
index 0000000..8613218
--- /dev/null
+++ b/content/examples/mtom/src/main/java/org/superbiz/mtom/AbstractService.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mtom;
+
+import javax.activation.DataHandler;
+
+public class AbstractService {
+
+ public Response convertToBytes(final Request request) {
+ return new Response(new DataHandler(request.getMessage().getBytes(), "application/octet-stream"));
+ }
+}
diff --git a/content/examples/mtom/src/main/java/org/superbiz/mtom/EjbService.java b/content/examples/mtom/src/main/java/org/superbiz/mtom/EjbService.java
new file mode 100755
index 0000000..b417854
--- /dev/null
+++ b/content/examples/mtom/src/main/java/org/superbiz/mtom/EjbService.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mtom;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.jws.soap.SOAPBinding.Use;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.soap.MTOM;
+
+@Stateless
+@WebService
+@SOAPBinding(use = Use.LITERAL, parameterStyle = ParameterStyle.BARE, style = Style.DOCUMENT)
+@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
+@MTOM
+public class EjbService extends AbstractService implements Service {
+}
diff --git a/content/examples/mtom/src/main/java/org/superbiz/mtom/PojoService.java b/content/examples/mtom/src/main/java/org/superbiz/mtom/PojoService.java
new file mode 100755
index 0000000..17a2728
--- /dev/null
+++ b/content/examples/mtom/src/main/java/org/superbiz/mtom/PojoService.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mtom;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.jws.soap.SOAPBinding.Use;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.soap.MTOM;
+
+@WebService
+@SOAPBinding(use = Use.LITERAL, parameterStyle = ParameterStyle.BARE, style = Style.DOCUMENT)
+@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
+@MTOM
+public class PojoService extends AbstractService implements Service {
+}
diff --git a/content/examples/mtom/src/main/java/org/superbiz/mtom/Request.java b/content/examples/mtom/src/main/java/org/superbiz/mtom/Request.java
new file mode 100755
index 0000000..804b8e2
--- /dev/null
+++ b/content/examples/mtom/src/main/java/org/superbiz/mtom/Request.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mtom;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Request {
+
+ private String message;
+
+ public Request() {
+ }
+
+ public Request(final String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+ public void setMessage(final String message) {
+ this.message = message;
+ }
+}
diff --git a/content/examples/mtom/src/main/java/org/superbiz/mtom/Response.java b/content/examples/mtom/src/main/java/org/superbiz/mtom/Response.java
new file mode 100755
index 0000000..dde9919
--- /dev/null
+++ b/content/examples/mtom/src/main/java/org/superbiz/mtom/Response.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mtom;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Response {
+
+ @XmlMimeType("application/octet-stream")
+ private DataHandler result;
+
+ public Response() {
+ }
+
+ public Response(final DataHandler result) {
+ this.result = result;
+ }
+
+ public DataHandler getResult() {
+ return this.result;
+ }
+
+ public void setResult(final DataHandler result) {
+ this.result = result;
+ }
+}
diff --git a/content/examples/mtom/src/main/java/org/superbiz/mtom/Service.java b/content/examples/mtom/src/main/java/org/superbiz/mtom/Service.java
new file mode 100755
index 0000000..21c88b0
--- /dev/null
+++ b/content/examples/mtom/src/main/java/org/superbiz/mtom/Service.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mtom;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.jws.soap.SOAPBinding.Use;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.soap.MTOM;
+
+@WebService
+@SOAPBinding(use = Use.LITERAL, parameterStyle = ParameterStyle.BARE, style = Style.DOCUMENT)
+@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
+@MTOM
+public interface Service {
+
+ Response convertToBytes(Request request);
+
+}
diff --git a/content/examples/mtom/src/test/java/org/superbiz/mtom/AbstractServiceTest.java b/content/examples/mtom/src/test/java/org/superbiz/mtom/AbstractServiceTest.java
new file mode 100755
index 0000000..07a78de
--- /dev/null
+++ b/content/examples/mtom/src/test/java/org/superbiz/mtom/AbstractServiceTest.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mtom;
+
+import org.apache.openejb.junit.ApplicationComposer;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.xml.ws.WebServiceRef;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+@RunWith(ApplicationComposer.class)
+public abstract class AbstractServiceTest {
+
+ @WebServiceRef
+ private Service service;
+
+ @Test
+ public void test() throws IOException {
+ final Response response = this.service.convertToBytes(new Request("hello world!"));
+
+ Assert.assertNotNull(response.getResult());
+
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+ response.getResult().writeTo(outputStream);
+
+ Assert.assertTrue("datahandler is empty", outputStream.size() > 0);
+ }
+
+}
diff --git a/content/examples/mtom/src/test/java/org/superbiz/mtom/EjbServiceTest.java b/content/examples/mtom/src/test/java/org/superbiz/mtom/EjbServiceTest.java
new file mode 100755
index 0000000..dcf7785
--- /dev/null
+++ b/content/examples/mtom/src/test/java/org/superbiz/mtom/EjbServiceTest.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mtom;
+
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+
+@EnableServices("jaxws") // maybe this should be @Inherited like @RunWith
+public class EjbServiceTest extends AbstractServiceTest {
+
+ @Module
+ public Class<?>[] module() {
+ return new Class<?>[]{EjbService.class};
+ }
+}
diff --git a/content/examples/mtom/src/test/java/org/superbiz/mtom/PojoServiceTest.java b/content/examples/mtom/src/test/java/org/superbiz/mtom/PojoServiceTest.java
new file mode 100755
index 0000000..cf2f013
--- /dev/null
+++ b/content/examples/mtom/src/test/java/org/superbiz/mtom/PojoServiceTest.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.mtom;
+
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+
+@EnableServices("jaxws") // maybe this should be @Inherited like @RunWith
+public class PojoServiceTest extends AbstractServiceTest {
+
+ @Module
+ public WebApp module() {
+ return new WebApp().addServlet("ws", PojoService.class.getName(), "/ws");
+ }
+}
diff --git a/content/examples/multi-jpa-provider-testing.html b/content/examples/multi-jpa-provider-testing.html
new file mode 100644
index 0000000..086169c
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/multi-jpa-provider-testing.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>multi-jpa-provider-testing</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example multi-jpa-provider-testing can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/multi-jpa-provider-testing" class="bare">https://github.com/apache/tomee/tree/master/examples/multi-jpa-provider-testing</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/multi-jpa-provider-testing.pdf b/content/examples/multi-jpa-provider-testing.pdf
new file mode 100644
index 0000000..4fd98c9
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing.pdf
Binary files differ
diff --git a/content/examples/multi-jpa-provider-testing/pom.xml b/content/examples/multi-jpa-provider-testing/pom.xml
new file mode 100755
index 0000000..12f51f8
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/pom.xml
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>multi-jpa-provider-testing</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Multiple JPA providers</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <plugin> <!-- run tests twice, once with openjpa and once with hibernate -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <executions>
+ <execution>
+ <id>test-hibernate</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <systemPropertyVariables>
+ <javax.persistence.provider>org.hibernate.ejb.HibernatePersistence</javax.persistence.provider>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-openjpa</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <systemPropertyVariables>
+ <javax.persistence.provider>org.apache.openjpa.persistence.PersistenceProviderImpl</javax.persistence.provider>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap.resolver</groupId>
+ <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+ <version>2.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-spi</artifactId>
+ <version>1.1.3</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ don't be shy and put all JPA provider in the classpath
+ otherwise arquillian has some difficulties in embedded mode to find your classes
+ -->
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.3.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency> <!-- just a facade pom which will bring hibernate for us -->
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core-hibernate</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/multi-jpa-provider-testing/src/main/java/org/superbiz/model/Person.java b/content/examples/multi-jpa-provider-testing/src/main/java/org/superbiz/model/Person.java
new file mode 100755
index 0000000..4a40f79
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/main/java/org/superbiz/model/Person.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.model;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Person {
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String name;
+
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/content/examples/multi-jpa-provider-testing/src/main/resources/META-INF/persistence.xml b/content/examples/multi-jpa-provider-testing/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..bb66de6
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="jpa">
+ <jta-data-source>jdbc/jpa</jta-data-source>
+ <properties>
+ <!--
+ OpenJPA
+ -->
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+
+ <!--
+ Hibernate
+ -->
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/JPATest.java b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/JPATest.java
new file mode 100755
index 0000000..e282034
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/JPATest.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
+import org.jboss.arquillian.transaction.api.annotation.Transactional;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.superbiz.model.Person;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Arquillian.class)
+public class JPATest {
+
+ @Deployment
+ public static WebArchive war() {
+ return ShrinkWrap.create(WebArchive.class)
+ .addClass(Person.class)
+ .addAsWebInfResource(new ClassLoaderAsset("META-INF/persistence.xml"), ArchivePaths.create("persistence.xml"));
+ }
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Test
+ @Transactional(TransactionMode.ROLLBACK)
+ public void persist() {
+ assertNotNull(em);
+
+ // do something with the em
+ final Person p = new Person();
+ p.setName("Apache OpenEJB");
+ em.persist(p);
+ }
+}
diff --git a/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/jpa/HibernateEnricher.java b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/jpa/HibernateEnricher.java
new file mode 100755
index 0000000..d5a206b
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/jpa/HibernateEnricher.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.enricher.jpa;
+
+import org.jboss.arquillian.container.test.spi.client.deployment.AuxiliaryArchiveProcessor;
+import org.jboss.shrinkwrap.api.Archive;
+import org.superbiz.enricher.maven.Enrichers;
+
+public class HibernateEnricher implements AuxiliaryArchiveProcessor {
+
+ @Override
+ public void process(final Archive<?> auxiliaryArchive) {
+ Enrichers.wrap(auxiliaryArchive).addAsLibraries(Enrichers.resolve("src/test/resources/hibernate-pom.xml"));
+ }
+}
diff --git a/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/jpa/JPAEnrichers.java b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/jpa/JPAEnrichers.java
new file mode 100755
index 0000000..552359d
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/jpa/JPAEnrichers.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.enricher.jpa;
+
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+
+// use it with tomee remote adapter
+// in embedded mode simply put all provider in appclassloader
+// otherwise arquillian will be fooled by src/main/java
+public final class JPAEnrichers {
+
+ private JPAEnrichers() {
+ // no-op
+ }
+
+ public static WebArchive addJPAProvider(final WebArchive war) {
+ final String provider = System.getProperty("javax.persistence.provider");
+ if (provider != null && provider.contains("hibernate")) {
+ new HibernateEnricher().process(war);
+ } else { // default
+ new OpenJPAEnricher().process(war);
+ }
+ return war;
+ }
+}
diff --git a/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/jpa/OpenJPAEnricher.java b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/jpa/OpenJPAEnricher.java
new file mode 100755
index 0000000..7928403
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/jpa/OpenJPAEnricher.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.enricher.jpa;
+
+import org.jboss.arquillian.container.test.spi.client.deployment.AuxiliaryArchiveProcessor;
+import org.jboss.shrinkwrap.api.Archive;
+import org.superbiz.enricher.maven.Enrichers;
+
+public class OpenJPAEnricher implements AuxiliaryArchiveProcessor {
+
+ @Override
+ public void process(final Archive<?> auxiliaryArchive) {
+ Enrichers.wrap(auxiliaryArchive).addAsLibraries(Enrichers.resolve("src/test/resources/openjpa-pom.xml"));
+ }
+}
diff --git a/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/maven/Enrichers.java b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/maven/Enrichers.java
new file mode 100755
index 0000000..be62ac9
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/maven/Enrichers.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.enricher.maven;
+
+import org.jboss.shrinkwrap.api.container.LibraryContainer;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+
+import javax.enterprise.inject.ResolutionException;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+public final class Enrichers {
+
+ private static final Map<String, File[]> CACHE = new HashMap<String, File[]>();
+
+ private Enrichers() {
+ // no-op
+ }
+
+ public static File[] resolve(final String pom) {
+ if (!CACHE.containsKey(pom)) {
+ try {
+
+ // try offline first since it is generally faster
+ CACHE.put(pom, Maven.resolver()
+ .offline(true)
+ .loadPomFromFile(pom)
+ .importRuntimeAndTestDependencies().resolve().withTransitivity()
+ .asFile());
+ } catch (ResolutionException re) { // try on central
+ CACHE.put(pom, Maven.resolver()
+ .loadPomFromFile(pom)
+ .importRuntimeAndTestDependencies().resolve().withTransitivity()
+ .asFile());
+ }
+ }
+ return CACHE.get(pom);
+ }
+
+ public static LibraryContainer wrap(final org.jboss.shrinkwrap.api.Archive<?> archive) {
+ if (!(LibraryContainer.class.isInstance(archive))) {
+ throw new IllegalArgumentException("Unsupported archive type: " + archive.getClass().getName());
+ }
+ return (LibraryContainer) archive;
+ }
+}
diff --git a/content/examples/multi-jpa-provider-testing/src/test/resources/arquillian.xml b/content/examples/multi-jpa-provider-testing/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..9ccc5d5
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/test/resources/arquillian.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+ <container qualifier="openejb" default="true">
+ <configuration>
+ <property name="properties">
+ # force classes to be loaded from webapp classloader and not from system classloader
+ # only relevant for embedded tests
+ openejb.classloader.forced-load = org.superbiz.model
+ </property>
+ </configuration>
+ </container>
+</arquillian>
diff --git a/content/examples/multi-jpa-provider-testing/src/test/resources/hibernate-pom.xml b/content/examples/multi-jpa-provider-testing/src/test/resources/hibernate-pom.xml
new file mode 100755
index 0000000..dca207a
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/test/resources/hibernate-pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbie</groupId>
+ <version>1.0.0</version>
+ <artifactId>hibernate-deps</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>4.1.8.Final</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.spec.javax.transaction</groupId>
+ <artifactId>jboss-transaction-api_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.3.0.Final</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/content/examples/multi-jpa-provider-testing/src/test/resources/openjpa-pom.xml b/content/examples/multi-jpa-provider-testing/src/test/resources/openjpa-pom.xml
new file mode 100755
index 0000000..ebab063
--- /dev/null
+++ b/content/examples/multi-jpa-provider-testing/src/test/resources/openjpa-pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbie</groupId>
+ <version>1.0.0</version>
+ <artifactId>openjpa-deps</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.2.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/content/examples/multiple-arquillian-adapters.html b/content/examples/multiple-arquillian-adapters.html
new file mode 100644
index 0000000..e7f154d
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/multiple-arquillian-adapters.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>multiple-arquillian-adapters</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example multiple-arquillian-adapters can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/multiple-arquillian-adapters" class="bare">https://github.com/apache/tomee/tree/master/examples/multiple-arquillian-adapters</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/multiple-arquillian-adapters.pdf b/content/examples/multiple-arquillian-adapters.pdf
new file mode 100644
index 0000000..cb3ae9e
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters.pdf
Binary files differ
diff --git a/content/examples/multiple-arquillian-adapters/pom.xml b/content/examples/multiple-arquillian-adapters/pom.xml
new file mode 100755
index 0000000..77799bf
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/pom.xml
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>multiple-arquillian-adapters</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Multiple Arquillian Adapters</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <tomee.version>1.7.1</tomee.version>
+ <openejb.version>4.7.1</openejb.version>
+ <arquillian.version>1.0.1.Final</arquillian.version>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <!--
+ Redefining execution to:
+ 1. set the right arquillian adapter
+ 2. set the category to execute (include/exclude works too)
+ 3. set the arquillian launcher to use
+ -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <executions>
+ <execution>
+ <id>test-embedded</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <groups>org.superbiz.embedded.standalone.Embedded</groups>
+ <systemPropertyVariables>
+ <arquillian.launch>embedded</arquillian.launch>
+ <openejb.arquillian.adapter>openejb</openejb.arquillian.adapter>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-embedded-remote</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <groups>org.superbiz.embedded.remote.EmbeddedRemote</groups>
+ <systemPropertyVariables>
+ <arquillian.launch>embedded-remote</arquillian.launch>
+ <openejb.arquillian.adapter>openejb</openejb.arquillian.adapter>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-tomee-embedded</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <groups>org.superbiz.tomee.embedded.TomEEEmbedded</groups>
+ <systemPropertyVariables>
+ <arquillian.launch>tomee-embedded</arquillian.launch>
+ <openejb.arquillian.adapter>tomee-embedded</openejb.arquillian.adapter>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-tomee-remote</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ <groups>org.superbiz.tomee.remote.TomEERemote</groups>
+ <systemPropertyVariables>
+ <arquillian.launch>tomee-remote</arquillian.launch>
+ <openejb.arquillian.adapter>tomee-remote</openejb.arquillian.adapter>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>true</skip>
+ <parallel>none</parallel>
+ <threadCount>1</threadCount>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- common arquillian dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>${arquillian.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- utility test deps -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- additional container part for embedded JAX-RS test -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>${openejb.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- arquillian adapters -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>${openejb.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-embedded</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/multiple-arquillian-adapters/src/main/java/org/superbiz/SomeEJB.java b/content/examples/multiple-arquillian-adapters/src/main/java/org/superbiz/SomeEJB.java
new file mode 100755
index 0000000..402a685
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/main/java/org/superbiz/SomeEJB.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class SomeEJB {
+
+ public String ok() {
+ return "ejb";
+ }
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/main/java/org/superbiz/SomeRest.java b/content/examples/multiple-arquillian-adapters/src/main/java/org/superbiz/SomeRest.java
new file mode 100755
index 0000000..5fb7fc2
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/main/java/org/superbiz/SomeRest.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import javax.ejb.Stateless;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("/rest")
+@Stateless
+public class SomeRest {
+
+ @GET
+ @Path("/ok")
+ public String ok() {
+ return "rest";
+ }
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/remote/EmbeddedRemote.java b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/remote/EmbeddedRemote.java
new file mode 100755
index 0000000..25d9301
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/remote/EmbeddedRemote.java
@@ -0,0 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.embedded.remote;
+
+public interface EmbeddedRemote {
+
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/remote/OpenEJBEmbeddedRemoteTest.java b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/remote/OpenEJBEmbeddedRemoteTest.java
new file mode 100755
index 0000000..f09b041
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/remote/OpenEJBEmbeddedRemoteTest.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.embedded.remote;
+
+import org.apache.ziplock.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.superbiz.SomeRest;
+
+import java.io.IOException;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@Category(EmbeddedRemote.class)
+@RunWith(Arquillian.class)
+public class OpenEJBEmbeddedRemoteTest {
+
+ @Deployment
+ public static JavaArchive jar() {
+ return ShrinkWrap.create(JavaArchive.class, "my-webapp.jar").addClass(SomeRest.class);
+ }
+
+ @Test
+ public void check() throws IOException {
+ final String content = IO.slurp(new URL("http://localhost:4204/my-webapp/rest/ok"));
+ assertEquals("rest", content);
+ }
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/standalone/Embedded.java b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/standalone/Embedded.java
new file mode 100755
index 0000000..5d65dbc
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/standalone/Embedded.java
@@ -0,0 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.embedded.standalone;
+
+public interface Embedded {
+
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/standalone/OpenEJBEmbeddedTest.java b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/standalone/OpenEJBEmbeddedTest.java
new file mode 100755
index 0000000..3532085
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/embedded/standalone/OpenEJBEmbeddedTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.embedded.standalone;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.superbiz.SomeEJB;
+
+import javax.ejb.EJB;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@Category(Embedded.class)
+@RunWith(Arquillian.class)
+public class OpenEJBEmbeddedTest {
+
+ @EJB
+ private SomeEJB ejb;
+
+ @Deployment
+ public static JavaArchive jar() {
+ return ShrinkWrap.create(JavaArchive.class).addClass(SomeEJB.class);
+ }
+
+ @Test
+ public void check() {
+ assertNotNull(ejb);
+ assertEquals("ejb", ejb.ok());
+ }
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/embedded/TomEEEmbedded.java b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/embedded/TomEEEmbedded.java
new file mode 100755
index 0000000..e2da33f
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/embedded/TomEEEmbedded.java
@@ -0,0 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.tomee.embedded;
+
+public interface TomEEEmbedded {
+
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/embedded/TomEEEmbeddedTest.java b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/embedded/TomEEEmbeddedTest.java
new file mode 100755
index 0000000..d815c17
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/embedded/TomEEEmbeddedTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.tomee.embedded;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.superbiz.SomeEJB;
+
+import javax.ejb.EJB;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@Category(TomEEEmbedded.class)
+@RunWith(Arquillian.class)
+public class TomEEEmbeddedTest {
+
+ @EJB
+ private SomeEJB ejb;
+
+ @Deployment
+ public static WebArchive war() { // use test name for the war otherwise arquillian ejb enricher doesn't work
+ return ShrinkWrap.create(WebArchive.class, "test.war").addClass(SomeEJB.class);
+ }
+
+ @Test
+ public void check() {
+ assertNotNull(ejb);
+ assertEquals("ejb", ejb.ok());
+ }
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/remote/TomEERemote.java b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/remote/TomEERemote.java
new file mode 100755
index 0000000..90d09a3
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/remote/TomEERemote.java
@@ -0,0 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.tomee.remote;
+
+public interface TomEERemote {
+
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/remote/TomEERemoteTest.java b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/remote/TomEERemoteTest.java
new file mode 100755
index 0000000..9814c2d
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/test/java/org/superbiz/tomee/remote/TomEERemoteTest.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.tomee.remote;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.superbiz.SomeEJB;
+
+import javax.ejb.EJB;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@Category(TomEERemote.class)
+@RunWith(Arquillian.class)
+public class TomEERemoteTest {
+
+ @EJB
+ private SomeEJB ejb;
+
+ @Deployment
+ public static WebArchive war() {
+ // use test name for the war otherwise arquillian ejb enricher doesn't work
+ // don't forget the category otherwise it will fail since the runner parse annotations
+ // in embedded mode it is not so important
+ return ShrinkWrap.create(WebArchive.class, "test.war").addClasses(SomeEJB.class, TomEERemote.class);
+ }
+
+ @Test
+ public void check() {
+ assertNotNull(ejb);
+ assertEquals("ejb", ejb.ok());
+ }
+}
diff --git a/content/examples/multiple-arquillian-adapters/src/test/resources/arquillian.xml b/content/examples/multiple-arquillian-adapters/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..a6132d7
--- /dev/null
+++ b/content/examples/multiple-arquillian-adapters/src/test/resources/arquillian.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+ <container qualifier="embedded">
+ <configuration>
+ <property name="properties">
+ # to ensure we don't start remote container even if it is found at classpath
+ openejb.embedded.remotable = false
+ </property>
+ </configuration>
+ </container>
+ <container qualifier="embedded-remote">
+ <configuration>
+ <property name="properties">
+ # optional if found at classpath
+ openejb.embedded.remotable = true
+ </property>
+ </configuration>
+ </container>
+ <container qualifier="tomee-embedded">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="dir">target/tomee-embedded</property>
+ <property name="appWorkingDir">target/work3</property>
+ </configuration>
+ </container>
+ <container qualifier="tomee-remote">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="ajpPort">-1</property>
+ <property name="dir">target/tomee-remote</property>
+ <property name="appWorkingDir">target/work4</property>
+ </configuration>
+ </container>
+</arquillian>
diff --git a/content/examples/multiple-tomee-arquillian.html b/content/examples/multiple-tomee-arquillian.html
new file mode 100644
index 0000000..4cbe679
--- /dev/null
+++ b/content/examples/multiple-tomee-arquillian.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/multiple-tomee-arquillian.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>multiple-tomee-arquillian</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example multiple-tomee-arquillian can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/multiple-tomee-arquillian" class="bare">https://github.com/apache/tomee/tree/master/examples/multiple-tomee-arquillian</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/multiple-tomee-arquillian.pdf b/content/examples/multiple-tomee-arquillian.pdf
new file mode 100644
index 0000000..e480316
--- /dev/null
+++ b/content/examples/multiple-tomee-arquillian.pdf
Binary files differ
diff --git a/content/examples/multiple-tomee-arquillian/pom.xml b/content/examples/multiple-tomee-arquillian/pom.xml
new file mode 100755
index 0000000..f0c2e19
--- /dev/null
+++ b/content/examples/multiple-tomee-arquillian/pom.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>multiple-tomee-arquillian</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Multiple TomEE with Arquillian</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <tomee.version>1.7.1</tomee.version>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <testResources>
+ <testResource>
+ <directory>${project.basedir}/src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <systemPropertyVariables>
+ <arquillian.launch>tomee-cluster</arquillian.launch>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>1.1.1.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>1.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/multiple-tomee-arquillian/src/test/java/org/superbiz/tomee/arquillian/multiple/MultipleTomEETest.java b/content/examples/multiple-tomee-arquillian/src/test/java/org/superbiz/tomee/arquillian/multiple/MultipleTomEETest.java
new file mode 100755
index 0000000..16f4768
--- /dev/null
+++ b/content/examples/multiple-tomee-arquillian/src/test/java/org/superbiz/tomee/arquillian/multiple/MultipleTomEETest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.tomee.arquillian.multiple;
+
+import org.apache.ziplock.IO;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.OperateOnDeployment;
+import org.jboss.arquillian.container.test.api.TargetsContainer;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Arquillian.class)
+public class MultipleTomEETest {
+
+ @Deployment(name = "war1", testable = false)
+ @TargetsContainer("tomee-1")
+ public static WebArchive createDep1() {
+ return ShrinkWrap.create(WebArchive.class, "application1.war")
+ .addAsWebResource(new StringAsset("Hello from TomEE 1"), "index.html");
+ }
+
+ @Deployment(name = "war2", testable = false)
+ @TargetsContainer("tomee-2")
+ public static WebArchive createDep2() {
+ return ShrinkWrap.create(WebArchive.class, "application2.war")
+ .addAsWebResource(new StringAsset("Hello from TomEE 2"), "index.html");
+ }
+
+ @Test
+ @OperateOnDeployment("war1")
+ public void testRunningInDep1(@ArquillianResource final URL url) throws IOException {
+ final String content = IO.slurp(url);
+ assertEquals("Hello from TomEE 1", content);
+ }
+
+ @Test
+ @OperateOnDeployment("war2")
+ public void testRunningInDep2(@ArquillianResource final URL url) throws IOException {
+ final String content = IO.slurp(url);
+ assertEquals("Hello from TomEE 2", content);
+ }
+}
diff --git a/content/examples/multiple-tomee-arquillian/src/test/resources/arquillian.xml b/content/examples/multiple-tomee-arquillian/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..c6e0273
--- /dev/null
+++ b/content/examples/multiple-tomee-arquillian/src/test/resources/arquillian.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <group qualifier="tomee-cluster">
+ <container qualifier="tomee-1">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="ajpPort">-1</property>
+ <property name="version">${tomee.version}</property>
+ <property name="dir">target/apache-tomee-remote-1</property>
+ <property name="appWorkingDir">target/arquillian-test-working-dir-1</property>
+ </configuration>
+ </container>
+ <container qualifier="tomee-2">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="ajpPort">-1</property>
+ <property name="version">${tomee.version}</property>
+ <property name="dir">target/apache-tomee-remote-2</property>
+ <property name="appWorkingDir">target/arquillian-test-working-dir-2</property>
+ </configuration>
+ </container>
+ </group>
+</arquillian>
diff --git a/content/examples/myfaces-codi-demo.html b/content/examples/myfaces-codi-demo.html
new file mode 100644
index 0000000..d494536
--- /dev/null
+++ b/content/examples/myfaces-codi-demo.html
@@ -0,0 +1,274 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/myfaces-codi-demo.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>MyFaces CODI Demo</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example myfaces-codi-demo can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/myfaces-codi-demo" class="bare">https://github.com/apache/tomee/tree/master/examples/myfaces-codi-demo</a></p>
+</div>
+<div class="paragraph">
+<p>Notice: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ .
+ <a href="http://www.apache.org/licenses/LICENSE-2.0" class="bare">http://www.apache.org/licenses/LICENSE-2.0</a>
+ .
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.</p>
+</div>
+<div class="paragraph">
+<p><h2>Steps to run the example</h2></p>
+</div>
+<div class="paragraph">
+<p>Build and start the demo:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>mvn clean package tomee:run</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Open:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>http://localhost:8080/myfaces-codi-1.0-SNAPSHOT/</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This example shows how to improve JSF2/CDI/BV/JPA applications with features provided by Apache MyFaces CODI and ExtVal.</p>
+</div>
+<div class="paragraph">
+<p><h2>Intro of MyFaces CODI and ExtVal</h2></p>
+</div>
+<div class="paragraph">
+<p>The Apache MyFaces Extensions CDI project (aka CODI) hosts portable extensions for Contexts and Dependency Injection (CDI - JSR 299). CODI is a toolbox for your CDI application. Like CDI itself CODI is focused on type-safety. It is a modularized and extensible framework. So it’s easy to choose the needed parts to facilitate the daily work in your project.</p>
+</div>
+<div class="paragraph">
+<p>MyFaces Extensions Validator (aka ExtVal) is a JSF centric validation framework which is compatible with JSF 1.x and JSF 2.x.
+This example shows how it improves the default integration of Bean-Validation (JSR-303) with JSF2 as well as meta-data based cross-field validation.</p>
+</div>
+<div class="paragraph">
+<p><h2>Illustrated Features</h2></p>
+</div>
+<div class="paragraph">
+<p><h3>Apache MyFaces CODI</h3></p>
+</div>
+<div class="paragraph">
+<p><ul></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><li><a href="./src/main/java/org/superbiz/myfaces/view/config/Pages.java" target="_blank">Type-safe view-config</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/InfoPage.java" target="_blank">Type-safe (custom) view-meta-data</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/MenuBean.java" target="_blank">Type-safe navigation</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/CustomJsfModuleConfig.java" target="_blank">Type-safe (specialized) config</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/CustomProjectStage.java" target="_blank">Type-safe custom project-stage</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/UserHolder.java" target="_blank">@WindowScoped</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/MenuBean.java" target="_blank">Controlling CODI scopes with WindowContext</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/FeedbackPage.java" target="_blank">@ViewAccessScoped</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/FeedbackPage.java" target="_blank">Manual conversation handling</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/security/LoginAccessDecisionVoter.java" target="_blank">Secured pages (AccessDecisionVoter)</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/repository/Repository.java" target="_blank">@Transactional</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">I18n (fluent API)</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/domain/validation/UniqueUserNameValidator.java" target="_blank">Dependency-Injection for JSR303 (BV) constraint-validators</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/DebugPhaseListener.java" target="_blank">Dependency-Injection for JSF phase-listeners</a></li>
+</ul>
+
+<h3>Apache MyFaces ExtVal</h3>
+
+<ul>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Cross-Field validation (@Equals)</a></li>
+<li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Type-safe group-validation (@BeanValidation) for JSF action-methods</a></li>
+</ul></code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/myfaces-codi-demo.pdf b/content/examples/myfaces-codi-demo.pdf
new file mode 100644
index 0000000..090e563
--- /dev/null
+++ b/content/examples/myfaces-codi-demo.pdf
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/README.md b/content/examples/myfaces-codi-demo/README.md
new file mode 100755
index 0000000..49fd421
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/README.md
@@ -0,0 +1,65 @@
+Title: MyFaces CODI Demo
+Notice: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ .
+ http://www.apache.org/licenses/LICENSE-2.0
+ .
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+<h2>Steps to run the example</h2>
+
+Build and start the demo:
+
+ mvn clean package tomee:run
+
+Open:
+
+ http://localhost:8080/myfaces-codi-1.1.1-SNAPSHOT/
+
+This example shows how to improve JSF2/CDI/BV/JPA applications with features provided by Apache MyFaces CODI and ExtVal.
+
+<h2>Intro of MyFaces CODI and ExtVal</h2>
+
+The Apache MyFaces Extensions CDI project (aka CODI) hosts portable extensions for Contexts and Dependency Injection (CDI - JSR 299). CODI is a toolbox for your CDI application. Like CDI itself CODI is focused on type-safety. It is a modularized and extensible framework. So it's easy to choose the needed parts to facilitate the daily work in your project.
+
+MyFaces Extensions Validator (aka ExtVal) is a JSF centric validation framework which is compatible with JSF 1.x and JSF 2.x.
+This example shows how it improves the default integration of Bean-Validation (JSR-303) with JSF2 as well as meta-data based cross-field validation.
+
+
+<h2>Illustrated Features</h2>
+
+<h3>Apache MyFaces CODI</h3>
+
+<ul>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/config/Pages.java" target="_blank">Type-safe view-config</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/InfoPage.java" target="_blank">Type-safe (custom) view-meta-data</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/MenuBean.java" target="_blank">Type-safe navigation</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/CustomJsfModuleConfig.java" target="_blank">Type-safe (specialized) config</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/CustomProjectStage.java" target="_blank">Type-safe custom project-stage</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/UserHolder.java" target="_blank">@WindowScoped</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/MenuBean.java" target="_blank">Controlling CODI scopes with WindowContext</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/FeedbackPage.java" target="_blank">@ViewAccessScoped</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/FeedbackPage.java" target="_blank">Manual conversation handling</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/security/LoginAccessDecisionVoter.java" target="_blank">Secured pages (AccessDecisionVoter)</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/repository/Repository.java" target="_blank">@Transactional</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">I18n (fluent API)</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/domain/validation/UniqueUserNameValidator.java" target="_blank">Dependency-Injection for JSR303 (BV) constraint-validators</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/DebugPhaseListener.java" target="_blank">Dependency-Injection for JSF phase-listeners</a></li>
+</ul>
+
+<h3>Apache MyFaces ExtVal</h3>
+
+<ul>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Cross-Field validation (@Equals)</a></li>
+ <li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Type-safe group-validation (@BeanValidation) for JSF action-methods</a></li>
+</ul>
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/pom.xml b/content/examples/myfaces-codi-demo/pom.xml
new file mode 100755
index 0000000..a59fd65
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/pom.xml
@@ -0,0 +1,131 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>myfaces-codi-demo</artifactId>
+
+ <name>OpenEJB :: Examples :: JSF2/CDI/BV/JPA/CODI</name>
+ <version>1.1.1-SNAPSHOT</version>
+
+ <packaging>war</packaging>
+
+ <properties>
+ <myfaces2.version>2.2.4</myfaces2.version>
+ <myfaces.codi.version>1.0.5</myfaces.codi.version>
+ <extval.version>2.0.8</extval.version>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>prime-repo</id>
+ <name>Prime Technology Maven Repository</name>
+ <url>http://repository.primefaces.org/</url>
+ <layout>default</layout>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.bundles</groupId>
+ <artifactId>myfaces-extcdi-bundle-jsf20</artifactId>
+ <version>${myfaces.codi.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator</groupId>
+ <artifactId>myfaces-extval-core</artifactId>
+ <version>${extval.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
+ <artifactId>myfaces-extval-property-validation</artifactId>
+ <version>${extval.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.validator.validation-modules</groupId>
+ <artifactId>myfaces-extval-bean-validation</artifactId>
+ <version>${extval.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>${myfaces2.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- 3rd party libs -->
+ <dependency>
+ <groupId>org.primefaces</groupId>
+ <artifactId>primefaces</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/CustomJsfModuleConfig.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/CustomJsfModuleConfig.java
new file mode 100755
index 0000000..7ca94a3
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/CustomJsfModuleConfig.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces;
+
+import org.apache.myfaces.extensions.cdi.jsf.api.config.JsfModuleConfig;
+
+import javax.enterprise.inject.Specializes;
+
+@Specializes
+public class CustomJsfModuleConfig extends JsfModuleConfig {
+
+ private static final long serialVersionUID = 1682809983274206270L;
+
+ @Override
+ public boolean isInvalidValueAwareMessageInterpolatorEnabled() {
+ return false;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/CustomProjectStage.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/CustomProjectStage.java
new file mode 100755
index 0000000..485f793
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/CustomProjectStage.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces;
+
+import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage;
+import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStageHolder;
+
+public class CustomProjectStage implements ProjectStageHolder {
+
+ public static final class Debugging extends ProjectStage {
+
+ private static final long serialVersionUID = -8626602281649294170L;
+ }
+
+ public static final Debugging Debugging = new Debugging();
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/DebugPhaseListener.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/DebugPhaseListener.java
new file mode 100755
index 0000000..0356629
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/DebugPhaseListener.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces;
+
+import org.apache.myfaces.extensions.cdi.core.api.Advanced;
+import org.apache.myfaces.extensions.cdi.core.api.activation.ProjectStageActivated;
+import org.apache.myfaces.extensions.cdi.core.api.logging.Logger;
+import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage;
+import org.apache.myfaces.extensions.cdi.jsf.api.listener.phase.JsfPhaseListener;
+
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.inject.Inject;
+
+@ProjectStageActivated({ProjectStage.Development.class, CustomProjectStage.Debugging.class})
+
+@Advanced
+@JsfPhaseListener
+public class DebugPhaseListener implements PhaseListener {
+
+ private static final long serialVersionUID = 5899542118538949019L;
+
+ @Inject
+ private Logger logger;
+
+ public void beforePhase(PhaseEvent phaseEvent) {
+ this.logger.info("before " + phaseEvent.getPhaseId());
+ }
+
+ public void afterPhase(PhaseEvent phaseEvent) {
+ this.logger.info("after " + phaseEvent.getPhaseId());
+ }
+
+ public PhaseId getPhaseId() {
+ return PhaseId.ANY_PHASE;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/AbstractDomainObject.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/AbstractDomainObject.java
new file mode 100755
index 0000000..76a01a5
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/AbstractDomainObject.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Version;
+import java.io.Serializable;
+
+@MappedSuperclass
+public abstract class AbstractDomainObject implements Serializable {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Version
+ private Long version;
+
+ public boolean isTransient() {
+ return this.version == null;
+ }
+
+ public Long getId() {
+ return id;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/Comment.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/Comment.java
new file mode 100755
index 0000000..ae095c7
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/Comment.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+
+@Entity
+public class Comment extends AbstractDomainObject {
+
+ private static final long serialVersionUID = -5718296682587279635L;
+
+ @Column(length = 2048)
+ private String description;
+
+ @ManyToOne(optional = false)
+ private Feedback feedback;
+
+ void setFeedback(Feedback feedback) {
+ this.feedback = feedback;
+ }
+
+ /*
+ * generated
+ */
+
+ public Comment() {
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/Feedback.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/Feedback.java
new file mode 100755
index 0000000..17f67ef
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/Feedback.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+public class Feedback extends AbstractDomainObject {
+
+ private static final long serialVersionUID = -431924785266663236L;
+
+ @Column(nullable = false, length = 32)
+ private String topic;
+
+ @Column(length = 128)
+ private String description;
+
+ @OneToMany(mappedBy = "feedback", cascade = CascadeType.ALL)
+ private List<Comment> comments = new ArrayList<Comment>();
+
+ public void addComment(Comment comment) {
+ comment.setFeedback(this);
+ this.comments.add(comment);
+ }
+
+ /*
+ * generated
+ */
+
+ public List<Comment> getComments() {
+ return comments;
+ }
+
+ public String getTopic() {
+ return topic;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/User.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/User.java
new file mode 100755
index 0000000..4170524
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/User.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain;
+
+import org.superbiz.myfaces.domain.validation.DifferentName;
+import org.superbiz.myfaces.domain.validation.Name;
+import org.superbiz.myfaces.domain.validation.Partial;
+import org.superbiz.myfaces.domain.validation.UniqueUserName;
+import org.superbiz.myfaces.domain.validation.UserName;
+
+import javax.enterprise.inject.Typed;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+@Table(name = "T_User")
+@Entity
+@NamedQuery(name = "findUserByName", query = "select u from User u where u.userName = :currentUser")
+@DifferentName(groups = Partial.class)
+@Typed()
+public class User extends AbstractDomainObject {
+
+ private static final long serialVersionUID = 3810638653455000233L;
+
+ @UserName(groups = UniqueUserName.class)
+ @Column(nullable = false, length = 9, unique = true)
+ private String userName;
+
+ @Size(min = 2, max = 20, message = "invalid first name")
+ @NotNull
+ @Column
+ private String firstName;
+
+ @Column
+ @Name(message = "invalid last name")
+ private String lastName;
+
+ @Column
+ private String password;
+
+ /*
+ * generated
+ */
+
+ public User() {
+ }
+
+ public User(String userName, String firstName, String lastName) {
+ this.userName = userName;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/DifferentName.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/DifferentName.java
new file mode 100755
index 0000000..25abbe7
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/DifferentName.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain.validation;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Constraint(validatedBy = DifferentNameValidator.class)
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface DifferentName {
+
+ String message() default "invalid name";
+
+ Class<?>[] groups() default {};
+
+ Class<? extends Payload>[] payload() default {};
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/DifferentNameValidator.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/DifferentNameValidator.java
new file mode 100755
index 0000000..83c9056
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/DifferentNameValidator.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain.validation;
+
+import org.superbiz.myfaces.domain.User;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+public class DifferentNameValidator implements ConstraintValidator<DifferentName, User> {
+
+ public void initialize(DifferentName differentName) {
+ }
+
+ public boolean isValid(User person, ConstraintValidatorContext constraintValidatorContext) {
+ return person == null || !(person.getFirstName() != null && person.getFirstName().equals(person.getLastName()));
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/Full.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/Full.java
new file mode 100755
index 0000000..f9e87cd
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/Full.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain.validation;
+
+import javax.validation.GroupSequence;
+import javax.validation.groups.Default;
+
+@GroupSequence({Default.class, UniqueUserName.class})
+public interface Full {
+
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/Name.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/Name.java
new file mode 100755
index 0000000..40a3c6a
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/Name.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain.validation;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.ReportAsSingleViolation;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Size(min = 2, max = 20)
+@NotNull
+
+@Constraint(validatedBy = {})
+@ReportAsSingleViolation
+
+@Target({METHOD, FIELD, ANNOTATION_TYPE})
+@Retention(RUNTIME)
+public @interface Name {
+
+ public abstract String message() default "invalid name";
+
+ public abstract Class<?>[] groups() default {};
+
+ public abstract Class<? extends Payload>[] payload() default {};
+}
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/Partial.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/Partial.java
new file mode 100755
index 0000000..d2f5427
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/Partial.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain.validation;
+
+public interface Partial {
+
+}
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/UniqueUserName.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/UniqueUserName.java
new file mode 100755
index 0000000..955c588
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/UniqueUserName.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain.validation;
+
+public interface UniqueUserName {
+
+}
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/UniqueUserNameValidator.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/UniqueUserNameValidator.java
new file mode 100755
index 0000000..ecf4abc
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/UniqueUserNameValidator.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain.validation;
+
+import org.apache.myfaces.extensions.cdi.core.api.Advanced;
+import org.superbiz.myfaces.repository.UserRepository;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+@Advanced
+@ApplicationScoped
+public class UniqueUserNameValidator implements ConstraintValidator<UserName, String> {
+
+ @Inject
+ private UserRepository userRepository;
+
+ public void initialize(UserName differentName) {
+ }
+
+ public boolean isValid(String userName, ConstraintValidatorContext constraintValidatorContext) {
+ return this.userRepository.loadUser(userName) == null;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/UserName.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/UserName.java
new file mode 100755
index 0000000..4ab5dc8
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/domain/validation/UserName.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.domain.validation;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.groups.Default;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@NotNull(groups = Default.class)
+@Size(min = 2, max = 9, message = "invalid name", groups = Default.class)
+
+@Constraint(validatedBy = UniqueUserNameValidator.class)
+@Target(FIELD)
+@Retention(RUNTIME)
+public @interface UserName {
+
+ String message() default "user-name exists already";
+
+ Class<?>[] groups() default {};
+
+ Class<? extends Payload>[] payload() default {};
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/FeedbackRepository.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/FeedbackRepository.java
new file mode 100755
index 0000000..6359bf5
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/FeedbackRepository.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.repository;
+
+import org.superbiz.myfaces.domain.Feedback;
+
+public interface FeedbackRepository extends GenericRepository<Feedback> {
+
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/GenericRepository.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/GenericRepository.java
new file mode 100755
index 0000000..230e74c
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/GenericRepository.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.repository;
+
+import org.superbiz.myfaces.domain.AbstractDomainObject;
+
+import java.io.Serializable;
+import java.util.List;
+
+public interface GenericRepository<T extends AbstractDomainObject> extends Serializable {
+
+ void save(T entity);
+
+ void remove(T entity);
+
+ List<T> loadAll();
+
+ T loadById(Long id);
+
+ T createNewEntity();
+}
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/Repository.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/Repository.java
new file mode 100755
index 0000000..77952d7
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/Repository.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.repository;
+
+import org.apache.myfaces.extensions.cdi.jpa.api.Transactional;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+
+@Target({TYPE})
+@Retention(RUNTIME)
+@Documented
+
+@RequestScoped
+@Transactional
+public @interface Repository {
+
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/UserRepository.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/UserRepository.java
new file mode 100755
index 0000000..6489e76
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/UserRepository.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.repository;
+
+import org.superbiz.myfaces.domain.User;
+
+public interface UserRepository extends GenericRepository<User> {
+
+ User loadUser(String userName);
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/AbstractGenericJpaRepository.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/AbstractGenericJpaRepository.java
new file mode 100755
index 0000000..7f570c4
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/AbstractGenericJpaRepository.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.repository.jpa;
+
+import org.superbiz.myfaces.domain.AbstractDomainObject;
+import org.superbiz.myfaces.repository.GenericRepository;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.List;
+
+/**
+ * Abstract repository class which provides default implementations for common repository methods.
+ */
+public abstract class AbstractGenericJpaRepository<T extends AbstractDomainObject> implements GenericRepository<T> {
+
+ protected final Class<? extends AbstractDomainObject> entityClass;
+
+ @Inject
+ protected EntityManager entityManager;
+
+ public AbstractGenericJpaRepository() {
+ Class currentClass = getClass();
+
+ if (currentClass.getName().contains("$$")) { //we are in a proxy
+ currentClass = currentClass.getSuperclass();
+ }
+
+ for (Type interfaceClass : currentClass.getGenericInterfaces()) {
+ for (Type genericInterfaceClass : ((Class) interfaceClass).getGenericInterfaces()) {
+ if (genericInterfaceClass instanceof ParameterizedType &&
+ GenericRepository.class.isAssignableFrom((Class) ((ParameterizedType) genericInterfaceClass).getRawType())) {
+ for (Type parameterizedType : ((ParameterizedType) genericInterfaceClass).getActualTypeArguments()) {
+ if (AbstractDomainObject.class.isAssignableFrom((Class) parameterizedType)) {
+ this.entityClass = (Class<? extends AbstractDomainObject>) parameterizedType;
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ throw new IllegalStateException("Entity type of " + currentClass.getName() + " not detected!");
+ }
+
+ @Override
+ public T createNewEntity() {
+ try {
+ return (T) this.entityClass.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void save(T entity) {
+ if (entity.isTransient()) {
+ this.entityManager.persist(entity);
+ } else {
+ this.entityManager.merge(entity);
+ }
+ }
+
+ public void remove(T entity) {
+ if (entity.isTransient()) {
+ throw new IllegalStateException("entity is not persistent");
+ }
+
+ this.entityManager.remove(loadById(entity.getId()));
+ }
+
+ public List<T> loadAll() {
+ return (List<T>) this.entityManager.createQuery("select entity from " + this.entityClass.getSimpleName() + " entity")
+ .getResultList();
+ }
+
+ public T loadById(Long id) {
+ return (T) this.entityManager.find(this.entityClass, id);
+ }
+}
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/EntityManagerProducer.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/EntityManagerProducer.java
new file mode 100755
index 0000000..7e84b3d
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/EntityManagerProducer.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.repository.jpa;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+@ApplicationScoped
+public class EntityManagerProducer {
+
+ @PersistenceUnit(unitName = "demoApplicationPU")
+ private EntityManagerFactory entityManagerFactory;
+
+ @Produces
+ @Default
+ @RequestScoped
+ public EntityManager create() {
+ return this.entityManagerFactory.createEntityManager();
+ }
+
+ public void dispose(@Disposes @Default EntityManager entityManager) {
+ if (entityManager.isOpen()) {
+ entityManager.close();
+ }
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/JpaFeedbackRepository.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/JpaFeedbackRepository.java
new file mode 100755
index 0000000..673e4ce
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/JpaFeedbackRepository.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.repository.jpa;
+
+import org.superbiz.myfaces.domain.Feedback;
+import org.superbiz.myfaces.repository.FeedbackRepository;
+import org.superbiz.myfaces.repository.Repository;
+
+@Repository
+public class JpaFeedbackRepository extends AbstractGenericJpaRepository<Feedback> implements FeedbackRepository {
+
+ private static final long serialVersionUID = -4140472572607337575L;
+}
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/JpaUserRepository.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/JpaUserRepository.java
new file mode 100755
index 0000000..b24a89c
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/repository/jpa/JpaUserRepository.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.repository.jpa;
+
+import org.superbiz.myfaces.domain.User;
+import org.superbiz.myfaces.repository.Repository;
+import org.superbiz.myfaces.repository.UserRepository;
+
+import javax.persistence.Query;
+import java.util.List;
+
+@Repository
+public class JpaUserRepository extends AbstractGenericJpaRepository<User> implements UserRepository {
+
+ private static final long serialVersionUID = 672568789774892077L;
+
+ public User loadUser(String userName) {
+ Query query = this.entityManager.createNamedQuery("findUserByName");
+ query.setParameter("currentUser", userName);
+
+ //just for the demo:
+ List result = query.getResultList();
+ if (result != null && result.size() == 1) {
+ return (User) result.iterator().next();
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/startup/ExtValLifecycleFactory.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/startup/ExtValLifecycleFactory.java
new file mode 100755
index 0000000..37c1131
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/startup/ExtValLifecycleFactory.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.startup;
+
+import org.apache.myfaces.extensions.validator.core.DefaultExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.ExtValCoreConfiguration;
+import org.apache.myfaces.extensions.validator.core.proxy.DefaultProxyHelper;
+import org.apache.myfaces.extensions.validator.core.proxy.ProxyHelper;
+import org.apache.myfaces.extensions.validator.core.startup.AbstractStartupListener;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import java.util.Iterator;
+
+//TODO remove it after upgrading to ExtVal r8+
+public class ExtValLifecycleFactory extends LifecycleFactory
+{
+ private final LifecycleFactory wrapped;
+
+ public ExtValLifecycleFactory(LifecycleFactory wrapped)
+ {
+ this.wrapped = wrapped;
+ }
+
+ @Override
+ public void addLifecycle(String lifecycleId, Lifecycle lifecycle)
+ {
+ wrapped.addLifecycle(lifecycleId, lifecycle);
+ }
+
+ @Override
+ public Lifecycle getLifecycle(String lifecycleId)
+ {
+ return new LifecycleWrapper(wrapped.getLifecycle(lifecycleId));
+ }
+
+ @Override
+ public Iterator<String> getLifecycleIds()
+ {
+ return wrapped.getLifecycleIds();
+ }
+
+ @Override
+ public LifecycleFactory getWrapped()
+ {
+ return wrapped;
+ }
+
+ private static class LifecycleWrapper extends Lifecycle
+ {
+ private final Lifecycle wrapped;
+ private static boolean firstPhaseListener = true;
+
+ private LifecycleWrapper(Lifecycle wrapped)
+ {
+ this.wrapped = wrapped;
+ }
+
+ @Override
+ public void addPhaseListener(PhaseListener listener)
+ {
+ if (firstPhaseListener)
+ {
+ //forced order independent of any other config
+ firstPhaseListener = false;
+ wrapped.addPhaseListener(new ExtValStartupListener());
+ }
+ wrapped.addPhaseListener(listener);
+ }
+
+ @Override
+ public void execute(FacesContext context) throws FacesException
+ {
+ wrapped.execute(context);
+ }
+
+ @Override
+ public PhaseListener[] getPhaseListeners()
+ {
+ return wrapped.getPhaseListeners();
+ }
+
+ @Override
+ public void removePhaseListener(PhaseListener listener)
+ {
+ wrapped.removePhaseListener(listener);
+ }
+
+ @Override
+ public void render(FacesContext context) throws FacesException
+ {
+ wrapped.render(context);
+ }
+ }
+
+ public static class ExtValStartupListener extends AbstractStartupListener
+ {
+ @Override
+ protected void init()
+ {
+ ExtValCoreConfiguration.use(new DefaultExtValCoreConfiguration() {
+ @Override
+ public ProxyHelper proxyHelper() {
+ return new DefaultProxyHelper() {
+ @Override
+ public boolean isProxiedClass(Class currentClass) {
+ if (currentClass == null || currentClass.getSuperclass() == null) {
+ return false;
+ }
+ return currentClass.getName().startsWith(currentClass.getSuperclass().getName()) &&
+ currentClass.getName().contains("$$");
+ }
+ };
+ }
+ }, true);
+ }
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/startup/ModuleStartupObserver.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/startup/ModuleStartupObserver.java
new file mode 100755
index 0000000..c827251
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/startup/ModuleStartupObserver.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.startup;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+@Singleton
+@Startup
+public class ModuleStartupObserver {
+
+ private Logger logger = Logger.getLogger(ModuleStartupObserver.class.getName());
+
+ @PostConstruct
+ public void logStartup() {
+ if (logger.isLoggable(Level.INFO)) {
+ logger.info("starting application module");
+ }
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/startup/SampleDataStartupObserver.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/startup/SampleDataStartupObserver.java
new file mode 100755
index 0000000..ca242eb
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/startup/SampleDataStartupObserver.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.startup;
+
+import org.apache.myfaces.extensions.cdi.core.api.activation.ProjectStageActivated;
+import org.apache.myfaces.extensions.cdi.core.api.startup.event.StartupEvent;
+import org.superbiz.myfaces.domain.User;
+import org.superbiz.myfaces.repository.UserRepository;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import static org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage.Development;
+import static org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage.IntegrationTest;
+
+//e.g. via the std. JSF project-stage or CODI project-stage org.apache.myfaces.extensions.cdi.ProjectStage=Development
+@ProjectStageActivated({Development.class, IntegrationTest.class})
+@ApplicationScoped
+public class SampleDataStartupObserver {
+
+ @Inject
+ private EntityManager entityManager;
+
+ protected void createSampleData(@Observes StartupEvent startupEvent, UserRepository userRepository) {
+ initDB(); //ok since we are in project-stage dev. or integration-test
+
+ User user = userRepository.createNewEntity();
+ user.setUserName("demo");
+ user.setFirstName("Demo");
+ user.setLastName("User");
+ user.setPassword("demo");
+ userRepository.save(user);
+ }
+
+ private void initDB() {
+ entityManager.getTransaction().begin();
+ Query query = entityManager.createNativeQuery("TRUNCATE SCHEMA public AND COMMIT");
+ query.executeUpdate();
+ entityManager.getTransaction().commit();
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/FeedbackPage.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/FeedbackPage.java
new file mode 100755
index 0000000..0575d92
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/FeedbackPage.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.view;
+
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.PreRenderView;
+import org.superbiz.myfaces.domain.Feedback;
+import org.superbiz.myfaces.repository.FeedbackRepository;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.Serializable;
+import java.util.List;
+
+@Named
+@ViewAccessScoped
+//alternative to @PageBean in the view-config:
+//@View(Pages.Secure.FeedbackList.class)
+public class FeedbackPage implements Serializable {
+
+ private static final long serialVersionUID = 744025508253889974L;
+
+ private List<Feedback> feedbackList;
+
+ @Inject
+ private Conversation conversation;
+
+ @Inject
+ private FeedbackRepository feedbackRepository;
+
+ private Feedback feedback;
+
+ @PostConstruct
+ protected void init() {
+ this.feedback = this.feedbackRepository.createNewEntity();
+ }
+
+ @PreRenderView
+ public void reloadFeedbackList() {
+ this.feedbackList = this.feedbackRepository.loadAll();
+ }
+
+ public void save() {
+ this.feedbackRepository.save(this.feedback);
+ this.conversation.close();
+ }
+
+ /*
+ * generated
+ */
+
+ public List<Feedback> getFeedbackList() {
+ return feedbackList;
+ }
+
+ public Feedback getFeedback() {
+ return feedback;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/InfoPage.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/InfoPage.java
new file mode 100755
index 0000000..6ff3d46
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/InfoPage.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.view;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewMetaData;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target({TYPE})
+@Retention(RUNTIME)
+@Documented
+
+@ViewMetaData
+public @interface InfoPage {
+
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/MenuBean.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/MenuBean.java
new file mode 100755
index 0000000..023bb16
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/MenuBean.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.view;
+
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowContext;
+import org.superbiz.myfaces.view.config.Pages;
+
+import javax.enterprise.inject.Model;
+import javax.inject.Inject;
+
+@Model
+public class MenuBean {
+
+ @Inject
+ private WindowContext windowContext;
+
+ public Class<? extends Pages> home() {
+ //close all conversations of the current window
+ this.windowContext.closeConversations();
+ return Pages.Index.class;
+ }
+
+ public Class<? extends Pages.Secure> feedback() {
+ //close all conversations of the current window
+ this.windowContext.closeConversations();
+ return Pages.Secure.FeedbackList.class;
+ }
+
+ public Class<? extends Pages> about() {
+ this.windowContext.closeConversations();
+ return Pages.About.class;
+ }
+
+ public Class<? extends Pages> login() {
+ this.windowContext.closeConversations();
+ return Pages.Login.class;
+ }
+
+ public Class<? extends Pages> register() {
+ this.windowContext.closeConversations();
+ return Pages.Registration.class;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/RegistrationPage.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/RegistrationPage.java
new file mode 100755
index 0000000..b664f80
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/RegistrationPage.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.view;
+
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped;
+import org.apache.myfaces.extensions.cdi.jsf.api.Jsf;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
+import org.apache.myfaces.extensions.validator.beanval.annotation.BeanValidation;
+import org.apache.myfaces.extensions.validator.crossval.annotation.Equals;
+import org.superbiz.myfaces.domain.User;
+import org.superbiz.myfaces.domain.validation.Full;
+import org.superbiz.myfaces.repository.UserRepository;
+import org.superbiz.myfaces.view.config.Pages;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.Serializable;
+
+import static org.apache.myfaces.extensions.cdi.message.api.payload.MessageSeverity.ERROR;
+
+@Named
+@ViewAccessScoped
+public class RegistrationPage implements Serializable {
+
+ private static final long serialVersionUID = 3844502441069448490L;
+
+ @Inject
+ private UserRepository userRepository;
+
+ @Inject
+ private Conversation conversation;
+
+ @Inject
+ private
+ @Jsf
+ MessageContext messageContext;
+
+ private User user = new User();
+
+ @Inject
+ private UserHolder userHolder;
+
+ @Equals("user.password")
+ private String repeatedPassword;
+
+ @BeanValidation(useGroups = Full.class) //triggers UniqueUserNameValidator
+ public Class<? extends Pages> register() {
+ this.userRepository.save(this.user);
+ this.messageContext.message()
+ .text("{msgUserRegistered}")
+ .namedArgument("userName", this.user.getUserName())
+ .add();
+
+ //in order to re-use the page-bean for the login-page
+ this.conversation.close();
+
+ return Pages.Login.class;
+ }
+
+ public Class<? extends Pages> login() {
+ User user = this.userRepository.loadUser(this.user.getUserName());
+ if (user != null && user.getPassword().equals(this.user.getPassword())) {
+ this.messageContext.message().text("{msgLoginSuccessful}").add();
+ this.userHolder.setCurrentUser(user);
+ return Pages.About.class;
+ }
+
+ this.messageContext.message().text("{msgLoginFailed}").payload(ERROR).add();
+
+ return null;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public String getRepeatedPassword() {
+ return repeatedPassword;
+ }
+
+ public void setRepeatedPassword(String repeatedPassword) {
+ this.repeatedPassword = repeatedPassword;
+ }
+}
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/UserHolder.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/UserHolder.java
new file mode 100755
index 0000000..dd29ff4
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/UserHolder.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.view;
+
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowScoped;
+import org.superbiz.myfaces.domain.User;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.Serializable;
+
+//due to the enhanced entities it isn't possible to use them directly (due to final methods)
+@WindowScoped
+public class UserHolder implements Serializable {
+
+ private static final long serialVersionUID = -7687528373042288584L;
+
+ @Inject
+ @New
+ private User user;
+
+ @Produces
+ @Dependent
+ @Named("currentUser")
+ protected User createCurrentUser() {
+ return this.user;
+ }
+
+ public void setCurrentUser(User user) {
+ this.user = user;
+ }
+
+ public boolean isLoggedIn() {
+ return this.user.getId() != null;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/config/Pages.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/config/Pages.java
new file mode 100755
index 0000000..2589dcc
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/config/Pages.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.view.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.view.DefaultErrorView;
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
+import org.apache.myfaces.extensions.cdi.core.api.security.Secured;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.PageBean;
+import org.superbiz.myfaces.view.FeedbackPage;
+import org.superbiz.myfaces.view.InfoPage;
+import org.superbiz.myfaces.view.security.LoginAccessDecisionVoter;
+
+import static org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page.NavigationMode.REDIRECT;
+
+@Page(navigation = REDIRECT)
+public interface Pages extends ViewConfig {
+
+ @Page
+ class Index implements Pages {
+
+ }
+
+ @InfoPage
+ @Page
+ class About implements Pages {
+
+ }
+
+ @Page
+ class Registration implements Pages {
+
+ }
+
+ @Page
+ class Login extends DefaultErrorView implements Pages /*just to benefit from the config*/ {
+
+ }
+
+ @Secured(LoginAccessDecisionVoter.class)
+ //@Secured(value = LoginAccessDecisionVoter.class, errorView = Login.class)
+ interface Secure extends Pages {
+
+ @PageBean(FeedbackPage.class)
+ @Page
+ class FeedbackList implements Secure {
+
+ }
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/security/LoginAccessDecisionVoter.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/security/LoginAccessDecisionVoter.java
new file mode 100755
index 0000000..089bc7b
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/security/LoginAccessDecisionVoter.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.view.security;
+
+import org.apache.myfaces.extensions.cdi.core.api.security.AbstractAccessDecisionVoter;
+import org.apache.myfaces.extensions.cdi.core.api.security.SecurityViolation;
+import org.apache.myfaces.extensions.cdi.jsf.api.Jsf;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
+import org.superbiz.myfaces.view.UserHolder;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.interceptor.InvocationContext;
+import java.util.Set;
+
+@ApplicationScoped
+public class LoginAccessDecisionVoter extends AbstractAccessDecisionVoter {
+
+ private static final long serialVersionUID = -6332617547592896599L;
+
+ @Inject
+ private UserHolder userHolder;
+
+ @Inject
+ @Jsf
+ private MessageContext messageContext;
+
+ @Override
+ protected void checkPermission(InvocationContext invocationContext, Set<SecurityViolation> violations) {
+ if (!this.userHolder.isLoggedIn()) {
+ violations.add(newSecurityViolation(this.messageContext.message().text("{msgAccessDenied}").toText()));
+ }
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/util/InfoBean.java b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/util/InfoBean.java
new file mode 100755
index 0000000..e75b494
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/java/org/superbiz/myfaces/view/util/InfoBean.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.myfaces.view.util;
+
+import org.apache.myfaces.extensions.cdi.core.api.CodiInformation;
+import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage;
+import org.apache.myfaces.extensions.cdi.core.api.provider.BeanManagerProvider;
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
+import org.apache.myfaces.extensions.cdi.jsf.api.Jsf;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.ViewConfigDescriptor;
+import org.apache.myfaces.extensions.cdi.jsf.api.config.view.ViewConfigResolver;
+import org.apache.myfaces.extensions.cdi.message.api.MessageContext;
+import org.apache.myfaces.extensions.validator.ExtValInformation;
+import org.superbiz.myfaces.view.InfoPage;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.Persistence;
+import javax.validation.Validation;
+import java.io.Serializable;
+
+@Named
+@SessionScoped
+public class InfoBean implements Serializable {
+
+ private static final long serialVersionUID = -1748909261695527800L;
+
+ @Inject
+ private
+ @Jsf
+ MessageContext messageContext;
+
+ @Inject
+ private ProjectStage projectStage;
+
+ @Inject
+ private ViewConfigResolver viewConfigResolver;
+
+ @Inject
+ private FacesContext facesContext;
+
+ private String applicationMessageVersionInfo;
+
+ private String beanValidationVersion;
+
+ private String jpaVersion;
+
+ @PostConstruct
+ protected void showWelcomeMessage() {
+ String versionString = ClassUtils.getJarVersion(InfoBean.class);
+
+ if (versionString != null) {
+ this.applicationMessageVersionInfo = " (v" + versionString + ")";
+ }
+
+ this.beanValidationVersion =
+ ClassUtils.getJarVersion(Validation.buildDefaultValidatorFactory().getValidator().getClass());
+
+ this.jpaVersion =
+ ClassUtils.getJarVersion(Persistence.createEntityManagerFactory("demoApplicationPU").getClass());
+
+ if (!ProjectStage.IntegrationTest.equals(this.projectStage)) {
+ this.messageContext.message().text("{msgWelcome}").add();
+ }
+ }
+
+ public boolean isInfoPage() {
+ ViewConfigDescriptor viewConfigDescriptor =
+ this.viewConfigResolver.getViewConfigDescriptor(this.facesContext.getViewRoot().getViewId());
+
+ if (viewConfigDescriptor == null) {
+ return false;
+ }
+
+ return !viewConfigDescriptor.getMetaData(InfoPage.class).isEmpty();
+ }
+
+ public String getProjectStage() {
+ return this.projectStage.toString();
+ }
+
+ public String getApplicationVersion() {
+ return this.applicationMessageVersionInfo;
+ }
+
+ public String getCodiVersion() {
+ return CodiInformation.VERSION;
+ }
+
+ public String getCdiVersion() {
+ return ClassUtils.getJarVersion(BeanManagerProvider.getInstance().getBeanManager().getClass());
+ }
+
+ public String getExtValVersion() {
+ return ExtValInformation.VERSION;
+ }
+
+ public String getJsfVersion() {
+ return ClassUtils.getJarVersion(FacesContext.class);
+ }
+
+ public String getBeanValidationVersion() {
+ return this.beanValidationVersion;
+ }
+
+ public String getJpaVersion() {
+ return this.jpaVersion;
+ }
+}
diff --git a/content/examples/myfaces-codi-demo/src/main/resources/META-INF/persistence.xml b/content/examples/myfaces-codi-demo/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..0e56230
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+
+ <persistence-unit name="demoApplicationPU" transaction-type="RESOURCE_LOCAL">
+ <!-- needed by tomee 1.6.0+-->
+ <non-jta-data-source>demoDS</non-jta-data-source>
+
+ <!-- config of (non-)jta-data-source isn't needed if there is just one -->
+ <!-- @MappedSuperclass classes - see OPENJPA-1926 -->
+ <class>org.superbiz.myfaces.domain.AbstractDomainObject</class>
+
+ <!-- entities -->
+ <class>org.superbiz.myfaces.domain.User</class>
+ <class>org.superbiz.myfaces.domain.Feedback</class>
+ <class>org.superbiz.myfaces.domain.Comment</class>
+
+ <properties>
+ <property name="openjpa.DataCache" value="true"/>
+ <property name="openjpa.DynamicEnhancementAgent" value="true"/>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ <property name="openjpa.jdbc.QuerySQLCache" value="true(EnableStatistics=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStageHolder b/content/examples/myfaces-codi-demo/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStageHolder
new file mode 100755
index 0000000..57f406f
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStageHolder
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.superbiz.myfaces.CustomProjectStage
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/resources/org/superbiz/myfaces/i18n/messages.properties b/content/examples/myfaces-codi-demo/src/main/resources/org/superbiz/myfaces/i18n/messages.properties
new file mode 100755
index 0000000..3d71dc8
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/resources/org/superbiz/myfaces/i18n/messages.properties
@@ -0,0 +1,60 @@
+#Licensed to the Apache Software Foundation (ASF) under one
+#or more contributor license agreements. See the NOTICE file
+#distributed with this work for additional information
+#regarding copyright ownership. The ASF licenses this file
+#to you under the Apache License, Version 2.0 (the
+#"License"); you may not use this file except in compliance
+#with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing,
+#software distributed under the License is distributed on an
+#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#KIND, either express or implied. See the License for the
+#specific language governing permissions and limitations
+#under the License.
+
+
+
+#overrule the default format {1}: {0} to ignore the labels
+#javax.faces.validator.BeanValidator.MESSAGE={0}
+#javax.faces.validator.BeanValidator.MESSAGE_detail={0}
+
+btnRegisterAndRestart=save and restart
+btnLogin=login
+lnkLogin=Login
+btnRegister=register
+
+lblLoginName=Login-name
+lblFirstName=First-name
+lblLastName=Last-name
+lblPassword=Password
+lblRepeatedPassword=Repeated password
+lblFinish=finish
+
+lblLeftMenuTitle=Menu
+lblHome=Home
+lblFeedback=Feedback
+
+lblWiki=Wiki
+lblExternalExamples=External examples
+
+menuDocumentation=Documentation
+menuMisc=Misc
+menuAbout=About
+
+welcome=Welcome
+msgWelcome=Welcome to the Apache TomEE/MyFaces-Stack Demo
+
+msgUserRegistered=User {userName} registered successfully!
+msgUserNotRegistered=Failed to register user {userName}!
+
+msgLoginSuccessful=Login successful!
+msgLoginFailed=Login failed!
+msgAccessDenied=Access denied!
+tblFeedbackTopic=Topic
+tblFeedbackDescription=Description
+lblTopic=Topic
+lblDescription=Feedback Text
+btnSave=save
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/WEB-INF/beans.xml b/content/examples/myfaces-codi-demo/src/main/webapp/WEB-INF/beans.xml
new file mode 100755
index 0000000..6a4e0bd
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<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>
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/WEB-INF/faces-config.xml b/content/examples/myfaces-codi-demo/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100755
index 0000000..20feafb
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<faces-config 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/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <factory>
+ <lifecycle-factory>org.superbiz.myfaces.startup.ExtValLifecycleFactory</lifecycle-factory>
+ </factory>
+
+ <application>
+ <locale-config>
+ <default-locale>en</default-locale>
+ <supported-locale>en</supported-locale>
+ </locale-config>
+ <message-bundle>org.superbiz.myfaces.i18n.messages</message-bundle>
+ <resource-bundle>
+ <base-name>org.superbiz.myfaces.i18n.messages</base-name>
+ <var>i18n</var>
+ </resource-bundle>
+ </application>
+
+</faces-config>
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/WEB-INF/web.xml b/content/examples/myfaces-codi-demo/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..e1b8aac
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<web-app 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/web-app_3_0.xsd"
+ version="3.0">
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.xhtml</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list>
+ <welcome-file>pages/index.xhtml</welcome-file>
+ </welcome-file-list>
+</web-app>
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/layout/main-template.xhtml b/content/examples/myfaces-codi-demo/src/main/webapp/layout/main-template.xhtml
new file mode 100755
index 0000000..1cb8079
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/layout/main-template.xhtml
@@ -0,0 +1,143 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:p="http://primefaces.prime.com.tr/ui"
+ >
+
+<f:view contentType="text/html">
+
+ <h:head>
+ <title>Apache TomEE/MyFaces-Stack Demo</title>
+ <h:outputStylesheet library="styles" name="base.css"/>
+ <h:outputStylesheet library="styles" name="theme.css"/>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ </h:head>
+ <h:body>
+ <div id="header">
+ <h:form id="topMenuForm" prependId="false">
+ <div id="top_menu">
+ <div id="top_menu_container">
+ <h:panelGroup rendered="#{infoBean.infoPage}">
+ <div class="date">Apache TomEE/MyFaces-Stack <b>Demo-App</b> #{infoBean.applicationVersion}</div>
+ </h:panelGroup>
+ <div id="projectStage" class="date">[#{infoBean.projectStage}]</div>
+ <ul>
+ <li>
+ <h:commandLink id="lnkLogin" value="#{i18n.lnkLogin}" action="#{menuBean.login}"/>
+ </li>
+ <li>
+ <a href="http://www.apache.org" target="_blank">Apache</a>
+ </li>
+ <li>
+ <a href="http://myfaces.apache.org" target="_blank">MyFaces</a>
+ </li>
+ </ul>
+ <div class="clear"></div>
+ </div>
+ </div>
+ </h:form>
+ <div id="header_bottom">
+ <div id="logo_banner_container">
+ <div id="logo">
+ <a href="http://myfaces.apache.org/">
+ <h:graphicImage library="images" name="myfaces_logo.jpg" alt="MyFaces logo"/>
+ </a>
+ </div>
+ <div id="banner">
+ <a href="http://myfaces.apache.org/extensions/cdi/index.html">
+ <h:graphicImage library="images" name="codi_logo.png" alt="CODI logo"/>
+ </a>
+ </div>
+ <div class="clear"></div>
+ </div>
+ </div>
+ </div>
+
+ <div id="main_container">
+ <div id="left_column">
+ <h:form id="menuForm" prependId="false">
+ <div class="left_menu_top">
+ <div class="left_menu_bottom">
+ <h5>#{i18n.lblLeftMenuTitle}</h5>
+
+ <div class="content">
+ <ul class="left_menu">
+ <ui:include src="menu.xhtml"/>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </h:form>
+
+ <div class="clear"></div>
+
+ <h:form id="leftMenuForm" prependId="false">
+
+ <div class="left_menu_top">
+ <div class="left_menu_bottom">
+ <h5>#{i18n.menuMisc}</h5>
+
+ <div class="content">
+ <ul class="left_menu">
+ <li class="none">
+ <h:commandLink id="menuAbout" value="#{i18n.menuAbout}" action="#{menuBean.about}"/>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </h:form>
+ <div class="clear"></div>
+ </div>
+ <div id="body_column">
+ <div>
+ <div class="section">
+
+ <ui:insert name="header"><h2>Apache TomEE/MyFaces-Stack Demo-App</h2></ui:insert>
+
+ <div class="main_content">
+ <h:form id="mainForm" prependId="false">
+ <ui:insert name="content"><p>No content available.</p></ui:insert>
+ </h:form>
+ </div>
+
+ </div>
+ </div>
+ </div>
+ <div class="clear"></div>
+ </div>
+ <p:growl sticky="false"/>
+ <div id="footer">
+ <div class="copyright">
+ <p>© The Apache Software Foundation
+ </p>
+ </div>
+ </div>
+ </h:body>
+</f:view>
+</html>
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/layout/menu.xhtml b/content/examples/myfaces-codi-demo/src/main/webapp/layout/menu.xhtml
new file mode 100755
index 0000000..cc2a35b
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/layout/menu.xhtml
@@ -0,0 +1,32 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<div id="menu"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ >
+
+ <li class="none">
+ <h:commandLink id="menuHome" value="#{i18n.lblHome}" action="#{menuBean.home}"/>
+ </li>
+
+ <li class="none">
+ <h:commandLink id="menuFeedback" value="#{i18n.lblFeedback}" action="#{menuBean.feedback}"/>
+ </li>
+
+</div>
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/pages/about.xhtml b/content/examples/myfaces-codi-demo/src/main/webapp/pages/about.xhtml
new file mode 100755
index 0000000..32e4f5d
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/pages/about.xhtml
@@ -0,0 +1,56 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h:panelGrid columns="2">
+ <h:outputLabel value="Current Window-ID:" for="wid"/>
+ <h:outputText id="wid" value="#{currentWindowContext.id}"/>
+
+ <h:outputLabel value="Apache MyFaces-Core:" for="jsfVersion"/>
+ <h:outputText id="jsfVersion" value="#{infoBean.jsfVersion}"/>
+
+ <h:outputLabel value="Apache OpenWebBeans:" for="cdiVersion"/>
+ <h:outputText id="cdiVersion" value="#{infoBean.cdiVersion}"/>
+
+ <h:outputLabel value="Apache MyFaces CODI:" for="codiVersion"/>
+ <h:outputText id="codiVersion" value="#{infoBean.codiVersion}"/>
+
+ <h:outputLabel value="Apache MyFaces ExtVal:" for="extValVersion"/>
+ <h:outputText id="extValVersion" value="#{infoBean.extValVersion}"/>
+
+ <h:outputLabel value="Apache BVal:" for="bValVersion"/>
+ <h:outputText id="bValVersion" value="#{infoBean.beanValidationVersion}"/>
+
+ <h:outputLabel value="Apache OpenJPA:" for="jpaVersion"/>
+ <h:outputText id="jpaVersion" value="#{infoBean.jpaVersion}"/>
+ </h:panelGrid>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/pages/index.xhtml b/content/examples/myfaces-codi-demo/src/main/webapp/pages/index.xhtml
new file mode 100755
index 0000000..ced13a9
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/pages/index.xhtml
@@ -0,0 +1,68 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h2>Illustrated Features</h2>
+
+ <h3>Apache MyFaces CODI</h3>
+ <ul>
+ <li>Type-safe view-config</li>
+ <li>Type-safe (custom) view-meta-data</li>
+ <li>Type-safe navigation</li>
+ <li>Type-safe (specialized) config</li>
+ <li>Type-safe custom project-stage</li>
+ <li>@WindowScoped</li>
+ <li>Controlling CODI scopes with WindowContext</li>
+ <li>@ViewAccessScoped</li>
+ <li>Manual conversation handling</li>
+ <li>Secured pages (AccessDecisionVoter)</li>
+ <li>@Transactional</li>
+ <li>I18n (fluent API)</li>
+ <li>Dependency-Injection for JSR303 (BV) constraint-validators</li>
+ <li>Dependency-Injection for JSF phase-listeners</li>
+ </ul>
+
+ <h3>Apache MyFaces ExtVal</h3>
+ <ul>
+ <li>Cross-Field validation (@Equals)</li>
+ <li>Type-safe group-validation (@BeanValidation) for JSF action-methods</li>
+ </ul>
+
+ <h2>Hints</h2>
+ <ul>
+ <li>
+ This application doesn't show the/a best practise. It's only a small application which shows a bunch of features.
+ </li>
+ <li>
+ To sync the project-stage of MyFaces CODI and JSF use e.g. faces.PROJECT_STAGE=Development in [tomee dir]/conf/system.properties
+ </li>
+ </ul>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/pages/login.xhtml b/content/examples/myfaces-codi-demo/src/main/webapp/pages/login.xhtml
new file mode 100755
index 0000000..7587d01
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/pages/login.xhtml
@@ -0,0 +1,48 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="loginName" value="#{i18n.lblLoginName}: "/>
+ <h:inputText id="loginName" label="#{i18n.lblLoginName}" value="#{registrationPage.user.userName}" required="true"/>
+ <h:message for="loginName" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="password" value="#{i18n.lblPassword}: "/>
+ <h:inputSecret id="password" label="#{i18n.lblPassword}" value="#{registrationPage.user.password}"/>
+ <h:message for="password" showSummary="true" showDetail="false"/>
+ </h:panelGrid>
+ <p/>
+ <h:panelGrid columns="2">
+ <h:commandButton id="login" value="#{i18n.btnLogin}" action="#{registrationPage.login}"/>
+ <h:commandLink id="register" value="#{i18n.btnRegister}" action="#{menuBean.register}" immediate="true"/>
+ </h:panelGrid>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/pages/registration.xhtml b/content/examples/myfaces-codi-demo/src/main/webapp/pages/registration.xhtml
new file mode 100755
index 0000000..ab7c0ec
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/pages/registration.xhtml
@@ -0,0 +1,57 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="firstName" value="#{i18n.lblFirstName}: "/>
+ <h:inputText id="firstName" label="#{i18n.lblFirstName}" value="#{registrationPage.user.firstName}"/>
+ <h:message for="firstName" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="lastName" value="#{i18n.lblLastName}: "/>
+ <h:inputText id="lastName" label="#{i18n.lblLastName}" value="#{registrationPage.user.lastName}"/>
+ <h:message for="lastName" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="loginName" value="#{i18n.lblLoginName}: "/>
+ <h:inputText id="loginName" label="#{i18n.lblLoginName}" value="#{registrationPage.user.userName}" required="true"/>
+ <h:message for="loginName" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="password" value="#{i18n.lblPassword}: "/>
+ <h:inputSecret id="password" label="#{i18n.lblPassword}" value="#{registrationPage.user.password}"/>
+ <h:message for="password" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="repeatedPassword" value="#{i18n.lblRepeatedPassword}: "/>
+ <h:inputSecret id="repeatedPassword" label="#{i18n.lblRepeatedPassword}" value="#{registrationPage.repeatedPassword}"/>
+ <h:message for="repeatedPassword" showSummary="true" showDetail="false"/>
+ </h:panelGrid>
+ <p/>
+ <h:commandButton id="register" value="#{i18n.btnRegister}" action="#{registrationPage.register}"/>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/pages/secure/feedbackList.xhtml b/content/examples/myfaces-codi-demo/src/main/webapp/pages/secure/feedbackList.xhtml
new file mode 100755
index 0000000..731b55a
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/pages/secure/feedbackList.xhtml
@@ -0,0 +1,65 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<html>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:p="http://primefaces.prime.com.tr/ui"
+ template="/layout/main-template.xhtml">
+
+ <ui:define name="content">
+ <h:panelGrid columns="3">
+ <h:outputLabel for="topic" value="#{i18n.lblTopic}: "/>
+ <h:inputText id="topic" label="#{i18n.lblTopic}" value="#{feedbackPage.feedback.topic}" required="true"/>
+ <h:message for="topic" showSummary="true" showDetail="false"/>
+
+ <h:outputLabel for="description" value="#{i18n.lblDescription}: "/>
+ <h:inputTextarea id="description" cols="80" rows="10" label="#{i18n.lblDescription}" value="#{feedbackPage.feedback.description}"/>
+ <h:message for="description" showSummary="true" showDetail="false"/>
+ </h:panelGrid>
+
+ <h:commandButton id="save" value="#{i18n.btnSave}" action="#{feedbackPage.save}"/>
+
+ <p/>
+
+ <p:dataTable var="entry" value="#{feedbackPage.feedbackList}" paginator="true" paginatorPosition="bottom"
+ rows="10">
+ <p:column>
+ <f:facet name="header">
+ <h:outputText value="#{i18n.tblFeedbackTopic}"/>
+ </f:facet>
+ #{entry.topic}
+ </p:column>
+ <p:column>
+ <f:facet name="header">
+ <h:outputText value="#{i18n.tblFeedbackDescription}"/>
+ </f:facet>
+ #{entry.description}
+ </p:column>
+ </p:dataTable>
+ </ui:define>
+
+</ui:composition>
+</html>
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/codi_logo.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/codi_logo.png
new file mode 100755
index 0000000..11b45ca
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/codi_logo.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/myfaces_logo.jpg b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/myfaces_logo.jpg
new file mode 100755
index 0000000..5c76195
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/myfaces_logo.jpg
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/code_section.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/code_section.png
new file mode 100755
index 0000000..e9d793d
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/code_section.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/footer.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/footer.png
new file mode 100755
index 0000000..7ac05e8
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/footer.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/h2.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/h2.png
new file mode 100755
index 0000000..3effe10
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/h2.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_bottom.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_bottom.png
new file mode 100755
index 0000000..34b412a
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_bottom.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_expand.gif b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_expand.gif
new file mode 100755
index 0000000..b964caf
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_expand.gif
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_expand_hover.gif b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_expand_hover.gif
new file mode 100755
index 0000000..aeff8a4
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_expand_hover.gif
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_expand_selected.gif b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_expand_selected.gif
new file mode 100755
index 0000000..3f18875
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_expand_selected.gif
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_option.gif b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_option.gif
new file mode 100755
index 0000000..a4357cb
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_option.gif
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_option_hover.gif b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_option_hover.gif
new file mode 100755
index 0000000..6e20b6f
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_option_hover.gif
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_top.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_top.png
new file mode 100755
index 0000000..6cde4b5
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/left_menu_top.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/logo_banner_container.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/logo_banner_container.png
new file mode 100755
index 0000000..cb82ada
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/logo_banner_container.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/main_space_list.gif b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/main_space_list.gif
new file mode 100755
index 0000000..a23c02b
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/main_space_list.gif
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/table_head.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/table_head.png
new file mode 100755
index 0000000..bdfa5c0
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/table_head.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/table_head_dark.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/table_head_dark.png
new file mode 100755
index 0000000..df5fa55
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/table_head_dark.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/top_menu.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/top_menu.png
new file mode 100755
index 0000000..7b41b40
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/top_menu.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/top_menu_hover.png b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/top_menu_hover.png
new file mode 100755
index 0000000..b0aaf44
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/top_menu_hover.png
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/transparent.gif b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/transparent.gif
new file mode 100755
index 0000000..fc25609
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/images/slices/transparent.gif
Binary files differ
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/styles/base.css b/content/examples/myfaces-codi-demo/src/main/webapp/resources/styles/base.css
new file mode 100755
index 0000000..20ec821
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/styles/base.css
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+body {
+ margin: 0;
+ padding: 0;
+}
+
+img {
+ border: none;
+}
+
+table {
+ padding: 0;
+ width: 50%;
+ margin-left: -2px;
+ margin-right: -2px;
+}
+
+acronym {
+ cursor: help;
+ border-bottom: 1px dotted #feb;
+}
+
+table.bodyTable th, table.bodyTable td {
+ padding: 2px 4px 2px 4px;
+ vertical-align: top;
+}
+
+div.clear {
+ clear: both;
+ visibility: hidden;
+}
+
+div.clear hr {
+ display: none;
+}
+
+#bannerLeft, #bannerRight {
+ font-size: xx-large;
+ font-weight: bold;
+}
+
+#bannerLeft img, #bannerRight img {
+ margin: 0;
+}
+
+.xleft, #bannerLeft img {
+ float: left;
+ text-shadow: #7CFC00 1px 1px 1px;
+}
+
+.xright, #bannerRight {
+ float: right;
+ text-shadow: #7CFC00 1px 1px 1px;
+}
+
+#banner {
+ padding: 0;
+}
+
+#banner img {
+ border: none;
+}
+
+#breadcrumbs {
+ padding: 3px 10px 3px 10px;
+}
+
+#leftColumn {
+ width: 170px;
+ float: left;
+ overflow: auto;
+}
+
+#bodyColumn {
+ margin-right: 1.5em;
+ margin-left: 197px;
+}
+
+#legend {
+ padding: 8px 0 8px 0;
+}
+
+#navcolumn {
+ padding: 8px 4px 0 8px;
+}
+
+#navcolumn h5 {
+ margin: 0;
+ padding: 0;
+ font-size: small;
+}
+
+#navcolumn ul {
+ margin: 0;
+ padding: 0;
+ font-size: small;
+}
+
+#navcolumn li {
+ list-style-type: none;
+ background-image: none;
+ background-repeat: no-repeat;
+ background-position: 0 0.4em;
+ padding-left: 16px;
+ list-style-position: outside;
+ line-height: 1.2em;
+ font-size: smaller;
+}
+
+#poweredBy {
+ text-align: center;
+}
+
+#navcolumn img {
+ margin-top: 10px;
+ margin-bottom: 3px;
+}
+
+#poweredBy img {
+ display: block;
+ margin: 20px 0 20px 17px;
+}
+
+#search img {
+ margin: 0;
+ display: block;
+}
+
+#search #q, #search #btnG {
+ border: 1px solid #999;
+ margin-bottom: 10px;
+}
+
+#search form {
+ margin: 0;
+}
+
+#lastPublished {
+ font-size: x-small;
+}
+
+.navSection {
+ margin-bottom: 2px;
+ padding: 8px;
+}
+
+.navSectionHead {
+ font-weight: bold;
+ font-size: x-small;
+}
+
+.section {
+ padding: 4px;
+}
+
+#footer {
+ padding: 3px 10px 3px 10px;
+ font-size: x-small;
+}
+
+#breadcrumbs {
+ font-size: x-small;
+ margin: 0;
+}
+
+.source {
+ padding: 12px;
+ margin: 1em 7px 1em 7px;
+}
+
+.source pre {
+ margin: 0;
+ padding: 0;
+}
\ No newline at end of file
diff --git a/content/examples/myfaces-codi-demo/src/main/webapp/resources/styles/theme.css b/content/examples/myfaces-codi-demo/src/main/webapp/resources/styles/theme.css
new file mode 100755
index 0000000..73e7161
--- /dev/null
+++ b/content/examples/myfaces-codi-demo/src/main/webapp/resources/styles/theme.css
@@ -0,0 +1,480 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Init --------------------------------------------------------------------- */
+* {
+ margin: 0px;
+ padding: 0px;
+}
+
+body {
+ text-align: center; /*font-size: 75%;*/
+ /*=12pixels*/
+ font-size: 12px;
+ font-family: verdana, tahoma, sans-serif;
+ font-weight: normal;
+ line-height: 1.4em;
+ color: #666666;
+ background-color: white;
+}
+
+div {
+ text-align: left;
+}
+
+span {
+ display: inline;
+}
+
+img {
+ display: block;
+}
+
+h1, h2, h3 {
+ font-family: arial, geneva, helvetica, sans-serif;
+ font-weight: bold;
+ margin-top: 10px;
+ color: #669900;
+}
+
+h1 {
+ font-size: 1.6em;
+}
+
+h2 {
+ font-size: 1.2em;
+}
+
+h3 {
+ font-size: 1.1em;
+}
+
+ul {
+ list-style-type: none;
+}
+
+a {
+ text-decoration: none;
+ color: #669900;
+}
+
+a:hover {
+ color: #FF9900;
+}
+
+/*
+ * Clear float positions.
+ */
+.clear {
+ clear: both;
+}
+
+/* IE fixes ------------------------------------------------ */
+/* Solve the IE 3px gap bug */
+/* Hides from IE5-mac \*/
+* html .section, p {
+ height: 1%;
+}
+
+/* End hide from IE5-mac */
+/* Add the min and max width in IE */
+* #main_container, * #top_menu_container, * #logo_banner_container, * .copyright {
+ width: expression(document . body . clientWidth > 1210 ? "1200px" : (
+ document . body . clientWidth < 960 ? "950px" : "auto") );
+}
+
+/* PNG transparency fix */
+img {
+ behavior: url(css/png-fix.htc);
+}
+
+/* IE fixes ----------------------------------------------------------------- */
+/* Fluid layout constraints ----------------------------------------- */
+#main_container, #top_menu_container, #logo_banner_container, .copyright {
+ max-width: 1200px;
+ min-width: 950px;
+}
+
+#footer, #top_menu, #header_bottom {
+ width: 100%;
+ min-width: 950px;
+}
+
+/* Main layout -------------------------------------------------------------- */
+#main_container {
+ margin: 0px auto 0px auto;
+}
+
+#footer {
+ margin: 0px;
+ border: 0px;
+ padding: 0px;
+ height: 90px;
+ margin-top: 50px;
+ text-align: center;
+ color: white;
+ background: #52842D url("#{resource['images:slices/footer.png']}") repeat-x;
+}
+
+/* Header layout ------------------------------------------------------------ */
+#top_menu {
+ width: auto;
+ height: 45px;
+ text-align: center;
+ background: #52842D url("#{resource['images:slices/top_menu.png']}") repeat-x;
+}
+
+#top_menu_container {
+ margin: 0px auto 0px auto;
+ padding-top: 4px;
+}
+
+#header_bottom {
+ height: auto;
+ text-align: center;
+ background: url("#{resource['images:slices/logo_banner_container.png']}") repeat-x;
+}
+
+#logo_banner_container {
+ margin: 0px auto 0px auto;
+}
+
+/* body layout -------------------------------------------------------------- */
+#left_column {
+ float: left;
+ width: 210px;
+ height: auto;
+}
+
+#body_column {
+ padding: 1px 0px 0px 230px;
+ width: auto;
+}
+
+/* footer layout ------------------------------------------------------------ */
+.copyright {
+ margin: 0px auto 0px auto;
+ padding-top: 15px;
+}
+
+/* logo_banner_container layout --------------------------------------------- */
+#logo {
+ float: left;
+ width: 210px;
+ height: 100px;
+ margin-top: 10px;
+}
+
+#banner {
+ float: right;
+ width: 210px;
+ height: 85px;
+ margin-top: 10px;
+}
+
+/* leftColumn layout ------------------------------------------------------ */
+.left_menu_container {
+ width: 210px;
+}
+
+#powered_by {
+ /*float: right;*/
+ text-align: center;
+}
+
+#powered_by img {
+ margin: 10px auto 10px auto;
+}
+
+/* left_menu layout --------------------------------------------------------- */
+.left_menu_top {
+ width: 210px;
+ background: url("#{resource['images:slices/left_menu_top.png']}") no-repeat top;
+}
+
+.left_menu_bottom {
+ width: 210px;
+ background: url("#{resource['images:slices/left_menu_bottom.png']}") no-repeat bottom;
+}
+
+/* top menu ----------------------------------------------------------------- */
+#top_menu div.date, #top_menu div.version {
+ margin: 9px 0px 0px 10px;
+ float: left;
+ color: white;
+}
+
+#top_menu ul {
+ float: right;
+ height: 37px;
+ border-right: 1px solid #80AA66;
+}
+
+#top_menu li {
+ display: inline;
+ height: 37px;
+ margin-left: -4px;
+}
+
+#top_menu a {
+ position: relative;
+ top: 9px;
+ border-left: 1px solid #80AA66;
+ padding: 10px 10px 13px 10px;
+ font-size: 12px;
+ color: white;
+}
+
+#top_menu a:hover {
+ text-decoration: underline;
+ background: url("#{resource['images:slices/top_menu_hover.png']}") repeat-x top;
+}
+
+/* left menu - first level menu --------------------------------------------- */
+.left_menu_top h5 {
+ padding: 26px 20px 0px 25px;
+ font-size: 1em;
+ color: #84683E;
+}
+
+ul.left_menu {
+ padding: 22px 20px 22px 25px;
+}
+
+ul.left_menu a {
+ font-size: 0.9em;
+ color: #705F38;
+ margin-left: 2px;
+ padding-left: 15px;
+}
+
+ul.left_menu a:hover {
+ color: #FF9900;
+}
+
+ul.left_menu li.none a {
+ background: url("#{resource['images:slices/left_menu_option.gif']}") no-repeat left;
+}
+
+ul.left_menu li.none a:hover {
+ background: url("#{resource['images:slices/left_menu_option_hover.gif']}") no-repeat left;
+}
+
+ul.left_menu li.none a.selected {
+ font-weight: bold;
+ background: none;
+}
+
+ul.left_menu li.expanded a {
+ font-weight: bold;
+ margin-left: 0px;
+ background: url("#{resource['images:slices/left_menu_expand_selected.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded a:hover {
+ background: url("#{resource['images:slices/left_menu_expand_hover.gif']}") no-repeat left;
+}
+
+ul.left_menu li.collapsed a {
+ margin-left: 0px;
+ background: url("#{resource['images:slices/left_menu_expand.gif']}") no-repeat left;
+}
+
+ul.left_menu li.collapsed a:hover {
+ background: url("#{resource['images:slices/left_menu_expand_hover.gif']}") no-repeat left;
+}
+
+/* left menu - second level menu ------------------------------------------- */
+ul.left_menu ul {
+ list-style-type: none;
+ padding: 0px 0px 10px 10px;
+}
+
+ul.left_menu li.expanded ul {
+ display: block;
+}
+
+ul.left_menu li.expanded ul a {
+ font-weight: normal;
+ background: none;
+}
+
+ul.left_menu li.expanded ul li.expanded a {
+ font-weight: bold;
+ background: url("#{resource['images:slices/left_menu_expand_selected.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded ul li.expanded a:hover {
+ background: url("#{resource['images:slices/left_menu_expand_hover.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded ul li.collapsed a {
+ font-weight: normal;
+ background: url("#{resource['images:slices/left_menu_expand.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded ul li.collapsed a:hover {
+ background: url("#{resource['images:slices/left_menu_expand_hover.gif']}") no-repeat left;
+}
+
+ul.left_menu li.expanded ul a.selected {
+ font-weight: bold;
+}
+
+ul.left_menu li.collapsed ul {
+ display: none;
+}
+
+ul.left_menu ul li.none a,
+ul.left_menu ul li.none a:hover,
+ul.left_menu ul li.none a.selected {
+ background: none;
+}
+
+/* left menu - third level menu --------------------------------------------- */
+ul.left_menu ul ul {
+ padding: 0px 0px 10px 10px;
+}
+
+ul.left_menu ul li.expanded ul {
+ display: block;
+}
+
+ul.left_menu ul li.expanded ul li.none a {
+ font-weight: normal;
+}
+
+ul.left_menu ul li.expanded ul li.none a.selected {
+ font-weight: bold;
+}
+
+ul.left_menu ul li.expanded ul li.none a,
+ul.left_menu ul li.expanded ul li.none a:hover,
+ul.left_menu ul li.expanded ul li.none a.selected {
+ background: none;
+}
+
+/* body_column -------------------------------------------------------------- */
+#body_column p {
+ margin: 15px 15px 0px 0px;
+}
+
+#body_column .section, #body_column dl {
+ margin: 25px 0px 0px 0px;
+ padding: 0px 10px;
+}
+
+#body_column .section {
+}
+
+#body_column .section .section {
+ margin: 0px;
+ border: 0px;
+ padding: 0px;
+ overflow: auto;
+}
+
+/* Overflow fix for IE */
+* #body_column .section .section {
+ position: relative;
+ width: 100%;
+ overflow: hidden;
+ overflow-x: auto;
+}
+
+#body_column ul {
+ margin: 0px 15px 10px 15px;
+}
+
+#body_column ul li {
+ padding: 0px 0px 0px 15px;
+ background: url("#{resource['images:slices/main_space_list.gif']}") no-repeat left 5px;
+}
+
+#body_column ol {
+ padding: 15px 0px 15px 20px;
+}
+
+#body_column ol ol {
+ padding: 0px 0px 0px 15px;
+}
+
+/* tables ------------------------------------------------------------------- */
+#body_column table.bodyTable {
+ margin: 0px 0px 10px 0px;
+ border-collapse: collapse;
+ padding: 2px;
+ font-family: Tahoma, Arial, sans-serif;
+ font-size: 0.9em;
+ color: #333333;
+ background: white;
+}
+
+#body_column table.bodyTable th, table.bodyTable tr, table.bodyTable td {
+ margin: 0px;
+ border: 1px solid white;
+ padding: 0px 7px 0px 7px;
+}
+
+#body_column table.bodyTable tr.a {
+ background: #F7F9F4;
+}
+
+#body_column table.bodyTable tr.b {
+ background: #F2F5ED;
+}
+
+#body_column table a.externalLink {
+ background: none;
+ padding-right: 0px;
+}
+
+#body_column table.bodyTable th {
+ padding: 7px 7px 5px 7px;
+ background: #CDDCB8 url("#{resource['images:slices/table_head_dark.png']}") repeat-x;
+}
+
+/* source sections ---------------------------------------------------------- */
+#body_column .source, code {
+ margin: 14px 0px 14px 0px;
+ border: 1px solid #E6E9DA;
+ font-size: 1.1em;
+ font-family: "Courier new", Courier, monospace;
+ color: #333333;
+ background: #F9FAF5 url("#{resource['images:slices/code_section.png']}") repeat-x top;
+}
+
+#body_column b {
+ padding-top: 10px;
+}
+
+#body_column h2 {
+ padding: 5px 10px 5px 10px;
+ border: 1px solid #D8E4C7;
+ background: white url("#{resource['images:slices/h2.png']}") repeat-x top;
+}
+
+.main_content {
+ padding: 30px;
+}
+
+/* copyright ---------------------------------------------------------------- */
+.copyright p {
+ font-size: 0.9em;
+}
\ No newline at end of file
diff --git a/content/examples/persistence-fragment.html b/content/examples/persistence-fragment.html
new file mode 100644
index 0000000..db32668
--- /dev/null
+++ b/content/examples/persistence-fragment.html
@@ -0,0 +1,337 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/persistence-fragment.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Persistence Fragment</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example persistence-fragment can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/persistence-fragment" class="bare">https://github.com/apache/tomee/tree/master/examples/persistence-fragment</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+ @Id
+ @GeneratedValue
+ private long id;
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ // no-op
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_fragment_xml">persistence-fragment.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence-fragment version="2.0">
+ <persistence-unit-fragment name="movie-unit">
+ <class>org.superbiz.injection.jpa.Movie</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ </persistence-unit-fragment>
+</persistence-fragment></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.jpa;
+
+import org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+
+public class MoviesTest {
+ @PersistenceUnit
+ private EntityManagerFactory emf;
+
+ @Test
+ public void test() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final EJBContainer container = EJBContainer.createEJBContainer(p);
+ final Context context = container.getContext();
+ context.bind("inject", this);
+
+ assertTrue(((ReloadableEntityManagerFactory) emf).getManagedClasses().contains(Movie.class.getName()));
+
+ container.close();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/persistence-fragment.pdf b/content/examples/persistence-fragment.pdf
new file mode 100644
index 0000000..ee9965e
--- /dev/null
+++ b/content/examples/persistence-fragment.pdf
Binary files differ
diff --git a/content/examples/persistence-fragment/README.md b/content/examples/persistence-fragment/README.md
new file mode 100755
index 0000000..7bf41de
--- /dev/null
+++ b/content/examples/persistence-fragment/README.md
@@ -0,0 +1,122 @@
+Title: Persistence Fragment
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Movie
+
+ package org.superbiz.injection.jpa;
+
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.Id;
+
+ @Entity
+ public class Movie {
+ @Id
+ @GeneratedValue
+ private long id;
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ // no-op
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+ }
+
+## persistence-fragment.xml
+
+ <persistence-fragment version="2.0">
+ <persistence-unit-fragment name="movie-unit">
+ <class>org.superbiz.injection.jpa.Movie</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ </persistence-unit-fragment>
+ </persistence-fragment>
+
+
+## MoviesTest
+
+ package org.superbiz.injection.jpa;
+
+ import org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import javax.persistence.EntityManagerFactory;
+ import javax.persistence.PersistenceUnit;
+ import java.util.Properties;
+
+ import static org.junit.Assert.assertTrue;
+
+ public class MoviesTest {
+ @PersistenceUnit
+ private EntityManagerFactory emf;
+
+ @Test
+ public void test() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final EJBContainer container = EJBContainer.createEJBContainer(p);
+ final Context context = container.getContext();
+ context.bind("inject", this);
+
+ assertTrue(((ReloadableEntityManagerFactory) emf).getManagedClasses().contains(Movie.class.getName()));
+
+ container.close();
+ }
+ }
+
+## persistence.xml
+
+ <persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
diff --git a/content/examples/persistence-fragment/pom.xml b/content/examples/persistence-fragment/pom.xml
new file mode 100755
index 0000000..0eafdde
--- /dev/null
+++ b/content/examples/persistence-fragment/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1178411 $ $Date: 2011-10-03 15:35:26 +0200 (lun. 03 oct. 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>persistence-fragment</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Persistence Fragment</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/persistence-fragment/src/main/java/org/superbiz/injection/jpa/Movie.java b/content/examples/persistence-fragment/src/main/java/org/superbiz/injection/jpa/Movie.java
new file mode 100755
index 0000000..9eb94fc
--- /dev/null
+++ b/content/examples/persistence-fragment/src/main/java/org/superbiz/injection/jpa/Movie.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue
+ private long id;
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ // no-op
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+}
diff --git a/content/examples/persistence-fragment/src/main/resources/META-INF/persistence-fragment.xml b/content/examples/persistence-fragment/src/main/resources/META-INF/persistence-fragment.xml
new file mode 100755
index 0000000..1963595
--- /dev/null
+++ b/content/examples/persistence-fragment/src/main/resources/META-INF/persistence-fragment.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence-fragment version="2.0">
+ <persistence-unit-fragment name="movie-unit">
+ <class>org.superbiz.injection.jpa.Movie</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ </persistence-unit-fragment>
+</persistence-fragment>
diff --git a/content/examples/persistence-fragment/src/test/java/org/superbiz/injection/jpa/MoviesTest.java b/content/examples/persistence-fragment/src/test/java/org/superbiz/injection/jpa/MoviesTest.java
new file mode 100755
index 0000000..aedbe0e
--- /dev/null
+++ b/content/examples/persistence-fragment/src/test/java/org/superbiz/injection/jpa/MoviesTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.jpa;
+
+import org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+
+public class MoviesTest {
+
+ @PersistenceUnit
+ private EntityManagerFactory emf;
+
+ @Test
+ public void test() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ final EJBContainer container = EJBContainer.createEJBContainer(p);
+ final Context context = container.getContext();
+ context.bind("inject", this);
+
+ assertTrue(((ReloadableEntityManagerFactory) emf).getManagedClasses().contains(Movie.class.getName()));
+
+ container.close();
+ }
+}
diff --git a/content/examples/persistence-fragment/src/test/resources/META-INF/persistence.xml b/content/examples/persistence-fragment/src/test/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..81146a9
--- /dev/null
+++ b/content/examples/persistence-fragment/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/pojo-webservice.html b/content/examples/pojo-webservice.html
new file mode 100644
index 0000000..8bed1e4
--- /dev/null
+++ b/content/examples/pojo-webservice.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/pojo-webservice.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>pojo-webservice</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example pojo-webservice can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/pojo-webservice" class="bare">https://github.com/apache/tomee/tree/master/examples/pojo-webservice</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/pojo-webservice.pdf b/content/examples/pojo-webservice.pdf
new file mode 100644
index 0000000..2d6b190
--- /dev/null
+++ b/content/examples/pojo-webservice.pdf
Binary files differ
diff --git a/content/examples/pojo-webservice/global-groovy.log b/content/examples/pojo-webservice/global-groovy.log
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/content/examples/pojo-webservice/global-groovy.log
diff --git a/content/examples/pojo-webservice/pom.xml b/content/examples/pojo-webservice/pom.xml
new file mode 100755
index 0000000..ed076bc
--- /dev/null
+++ b/content/examples/pojo-webservice/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>pojo-webservice</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: Pojo WS</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <tomee.version>1.7.1</tomee.version>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ <repository>
+ <id>tomcat-m2-repo</id>
+ <name>Tomcat Dev Repository</name>
+ <url>http://tomcat.apache.org/dev/dist/m2-repository/</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <defaultGoal>package</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin> <!-- http://localhost:8080/pojo-webservice?wsdl -->
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ <configuration>
+ <tomeeVersion>${tomee.version}</tomeeVersion>
+ <tomeeClassifier>plus</tomeeClassifier>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>local-release-repo</id>
+ <url>file://${project.build.outputDirectory}/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>local-snapshot-repo</id>
+ <url>file://${project.build.outputDirectory}/repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/pojo-webservice/soapui-errors.log b/content/examples/pojo-webservice/soapui-errors.log
new file mode 100755
index 0000000..0072786
--- /dev/null
+++ b/content/examples/pojo-webservice/soapui-errors.log
@@ -0,0 +1,30 @@
+2012-06-28 18:59:46,134 ERROR [errorlog] com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+ at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:138)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:534)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:523)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:97)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:226)
+ at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
+ at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
+ at java.lang.Thread.run(Thread.java:662)
+2012-06-28 19:00:22,801 ERROR [errorlog] com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+ at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:138)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:534)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:523)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:97)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:226)
+ at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
+ at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
+ at java.lang.Thread.run(Thread.java:662)
+2012-06-28 19:01:09,715 ERROR [errorlog] com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+ at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:138)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:534)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:523)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:97)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:226)
+ at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
+ at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
+ at java.lang.Thread.run(Thread.java:662)
diff --git a/content/examples/pojo-webservice/soapui.log b/content/examples/pojo-webservice/soapui.log
new file mode 100755
index 0000000..303a735
--- /dev/null
+++ b/content/examples/pojo-webservice/soapui.log
@@ -0,0 +1,50 @@
+2012-06-28 18:57:03,268 INFO [DefaultSoapUICore] initialized soapui-settings from [/opt/softs/soapui-4.0.1/soapui-settings.xml]
+2012-06-28 18:57:05,058 INFO [SoapUI] Used java version: 1.6.0_30
+2012-06-28 18:59:32,641 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/xop.xsd with targetNamespace http://www.w3.org/2004/08/xop/include
+2012-06-28 18:59:33,004 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/XMLSchema.xsd with targetNamespace http://www.w3.org/2001/XMLSchema
+2012-06-28 18:59:33,005 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/xml.xsd with targetNamespace http://www.w3.org/XML/1998/namespace
+2012-06-28 18:59:33,006 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/swaref.xsd with targetNamespace http://ws-i.org/profiles/basic/1.1/xsd
+2012-06-28 18:59:33,007 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/xmime200505.xsd with targetNamespace http://www.w3.org/2005/05/xmlmime
+2012-06-28 18:59:33,008 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/xmime200411.xsd with targetNamespace http://www.w3.org/2004/11/xmlmime
+2012-06-28 18:59:33,010 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/soapEnvelope.xsd with targetNamespace http://schemas.xmlsoap.org/soap/envelope/
+2012-06-28 18:59:33,027 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/soapEncoding.xsd with targetNamespace http://schemas.xmlsoap.org/soap/encoding/
+2012-06-28 18:59:33,029 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/soapEnvelope12.xsd with targetNamespace http://www.w3.org/2003/05/soap-envelope
+2012-06-28 18:59:33,036 INFO [SchemaUtils] Added default schema from file:/opt/softs/soapui-4.0.1/bin/soapui-4.0.1.jar!/com/eviware/soapui/resources/xsds/soapEncoding12.xsd with targetNamespace http://www.w3.org/2003/05/soap-encoding
+2012-06-28 18:59:46,131 ERROR [WsdlLoader] Failed to load url [http://localhost:8080/pojo-webservice?wsdl]
+2012-06-28 18:59:46,132 ERROR [SoapUI] An error occured [com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException], see error log for details
+2012-06-28 18:59:46,134 ERROR [errorlog] com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+ at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:138)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:534)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:523)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:97)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:226)
+ at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
+ at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
+ at java.lang.Thread.run(Thread.java:662)
+2012-06-28 19:00:22,801 ERROR [WsdlLoader] Failed to load url [http://127.0.01:8080/pojo-webservice?wsdl]
+2012-06-28 19:00:22,801 ERROR [SoapUI] An error occured [com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException], see error log for details
+2012-06-28 19:00:22,801 ERROR [errorlog] com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+ at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:138)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:534)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:523)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:97)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:226)
+ at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
+ at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
+ at java.lang.Thread.run(Thread.java:662)
+2012-06-28 19:01:09,714 ERROR [WsdlLoader] Failed to load url [http://localhost:8080/pojo-webservice/?wsdl]
+2012-06-28 19:01:09,715 ERROR [SoapUI] An error occured [com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException], see error log for details
+2012-06-28 19:01:09,715 ERROR [errorlog] com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+com.eviware.soapui.impl.support.definition.support.InvalidDefinitionException
+ at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:138)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:534)
+ at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:523)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:97)
+ at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:226)
+ at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
+ at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:149)
+ at java.lang.Thread.run(Thread.java:662)
+2012-06-28 19:01:24,521 INFO [DefaultSoapUICore] Settings saved to [/opt/softs/soapui-4.0.1/soapui-settings.xml]
+2012-06-28 19:01:28,074 INFO [WorkspaceImpl] Saved workspace to [/opt/dev/openejb/openejb-trunk/examples/webapps/pojo-webservice/../../TestPBE-workspace.xml]
diff --git a/content/examples/pojo-webservice/src/main/java/org/superbiz/ws/pojo/PojoWS.java b/content/examples/pojo-webservice/src/main/java/org/superbiz/ws/pojo/PojoWS.java
new file mode 100755
index 0000000..15fb025
--- /dev/null
+++ b/content/examples/pojo-webservice/src/main/java/org/superbiz/ws/pojo/PojoWS.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.pojo;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.transaction.UserTransaction;
+import javax.xml.ws.WebServiceContext;
+
+@WebService
+public class PojoWS implements WS {
+
+ @Resource
+ private WebServiceContext webServiceContext;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @Override
+ public String ws() {
+ return webServiceContext + " & " + userTransaction;
+ }
+
+ public void setWebServiceContext(WebServiceContext webServiceContext) {
+ this.webServiceContext = webServiceContext;
+ }
+
+ public void setUserTransaction(UserTransaction userTransaction) {
+ this.userTransaction = userTransaction;
+ }
+}
diff --git a/content/examples/pojo-webservice/src/main/java/org/superbiz/ws/pojo/WS.java b/content/examples/pojo-webservice/src/main/java/org/superbiz/ws/pojo/WS.java
new file mode 100755
index 0000000..75b4a9f
--- /dev/null
+++ b/content/examples/pojo-webservice/src/main/java/org/superbiz/ws/pojo/WS.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.pojo;
+
+import javax.jws.WebService;
+
+@WebService
+public interface WS {
+
+ String ws();
+}
diff --git a/content/examples/pojo-webservice/src/main/webapp/WEB-INF/web.xml b/content/examples/pojo-webservice/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..018aa23
--- /dev/null
+++ b/content/examples/pojo-webservice/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<web-app 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/web-app_3_0.xsd"
+ version="3.0">
+ <servlet>
+ <servlet-name>ws</servlet-name>
+ <servlet-class>org.superbiz.ws.pojo.PojoWS</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ws</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
diff --git a/content/examples/polling-parent.html b/content/examples/polling-parent.html
new file mode 100644
index 0000000..0235e2f
--- /dev/null
+++ b/content/examples/polling-parent.html
@@ -0,0 +1,239 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/polling-parent.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>polling-parent</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example polling-parent can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/polling-parent" class="bare">https://github.com/apache/tomee/tree/master/examples/polling-parent</a></p>
+</div>
+</div>
+</div>
+<h1 id="_sample" class="sect0">Sample #</h1>
+<div class="paragraph">
+<p>This sample implements a simple polling application.</p>
+</div>
+<div class="paragraph">
+<p>You can create polls and then vote (+1 or -1) for each poll (called Subject).</p>
+</div>
+<div class="paragraph">
+<p>The front is a JAX-RS front and the backend uses EJBs and JPA.</p>
+</div>
+<h1 id="_module" class="sect0">Module #</h1>
+<div class="paragraph">
+<p>The application contains several modules:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>polling-domain: entities used by the client side too</p>
+</li>
+<li>
+<p>polling-core: the middle/dao layer</p>
+</li>
+<li>
+<p>polling-web: front layer (REST services)</p>
+</li>
+</ul>
+</div>
+<h1 id="_what_is_noticeable" class="sect0">What is noticeable #</h1>
+<div class="paragraph">
+<p>The front layer contains a MBean managed by CDI (VoteCounter) which is used by REST services to update information you
+can retrieve through JMX protocol (JConsole client is fine to see it ;)).</p>
+</div>
+<div class="paragraph">
+<p>It manages a dynamic datasource too. It manages in the example configuration 2 clients.</p>
+</div>
+<div class="paragraph">
+<p>It is a simple round robin by request. That’s why from the client if you simply create a poll then find it
+you’ll not find the persisted poll, you need to do it once again.</p>
+</div>
+<h1 id="_client" class="sect0">Client #</h1>
+<div class="paragraph">
+<p>It lets you create poll, retrieve them, find the best poll and vote for any poll.</p>
+</div>
+<div class="paragraph">
+<p>Please type help for more information.</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/polling-parent.pdf b/content/examples/polling-parent.pdf
new file mode 100644
index 0000000..72bb44b
--- /dev/null
+++ b/content/examples/polling-parent.pdf
Binary files differ
diff --git a/content/examples/polling-parent/README.md b/content/examples/polling-parent/README.md
new file mode 100755
index 0000000..5a29492
--- /dev/null
+++ b/content/examples/polling-parent/README.md
@@ -0,0 +1,31 @@
+# Sample #
+
+This sample implements a simple polling application.
+
+You can create polls and then vote (+1 or -1) for each poll (called Subject).
+
+The front is a JAX-RS front and the backend uses EJBs and JPA.
+
+# Module #
+
+The application contains several modules:
+
+* polling-domain: entities used by the client side too
+* polling-core: the middle/dao layer
+* polling-web: front layer (REST services)
+
+# What is noticeable #
+
+The front layer contains a MBean managed by CDI (VoteCounter) which is used by REST services to update information you
+can retrieve through JMX protocol (JConsole client is fine to see it ;)).
+
+It manages a dynamic datasource too. It manages in the example configuration 2 clients.
+
+It is a simple round robin by request. That's why from the client if you simply create a poll then find it
+you'll not find the persisted poll, you need to do it once again.
+
+# Client #
+
+It lets you create poll, retrieve them, find the best poll and vote for any poll.
+
+Please type help for more information.
diff --git a/content/examples/polling-parent/polling-client/pom.xml b/content/examples/polling-parent/polling-client/pom.xml
new file mode 100755
index 0000000..0a7edce
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>polling-parent</artifactId>
+ <groupId>jug</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>polling-client</artifactId>
+ <name>OpenEJB :: Examples :: Polling :: Client</name>
+ <description>Just a cli to avoid to remember URLs</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-bundle</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-finder-shaded</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-reflect</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>polling-domain</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <includePluginDependencies>true</includePluginDependencies>
+ <mainClass>jug.client.Client</mainClass>
+ <arguments>
+ <argument>http://localhost:8080/polling-web-${project.version}/</argument>
+ </arguments>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency> <!-- because entities was enhanced -->
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/Client.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/Client.java
new file mode 100755
index 0000000..419b9eb
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/Client.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client;
+
+import jline.ConsoleReader;
+import jline.FileNameCompletor;
+import jline.SimpleCompletor;
+import jug.client.command.api.AbstractCommand;
+import jug.client.util.CommandManager;
+import org.apache.xbean.recipe.ObjectRecipe;
+import org.apache.xbean.recipe.Option;
+
+import java.io.OutputStreamWriter;
+import java.util.Map;
+
+public class Client {
+
+ private static final String PROMPT = System.getProperty("user.name") + " @ jug > ";
+ private static final String EXIT_CMD = "exit";
+
+ private Client() {
+ // no-op
+ }
+
+ public static void main(final String[] args) throws Exception {
+ if (args.length != 1) {
+ System.err.println("Pass the base url as parameter");
+ return;
+ }
+
+ final ConsoleReader reader = new ConsoleReader(System.in, new OutputStreamWriter(System.out));
+ reader.addCompletor(new FileNameCompletor());
+ reader.addCompletor(new SimpleCompletor(CommandManager.keys().toArray(new String[CommandManager.size()])));
+
+ String line;
+ while ((line = reader.readLine(PROMPT)) != null) {
+ if (EXIT_CMD.equals(line)) {
+ break;
+ }
+
+ Class<?> cmdClass = null;
+ for (Map.Entry<String, Class<?>> cmd : CommandManager.getCommands().entrySet()) {
+ if (line.startsWith(cmd.getKey())) {
+ cmdClass = cmd.getValue();
+ break;
+ }
+ }
+
+ if (cmdClass != null) {
+ final ObjectRecipe recipe = new ObjectRecipe(cmdClass);
+ recipe.setProperty("url", args[0]);
+ recipe.setProperty("command", line);
+ recipe.setProperty("commands", CommandManager.getCommands());
+
+ recipe.allow(Option.CASE_INSENSITIVE_PROPERTIES);
+ recipe.allow(Option.IGNORE_MISSING_PROPERTIES);
+ recipe.allow(Option.NAMED_PARAMETERS);
+
+ try {
+ final AbstractCommand cmdInstance = (AbstractCommand) recipe.create();
+ cmdInstance.execute(line);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ System.err.println("sorry i don't understand '" + line + "'");
+ }
+ }
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/api/AbstractCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/api/AbstractCommand.java
new file mode 100755
index 0000000..b4fc913
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/api/AbstractCommand.java
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.api;
+
+import jug.client.util.ClientNameHolder;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.codehaus.jettison.util.StringIndenter;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+public abstract class AbstractCommand {
+
+ protected String command;
+ protected String url;
+
+ protected WebClient client;
+
+ public void execute(final String cmd) {
+ final Response response = invoke(cmd);
+ if (response == null) {
+ return;
+ }
+
+ System.out.println("Status: " + response.getStatus());
+ try {
+ String json = slurp((InputStream) response.getEntity());
+ System.out.println(format(json));
+ } catch (IOException e) {
+ System.err.println("can't get output: " + e.getMessage());
+ }
+ }
+
+ protected String format(final String json) throws IOException {
+ final StringIndenter formatter = new StringIndenter(json);
+ final Writer outWriter = new StringWriter();
+ IOUtils.copy(new StringReader(formatter.result()), outWriter, 2048);
+ outWriter.close();
+ return outWriter.toString();
+ }
+
+ protected abstract Response invoke(final String cmd);
+
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ client = WebClient.create(url).accept(MediaType.APPLICATION_JSON);
+ if (ClientNameHolder.getCurrent() != null) {
+ client.query("client", ClientNameHolder.getCurrent());
+ }
+ }
+
+ public static String slurp(final InputStream from) throws IOException {
+ ByteArrayOutputStream to = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = from.read(buffer)) != -1) {
+ to.write(buffer, 0, length);
+ }
+ to.flush();
+ return new String(to.toByteArray());
+ }
+}
+
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/api/Command.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/api/Command.java
new file mode 100755
index 0000000..dde75a0
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/api/Command.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface Command {
+
+ String usage() default "";
+
+ String name() default "";
+
+ String description() default "";
+}
+
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/BestPollCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/BestPollCommand.java
new file mode 100755
index 0000000..7222976
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/BestPollCommand.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.AbstractCommand;
+import jug.client.command.api.Command;
+
+import javax.ws.rs.core.Response;
+
+@Command(name = "best", usage = "best", description = "find best poll")
+public class BestPollCommand extends AbstractCommand {
+
+ @Override
+ protected Response invoke(String cmd) {
+ return client.path("api/subject/best").get();
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/ExitCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/ExitCommand.java
new file mode 100755
index 0000000..d1ed1f0
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/ExitCommand.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.AbstractCommand;
+import jug.client.command.api.Command;
+
+import javax.ws.rs.core.Response;
+
+// just to get it in the help
+@Command(name = "exit", usage = "exit", description = "exit from the cli")
+public class ExitCommand extends AbstractCommand {
+
+ @Override
+ public void execute(String cmd) {
+ throw new UnsupportedOperationException("shouldn't be called directly");
+ }
+
+ @Override
+ protected Response invoke(String cmd) {
+ return null;
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/HelpCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/HelpCommand.java
new file mode 100755
index 0000000..9c45efc
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/HelpCommand.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.AbstractCommand;
+import jug.client.command.api.Command;
+
+import javax.ws.rs.core.Response;
+import java.util.Map;
+
+@Command(name = "help", usage = "help", description = "print this help")
+public class HelpCommand extends AbstractCommand {
+
+ private Map<String, Class<?>> commands;
+
+ @Override
+ public void execute(final String cmd) {
+ for (Map.Entry<String, Class<?>> command : commands.entrySet()) {
+ try {
+ final Class<?> clazz = command.getValue();
+ final Command annotation = clazz.getAnnotation(Command.class);
+ System.out.println(annotation.name() + ": " + annotation.description());
+ System.out.println("\tUsage: " + annotation.usage());
+ } catch (Exception e) {
+ // ignored = command not available
+ }
+ }
+ }
+
+ @Override
+ protected Response invoke(String cmd) {
+ return null;
+ }
+
+ public void setCommands(Map<String, Class<?>> commands) {
+ this.commands = commands;
+ }
+}
+
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/NewPollCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/NewPollCommand.java
new file mode 100755
index 0000000..a65bc6a
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/NewPollCommand.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.Command;
+
+@Command(name = "new-poll", usage = "new-poll [<name>, <question>]", description = "create a new poll")
+public class NewPollCommand extends QueryAndPostCommand {
+
+ @Override
+ protected String getName() {
+ return "name";
+ }
+
+ @Override
+ protected String getPath() {
+ return "api/subject/create";
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/PollResultCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/PollResultCommand.java
new file mode 100755
index 0000000..ad05774
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/PollResultCommand.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.AbstractCommand;
+import jug.client.command.api.Command;
+
+import javax.ws.rs.core.Response;
+
+import static jug.client.command.impl.PollResultCommand.RESULT_CMD;
+
+@Command(name = RESULT_CMD, usage = RESULT_CMD + " <name>", description = "result of a poll")
+public class PollResultCommand extends AbstractCommand {
+
+ public static final String RESULT_CMD = "result";
+
+ @Override
+ protected Response invoke(String cmd) {
+ if (RESULT_CMD.length() + 1 >= cmd.length()) {
+ System.err.println("please specify a poll name");
+ return null;
+ }
+
+ return client.path("api/subject/result/".concat(cmd.substring(RESULT_CMD.length() + 1))).get();
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/PollsCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/PollsCommand.java
new file mode 100755
index 0000000..8d78e6a
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/PollsCommand.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.AbstractCommand;
+import jug.client.command.api.Command;
+
+import javax.ws.rs.core.Response;
+
+@Command(name = "polls", usage = "polls", description = "list polls")
+public class PollsCommand extends AbstractCommand {
+
+ @Override
+ public Response invoke(final String cmd) {
+ return client.path("api/subject/list").get();
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/QueryAndPostCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/QueryAndPostCommand.java
new file mode 100755
index 0000000..8af0a3f
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/QueryAndPostCommand.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.AbstractCommand;
+import jug.client.command.api.Command;
+
+import javax.ws.rs.core.Response;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public abstract class QueryAndPostCommand extends AbstractCommand {
+
+ private static final Pattern PATTERN = Pattern.compile(" \\[(.*),(.*)\\]");
+
+ @Override
+ protected Response invoke(final String cmd) {
+ final Matcher matcher = PATTERN.matcher(cmd.substring(getClass().getAnnotation(Command.class).name().length()));
+ if (!matcher.matches() || matcher.groupCount() != 2) {
+ System.err.println("'" + cmd + "' doesn't match command usage");
+ return null;
+ }
+
+ return client.path(getPath()).query(getName(), matcher.group(1).trim()).post(prePost(matcher.group(2).trim()));
+ }
+
+ protected String prePost(final String post) {
+ return post;
+ }
+
+ protected abstract String getName();
+
+ protected abstract String getPath();
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/ShowPollCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/ShowPollCommand.java
new file mode 100755
index 0000000..5313223
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/ShowPollCommand.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.AbstractCommand;
+import jug.client.command.api.Command;
+
+import javax.ws.rs.core.Response;
+
+import static jug.client.command.impl.ShowPollCommand.SHOW_POLL_CMD;
+
+@Command(name = SHOW_POLL_CMD, usage = SHOW_POLL_CMD + " <name>", description = "show a poll")
+public class ShowPollCommand extends AbstractCommand {
+
+ public static final String SHOW_POLL_CMD = "show-poll";
+
+ @Override
+ protected Response invoke(String cmd) {
+ if (SHOW_POLL_CMD.length() + 1 >= cmd.length()) {
+ System.err.println("please specify a poll name");
+ return null;
+ }
+
+ return client.path("api/subject/find/".concat(cmd.substring(SHOW_POLL_CMD.length() + 1))).get();
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/SwitchClientCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/SwitchClientCommand.java
new file mode 100755
index 0000000..3bf715b
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/SwitchClientCommand.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.AbstractCommand;
+import jug.client.command.api.Command;
+import jug.client.util.ClientNameHolder;
+
+import javax.ws.rs.core.Response;
+import java.util.Map;
+
+@Command(name = "client", usage = "client <name>", description = "change client")
+public class SwitchClientCommand extends AbstractCommand {
+
+ private Map<String, Class<?>> commands;
+
+ @Override
+ public void execute(final String cmd) {
+ if (cmd.length() <= "client ".length()) {
+ System.err.println("please specify a client name (client1 or client2)");
+ return;
+ }
+
+ final String client = cmd.substring(7);
+ ClientNameHolder.setCurrent(client);
+ }
+
+ @Override
+ protected Response invoke(String cmd) {
+ return null;
+ }
+}
+
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/VoteCommand.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/VoteCommand.java
new file mode 100755
index 0000000..c95dfff
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/command/impl/VoteCommand.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.command.impl;
+
+import jug.client.command.api.Command;
+import jug.domain.Value;
+
+@Command(name = "vote", usage = "vote [<subject name>, +1|-1]", description = "vote for a subject")
+public class VoteCommand extends QueryAndPostCommand {
+
+ @Override
+ protected String getName() {
+ return "subject";
+ }
+
+ @Override
+ protected String getPath() {
+ return "api/subject/vote";
+ }
+
+ @Override
+ protected String prePost(final String post) {
+ if ("+1".equals(post) || "like".equals(post)) {
+ return Value.I_LIKE.name();
+ }
+ if ("-1".equals(post)) {
+ return Value.I_DONT_LIKE.name();
+ }
+ throw new IllegalArgumentException("please use +1 or -1 and not '" + post + "'");
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/util/ClientNameHolder.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/util/ClientNameHolder.java
new file mode 100755
index 0000000..da5f425
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/util/ClientNameHolder.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.util;
+
+public class ClientNameHolder {
+
+ private static String current = null;
+
+ public static String getCurrent() {
+ return current;
+ }
+
+ public static void setCurrent(String current) {
+ ClientNameHolder.current = current;
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/util/CommandManager.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/util/CommandManager.java
new file mode 100755
index 0000000..65141ee
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/util/CommandManager.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.util;
+
+import jug.client.command.api.Command;
+import org.apache.xbean.finder.Annotated;
+import org.apache.xbean.finder.AnnotationFinder;
+import org.apache.xbean.finder.IAnnotationFinder;
+import org.apache.xbean.finder.UrlSet;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class CommandManager {
+
+ private static final Logger LOGGER = Logger.getLogger(CommandManager.class.getName());
+ private static final Map<String, Class<?>> COMMANDS = new TreeMap<String, Class<?>>();
+
+ static {
+ final ClassLoader loader = CommandManager.class.getClassLoader();
+ try {
+ UrlSet urlSet = new UrlSet(loader);
+ urlSet = urlSet.exclude(loader);
+ urlSet = urlSet.include(CommandManager.class.getProtectionDomain().getCodeSource().getLocation());
+
+ final IAnnotationFinder finder = new AnnotationFinder(new ConfigurableClasspathArchive(loader, urlSet.getUrls()));
+ for (Annotated<Class<?>> cmd : finder.findMetaAnnotatedClasses(Command.class)) {
+ try {
+ final Command annotation = cmd.getAnnotation(Command.class);
+ final String key = annotation.name();
+ if (!COMMANDS.containsKey(key)) {
+ COMMANDS.put(key, cmd.get());
+ } else {
+ LOGGER.warning("command " + key + " already exists, this one will be ignored ( " + annotation.description() + ")");
+ }
+ } catch (Exception e) {
+ // command ignored
+ }
+ }
+ } catch (RuntimeException e) {
+ LOGGER.log(Level.SEVERE, "an error occured while getting commands", e);
+ } catch (IOException e) {
+ LOGGER.log(Level.SEVERE, "an error occured while getting commands", e);
+ }
+ }
+
+ public static Map<String, Class<?>> getCommands() {
+ return COMMANDS;
+ }
+
+ public static int size() {
+ return COMMANDS.size();
+ }
+
+ public static Set<String> keys() {
+ return COMMANDS.keySet();
+ }
+}
diff --git a/content/examples/polling-parent/polling-client/src/main/java/jug/client/util/ConfigurableClasspathArchive.java b/content/examples/polling-parent/polling-client/src/main/java/jug/client/util/ConfigurableClasspathArchive.java
new file mode 100755
index 0000000..fb9b090
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/java/jug/client/util/ConfigurableClasspathArchive.java
@@ -0,0 +1,196 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.client.util;
+
+import org.apache.xbean.finder.archive.Archive;
+import org.apache.xbean.finder.archive.ClassesArchive;
+import org.apache.xbean.finder.archive.ClasspathArchive;
+import org.apache.xbean.finder.archive.CompositeArchive;
+import org.apache.xbean.finder.archive.FilteredArchive;
+import org.apache.xbean.finder.filter.Filter;
+import org.apache.xbean.finder.filter.FilterList;
+import org.apache.xbean.finder.filter.PackageFilter;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class ConfigurableClasspathArchive extends CompositeArchive {
+
+ private static final SAXParserFactory SAX_FACTORY = SAXParserFactory.newInstance();
+ private static final String SCAN_XML = "META-INF/scan.xml";
+
+ public ConfigurableClasspathArchive(final ClassLoader loader, final Iterable<URL> urls) {
+ super(archive(loader, urls, true));
+ }
+
+ public static List<Archive> archive(final ClassLoader loader, final Iterable<URL> urls, boolean forceDescriptor) {
+ final List<Archive> archives = new ArrayList<Archive>();
+ for (URL location : urls) {
+ try {
+ archives.add(archive(loader, location, true));
+ } catch (Exception e) {
+ // ignored
+ }
+ }
+ return archives;
+ }
+
+ public static Archive archive(final ClassLoader loader, final URL location, boolean forceDescriptor) {
+ try {
+ URL scanXml = loader.getResource(SCAN_XML);
+ if (scanXml == null && !forceDescriptor) {
+ return ClasspathArchive.archive(loader, location);
+ } else if (scanXml == null) {
+ return new ClassesArchive();
+ }
+
+ // read descriptors
+ ScanHandler scan;
+ if (scanXml != null) {
+ scan = read(scanXml);
+ } else {
+ scan = new ScanHandler();
+ }
+
+ final Archive packageArchive = packageArchive(scan.getPackages(), loader, location);
+ final Archive classesArchive = classesArchive(scan.getPackages(), scan.getClasses(), loader);
+
+ if (packageArchive != null && classesArchive != null) {
+ return new CompositeArchive(classesArchive, packageArchive);
+ } else if (packageArchive != null) {
+ return packageArchive;
+ }
+ return classesArchive;
+ } catch (IOException e) {
+ if (forceDescriptor) {
+ return new ClassesArchive();
+ }
+ return ClasspathArchive.archive(loader, location);
+ }
+ }
+
+ public static Archive packageArchive(final Set<String> packageNames, final ClassLoader loader, final URL url) {
+ if (!packageNames.isEmpty()) {
+ return new FilteredArchive(ClasspathArchive.archive(loader, url), filters(packageNames));
+ }
+ return null;
+ }
+
+ private static Filter filters(final Set<String> packageNames) {
+ final List<Filter> filters = new ArrayList<Filter>();
+ for (String packageName : packageNames) {
+ filters.add(new PackageFilter(packageName));
+ }
+ return new FilterList(filters);
+ }
+
+ public static Archive classesArchive(final Set<String> packages, final Set<String> classnames, final ClassLoader loader) {
+ Class<?>[] classes = new Class<?>[classnames.size()];
+ int i = 0;
+ for (String clazz : classnames) {
+ // skip classes managed by package filtering
+ if (packages != null && clazzInPackage(packages, clazz)) {
+ continue;
+ }
+
+ try {
+ classes[i++] = loader.loadClass(clazz);
+ } catch (ClassNotFoundException e) {
+ // ignored
+ }
+ }
+
+ if (i != classes.length) { // shouldn't occur
+ final Class<?>[] updatedClasses = new Class<?>[i];
+ System.arraycopy(classes, 0, updatedClasses, 0, i);
+ classes = updatedClasses;
+ }
+
+ return new ClassesArchive(classes);
+ }
+
+ private static boolean clazzInPackage(final Collection<String> packagename, final String clazz) {
+ for (String str : packagename) {
+ if (clazz.startsWith(str)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static ScanHandler read(final URL scanXml) throws IOException {
+ final SAXParser parser;
+ try {
+ synchronized (SAX_FACTORY) {
+ parser = SAX_FACTORY.newSAXParser();
+ }
+ final ScanHandler handler = new ScanHandler();
+ parser.parse(new BufferedInputStream(scanXml.openStream()), handler);
+ return handler;
+ } catch (Exception e) {
+ throw new IOException("can't parse " + scanXml.toExternalForm());
+ }
+ }
+
+ public static final class ScanHandler extends DefaultHandler {
+
+ private final Set<String> classes = new HashSet<String>();
+ private final Set<String> packages = new HashSet<String>();
+ private Set<String> current = null;
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ if (qName.equals("class")) {
+ current = classes;
+ } else if (qName.equals("package")) {
+ current = packages;
+ }
+ }
+
+ @Override
+ public void characters(char ch[], int start, int length) throws SAXException {
+ if (current != null) {
+ current.add(new String(ch, start, length));
+ }
+ }
+
+ @Override
+ public void endElement(final String uri, final String localName, final String qName) throws SAXException {
+ current = null;
+ }
+
+ public Set<String> getPackages() {
+ return packages;
+ }
+
+ public Set<String> getClasses() {
+ return classes;
+ }
+ }
+}
+
diff --git a/content/examples/polling-parent/polling-client/src/main/resources/META-INF/scan.xml b/content/examples/polling-parent/polling-client/src/main/resources/META-INF/scan.xml
new file mode 100755
index 0000000..b8f4988
--- /dev/null
+++ b/content/examples/polling-parent/polling-client/src/main/resources/META-INF/scan.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<scan>
+ <packages>
+ <package>jug.client.command</package>
+ </packages>
+</scan>
diff --git a/content/examples/polling-parent/polling-core/pom.xml b/content/examples/polling-parent/polling-core/pom.xml
new file mode 100755
index 0000000..7dacb98
--- /dev/null
+++ b/content/examples/polling-parent/polling-core/pom.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>polling-parent</artifactId>
+ <groupId>jug</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>polling-core</artifactId>
+ <name>OpenEJB :: Examples :: Polling :: Core</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>polling-domain</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/content/examples/polling-parent/polling-core/src/main/java/jug/dao/SubjectDao.java b/content/examples/polling-parent/polling-core/src/main/java/jug/dao/SubjectDao.java
new file mode 100755
index 0000000..2fb6fcb
--- /dev/null
+++ b/content/examples/polling-parent/polling-core/src/main/java/jug/dao/SubjectDao.java
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.dao;
+
+import jug.domain.Subject;
+import jug.domain.Value;
+import jug.domain.Vote;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.util.Collection;
+
+@Singleton
+@Lock(LockType.READ)
+public class SubjectDao {
+
+ @PersistenceContext(unitName = "polling")
+ private EntityManager em;
+
+ @Inject
+ private ReadSubjectDao readDao;
+
+ public Subject create(final String name, final String question) {
+ final Subject subject = new Subject();
+ subject.setName(name);
+ subject.setQuestion(question);
+
+ em.persist(subject);
+ return subject;
+ }
+
+ public Subject addVote(final Subject subject, final Vote vote) {
+ final Vote foundVote = retrieve(vote, Vote.class, vote.getId());
+ final Subject subjectToUpdate = retrieve(subject, Subject.class, subject.getId());
+
+ subjectToUpdate.getVotes().add(foundVote);
+ return subjectToUpdate;
+ }
+
+ public Subject findByName(final String name) {
+ return readDao.findByName(name);
+ }
+
+ public Collection<Subject> findAll() {
+ return readDao.findAll();
+ }
+
+ public int subjectLikeVoteNumber(final String subjectName) {
+ return subjectVoteNumber(subjectName, Value.I_LIKE);
+ }
+
+ public int subjectNotLikeVoteNumber(final String subjectName) {
+ return subjectVoteNumber(subjectName, Value.I_DONT_LIKE);
+ }
+
+ private int subjectVoteNumber(final String subjectName, final Value value) {
+ return em.createNamedQuery(Subject.COUNT_VOTE, Number.class)
+ .setParameter("name", subjectName)
+ .setParameter("value", value)
+ .getSingleResult().intValue();
+ }
+
+ private <T> T retrieve(final T object, final Class<T> clazz, long id) {
+ if (em.contains(object)) {
+ return object;
+ }
+
+ final T t = em.find(clazz, id);
+ if (t == null) {
+ throw new IllegalArgumentException(clazz.getSimpleName() + " not found");
+ }
+ return t;
+ }
+
+ public Subject bestSubject() {
+ int bestScore = 0;
+ Subject best = null;
+ for (Subject subject : findAll()) {
+ int currentScore = subject.score();
+ if (best == null || bestScore < currentScore) {
+ bestScore = currentScore;
+ best = subject;
+ }
+ }
+ return best;
+ }
+
+ @Singleton
+ @Lock(LockType.READ)
+ @PersistenceContext(name = "polling")
+ public static interface ReadSubjectDao {
+
+ Subject findByName(final String name);
+
+ Collection<Subject> findAll();
+ }
+}
diff --git a/content/examples/polling-parent/polling-core/src/main/java/jug/dao/VoteDao.java b/content/examples/polling-parent/polling-core/src/main/java/jug/dao/VoteDao.java
new file mode 100755
index 0000000..40ca37d
--- /dev/null
+++ b/content/examples/polling-parent/polling-core/src/main/java/jug/dao/VoteDao.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.dao;
+
+import jug.domain.Value;
+import jug.domain.Vote;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Singleton
+@Lock(LockType.READ)
+public class VoteDao {
+
+ @PersistenceContext(unitName = "polling")
+ private EntityManager em;
+
+ public Vote create(final Value voteValue) {
+ final Vote vote = new Vote();
+ vote.setValue(voteValue);
+
+ em.persist(vote);
+ return vote;
+ }
+}
diff --git a/content/examples/polling-parent/polling-core/src/main/resources/META-INF/beans.xml b/content/examples/polling-parent/polling-core/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/polling-parent/polling-core/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/polling-parent/polling-core/src/test/java/jug/dao/SubjectDaoTest.java b/content/examples/polling-parent/polling-core/src/test/java/jug/dao/SubjectDaoTest.java
new file mode 100755
index 0000000..74ef984
--- /dev/null
+++ b/content/examples/polling-parent/polling-core/src/test/java/jug/dao/SubjectDaoTest.java
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.dao;
+
+import jug.domain.Subject;
+import jug.domain.Value;
+import jug.domain.Vote;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.NamingException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class SubjectDaoTest {
+
+ private static EJBContainer container;
+
+ @Inject
+ private SubjectDao subjectDao;
+
+ @Inject
+ private VoteDao voteDao;
+
+ @BeforeClass
+ public static void start() {
+ container = EJBContainer.createEJBContainer();
+ }
+
+ @Before
+ public void inject() throws NamingException {
+ container.getContext().bind("inject", this);
+ }
+
+ @AfterClass
+ public static void stop() {
+ container.close();
+ }
+
+ @Test
+ public void persistSimpleSubject() {
+ final Subject subject = subjectDao.create("TOMEE_JUG", "What do you think about this JUG?");
+ assertNotNull(subject);
+ assertEquals("TOMEE_JUG", subject.getName());
+ }
+
+ @Test
+ public void playWithVotes() {
+ Subject subject = subjectDao.create("TOMEE_JUG_2", "What do you think about this JUG?");
+
+ final Vote vote = voteDao.create(Value.I_LIKE);
+ subject = subjectDao.addVote(subject, vote);
+ assertEquals(1, subject.getVotes().size());
+
+ final Vote moreVote = voteDao.create(Value.I_LIKE);
+ subject = subjectDao.addVote(subject, moreVote);
+ assertEquals(2, subject.getVotes().size());
+
+ final Vote notLiked = voteDao.create(Value.I_DONT_LIKE);
+ subject = subjectDao.addVote(subject, notLiked);
+ assertEquals(3, subject.getVotes().size());
+
+ final Subject retrievedSubject = subjectDao.findByName("TOMEE_JUG_2");
+ assertNotNull(retrievedSubject);
+ assertNotNull(retrievedSubject.getVotes());
+ assertEquals(3, retrievedSubject.getVotes().size());
+ }
+
+ @Test
+ public void voteNumber() {
+ final Subject subject = subjectDao.create("TOMEE_JUG_3", "What do you think about this JUG?");
+
+ subjectDao.addVote(subject, voteDao.create(Value.I_LIKE));
+ subjectDao.addVote(subject, voteDao.create(Value.I_LIKE));
+ subjectDao.addVote(subject, voteDao.create(Value.I_DONT_LIKE));
+
+ assertEquals(2, subjectDao.subjectLikeVoteNumber("TOMEE_JUG_3"));
+ assertEquals(1, subjectDao.subjectNotLikeVoteNumber("TOMEE_JUG_3"));
+ }
+}
diff --git a/content/examples/polling-parent/polling-core/src/test/resources/META-INF/beans.xml b/content/examples/polling-parent/polling-core/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/polling-parent/polling-core/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/polling-parent/polling-domain/pom.xml b/content/examples/polling-parent/polling-domain/pom.xml
new file mode 100755
index 0000000..c13f5ba
--- /dev/null
+++ b/content/examples/polling-parent/polling-domain/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>polling-parent</artifactId>
+ <groupId>jug</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>polling-domain</artifactId>
+ <name>OpenEJB :: Examples :: Polling :: Domain</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>2.3.0</version>
+ <configuration>
+ <includes>jug/domain/*.class</includes>
+ <addDefaultConstructor>true</addDefaultConstructor>
+ <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+ </configuration>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb.patch</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.4.0-nonfinal-1598334</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Result.java b/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Result.java
new file mode 100755
index 0000000..7d52fd1
--- /dev/null
+++ b/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Result.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.domain;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement
+@XmlType(propOrder = {
+ "likes",
+ "unlikes",
+ "sum"
+})
+public class Result {
+
+ private int likes;
+ private int unlikes;
+ private int sum;
+
+ public Result() {
+ // no-op
+ }
+
+ public Result(int likes, int unlikes) {
+ this.likes = likes;
+ this.unlikes = -Math.abs(unlikes);
+ sum = likes + unlikes;
+ }
+
+ public int getLikes() {
+ return likes;
+ }
+
+ public void setLikes(int likes) {
+ this.likes = likes;
+ }
+
+ public int getUnlikes() {
+ return unlikes;
+ }
+
+ public void setUnlikes(int unlikes) {
+ this.unlikes = unlikes;
+ }
+
+ public int getSum() {
+ return sum;
+ }
+
+ public void setSum(int sum) {
+ this.sum = sum;
+ }
+}
diff --git a/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Subject.java b/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Subject.java
new file mode 100755
index 0000000..dfe41ca
--- /dev/null
+++ b/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Subject.java
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.domain;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.Collection;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = Subject.FIND_ALL, query = "select s from Subject s"),
+ @NamedQuery(name = Subject.FIND_BY_NAME_QUERY, query = "select s from Subject s where s.name = :name"),
+ @NamedQuery(name = Subject.COUNT_VOTE, query = "select count(s) from Subject s left join s.votes v where v.value = :value and :name = s.name")
+ })
+@XmlRootElement
+public class Subject {
+
+ public static final String FIND_BY_NAME_QUERY = "Subject.findByName";
+ public static final String COUNT_VOTE = "Subject.countVoteNumber";
+ public static final String FIND_ALL = "Subject.findAll";
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String name;
+
+ private String question;
+
+ @OneToMany(fetch = FetchType.EAGER)
+ private Collection<Vote> votes = new ArrayList<Vote>();
+
+ public Subject() {
+ // no-op
+ }
+
+ public Subject(String name, String question) {
+ this.name = name;
+ this.question = question;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getQuestion() {
+ return question;
+ }
+
+ public void setQuestion(String question) {
+ this.question = question;
+ }
+
+ public Collection<Vote> getVotes() {
+ return votes;
+ }
+
+ public void setVotes(Collection<Vote> votes) {
+ this.votes = votes;
+ }
+
+ public int score() {
+ int s = 0;
+ for (Vote vote : votes) {
+ if (vote.getValue().equals(Value.I_LIKE)) {
+ s++;
+ } else {
+ s--;
+ }
+ }
+ return s;
+ }
+}
diff --git a/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Value.java b/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Value.java
new file mode 100755
index 0000000..518142a
--- /dev/null
+++ b/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Value.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.domain;
+
+public enum Value {
+ I_LIKE,
+ I_DONT_LIKE;
+}
diff --git a/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Vote.java b/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Vote.java
new file mode 100755
index 0000000..605f66d
--- /dev/null
+++ b/content/examples/polling-parent/polling-domain/src/main/java/jug/domain/Vote.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.domain;
+
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@XmlRootElement
+public class Vote {
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+ @Enumerated(EnumType.STRING)
+ private Value value;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Value getValue() {
+ return value;
+ }
+
+ public void setValue(Value value) {
+ this.value = value;
+ }
+}
diff --git a/content/examples/polling-parent/polling-domain/src/main/resources/META-INF/persistence.xml b/content/examples/polling-parent/polling-domain/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..e75dc36
--- /dev/null
+++ b/content/examples/polling-parent/polling-domain/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <!-- proxy datasource (the only one really used) -->
+ <persistence-unit name="polling">
+ <jta-data-source>jdbc/polling</jta-data-source>
+ <class>jug.domain.Subject</class>
+ <class>jug.domain.Vote</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ <property name="openjpa.ManagedRuntime" value="jndi(TransactionManagerName=java:comp/TransactionManager)"/>
+ </properties>
+ </persistence-unit>
+
+ <!-- real multiple clients - here JPA is only used to create datasources -->
+ <!-- often not needed in production -->
+ <persistence-unit name="client1">
+ <jta-data-source>jdbc/client1</jta-data-source>
+ <non-jta-data-source>jdbc/client1-non-jta</non-jta-data-source>
+ <class>jug.domain.Subject</class>
+ <class>jug.domain.Vote</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ <persistence-unit name="client2">
+ <jta-data-source>jdbc/client2</jta-data-source>
+ <non-jta-data-source>jdbc/client2-non-jta</non-jta-data-source>
+ <class>jug.domain.Subject</class>
+ <class>jug.domain.Vote</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/polling-parent/polling-web/pom.xml b/content/examples/polling-parent/polling-web/pom.xml
new file mode 100755
index 0000000..2e1e1e8
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/pom.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>polling-parent</artifactId>
+ <groupId>jug</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>polling-web</artifactId>
+ <name>OpenEJB :: Examples :: Polling :: Web</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-embedded</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-webservices</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>polling-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>${version.tomee}</version>
+ <configuration>
+ <tomeeClassifier>jaxrs</tomeeClassifier>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/content/examples/polling-parent/polling-web/src/main/java/jug/monitoring/VoteCounter.java b/content/examples/polling-parent/polling-web/src/main/java/jug/monitoring/VoteCounter.java
new file mode 100755
index 0000000..1883d92
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/java/jug/monitoring/VoteCounter.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.monitoring;
+
+import jug.domain.Subject;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.management.Description;
+import javax.management.MBean;
+import javax.management.ManagedAttribute;
+import javax.management.ManagedOperation;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@MBean
+@ApplicationScoped
+@Description("count the number of vote by subject")
+public class VoteCounter {
+
+ private final Map<String, Subject> subjects = new ConcurrentHashMap<String, Subject>();
+
+ @ManagedAttribute
+ @Description("number of poll created/updated in this instance")
+ public int getSubjectNumber() {
+ return subjects.size();
+ }
+
+ @ManagedOperation
+ @Description("current score of the specified poll")
+ public String names() {
+ return subjects.keySet().toString();
+ }
+
+ @ManagedOperation
+ @Description("current score of the specified poll")
+ public String score(final String name) {
+ if (subjects.containsKey(name)) {
+ return Integer.toString(subjects.get(name).score());
+ }
+ return "poll not found";
+ }
+
+ public void putSubject(final Subject subject) {
+ subjects.put(subject.getName(), subject);
+ }
+}
diff --git a/content/examples/polling-parent/polling-web/src/main/java/jug/rest/PollingApplication.java b/content/examples/polling-parent/polling-web/src/main/java/jug/rest/PollingApplication.java
new file mode 100755
index 0000000..b9501c7
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/java/jug/rest/PollingApplication.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.rest;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import java.util.HashSet;
+import java.util.Set;
+
+@ApplicationPath("/api")
+public class PollingApplication extends Application {
+
+ public Set<Class<?>> getClasses() {
+ final Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(SubjectService.class);
+ return classes;
+ }
+}
diff --git a/content/examples/polling-parent/polling-web/src/main/java/jug/rest/SubjectService.java b/content/examples/polling-parent/polling-web/src/main/java/jug/rest/SubjectService.java
new file mode 100755
index 0000000..b4cf18d
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/java/jug/rest/SubjectService.java
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.rest;
+
+import jug.dao.SubjectDao;
+import jug.dao.VoteDao;
+import jug.domain.Result;
+import jug.domain.Subject;
+import jug.domain.Value;
+import jug.domain.Vote;
+import jug.monitoring.VoteCounter;
+
+import javax.annotation.Resource;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import java.util.Collection;
+import java.util.List;
+
+@Path("subject")
+@Singleton // an ejb just to be able to test in standalone
+@Lock(LockType.READ)
+@TransactionAttribute(TransactionAttributeType.SUPPORTS)
+@Produces({MediaType.APPLICATION_JSON})
+public class SubjectService {
+
+ @Inject
+ private SubjectDao dao;
+
+ @Inject
+ private VoteDao voteDao;
+
+ @Inject
+ private VoteCounter counter;
+
+ @Resource(name = "poll.blacklist")
+ private List<String> blackList;
+
+ @POST
+ @Path("create")
+ public Subject create(final String question, @QueryParam("name") final String name) {
+ if (blackList.contains(name)) {
+ throw new IllegalArgumentException("name blacklisted");
+ }
+
+ final Subject subject = dao.create(name, question);
+
+ counter.putSubject(subject);
+
+ return subject;
+ }
+
+ @GET
+ @Path("list")
+ public Collection<Subject> list() {
+ return dao.findAll();
+ }
+
+ @GET
+ @Path("find/{name}")
+ public Subject findByName(@PathParam("name") final String name) {
+ return dao.findByName(name);
+ }
+
+ @GET
+ @Path("best")
+ public Subject best() {
+ return dao.bestSubject();
+ }
+
+ @GET
+ @Path("result/{name}")
+ public Result result(@PathParam("name") final String name) {
+ return new Result(dao.subjectLikeVoteNumber(name), -dao.subjectNotLikeVoteNumber(name));
+ }
+
+ @POST
+ @Path("vote")
+ public Vote vote(final String input, @QueryParam("subject") final String subjectName) {
+ final Vote vote = voteDao.create(Value.valueOf(input));
+ final Subject subject = dao.findByName(subjectName);
+ dao.addVote(subject, vote);
+
+ counter.putSubject(subject); // update
+
+ return vote;
+ }
+}
diff --git a/content/examples/polling-parent/polling-web/src/main/java/jug/routing/DataSourceInitializer.java b/content/examples/polling-parent/polling-web/src/main/java/jug/routing/DataSourceInitializer.java
new file mode 100755
index 0000000..f734b02
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/java/jug/routing/DataSourceInitializer.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.routing;
+
+import jug.domain.Subject;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+// hack for OpenJPA
+// it initializes lazily datasource (buildSchema) so simply call it here
+// for hibernate it works without this hack
+@ApplicationScoped
+public class DataSourceInitializer {
+
+ @PersistenceContext(unitName = "client1")
+ private EntityManager client1;
+
+ @PersistenceContext(unitName = "client2")
+ private EntityManager client2;
+
+ private boolean invoked = false;
+
+ public void init() {
+ if (invoked) {
+ return;
+ }
+
+ client1.find(Subject.class, 0);
+ client2.find(Subject.class, 0);
+ invoked = true;
+ }
+}
diff --git a/content/examples/polling-parent/polling-web/src/main/java/jug/routing/PollingRouter.java b/content/examples/polling-parent/polling-web/src/main/java/jug/routing/PollingRouter.java
new file mode 100755
index 0000000..4589034
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/java/jug/routing/PollingRouter.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.routing;
+
+import org.apache.openejb.resource.jdbc.router.AbstractRouter;
+
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class PollingRouter extends AbstractRouter {
+
+ private Map<String, DataSource> dataSources = null;
+ private ThreadLocal<DataSource> currentDataSource = new ThreadLocal<DataSource>() {
+ @Override
+ public DataSource initialValue() {
+ return dataSources.get("jdbc/client1");
+ }
+ };
+
+ @Override
+ public DataSource getDataSource() {
+ if (dataSources == null) {
+ init();
+ }
+ return currentDataSource.get();
+ }
+
+ public void setDataSource(final String client) {
+ if (dataSources == null) {
+ init();
+ }
+
+ final String datasourceName = "jdbc/" + client;
+ if (!dataSources.containsKey(datasourceName)) {
+ throw new IllegalArgumentException("data source called " + datasourceName + " can't be found.");
+ }
+ final DataSource ds = dataSources.get(datasourceName);
+ currentDataSource.set(ds);
+ }
+
+ private synchronized void init() {
+ if (dataSources != null) {
+ return;
+ }
+
+ dataSources = new HashMap<String, DataSource>();
+ for (String ds : Arrays.asList("jdbc/client1", "jdbc/client2")) {
+ try {
+ final Object o = getOpenEJBResource(ds);
+ if (o instanceof DataSource) {
+ dataSources.put(ds, DataSource.class.cast(o));
+ }
+ } catch (NamingException e) {
+ // ignored
+ }
+ }
+ }
+
+ public void clear() {
+ currentDataSource.remove();
+ }
+}
diff --git a/content/examples/polling-parent/polling-web/src/main/java/jug/routing/RoutingFilter.java b/content/examples/polling-parent/polling-web/src/main/java/jug/routing/RoutingFilter.java
new file mode 100755
index 0000000..a503f38
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/java/jug/routing/RoutingFilter.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.routing;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Logger;
+
+@WebFilter(displayName = "routing-filter", urlPatterns = {"/*"})
+public class RoutingFilter implements Filter {
+
+ private static final Logger LOGGER = Logger.getLogger(RoutingFilter.class.getName());
+ private static final AtomicInteger COUNTER = new AtomicInteger();
+
+ @Resource(name = "ClientRouter", type = PollingRouter.class)
+ private PollingRouter router;
+
+ @Inject
+ private DataSourceInitializer init;
+
+ @Override
+ public void init(final FilterConfig filterConfig) throws ServletException {
+ init.init();
+ }
+
+ @Override
+ public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
+ String client = servletRequest.getParameter("client");
+ if (client == null) {
+ client = getRandomClient();
+ }
+ LOGGER.info("using client " + client);
+ router.setDataSource(client);
+ try {
+ filterChain.doFilter(servletRequest, servletResponse);
+ } finally {
+ router.clear();
+ }
+ }
+
+ private String getRandomClient() {
+ return "client" + (1 + COUNTER.getAndIncrement() % 2); // 2 clients
+ }
+
+ @Override
+ public void destroy() {
+ // no-op
+ }
+}
diff --git a/content/examples/polling-parent/polling-web/src/main/resources/META-INF/beans.xml b/content/examples/polling-parent/polling-web/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..a5d6323
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<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"/>
diff --git a/content/examples/polling-parent/polling-web/src/main/resources/META-INF/env-entries.properties b/content/examples/polling-parent/polling-web/src/main/resources/META-INF/env-entries.properties
new file mode 100755
index 0000000..7508ffd
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/resources/META-INF/env-entries.properties
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+poll.blacklist=test
diff --git a/content/examples/polling-parent/polling-web/src/main/resources/META-INF/jug.polling/service-jar.xml b/content/examples/polling-parent/polling-web/src/main/resources/META-INF/jug.polling/service-jar.xml
new file mode 100755
index 0000000..ed26a64
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/resources/META-INF/jug.polling/service-jar.xml
@@ -0,0 +1,23 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ServiceJar>
+ <!-- can also be done in tomee.xml with <Resource id="PollingRouter" class-name="jug.routing.PollingRouter" /> -->
+ <ServiceProvider id="PollingRouter"
+ service="Resource" type="org.apache.openejb.resource.jdbc.Router"
+ class-name="jug.routing.PollingRouter"/>
+</ServiceJar>
diff --git a/content/examples/polling-parent/polling-web/src/main/resources/META-INF/resources.xml b/content/examples/polling-parent/polling-web/src/main/resources/META-INF/resources.xml
new file mode 100755
index 0000000..670b761
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/resources/META-INF/resources.xml
@@ -0,0 +1,67 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <!-- router -->
+ <Resource id="ClientRouter" type="jug.routing.PollingRouter" provider="jug.polling:PollingRouter"/>
+
+ <!-- routed datasources -->
+ <Resource id="jdbc/polling" provider="RoutedDataSource" type="javax.sql.DataSource">
+ Router = ClientRouter
+ </Resource>
+
+ <!-- real datasources -->
+ <Resource id="jdbc/client1" type="javax.sql.DataSource">
+ JdbcDriver org.hsqldb.jdbcDriver
+ JdbcUrl jdbc:hsqldb:mem:client1
+ UserName sa
+ Password
+ JtaManaged true
+ </Resource>
+
+ <Resource id="jdbc/client1-non-jta" type="javax.sql.DataSource">
+ JdbcDriver org.hsqldb.jdbcDriver
+ JdbcUrl jdbc:hsqldb:mem:client1
+ UserName sa
+ Password
+ JtaManaged false
+ </Resource>
+
+ <Resource id="jdbc/client2" type="javax.sql.DataSource">
+ JdbcDriver org.hsqldb.jdbcDriver
+ JdbcUrl jdbc:hsqldb:mem:client2
+ UserName sa
+ Password
+ JtaManaged true
+ </Resource>
+
+ <Resource id="jdbc/client2-non-jta" type="javax.sql.DataSource">
+ JdbcDriver org.hsqldb.jdbcDriver
+ JdbcUrl jdbc:hsqldb:mem:client2
+ UserName sa
+ Password
+ JtaManaged false
+ </Resource>
+
+ <!-- for remote ejb injection
+ <Resource id="middle-server" type="org.apache.openejb.config.sys.JndiProvider">
+ java.naming.factory.initial = org.apache.openejb.client.RemoteInitialContextFactory
+ java.naming.provider.url = failover:ejb://192.168.1.20:4201,ejbd://192.168.1.30:4201
+ # java.naming.provider.url = multicast:ejb://192168120:4201?group=default
+ </Resource>
+ -->
+</resources>
diff --git a/content/examples/polling-parent/polling-web/src/main/webapp/WEB-INF/beans.xml b/content/examples/polling-parent/polling-web/src/main/webapp/WEB-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/polling-parent/polling-web/src/main/webapp/WEB-INF/env-entries.properties b/content/examples/polling-parent/polling-web/src/main/webapp/WEB-INF/env-entries.properties
new file mode 100755
index 0000000..e5c1e2e
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/main/webapp/WEB-INF/env-entries.properties
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+poll.blacklist=poll
diff --git a/content/examples/polling-parent/polling-web/src/test/java/jug/rest/SubjectServiceTest.java b/content/examples/polling-parent/polling-web/src/test/java/jug/rest/SubjectServiceTest.java
new file mode 100755
index 0000000..608fb5a
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/test/java/jug/rest/SubjectServiceTest.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.rest;
+
+import jug.routing.DataSourceInitializer;
+import jug.routing.PollingRouter;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.OpenEjbContainer;
+import org.apache.openejb.loader.IO;
+import org.apache.openejb.util.NetworkUtil;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.annotation.Resource;
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.NamingException;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+
+public class SubjectServiceTest {
+
+ private static EJBContainer container;
+ private static int port = -1;
+
+ @Inject
+ private DataSourceInitializer init;
+
+ @Resource(name = "ClientRouter", type = PollingRouter.class)
+ private PollingRouter router;
+
+ @BeforeClass
+ public static void start() {
+ port = NetworkUtil.getNextAvailablePort();
+ final Properties properties = new Properties();
+ properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
+ properties.setProperty(EJBContainer.APP_NAME, "polling/api");
+ properties.setProperty(EJBContainer.PROVIDER, "openejb");
+ properties.setProperty("httpejbd.port", Integer.toString(port));
+ container = EJBContainer.createEJBContainer(properties);
+ }
+
+ @Before
+ public void inject() throws NamingException {
+ container.getContext().bind("inject", this);
+ init.init();
+ }
+
+ @AfterClass
+ public static void stop() {
+ container.close();
+ }
+
+ @Test
+ public void createVote() throws IOException {
+ final Response response = WebClient.create("http://localhost:" + port + "/polling/")
+ .path("api/subject/create")
+ .accept("application/json")
+ .query("name", "TOMEE_JUG_JSON")
+ .post("was it cool?");
+ final String output = IO.slurp((InputStream) response.getEntity());
+ assertTrue("output doesn't contain TOMEE_JUG_JSON '" + output + "'", output.contains("TOMEE_JUG_JSON"));
+ }
+}
diff --git a/content/examples/polling-parent/polling-web/src/test/java/jug/rest/arquillian/SubjectServiceTomEETest.java b/content/examples/polling-parent/polling-web/src/test/java/jug/rest/arquillian/SubjectServiceTomEETest.java
new file mode 100755
index 0000000..27ce3c2
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/test/java/jug/rest/arquillian/SubjectServiceTomEETest.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jug.rest.arquillian;
+
+import jug.dao.SubjectDao;
+import jug.domain.Subject;
+import jug.monitoring.VoteCounter;
+import jug.rest.SubjectService;
+import jug.routing.PollingRouter;
+import org.apache.commons.io.IOUtils;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.ziplock.JarLocation;
+import org.apache.ziplock.WebModule;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.RunAsClient;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.BufferedInputStream;
+import java.net.URL;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@RunAsClient
+@RunWith(Arquillian.class)
+public class SubjectServiceTomEETest {
+
+ @ArquillianResource
+ private URL url;
+
+ @Deployment
+ public static WebArchive archive() {
+ return new WebModule(SubjectServiceTomEETest.class).getArchive()
+ .addClass(VoteCounter.class)
+ .addPackage(Subject.class.getPackage()) // domain
+ .addAsWebInfResource(new ClassLoaderAsset("META-INF/persistence.xml"), "persistence.xml")
+ .addAsWebInfResource(new ClassLoaderAsset("META-INF/env-entries.properties"), "env-entries.properties")
+ .addAsWebInfResource(new ClassLoaderAsset("META-INF/resources.xml"), "resources.xml")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
+ .addPackage(PollingRouter.class.getPackage()) // core
+ .addPackage(SubjectDao.class.getPackage()) // core
+ .addPackage(SubjectService.class.getPackage()) // front
+ .addAsLibrary(JarLocation.jarLocation(IOUtils.class)) // helper for client test
+ .addAsLibrary(JarLocation.jarLocation(Test.class)); // junit
+ }
+
+ @Test
+ public void checkThereIsSomeOutput() throws Exception {
+ final String base = url.toExternalForm();
+ WebClient.create(base)
+ .path("api/subject/create")
+ .accept("application/json")
+ .query("name", "SubjectServiceTomEETest")
+ .post("SubjectServiceTomEETest");
+ for (int i = 0; i < 2; i++) { // we have a dynamic datasource so let it round
+ final URL url = new URL(base + "api/subject/list");
+ final String output = IOUtils.toString(new BufferedInputStream(url.openStream()));
+ if (output.contains("SubjectServiceTomEETest")) {
+ return;
+ }
+ }
+ fail("created entry not found");
+ }
+}
diff --git a/content/examples/polling-parent/polling-web/src/test/resources/arquillian.xml b/content/examples/polling-parent/polling-web/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..1f3d6f9
--- /dev/null
+++ b/content/examples/polling-parent/polling-web/src/test/resources/arquillian.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+ <container qualifier="tomee" default="true">
+ <configuration> <!-- random ports -->
+ <property name="httpPort">-1</property>
+ <property name="stopPort">-1</property>
+ </configuration>
+ </container>
+</arquillian>
diff --git a/content/examples/polling-parent/pom.xml b/content/examples/polling-parent/pom.xml
new file mode 100755
index 0000000..48f7e8e
--- /dev/null
+++ b/content/examples/polling-parent/pom.xml
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>jug</groupId>
+ <artifactId>polling-parent</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>OpenEJB :: Examples :: Polling</name>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <forkMode>always</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-plugin-snapshot</id>
+ <name>Apache Snapshot Plugin Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <modules>
+ <module>polling-domain</module>
+ <module>polling-core</module>
+ <module>polling-web</module>
+ <module>polling-client</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- API -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-api</artifactId>
+ <version>${version.openejb}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- impl - for standard code scope test is fine -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>${version.openejb}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>${version.openejb}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- test -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-embedded</artifactId>
+ <version>${version.tomee}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-webservices</artifactId>
+ <version>${version.tomee}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>${version.tomee}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.0.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- client -->
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-bundle</artifactId>
+ <version>2.6.14</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-finder-shaded</artifactId>
+ <version>${xbean.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-reflect</artifactId>
+ <version>${xbean.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>0.9.94</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.3.4</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <properties>
+ <xbean.version>3.17</xbean.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <version.tomee>1.7.1</version.tomee>
+ <version.openejb>4.7.1</version.openejb>
+ </properties>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/pom.xml b/content/examples/pom.xml
new file mode 100755
index 0000000..678adda
--- /dev/null
+++ b/content/examples/pom.xml
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!--test 2-->
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>openejb</artifactId>
+ <groupId>org.apache.openejb</groupId>
+ <version>4.7.1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>examples</artifactId>
+ <packaging>pom</packaging>
+ <name>OpenEJB :: Examples</name>
+ <modules>
+ <module>access-timeout-meta</module>
+ <module>access-timeout</module>
+ <module>alternate-descriptors</module>
+ <module>application-composer</module>
+ <module>applicationcomposer-jaxws-cdi</module>
+ <module>applicationexception</module>
+ <module>async-methods</module>
+ <module>async-postconstruct</module>
+ <module>bean-validation-design-by-contract</module>
+ <module>cdi-alternative-and-stereotypes</module>
+ <module>cdi-application-scope</module>
+ <module>cdi-basic</module>
+ <module>cdi-ejbcontext-jaas</module>
+ <module>cdi-events</module>
+ <module>cdi-interceptors</module>
+ <module>cdi-produces-disposes</module>
+ <module>cdi-produces-field</module>
+ <module>cdi-query</module>
+ <module>cdi-realm</module>
+ <module>cdi-request-scope</module>
+ <module>cdi-session-scope</module>
+ <module>change-jaxws-url</module>
+ <module>component-interfaces</module>
+ <module>client-resource-lookup-preview</module>
+ <module>cucumber-jvm</module>
+ <module>custom-injection</module>
+ <module>datasource-ciphered-password</module>
+ <module>datasource-definition</module>
+ <module>datasource-versioning</module>
+ <module>decorators</module>
+ <module>deltaspike-configproperty</module>
+ <module>deltaspike-exception-handling</module>
+ <module>deltaspike-fullstack</module>
+ <module>deltaspike-i18n</module>
+ <module>dynamic-dao-implementation</module>
+ <module>dynamic-datasource-routing</module>
+ <module>dynamic-implementation</module>
+ <module>dynamic-proxy-to-access-mbean</module>
+ <module>ear-testing</module>
+ <module>ejb-examples</module>
+ <module>ejb-webservice</module>
+ <module>groovy-cdi</module>
+ <module>groovy-jpa</module>
+ <module>groovy-spock</module>
+ <module>helloworld-weblogic</module>
+ <module>injection-of-connectionfactory</module>
+ <module>injection-of-datasource</module>
+ <module>injection-of-ejbs</module>
+ <module>injection-of-entitymanager</module>
+ <module>injection-of-env-entry</module>
+ <module>interceptors</module>
+ <module>jpa-eclipselink</module>
+ <module>jpa-hibernate</module>
+ <module>jpa-enumerated</module>
+ <module>jsf-managedBean-and-ejb</module>
+ <module>jsf-cdi-and-ejb</module>
+ <module>lookup-of-ejbs</module>
+ <module>lookup-of-ejbs-with-descriptor</module>
+ <module>mbean-auto-registration</module>
+ <module>movies-complete-meta</module>
+ <module>movies-complete</module>
+ <module>mtom</module>
+ <module>multi-jpa-provider-testing</module>
+ <module>multiple-arquillian-adapters</module>
+ <module>multiple-tomee-arquillian</module>
+ <module>myfaces-codi-demo</module>
+ <module>persistence-fragment</module>
+ <module>pojo-webservice</module>
+ <module>polling-parent</module>
+ <module>projectstage-demo</module>
+ <module>quartz-app</module>
+ <module>realm-in-tomee</module>
+ <module>reload-persistence-unit-properties</module>
+ <module>resources-declared-in-webapp</module>
+ <module>rest-applicationcomposer-mockito</module>
+ <module>rest-applicationcomposer</module>
+ <module>rest-cdi</module>
+ <module>rest-jaas</module>
+ <module>rest-on-ejb</module>
+ <module>rest-example</module>
+ <module>rest-example-with-application</module>
+ <module>rest-xml-json</module>
+ <module>scala-basic</module>
+ <module>schedule-expression</module>
+ <module>schedule-events</module>
+ <module>schedule-methods-meta</module>
+ <module>schedule-methods</module>
+ <module>server-events</module>
+ <module>simple-cdi-interceptor</module>
+ <module>simple-cmp2</module>
+ <module>simple-mdb-and-cdi</module>
+ <module>simple-mdb</module>
+ <module>simple-mdb-with-descriptor</module>
+ <module>simple-osgi</module>
+ <module>simple-rest</module>
+ <module>simple-singleton</module>
+ <module>simple-stateful</module>
+ <module>simple-stateful-callbacks</module>
+ <module>simple-stateless</module>
+ <module>simple-stateless-callbacks</module>
+ <module>simple-stateless-with-descriptor</module>
+ <module>simple-webservice</module>
+ <module>simple-webservice-without-interface</module>
+ <module>spring-data-proxy</module>
+ <module>spring-data-proxy-meta</module>
+ <module>struts</module>
+ <module>telephone-stateful</module>
+ <module>testcase-injection</module>
+ <module>testing-security-meta</module>
+ <module>testing-security</module>
+ <module>testing-security-2</module>
+ <module>testing-security-3</module>
+ <module>testing-security-4</module>
+ <module>testing-transactions</module>
+ <module>testing-transactions-bmt</module>
+ <module>tomee-jersey-eclipselink</module>
+ <module>transaction-rollback</module>
+ <module>troubleshooting</module>
+ <module>webservice-attachments</module>
+ <module>webservice-inheritance</module>
+ <module>webservice-security</module>
+ <module>webservice-ws-security</module>
+ <module>webservice-ws-with-resources-config</module>
+ <module>webservice-handlerchain</module>
+ <module>webservice-holder</module>
+ <module>moviefun</module>
+ <module>moviefun-rest</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>apache-release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.3</version>
+ <inherited>false</inherited>
+ <configuration>
+ <descriptors>
+ <descriptor>src.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>gnu</tarLongFileMode>
+ <finalName>openejb-examples-${project.version}</finalName>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/content/examples/projectstage-demo.html b/content/examples/projectstage-demo.html
new file mode 100644
index 0000000..0ece691
--- /dev/null
+++ b/content/examples/projectstage-demo.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/projectstage-demo.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>projectstage-demo</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example projectstage-demo can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/projectstage-demo" class="bare">https://github.com/apache/tomee/tree/master/examples/projectstage-demo</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/projectstage-demo.pdf b/content/examples/projectstage-demo.pdf
new file mode 100644
index 0000000..62a1c42
--- /dev/null
+++ b/content/examples/projectstage-demo.pdf
Binary files differ
diff --git a/content/examples/projectstage-demo/pom.xml b/content/examples/projectstage-demo/pom.xml
new file mode 100755
index 0000000..befcc47
--- /dev/null
+++ b/content/examples/projectstage-demo/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>projectstage-demo</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: DeltaSpike ProjectStage</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltaspike.core</groupId>
+ <artifactId>deltaspike-core-api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>1.1.5.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-tomee-remote</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <tomee.version>1.7.1</tomee.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <!--skipTests>false</skipTests-->
+ <!--
+TODO: remove the skipTests flag. I needed to do it because it was throwing this exception.
+Test set: org.superbiz.projectstage.TestingProjectStageTest
+Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.194 sec <<< FAILURE!
+checkManagerValue(org.superbiz.projectstage.TestingProjectStageTest) Time elapsed: 0.131 sec <<< ERROR!
+java.lang.ClassCastException: $Proxy52 cannot be cast to org.junit.runner.RunWith
+ -->
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/content/examples/projectstage-demo/src/main/java/org/superbiz/Manager.java b/content/examples/projectstage-demo/src/main/java/org/superbiz/Manager.java
new file mode 100755
index 0000000..f0edad9
--- /dev/null
+++ b/content/examples/projectstage-demo/src/main/java/org/superbiz/Manager.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+public class Manager {
+
+ private final String name;
+
+ public Manager(final String name) {
+ this.name = name;
+ }
+
+ public String name() {
+ return name;
+ }
+}
diff --git a/content/examples/projectstage-demo/src/main/java/org/superbiz/ManagerFactory.java b/content/examples/projectstage-demo/src/main/java/org/superbiz/ManagerFactory.java
new file mode 100755
index 0000000..2837afc
--- /dev/null
+++ b/content/examples/projectstage-demo/src/main/java/org/superbiz/ManagerFactory.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public final class ManagerFactory {
+
+ @Inject
+ private ProjectStage projectStage;
+
+ @Produces
+ public Manager currentManager() {
+ if (ProjectStage.UnitTest.equals(projectStage)) {
+ return new Manager("test");
+ } else if (ProjectStage.Development.equals(projectStage)) {
+ return new Manager("dev");
+ }
+ return new Manager(projectStage.toString());
+ }
+}
diff --git a/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/BaseTestForProjectStage.java b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/BaseTestForProjectStage.java
new file mode 100755
index 0000000..7318eae
--- /dev/null
+++ b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/BaseTestForProjectStage.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.projectstage;
+
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.apache.deltaspike.core.spi.config.ConfigSourceProvider;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+import org.superbiz.Manager;
+import org.superbiz.ManagerFactory;
+import org.superbiz.projectstage.util.ProjectStageProducer;
+
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+public abstract class BaseTestForProjectStage {
+
+ @Inject
+ protected Manager manager;
+
+ protected static WebArchive war(final String projectStageName) {
+ return ShrinkWrap.create(WebArchive.class)
+ .addClasses(ProjectStageProducer.class, BaseTestForProjectStage.class, Manager.class, ManagerFactory.class)
+ .addAsResource(new StringAsset("org.apache.deltaspike.ProjectStage = " + projectStageName), ArchivePaths.create(ProjectStageProducer.CONFIG_PATH))
+ .addAsServiceProvider(ConfigSourceProvider.class, ProjectStageProducer.class)
+ .addAsLibraries(JarLocation.jarLocation(ProjectStage.class))
+ .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+ }
+
+ public abstract void checkManagerValue();
+}
diff --git a/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/DevProjectStageTest.java b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/DevProjectStageTest.java
new file mode 100755
index 0000000..aeab10a
--- /dev/null
+++ b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/DevProjectStageTest.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.projectstage;
+
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class DevProjectStageTest extends BaseTestForProjectStage {
+
+ @Deployment
+ public static WebArchive war() {
+ return BaseTestForProjectStage.war(ProjectStage.Development.toString());
+ }
+
+ @Test
+ @Override
+ public void checkManagerValue() {
+ assertEquals("dev", manager.name());
+ }
+}
diff --git a/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/ProductionProjectStageTest.java b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/ProductionProjectStageTest.java
new file mode 100755
index 0000000..b32d329
--- /dev/null
+++ b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/ProductionProjectStageTest.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.projectstage;
+
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.superbiz.projectstage.util.ProjectStageProducer;
+
+import static org.junit.Assert.assertEquals;
+
+public class ProductionProjectStageTest extends BaseTestForProjectStage {
+
+ @Deployment
+ public static WebArchive war() {
+ return BaseTestForProjectStage.war(ProjectStage.Production.toString());
+ }
+
+
+ @Test
+ public void checkManagerValue() {
+ assertEquals(ProjectStageProducer.value("org.apache.deltaspike.ProjectStage"), manager.name());
+ }
+}
diff --git a/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/TestingProjectStageTest.java b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/TestingProjectStageTest.java
new file mode 100755
index 0000000..186d07d
--- /dev/null
+++ b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/TestingProjectStageTest.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.projectstage;
+
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestingProjectStageTest extends BaseTestForProjectStage {
+
+ @Deployment
+ public static WebArchive war() {
+ return BaseTestForProjectStage.war(ProjectStage.UnitTest.toString());
+ }
+
+ @Test
+ @Override
+ public void checkManagerValue() {
+ assertEquals("test", manager.name());
+ }
+}
diff --git a/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/util/ProjectStageProducer.java b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/util/ProjectStageProducer.java
new file mode 100755
index 0000000..2906993
--- /dev/null
+++ b/content/examples/projectstage-demo/src/test/java/org/superbiz/projectstage/util/ProjectStageProducer.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.projectstage.util;
+
+import org.apache.deltaspike.core.spi.config.ConfigSource;
+import org.apache.deltaspike.core.spi.config.ConfigSourceProvider;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+public final class ProjectStageProducer implements ConfigSourceProvider {
+
+ public static final String CONFIG_PATH = "project-stage.properties";
+
+ private static final Properties PROPERTIES = new Properties();
+
+ static {
+ try {
+ PROPERTIES.load(ProjectStageProducer.class.getResourceAsStream("/project-stage.properties"));
+ } catch (final IOException e) {
+ // no-op
+ }
+ }
+
+ @Override
+ public List<ConfigSource> getConfigSources() {
+ return new ArrayList<ConfigSource>() {{
+ add(new ConfigSource() {
+ @Override
+ public int getOrdinal() {
+ return 0;
+ }
+
+ @Override
+ public String getPropertyValue(final String key) {
+ return value(key);
+ }
+
+ @Override
+ public String getConfigName() {
+ return "test-project-stage";
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public boolean isScannable() {
+ return false;
+ }
+ });
+ }};
+ }
+
+ public static String value(final String key) {
+ return PROPERTIES.getProperty(key);
+ }
+}
diff --git a/content/examples/projectstage-demo/src/test/resources/arquillian.xml b/content/examples/projectstage-demo/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..e579f46
--- /dev/null
+++ b/content/examples/projectstage-demo/src/test/resources/arquillian.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian xmlns="http://jboss.org/schema/arquillian"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+ <container qualifier="tomee-remote" default="true">
+ <configuration>
+ <property name="httpPort">-1</property>
+ <property name="ajpPort">-1</property>
+ <property name="stopPort">-1</property>
+ <property name="dir">target/tomee-remote</property>
+ <property name="appWorkingDir">target/arquillian-remote-working-dir</property>
+ <property name="portRange">20001-30000</property>
+ <property name="cleanOnStartUp">true</property>
+ </configuration>
+ </container>
+</arquillian>
diff --git a/content/examples/quartz-app.html b/content/examples/quartz-app.html
new file mode 100644
index 0000000..128e9e3
--- /dev/null
+++ b/content/examples/quartz-app.html
@@ -0,0 +1,443 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/quartz-app.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Quartz Resource Adapter usage</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example quartz-app can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/quartz-app" class="bare">https://github.com/apache/tomee/tree/master/examples/quartz-app</a></p>
+</div>
+<div class="paragraph">
+<p>Note this example is somewhat dated. It predates the schedule API which was added to EJB 3.1. Modern applications should use the schedule API which has many, if not all,
+the same features as Quartz. In fact, Quartz is the engine that drives the <code>@Schedule</code> and <code>ScheduleExpression</code> support in OpenEJB and TomEE.</p>
+</div>
+<div class="paragraph">
+<p>Despite being dated from a scheduling perspective it is still an excellent reference for how to plug-in and test a custom Java EE Resource Adapter.</p>
+</div>
+</div>
+</div>
+<h1 id="_project_structure" class="sect0">Project structure</h1>
+<div class="paragraph">
+<p>As <code>.rar</code> files do not do well on a standard classpath structure the goal is to effectively "unwrap" the <code>.rar</code> so that its dependencies are on the classpath and its <code>ra.xml</code> file
+can be found in scanned by OpenEJB.</p>
+</div>
+<div class="paragraph">
+<p>We do this by creating a mini maven module to represent the rar in maven terms. The <code>pom.xml</code> of the "rar module" declares all of the jars that would be inside <code>.rar</code> as maven
+dependencies. The <code>ra.xml</code> file is added to the project in <code>src/main/resources/META-INF/ra.xml</code> where it will be visible to other modules.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>quartz-app
+quartz-app/pom.xml
+quartz-app/quartz-beans
+quartz-app/quartz-beans/pom.xml
+quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobBean.java
+quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobScheduler.java
+quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/QuartzMdb.java
+quartz-app/quartz-beans/src/main/resources/META-INF
+quartz-app/quartz-beans/src/main/resources/META-INF/ejb-jar.xml
+quartz-app/quartz-beans/src/test/java/org/superbiz/quartz/QuartzMdbTest.java
+quartz-app/quartz-ra
+quartz-app/quartz-ra/pom.xml
+quartz-app/quartz-ra/src/main/resources/META-INF
+quartz-app/quartz-ra/src/main/resources/META-INF/ra.xml</pre>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ra_xml">ra.xml</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The connector in question has both inbound and outbound Resource Adapters. The inbound Resource Adapter can be used to drive message driven beans (MDBs)</p>
+</div>
+<div class="paragraph">
+<p>the outbound Resource Adapter, <code>QuartzResourceAdapter</code>, can be injected into any component via <code>@Resource</code> and used to originate and send messages or events.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <description>Quartz ResourceAdapter</description>
+ <display-name>Quartz ResourceAdapter</display-name>
+
+ <vendor-name>OpenEJB</vendor-name>
+ <eis-type>Quartz Adapter</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+
+ <resourceadapter id="QuartzResourceAdapter">
+ <resourceadapter-class>org.apache.openejb.resource.quartz.QuartzResourceAdapter</resourceadapter-class>
+
+ <inbound-resourceadapter>
+ <messageadapter>
+ <messagelistener>
+ <messagelistener-type>org.quartz.Job</messagelistener-type>
+ <activationspec>
+ <activationspec-class>org.apache.openejb.resource.quartz.JobSpec</activationspec-class>
+ </activationspec>
+ </messagelistener>
+ </messageadapter>
+ </inbound-resourceadapter>
+
+ </resourceadapter>
+</connector></code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_using_the_outbound_resource_adapter" class="sect0">Using the Outbound Resource Adapter</h1>
+<div class="paragraph">
+<p>Here we see the outbound resource adapter used in a stateless session bean to schedule a job that will be executed by the MDB</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.quartz;
+
+import org.apache.openejb.resource.quartz.QuartzResourceAdapter;
+import org.quartz.Job;
+import org.quartz.JobDetail;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.quartz.Scheduler;
+import org.quartz.SimpleTrigger;
+
+import javax.ejb.Stateless;
+import javax.naming.InitialContext;
+import java.util.Date;
+
+@Stateless
+public class JobBean implements JobScheduler {
+
+ @Override
+ public Date createJob() throws Exception {
+
+ final QuartzResourceAdapter ra = (QuartzResourceAdapter) new InitialContext().lookup("java:openejb/Resource/QuartzResourceAdapter");
+ final Scheduler s = ra.getScheduler();
+
+ //Add a job type
+ final JobDetail jd = new JobDetail("job1", "group1", JobBean.MyTestJob.class);
+ jd.getJobDataMap().put("MyJobKey", "MyJobValue");
+
+ //Schedule my 'test' job to run now
+ final SimpleTrigger trigger = new SimpleTrigger("trigger1", "group1", new Date());
+ return s.scheduleJob(jd, trigger);
+ }
+
+ public static class MyTestJob implements Job {
+
+ @Override
+ public void execute(JobExecutionContext context) throws JobExecutionException {
+ System.out.println("This is a simple test job to get: " + context.getJobDetail().getJobDataMap().get("MyJobKey"));
+ }
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_recieving_data_from_the_inbound_resource_adapter" class="sect0">Recieving data from the Inbound Resource Adapter</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.quartz;
+
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+
+@MessageDriven(activationConfig = {
+ @ActivationConfigProperty(propertyName = "cronExpression", propertyValue = "* * * * * ?")})
+public class QuartzMdb implements Job {
+
+ @Override
+ public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+ System.out.println("Executing Job");
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_test_case" class="sect0">Test case</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.quartz;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Date;
+import java.util.Properties;
+
+public class QuartzMdbTest {
+
+ private static InitialContext initialContext = null;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+
+ if (null == initialContext) {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ initialContext = new InitialContext(properties);
+ }
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ if (null != initialContext) {
+ initialContext.close();
+ initialContext = null;
+ }
+ }
+
+ @Test
+ public void testLookup() throws Exception {
+
+ final JobScheduler jbi = (JobScheduler) initialContext.lookup("JobBeanLocal");
+ final Date d = jbi.createJob();
+ Thread.sleep(500);
+ System.out.println("Scheduled test job should have run at: " + d.toString());
+ }
+
+ @Test
+ public void testMdb() throws Exception {
+ // Sleep 3 seconds and give quartz a chance to execute our MDB
+ Thread.sleep(3000);
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.quartz.QuartzMdbTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/quartz-app/quartz-beans
+INFO - openejb.base = /Users/dblevins/examples/quartz-app/quartz-beans
+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 ConnectorModule in classpath: /Users/dblevins/examples/quartz-app/quartz-ra/target/quartz-ra-1.0.jar
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/quartz-app/quartz-beans/target/classes
+INFO - Beginning load: /Users/dblevins/examples/quartz-app/quartz-ra/target/quartz-ra-1.0.jar
+INFO - Extracting jar: /Users/dblevins/examples/quartz-app/quartz-ra/target/quartz-ra-1.0.jar
+INFO - Extracted path: /Users/dblevins/examples/quartz-app/quartz-ra/target/quartz-ra-1.0
+INFO - Beginning load: /Users/dblevins/examples/quartz-app/quartz-beans/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/quartz-app/quartz-beans/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean JobBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=QuartzResourceAdapter, type=Resource, provider-id=QuartzResourceAdapter)
+INFO - Configuring Service(id=quartz-ra-1.0, type=Container, provider-id=Default MDB Container)
+INFO - Enterprise application "/Users/dblevins/examples/quartz-app/quartz-beans/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/quartz-app/quartz-beans/classpath.ear
+INFO - Jndi(name=JobBeanLocal) --> Ejb(deployment-id=JobBean)
+INFO - Jndi(name=global/classpath.ear/quartz-beans/JobBean!org.superbiz.quartz.JobScheduler) --> Ejb(deployment-id=JobBean)
+INFO - Jndi(name=global/classpath.ear/quartz-beans/JobBean) --> Ejb(deployment-id=JobBean)
+INFO - Created Ejb(deployment-id=JobBean, ejb-name=JobBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=QuartzMdb, ejb-name=QuartzMdb, container=quartz-ra-1.0)
+Executing Job
+INFO - Started Ejb(deployment-id=JobBean, ejb-name=JobBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=QuartzMdb, ejb-name=QuartzMdb, container=quartz-ra-1.0)
+INFO - Deployed Application(path=/Users/dblevins/examples/quartz-app/quartz-beans/classpath.ear)
+This is a simple test job to get: MyJobValue
+Scheduled test job should have run at: Fri Oct 28 17:05:12 PDT 2011
+Executing Job
+Executing Job
+Executing Job
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.971 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/quartz-app.pdf b/content/examples/quartz-app.pdf
new file mode 100644
index 0000000..12f7adc
--- /dev/null
+++ b/content/examples/quartz-app.pdf
Binary files differ
diff --git a/content/examples/quartz-app/README.md b/content/examples/quartz-app/README.md
new file mode 100755
index 0000000..393a75f
--- /dev/null
+++ b/content/examples/quartz-app/README.md
@@ -0,0 +1,231 @@
+Title: Quartz Resource Adapter usage
+
+Note this example is somewhat dated. It predates the schedule API which was added to EJB 3.1. Modern applications should use the schedule API which has many, if not all,
+the same features as Quartz. In fact, Quartz is the engine that drives the `@Schedule` and `ScheduleExpression` support in OpenEJB and TomEE.
+
+Despite being dated from a scheduling perspective it is still an excellent reference for how to plug-in and test a custom Java EE Resource Adapter.
+
+# Project structure
+
+As `.rar` files do not do well on a standard classpath structure the goal is to effectively "unwrap" the `.rar` so that its dependencies are on the classpath and its `ra.xml` file
+can be found in scanned by OpenEJB.
+
+We do this by creating a mini maven module to represent the rar in maven terms. The `pom.xml` of the "rar module" declares all of the jars that would be inside `.rar` as maven
+dependencies. The `ra.xml` file is added to the project in `src/main/resources/META-INF/ra.xml` where it will be visible to other modules.
+
+ quartz-app
+ quartz-app/pom.xml
+ quartz-app/quartz-beans
+ quartz-app/quartz-beans/pom.xml
+ quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobBean.java
+ quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobScheduler.java
+ quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/QuartzMdb.java
+ quartz-app/quartz-beans/src/main/resources/META-INF
+ quartz-app/quartz-beans/src/main/resources/META-INF/ejb-jar.xml
+ quartz-app/quartz-beans/src/test/java/org/superbiz/quartz/QuartzMdbTest.java
+ quartz-app/quartz-ra
+ quartz-app/quartz-ra/pom.xml
+ quartz-app/quartz-ra/src/main/resources/META-INF
+ quartz-app/quartz-ra/src/main/resources/META-INF/ra.xml
+
+## ra.xml
+
+The connector in question has both inbound and outbound Resource Adapters. The inbound Resource Adapter can be used to drive message driven beans (MDBs)
+
+the outbound Resource Adapter, `QuartzResourceAdapter`, can be injected into any component via `@Resource` and used to originate and send messages or events.
+
+ <connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <description>Quartz ResourceAdapter</description>
+ <display-name>Quartz ResourceAdapter</display-name>
+
+ <vendor-name>OpenEJB</vendor-name>
+ <eis-type>Quartz Adapter</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+
+ <resourceadapter id="QuartzResourceAdapter">
+ <resourceadapter-class>org.apache.openejb.resource.quartz.QuartzResourceAdapter</resourceadapter-class>
+
+ <inbound-resourceadapter>
+ <messageadapter>
+ <messagelistener>
+ <messagelistener-type>org.quartz.Job</messagelistener-type>
+ <activationspec>
+ <activationspec-class>org.apache.openejb.resource.quartz.JobSpec</activationspec-class>
+ </activationspec>
+ </messagelistener>
+ </messageadapter>
+ </inbound-resourceadapter>
+
+ </resourceadapter>
+ </connector>
+
+
+# Using the Outbound Resource Adapter
+
+Here we see the outbound resource adapter used in a stateless session bean to schedule a job that will be executed by the MDB
+
+ package org.superbiz.quartz;
+
+ import org.apache.openejb.resource.quartz.QuartzResourceAdapter;
+ import org.quartz.Job;
+ import org.quartz.JobDetail;
+ import org.quartz.JobExecutionContext;
+ import org.quartz.JobExecutionException;
+ import org.quartz.Scheduler;
+ import org.quartz.SimpleTrigger;
+
+ import javax.ejb.Stateless;
+ import javax.naming.InitialContext;
+ import java.util.Date;
+
+ @Stateless
+ public class JobBean implements JobScheduler {
+
+ @Override
+ public Date createJob() throws Exception {
+
+ final QuartzResourceAdapter ra = (QuartzResourceAdapter) new InitialContext().lookup("java:openejb/Resource/QuartzResourceAdapter");
+ final Scheduler s = ra.getScheduler();
+
+ //Add a job type
+ final JobDetail jd = new JobDetail("job1", "group1", JobBean.MyTestJob.class);
+ jd.getJobDataMap().put("MyJobKey", "MyJobValue");
+
+ //Schedule my 'test' job to run now
+ final SimpleTrigger trigger = new SimpleTrigger("trigger1", "group1", new Date());
+ return s.scheduleJob(jd, trigger);
+ }
+
+ public static class MyTestJob implements Job {
+
+ @Override
+ public void execute(JobExecutionContext context) throws JobExecutionException {
+ System.out.println("This is a simple test job to get: " + context.getJobDetail().getJobDataMap().get("MyJobKey"));
+ }
+ }
+ }
+
+# Recieving data from the Inbound Resource Adapter
+
+
+ package org.superbiz.quartz;
+
+ import org.quartz.Job;
+ import org.quartz.JobExecutionContext;
+ import org.quartz.JobExecutionException;
+
+ import javax.ejb.ActivationConfigProperty;
+ import javax.ejb.MessageDriven;
+
+ @MessageDriven(activationConfig = {
+ @ActivationConfigProperty(propertyName = "cronExpression", propertyValue = "* * * * * ?")})
+ public class QuartzMdb implements Job {
+
+ @Override
+ public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+ System.out.println("Executing Job");
+ }
+ }
+
+# Test case
+
+ package org.superbiz.quartz;
+
+ import org.junit.AfterClass;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.Date;
+ import java.util.Properties;
+
+ public class QuartzMdbTest {
+
+ private static InitialContext initialContext = null;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+
+ if (null == initialContext) {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ initialContext = new InitialContext(properties);
+ }
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ if (null != initialContext) {
+ initialContext.close();
+ initialContext = null;
+ }
+ }
+
+ @Test
+ public void testLookup() throws Exception {
+
+ final JobScheduler jbi = (JobScheduler) initialContext.lookup("JobBeanLocal");
+ final Date d = jbi.createJob();
+ Thread.sleep(500);
+ System.out.println("Scheduled test job should have run at: " + d.toString());
+ }
+
+ @Test
+ public void testMdb() throws Exception {
+ // Sleep 3 seconds and give quartz a chance to execute our MDB
+ Thread.sleep(3000);
+ }
+ }
+
+# Running
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.quartz.QuartzMdbTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/quartz-app/quartz-beans
+ INFO - openejb.base = /Users/dblevins/examples/quartz-app/quartz-beans
+ 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 ConnectorModule in classpath: /Users/dblevins/examples/quartz-app/quartz-ra/target/quartz-ra-1.0.jar
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/quartz-app/quartz-beans/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/quartz-app/quartz-ra/target/quartz-ra-1.0.jar
+ INFO - Extracting jar: /Users/dblevins/examples/quartz-app/quartz-ra/target/quartz-ra-1.0.jar
+ INFO - Extracted path: /Users/dblevins/examples/quartz-app/quartz-ra/target/quartz-ra-1.0
+ INFO - Beginning load: /Users/dblevins/examples/quartz-app/quartz-beans/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/quartz-app/quartz-beans/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean JobBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=QuartzResourceAdapter, type=Resource, provider-id=QuartzResourceAdapter)
+ INFO - Configuring Service(id=quartz-ra-1.0, type=Container, provider-id=Default MDB Container)
+ INFO - Enterprise application "/Users/dblevins/examples/quartz-app/quartz-beans/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/quartz-app/quartz-beans/classpath.ear
+ INFO - Jndi(name=JobBeanLocal) --> Ejb(deployment-id=JobBean)
+ INFO - Jndi(name=global/classpath.ear/quartz-beans/JobBean!org.superbiz.quartz.JobScheduler) --> Ejb(deployment-id=JobBean)
+ INFO - Jndi(name=global/classpath.ear/quartz-beans/JobBean) --> Ejb(deployment-id=JobBean)
+ INFO - Created Ejb(deployment-id=JobBean, ejb-name=JobBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=QuartzMdb, ejb-name=QuartzMdb, container=quartz-ra-1.0)
+ Executing Job
+ INFO - Started Ejb(deployment-id=JobBean, ejb-name=JobBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=QuartzMdb, ejb-name=QuartzMdb, container=quartz-ra-1.0)
+ INFO - Deployed Application(path=/Users/dblevins/examples/quartz-app/quartz-beans/classpath.ear)
+ This is a simple test job to get: MyJobValue
+ Scheduled test job should have run at: Fri Oct 28 17:05:12 PDT 2011
+ Executing Job
+ Executing Job
+ Executing Job
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.971 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/quartz-app/pom.xml b/content/examples/quartz-app/pom.xml
new file mode 100755
index 0000000..ee1f0fc
--- /dev/null
+++ b/content/examples/quartz-app/pom.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz.quartz</groupId>
+ <artifactId>quartz-app</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>OpenEJB :: Examples :: Quartz</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <version.openejb>4.7.1</version.openejb>
+ </properties>
+ <modules>
+ <module>quartz-ra</module>
+ <module>quartz-beans</module>
+ </modules>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots/</url>
+ </repository>
+ </repositories>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <dependencyManagement>
+ <dependencies>
+ <!--
+ TomEE/OpenEJB uses a shaded version of quartz
+ allowing users to use their own version of quartz
+ and avoid version conflicts.
+
+ This example shows an application that uses its
+ own version of quartz.
+ -->
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>${version.openejb}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/quartz-app/quartz-beans/pom.xml b/content/examples/quartz-app/quartz-beans/pom.xml
new file mode 100755
index 0000000..c6c40c5
--- /dev/null
+++ b/content/examples/quartz-app/quartz-beans/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.superbiz.quartz</groupId>
+ <artifactId>quartz-app</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>quartz-beans</artifactId>
+ <packaging>jar</packaging>
+ <name>OpenEJB :: Examples :: Quartz :: Quartz Beans</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.superbiz.quartz</groupId>
+ <artifactId>quartz-ra</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>oro</groupId>
+ <artifactId>oro</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!--
+ Note that <scope>test</scope> is NOT specified here because some OpenEJB specific classes
+ are used in the JobBean example.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobBean.java b/content/examples/quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobBean.java
new file mode 100755
index 0000000..b22c2b5
--- /dev/null
+++ b/content/examples/quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobBean.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.quartz;
+
+import org.apache.openejb.resource.quartz.QuartzResourceAdapter;
+import org.apache.openejb.quartz.Job;
+import org.apache.openejb.quartz.JobBuilder;
+import org.apache.openejb.quartz.JobDetail;
+import org.apache.openejb.quartz.JobExecutionContext;
+import org.apache.openejb.quartz.JobExecutionException;
+import org.apache.openejb.quartz.Scheduler;
+import org.apache.openejb.quartz.SimpleScheduleBuilder;
+import org.apache.openejb.quartz.SimpleTrigger;
+import org.apache.openejb.quartz.TriggerBuilder;
+
+import javax.ejb.Stateless;
+import javax.naming.InitialContext;
+import java.util.Date;
+
+@Stateless
+public class JobBean implements JobScheduler {
+
+ @Override
+ public Date createJob() throws Exception {
+
+ final QuartzResourceAdapter ra = (QuartzResourceAdapter) new InitialContext().lookup("java:openejb/Resource/QuartzResourceAdapter");
+ final Scheduler s = ra.getScheduler();
+
+ //Add a job type
+ final JobDetail jd = JobBuilder.newJob(MyTestJob.class).withIdentity("job1", "group1").build();
+ jd.getJobDataMap().put("MyJobKey", "MyJobValue");
+
+ //Schedule my 'test' job to run now
+ final SimpleTrigger trigger = TriggerBuilder.newTrigger()
+ .withIdentity("trigger1", "group1")
+ .forJob(jd)
+ .withSchedule(SimpleScheduleBuilder.simpleSchedule()
+ .withRepeatCount(0)
+ .withIntervalInSeconds(0))
+ .build();
+ return s.scheduleJob(jd, trigger);
+ }
+
+ public static class MyTestJob implements Job {
+
+ @Override
+ public void execute(JobExecutionContext context) throws JobExecutionException {
+ System.out.println("This is a simple test job to get: " + context.getJobDetail().getJobDataMap().get("MyJobKey"));
+ }
+ }
+}
diff --git a/content/examples/quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobScheduler.java b/content/examples/quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobScheduler.java
new file mode 100755
index 0000000..6d8dc85
--- /dev/null
+++ b/content/examples/quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/JobScheduler.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.quartz;
+
+import javax.ejb.Local;
+import java.util.Date;
+
+@Local
+public interface JobScheduler {
+
+ Date createJob() throws Exception;
+}
diff --git a/content/examples/quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/QuartzMdb.java b/content/examples/quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/QuartzMdb.java
new file mode 100755
index 0000000..b8f9aa7
--- /dev/null
+++ b/content/examples/quartz-app/quartz-beans/src/main/java/org/superbiz/quartz/QuartzMdb.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.quartz;
+
+import org.apache.openejb.quartz.Job;
+import org.apache.openejb.quartz.JobExecutionContext;
+import org.apache.openejb.quartz.JobExecutionException;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+
+@MessageDriven(activationConfig = {
+ @ActivationConfigProperty(propertyName = "cronExpression", propertyValue = "* * * * * ?")
+})
+public class QuartzMdb implements Job {
+
+ @Override
+ public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+ System.out.println("Executing Job");
+ }
+}
diff --git a/content/examples/quartz-app/quartz-beans/src/main/resources/META-INF/ejb-jar.xml b/content/examples/quartz-app/quartz-beans/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..91be4f8
--- /dev/null
+++ b/content/examples/quartz-app/quartz-beans/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
diff --git a/content/examples/quartz-app/quartz-beans/src/test/java/org/superbiz/quartz/QuartzMdbTest.java b/content/examples/quartz-app/quartz-beans/src/test/java/org/superbiz/quartz/QuartzMdbTest.java
new file mode 100755
index 0000000..1fc9a81
--- /dev/null
+++ b/content/examples/quartz-app/quartz-beans/src/test/java/org/superbiz/quartz/QuartzMdbTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.quartz;
+
+import org.apache.openejb.config.OutputGeneratedDescriptors;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Date;
+import java.util.Properties;
+
+public class QuartzMdbTest {
+
+ private static InitialContext initialContext = null;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ System.setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS, "false"); // just to avoid to dump files in /tmp
+ if (null == initialContext) {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.deployments.classpath.include", ".*quartz-.*");
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ initialContext = new InitialContext(properties);
+ }
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ if (null != initialContext) {
+ initialContext.close();
+ initialContext = null;
+ }
+ }
+
+ @Test
+ public void testLookup() throws Exception {
+
+ final JobScheduler jbi = (JobScheduler) initialContext.lookup("JobBeanLocal");
+ final Date d = jbi.createJob();
+ Thread.sleep(500);
+ System.out.println("Scheduled test job should have run at: " + d.toString());
+ }
+
+ @Test
+ public void testMdb() throws Exception {
+ // Sleep 3 seconds and give quartz a chance to execute our MDB
+ Thread.sleep(3000);
+ }
+}
diff --git a/content/examples/quartz-app/quartz-ra/pom.xml b/content/examples/quartz-app/quartz-ra/pom.xml
new file mode 100755
index 0000000..67dd581
--- /dev/null
+++ b/content/examples/quartz-app/quartz-ra/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.superbiz.quartz</groupId>
+ <artifactId>quartz-app</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>quartz-ra</artifactId>
+ <packaging>jar</packaging>
+ <name>OpenEJB :: Examples :: Quartz :: Quartz Resource Adapter</name>
+ <description>
+ Maven doesn't allow rar files in the test classpath for some reason,
+ so we have to pull this trick to get it in the classpath.
+ </description>
+ <dependencies>
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/quartz-app/quartz-ra/src/main/resources/META-INF/ra.xml b/content/examples/quartz-app/quartz-ra/src/main/resources/META-INF/ra.xml
new file mode 100755
index 0000000..1defe9e
--- /dev/null
+++ b/content/examples/quartz-app/quartz-ra/src/main/resources/META-INF/ra.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <description>Quartz ResourceAdapter</description>
+ <display-name>Quartz ResourceAdapter</display-name>
+
+ <vendor-name>OpenEJB</vendor-name>
+ <eis-type>Quartz Adapter</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+
+ <resourceadapter id="QuartzResourceAdapter">
+ <resourceadapter-class>org.apache.openejb.resource.quartz.QuartzResourceAdapter</resourceadapter-class>
+
+ <inbound-resourceadapter>
+ <messageadapter>
+ <messagelistener>
+ <messagelistener-type>org.apache.openejb.quartz.Job</messagelistener-type>
+ <activationspec>
+ <activationspec-class>org.apache.openejb.resource.quartz.JobSpec</activationspec-class>
+ </activationspec>
+ </messagelistener>
+ </messageadapter>
+ </inbound-resourceadapter>
+
+ </resourceadapter>
+</connector>
diff --git a/content/examples/realm-in-tomee.html b/content/examples/realm-in-tomee.html
new file mode 100644
index 0000000..7a9c53c
--- /dev/null
+++ b/content/examples/realm-in-tomee.html
@@ -0,0 +1,240 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/realm-in-tomee.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>DataSourceRealm and TomEE DataSource</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example realm-in-tomee can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/realm-in-tomee" class="bare">https://github.com/apache/tomee/tree/master/examples/realm-in-tomee</a></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_quick_start">Quick start</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>To test it:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>mvn clean package tomee:run</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_how_does_it_work">How does it work?</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>A datasource is defined in tomee.xml:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><Resource id="myDataSource" type="DataSource" /> <!-- standard properties -->
+
+Then this datasource is referenced in server.xml:
+
+<Realm
+ className="org.apache.catalina.realm.DataSourceRealm"
+ dataSourceName="myDataSource"
+ userTable="users"
+ userNameCol="user_name"
+ userCredCol="user_pass"
+ userRoleTable="user_roles"
+ roleNameCol="role_name"/>
+
+To initialize the datasource (for the test) we used the TomEE hook which consists in providing
+a file import-<datasource name>.sql. It should be in the classpath of the datasource so here it is
+the TomEE classpath so we added it to lib (by default in the classloader). It simply contains the
+table creations and the insertion of the "admin" "tomee" with the password "tomee".
+
+## Test it
+
+Go to http://localhost:8080/realm-in-tomee-1.1.0-SNAPSHOT/, then connect using
+the login/password tomee/tomee. You should see "Home".</code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/realm-in-tomee.pdf b/content/examples/realm-in-tomee.pdf
new file mode 100644
index 0000000..03d1276
--- /dev/null
+++ b/content/examples/realm-in-tomee.pdf
Binary files differ
diff --git a/content/examples/realm-in-tomee/README.md b/content/examples/realm-in-tomee/README.md
new file mode 100755
index 0000000..d691823
--- /dev/null
+++ b/content/examples/realm-in-tomee/README.md
@@ -0,0 +1,34 @@
+Title: DataSourceRealm and TomEE DataSource
+
+## Quick start
+
+To test it:
+
+ mvn clean package tomee:run
+
+## How does it work?
+
+A datasource is defined in tomee.xml:
+
+ <Resource id="myDataSource" type="DataSource" /> <!-- standard properties -->
+
+Then this datasource is referenced in server.xml:
+
+ <Realm
+ className="org.apache.catalina.realm.DataSourceRealm"
+ dataSourceName="myDataSource"
+ userTable="users"
+ userNameCol="user_name"
+ userCredCol="user_pass"
+ userRoleTable="user_roles"
+ roleNameCol="role_name"/>
+
+To initialize the datasource (for the test) we used the TomEE hook which consists in providing
+a file import-<datasource name>.sql. It should be in the classpath of the datasource so here it is
+the TomEE classpath so we added it to lib (by default in the classloader). It simply contains the
+table creations and the insertion of the "admin" "tomee" with the password "tomee".
+
+## Test it
+
+Go to http://localhost:8080/realm-in-tomee-1.1.1-SNAPSHOT/, then connect using
+the login/password tomee/tomee. You should see "Home".
diff --git a/content/examples/realm-in-tomee/pom.xml b/content/examples/realm-in-tomee/pom.xml
new file mode 100755
index 0000000..15b7cd7
--- /dev/null
+++ b/content/examples/realm-in-tomee/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>realm-in-tomee</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: DataSource Realm</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/realm-in-tomee/src/main/tomee/conf/server.xml b/content/examples/realm-in-tomee/src/main/tomee/conf/server.xml
new file mode 100755
index 0000000..bbd077a
--- /dev/null
+++ b/content/examples/realm-in-tomee/src/main/tomee/conf/server.xml
@@ -0,0 +1,46 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<Server port="8005" shutdown="SHUTDOWN">
+ <Listener className="org.apache.tomee.catalina.ServerListener"/>
+ <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on"/>
+ <Listener className="org.apache.catalina.core.JasperListener"/>
+ <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
+ <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
+ <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
+
+ <Service name="Catalina">
+ <Connector port="8080" protocol="HTTP/1.1"
+ connectionTimeout="20000"/>
+
+ <Engine name="Catalina" defaultHost="localhost">
+ <Realm className="org.apache.catalina.realm.LockOutRealm">
+ <Realm
+ className="org.apache.catalina.realm.DataSourceRealm"
+ dataSourceName="myDataSource"
+ userTable="users"
+ userNameCol="user_name"
+ userCredCol="user_pass"
+ userRoleTable="user_roles"
+ roleNameCol="role_name"/>
+ </Realm>
+
+ <Host name="localhost" appBase="webapps"
+ unpackWARs="true" autoDeploy="true"/>
+ </Engine>
+ </Service>
+</Server>
diff --git a/content/examples/realm-in-tomee/src/main/tomee/conf/tomee.xml b/content/examples/realm-in-tomee/src/main/tomee/conf/tomee.xml
new file mode 100755
index 0000000..f11b032
--- /dev/null
+++ b/content/examples/realm-in-tomee/src/main/tomee/conf/tomee.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<tomee>
+ <Resource id="myDataSource" type="DataSource"/>
+ <!-- configure it -->
+</tomee>
\ No newline at end of file
diff --git a/content/examples/realm-in-tomee/src/main/tomee/lib/import-myDataSource.sql b/content/examples/realm-in-tomee/src/main/tomee/lib/import-myDataSource.sql
new file mode 100755
index 0000000..8d89caa
--- /dev/null
+++ b/content/examples/realm-in-tomee/src/main/tomee/lib/import-myDataSource.sql
@@ -0,0 +1,21 @@
+--
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+create table users (user_name varchar(15) not null primary key, user_pass varchar(15) not null);
+create table user_roles (user_name varchar(15) not null, role_name varchar(15) not null, primary key (user_name, role_name));
+insert into users(user_name, user_pass) values('tomee', 'tomee');
+insert into user_roles(user_name, role_name) values('tomee', 'admin');
diff --git a/content/examples/realm-in-tomee/src/main/webapp/WEB-INF/web.xml b/content/examples/realm-in-tomee/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..e88b70c
--- /dev/null
+++ b/content/examples/realm-in-tomee/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<web-app 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/web-app_3_0.xsd"
+ version="3.0">
+ <security-constraint>
+ <display-name>Realm In TomEE</display-name>
+ <web-resource-collection>
+ <web-resource-name>Secured</web-resource-name>
+ <url-pattern>/index.jsp</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>admin</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>Admin space</realm-name>
+ </login-config>
+ <security-role>
+ <description>Admin</description>
+ <role-name>admin</role-name>
+ </security-role>
+</web-app>
diff --git a/content/examples/realm-in-tomee/src/main/webapp/index.jsp b/content/examples/realm-in-tomee/src/main/webapp/index.jsp
new file mode 100755
index 0000000..986acdf
--- /dev/null
+++ b/content/examples/realm-in-tomee/src/main/webapp/index.jsp
@@ -0,0 +1,26 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<html>
+<head>
+ <title>Realm In TomEE</title>
+</head>
+<body>
+<h1>Home</h1>
+</body>
+</html>
diff --git a/content/examples/reload-persistence-unit-properties.html b/content/examples/reload-persistence-unit-properties.html
new file mode 100644
index 0000000..42d5d42
--- /dev/null
+++ b/content/examples/reload-persistence-unit-properties.html
@@ -0,0 +1,259 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/reload-persistence-unit-properties.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Reload Persistence Unit Properties</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example reload-persistence-unit-properties can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/reload-persistence-unit-properties" class="bare">https://github.com/apache/tomee/tree/master/examples/reload-persistence-unit-properties</a></p>
+</div>
+<div class="paragraph">
+<p>This example aims to simulate a benchmark campaign on JPA.</p>
+</div>
+<div class="paragraph">
+<p>First you’ll run your application then you’ll realize you could need L2 cache to respect your SLA.</p>
+</div>
+<div class="paragraph">
+<p>So you change your persistence.xml configuration, then restart your application,
+you wait a bit because you are using OpenEJB ;)…​but you wait…​</p>
+</div>
+<div class="paragraph">
+<p>So to try to go faster on long campaign simply change your configuration at runtime to test it then when it works change
+your configuration file to keep the modification.</p>
+</div>
+<div class="paragraph">
+<p>To do it we can simply use JMX.</p>
+</div>
+<div class="paragraph">
+<p>OpenEJB automatically register one MBeans by entitymanager (persistence unit).</p>
+</div>
+<div class="paragraph">
+<p>It allows you mainly to change your persistence unit properties even if more is possible.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_test_itself">The test itself</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The test is simple: we persist an entity, we query it three times without cache then we activate cache and realize
+running again our queries that one is enough to do the same.</p>
+</div>
+</div>
+</div>
+<h1 id="_the_output" class="sect0">The output</h1>
+<div class="paragraph">
+<p>In the ouput we find the 3 parts described just before.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>INFO - TEST, data initialization
+DEBUG - <t 1523828380, conn 93608538> executing stmnt 1615782385 CREATE TABLE Person (id BIGINT NOT NULL, name VARCHAR(255), PRIMARY KEY (id))
+DEBUG - <t 1523828380, conn 93608538> [1 ms] spent
+DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 668144844 INSERT INTO Person (id, name) VALUES (?, ?) [params=?, ?]
+DEBUG - <t 1523828380, conn 1506565411> [0 ms] spent
+INFO - TEST, end of data initialization</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>INFO - TEST, doing some queries without cache
+DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 1093240870 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+DEBUG - <t 1523828380, conn 1506565411> [0 ms] spent
+DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 1983702821 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+DEBUG - <t 1523828380, conn 1506565411> [0 ms] spent
+DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 1178041898 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+DEBUG - <t 1523828380, conn 1506565411> [1 ms] spent
+INFO - TEST, queries without cache done</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>INFO - TEST, doing some queries with cache
+DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 1532943889 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+DEBUG - <t 1523828380, conn 1506565411> [0 ms] spent
+INFO - TEST, queries with cache done</pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/reload-persistence-unit-properties.pdf b/content/examples/reload-persistence-unit-properties.pdf
new file mode 100644
index 0000000..d8c0b4c
--- /dev/null
+++ b/content/examples/reload-persistence-unit-properties.pdf
Binary files differ
diff --git a/content/examples/reload-persistence-unit-properties/README.md b/content/examples/reload-persistence-unit-properties/README.md
new file mode 100755
index 0000000..d9f31ce
--- /dev/null
+++ b/content/examples/reload-persistence-unit-properties/README.md
@@ -0,0 +1,52 @@
+Title: Reload Persistence Unit Properties
+
+This example aims to simulate a benchmark campaign on JPA.
+
+First you'll run your application then you'll realize you could need L2 cache to respect your SLA.
+
+So you change your persistence.xml configuration, then restart your application,
+you wait a bit because you are using OpenEJB ;)...but you wait...
+
+So to try to go faster on long campaign simply change your configuration at runtime to test it then when it works change
+your configuration file to keep the modification.
+
+To do it we can simply use JMX.
+
+OpenEJB automatically register one MBeans by entitymanager (persistence unit).
+
+It allows you mainly to change your persistence unit properties even if more is possible.
+
+## The test itself
+
+The test is simple: we persist an entity, we query it three times without cache then we activate cache and realize
+running again our queries that one is enough to do the same.
+
+# The output
+
+In the ouput we find the 3 parts described just before.
+
+ INFO - TEST, data initialization
+ DEBUG - <t 1523828380, conn 93608538> executing stmnt 1615782385 CREATE TABLE Person (id BIGINT NOT NULL, name VARCHAR(255), PRIMARY KEY (id))
+ DEBUG - <t 1523828380, conn 93608538> [1 ms] spent
+ DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 668144844 INSERT INTO Person (id, name) VALUES (?, ?) [params=?, ?]
+ DEBUG - <t 1523828380, conn 1506565411> [0 ms] spent
+ INFO - TEST, end of data initialization
+
+
+ INFO - TEST, doing some queries without cache
+ DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 1093240870 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+ DEBUG - <t 1523828380, conn 1506565411> [0 ms] spent
+ DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 1983702821 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+ DEBUG - <t 1523828380, conn 1506565411> [0 ms] spent
+ DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 1178041898 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+ DEBUG - <t 1523828380, conn 1506565411> [1 ms] spent
+ INFO - TEST, queries without cache done
+
+
+ INFO - TEST, doing some queries with cache
+ DEBUG - <t 1523828380, conn 1506565411> executing prepstmnt 1532943889 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+ DEBUG - <t 1523828380, conn 1506565411> [0 ms] spent
+ INFO - TEST, queries with cache done
+
+
+
diff --git a/content/examples/reload-persistence-unit-properties/pom.xml b/content/examples/reload-persistence-unit-properties/pom.xml
new file mode 100755
index 0000000..fc616f2
--- /dev/null
+++ b/content/examples/reload-persistence-unit-properties/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1178411 $ $Date: 2011-10-03 15:35:26 +0200 (lun. 03 oct. 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>reload-persistence-unit-properties</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Reloadable Persistence Unit Properties</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/Person.java b/content/examples/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/Person.java
new file mode 100755
index 0000000..3a623c9
--- /dev/null
+++ b/content/examples/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/Person.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.reloadable.pu;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Person {
+
+ @Id
+ private long id;
+ private String name;
+
+ public Person() {
+ // no-op
+ }
+
+ public Person(long id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/content/examples/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/PersonManager.java b/content/examples/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/PersonManager.java
new file mode 100755
index 0000000..f300add
--- /dev/null
+++ b/content/examples/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/PersonManager.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.reloadable.pu;
+
+import javax.ejb.Singleton;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+@Singleton
+public class PersonManager {
+
+ private static int ID = 0;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ public Person createUser(String name) {
+ Person user = new Person(ID++, name);
+ em.persist(user);
+ return user;
+ }
+
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public Person search(long id) {
+ return em.find(Person.class, id);
+ }
+}
diff --git a/content/examples/reload-persistence-unit-properties/src/main/resources/META-INF/persistence.xml b/content/examples/reload-persistence-unit-properties/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..8816db0
--- /dev/null
+++ b/content/examples/reload-persistence-unit-properties/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="reloadable">
+ <jta-data-source>My Default DataSource</jta-data-source>
+ <class>org.superbiz.reloadable.pu.Person</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ <property name="openjpa.Log" value="SQL=TRACE"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/reload-persistence-unit-properties/src/test/java/org/superbiz/reloadable/pu/CacheActivationTest.java b/content/examples/reload-persistence-unit-properties/src/test/java/org/superbiz/reloadable/pu/CacheActivationTest.java
new file mode 100755
index 0000000..7b3c521
--- /dev/null
+++ b/content/examples/reload-persistence-unit-properties/src/test/java/org/superbiz/reloadable/pu/CacheActivationTest.java
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.reloadable.pu;
+
+import org.apache.openejb.monitoring.LocalMBeanServer;
+import org.apache.openjpa.persistence.StoreCacheImpl;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.naming.NamingException;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import java.lang.management.ManagementFactory;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class CacheActivationTest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CacheActivationTest.class);
+
+ private static EJBContainer container;
+
+ @EJB
+ private PersonManager mgr;
+
+ @PersistenceUnit
+ private EntityManagerFactory emf;
+
+ @BeforeClass
+ public static void start() {
+ final Properties properties = new Properties();
+ properties.setProperty(LocalMBeanServer.OPENEJB_JMX_ACTIVE, Boolean.TRUE.toString());
+ container = EJBContainer.createEJBContainer(properties);
+ }
+
+ @Before
+ public void inject() throws NamingException {
+ container.getContext().bind("inject", this);
+ }
+
+ @AfterClass
+ public static void shutdown() {
+ if (container != null) {
+ container.close();
+ }
+ }
+
+ @Test
+ public void activeCacheAtRuntime() throws Exception {
+ LOGGER.info("TEST, data initialization");
+ final Person person = mgr.createUser("user #1");
+ final long personId = person.getId();
+ LOGGER.info("TEST, end of data initialization\n\n");
+
+ assertNull(((StoreCacheImpl) emf.getCache()).getDelegate());
+ LOGGER.info("TEST, doing some queries without cache");
+ query(personId);
+ LOGGER.info("TEST, queries without cache done\n\n");
+
+ activateCache();
+
+ assertNotNull(((StoreCacheImpl) emf.getCache()).getDelegate());
+ LOGGER.info("TEST, doing some queries with cache");
+ query(personId);
+ LOGGER.info("TEST, queries with cache done\n\n");
+ }
+
+ private void activateCache() throws Exception {
+ ObjectName on = new ObjectName("openejb.management:ObjectType=persistence-unit,PersistenceUnit=reloadable");
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ server.invoke(on, "setProperty", new Object[]{"openjpa.DataCache", "true"}, null);
+ server.invoke(on, "setProperty", new Object[]{"openjpa.RemoteCommitProvider", "sjvm"}, null);
+ server.invoke(on, "setSharedCacheMode", new Object[]{"ALL"}, null);
+ server.invoke(on, "reload", new Object[0], null);
+ }
+
+ private void query(long personId) {
+ for (int i = 0; i < 3; i++) { // some multiple time to get if cache works or not
+ Person found = mgr.search(personId);
+ assertNotNull(found);
+ assertEquals(personId, found.getId());
+ }
+ }
+}
diff --git a/content/examples/resources-declared-in-webapp.html b/content/examples/resources-declared-in-webapp.html
new file mode 100644
index 0000000..c7c8db4
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp.html
@@ -0,0 +1,347 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/resources-declared-in-webapp.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Resources Declared in Webapp</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example resources-declared-in-webapp can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/resources-declared-in-webapp" class="bare">https://github.com/apache/tomee/tree/master/examples/resources-declared-in-webapp</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_manager">Manager</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.bean;
+
+import org.superbiz.resource.ManagerResource;
+
+import javax.annotation.Resource;
+import javax.ejb.Singleton;
+
+@Singleton
+public class Manager {
+ @Resource(name = "My Manager Team", type = ManagerResource.class)
+ private ManagerResource resource;
+
+ public String work() {
+ return "manage a resource of type " + resource.resourceType();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_managerresource">ManagerResource</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.resource;
+
+public class ManagerResource {
+ public String resourceType() {
+ return "team";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_managerservlet">ManagerServlet</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.servlet;
+
+import org.superbiz.bean.Manager;
+
+import javax.ejb.EJB;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebServlet(name = "manager servlet", urlPatterns = "/")
+public class ManagerServlet extends HttpServlet {
+ @EJB
+ private Manager manager;
+
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.getOutputStream().print(manager.work());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ejb-jar/></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_service_jar_xml">service-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ServiceJar>
+ <ServiceProvider id="ManagerResource" service="Resource"
+ type="org.superbiz.resource.ManagerResource"
+ class-name="org.superbiz.resource.ManagerResource"/>
+</ServiceJar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_resources_xml">resources.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><resources>
+ <Resource id="My Manager Team" type="org.superbiz.resource.ManagerResource" provider="org.superbiz#ManagerResource"/>
+</resources></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_web_xml">web.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<web-app version="3.0" 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/web-app_3_0.xsd"/></code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/resources-declared-in-webapp.pdf b/content/examples/resources-declared-in-webapp.pdf
new file mode 100644
index 0000000..c8a76d7
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp.pdf
Binary files differ
diff --git a/content/examples/resources-declared-in-webapp/README.md b/content/examples/resources-declared-in-webapp/README.md
new file mode 100755
index 0000000..6f50839
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp/README.md
@@ -0,0 +1,116 @@
+Title: Resources Declared in Webapp
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Manager
+
+ package org.superbiz.bean;
+
+ import org.superbiz.resource.ManagerResource;
+
+ import javax.annotation.Resource;
+ import javax.ejb.Singleton;
+
+ @Singleton
+ public class Manager {
+ @Resource(name = "My Manager Team", type = ManagerResource.class)
+ private ManagerResource resource;
+
+ public String work() {
+ return "manage a resource of type " + resource.resourceType();
+ }
+ }
+
+## ManagerResource
+
+ package org.superbiz.resource;
+
+ public class ManagerResource {
+ public String resourceType() {
+ return "team";
+ }
+ }
+
+## ManagerServlet
+
+ package org.superbiz.servlet;
+
+ import org.superbiz.bean.Manager;
+
+ import javax.ejb.EJB;
+ import javax.servlet.ServletException;
+ import javax.servlet.annotation.WebServlet;
+ import javax.servlet.http.HttpServlet;
+ import javax.servlet.http.HttpServletRequest;
+ import javax.servlet.http.HttpServletResponse;
+ import java.io.IOException;
+
+ @WebServlet(name = "manager servlet", urlPatterns = "/")
+ public class ManagerServlet extends HttpServlet {
+ @EJB
+ private Manager manager;
+
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.getOutputStream().print(manager.work());
+ }
+ }
+
+## ejb-jar.xml
+
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+ <ejb-jar/>
+
+
+## service-jar.xml
+
+ <ServiceJar>
+ <ServiceProvider id="ManagerResource" service="Resource"
+ type="org.superbiz.resource.ManagerResource"
+ class-name="org.superbiz.resource.ManagerResource"/>
+ </ServiceJar>
+
+
+## resources.xml
+
+ <resources>
+ <Resource id="My Manager Team" type="org.superbiz.resource.ManagerResource" provider="org.superbiz#ManagerResource"/>
+ </resources>
+
+
+## web.xml
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+ <web-app version="3.0" 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/web-app_3_0.xsd"/>
+
diff --git a/content/examples/resources-declared-in-webapp/pom.xml b/content/examples/resources-declared-in-webapp/pom.xml
new file mode 100755
index 0000000..2f89653
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp/pom.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>resources-declared-in-webapp</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: Resource Declared In A Webapp</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ <repository>
+ <id>tomcat-m2-repo</id>
+ <name>Tomcat Dev Repository</name>
+ <url>http://tomcat.apache.org/dev/dist/m2-repository/</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1.1</version>
+ <configuration>
+ <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.googlecode.t7mp</groupId>
+ <artifactId>maven-t7-plugin</artifactId>
+ <version>0.9.7</version>
+ <configuration>
+ <tomcatHttpPort>1234</tomcatHttpPort>
+ <tomcatShutdownPort>13245</tomcatShutdownPort>
+ <tomcatVersion>7.0.27</tomcatVersion>
+ <webapps>
+ <webappArtifact>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-tomcat-plus-webapp</artifactId>
+ <version>${openejb.version}</version>
+ <contextPath>openejb</contextPath>
+ </webappArtifact>
+ </webapps>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/resources-declared-in-webapp/src/main/java/org/superbiz/bean/Manager.java b/content/examples/resources-declared-in-webapp/src/main/java/org/superbiz/bean/Manager.java
new file mode 100755
index 0000000..0b2eab0
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp/src/main/java/org/superbiz/bean/Manager.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.bean;
+
+import org.superbiz.resource.ManagerResource;
+
+import javax.annotation.Resource;
+import javax.ejb.Singleton;
+
+@Singleton
+public class Manager {
+
+ @Resource(name = "My Manager Team", type = ManagerResource.class)
+ private ManagerResource resource;
+
+ public String work() {
+ return "manage a resource of type " + resource.resourceType();
+ }
+}
diff --git a/content/examples/resources-declared-in-webapp/src/main/java/org/superbiz/resource/ManagerResource.java b/content/examples/resources-declared-in-webapp/src/main/java/org/superbiz/resource/ManagerResource.java
new file mode 100755
index 0000000..4008baa
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp/src/main/java/org/superbiz/resource/ManagerResource.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.resource;
+
+public class ManagerResource {
+
+ public String resourceType() {
+ return "team";
+ }
+}
diff --git a/content/examples/resources-declared-in-webapp/src/main/java/org/superbiz/servlet/ManagerServlet.java b/content/examples/resources-declared-in-webapp/src/main/java/org/superbiz/servlet/ManagerServlet.java
new file mode 100755
index 0000000..05706a2
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp/src/main/java/org/superbiz/servlet/ManagerServlet.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.servlet;
+
+import org.superbiz.bean.Manager;
+
+import javax.ejb.EJB;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@WebServlet(name = "manager servlet", urlPatterns = "/")
+public class ManagerServlet extends HttpServlet {
+
+ @EJB
+ private Manager manager;
+
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.getOutputStream().print(manager.work());
+ }
+}
diff --git a/content/examples/resources-declared-in-webapp/src/main/resources/META-INF/ejb-jar.xml b/content/examples/resources-declared-in-webapp/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..bd9ba53
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ejb-jar/>
diff --git a/content/examples/resources-declared-in-webapp/src/main/resources/META-INF/org.superbiz/service-jar.xml b/content/examples/resources-declared-in-webapp/src/main/resources/META-INF/org.superbiz/service-jar.xml
new file mode 100755
index 0000000..46b4fdb
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp/src/main/resources/META-INF/org.superbiz/service-jar.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev$ -->
+<ServiceJar>
+ <ServiceProvider id="ManagerResource" service="Resource"
+ type="org.superbiz.resource.ManagerResource"
+ class-name="org.superbiz.resource.ManagerResource"/>
+</ServiceJar>
diff --git a/content/examples/resources-declared-in-webapp/src/main/resources/META-INF/resources.xml b/content/examples/resources-declared-in-webapp/src/main/resources/META-INF/resources.xml
new file mode 100755
index 0000000..dbb7d9c
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp/src/main/resources/META-INF/resources.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <Resource id="My Manager Team" type="org.superbiz.resource.ManagerResource" provider="org.superbiz#ManagerResource"/>
+</resources>
diff --git a/content/examples/resources-declared-in-webapp/src/main/webapp/WEB-INF/web.xml b/content/examples/resources-declared-in-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..4b5e733
--- /dev/null
+++ b/content/examples/resources-declared-in-webapp/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<web-app version="3.0" 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/web-app_3_0.xsd"/>
diff --git a/content/examples/resources-jmx-example.html b/content/examples/resources-jmx-example.html
new file mode 100644
index 0000000..35594a7
--- /dev/null
+++ b/content/examples/resources-jmx-example.html
@@ -0,0 +1,1124 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/resources-jmx-example.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Custom resources in an EAR archive</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example resources-jmx-example can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/resources-jmx-example" class="bare">https://github.com/apache/tomee/tree/master/examples/resources-jmx-example</a></p>
+</div>
+<div class="paragraph">
+<p>TomEE allows you to define your own resources within your application, and declare them in <code>META-INF/resources.xml</code>. This allows you do inject these resource into any managed component within your application.</p>
+</div>
+<div class="paragraph">
+<p>In addition to this, you can also define a <code>create</code> method on either the resource itself, or on a POJO that acts as a factory. This example demonstrates using the <code>create</code> method to additionally register the resource as a JMX MBean, as well as make it available for injection.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_resource">Resource</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Custom resources can be defined using very simple Java classes. In this particular instance, as the application also wants to register this resource as an MBean, the resource class needs to follow the MBean specification.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public class Hello implements HelloMBean {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>private AtomicInteger count = new AtomicInteger(0);</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Override
+public String greet(String name) {
+ if (name == null) {
+ throw new NullPointerException("Name cannot be null");
+ }</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> return "Hello, " + name;
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Override
+public int getCount() {
+ return count.get();
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Override
+public void setCount(int value) {
+ count.set(value);
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> @Override
+ public void increment() {
+ count.incrementAndGet();
+ }
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public interface HelloMBean {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public String greet(final String name);</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public int getCount();</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public void setCount(int count);</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public void increment();</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_create_method">Create method</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>To avoid adding the logic to register the resource as an MBean in every resource, the application provides a single class with a create() method that takes care of this logic for us.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public class JMXBeanCreator {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>private static Logger LOGGER = Logger.getLogger(JMXBeanCreator.class.getName());
+private Properties properties;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public Object create() throws MBeanRegistrationException {
+ // instantiate the bean</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>final String code = properties.getProperty("code");
+final String name = properties.getProperty("name");</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>requireNotNull(code);
+requireNotNull(name);</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>try {
+ final Class<?> cls = Class.forName(code, true, Thread.currentThread().getContextClassLoader());
+ final Object instance = cls.newInstance();</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>final Field[] fields = cls.getDeclaredFields();
+for (final Field field : fields) {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>final String property = properties.getProperty(field.getName());
+if (property == null) {
+ continue;
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> try {
+ field.setAccessible(true);
+ field.set(instance, Converter.convert(property, field.getType(), field.getName()));
+ } catch (Exception e) {
+ LOGGER.info(String.format("Unable to set value %s on field %s", property, field.getName()));
+ }
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+final ObjectName objectName = new ObjectName(name);
+mbs.registerMBean(instance, objectName);</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>return instance;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> } catch (final ClassNotFoundException e) {
+ LOGGER.severe("Unable to find class " + code);
+ throw new MBeanRegistrationException(e);
+ } catch (final InstantiationException e) {
+ LOGGER.severe("Unable to create instance of class " + code);
+ throw new MBeanRegistrationException(e);
+ } catch (final IllegalAccessException e) {
+ LOGGER.severe("Illegal access: " + code);
+ throw new MBeanRegistrationException(e);
+ } catch (final MalformedObjectNameException e) {
+ LOGGER.severe("Malformed MBean name: " + name);
+ throw new MBeanRegistrationException(e);
+ } catch (final InstanceAlreadyExistsException e) {
+ LOGGER.severe("Instance already exists: " + name);
+ throw new MBeanRegistrationException(e);
+ } catch (final NotCompliantMBeanException e) {
+ LOGGER.severe("Class is not a valid MBean: " + code);
+ throw new MBeanRegistrationException(e);
+ } catch (final javax.management.MBeanRegistrationException e) {
+ LOGGER.severe("Error registering " + name + ", " + code);
+ throw new MBeanRegistrationException(e);
+ }
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>private void requireNotNull(final String object) throws MBeanRegistrationException {
+ if (object == null) {
+ throw new MBeanRegistrationException("code property not specified, stopping");
+ }
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public Properties getProperties() {
+ return properties;
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> public void setProperties(final Properties properties) {
+ this.properties = properties;
+ }
+}</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Note that this class uses the properties defined in the <Resource> configuration (below), combined with reflection, to instantiate the resource, and set its attributes. The code above requires two properties <code>code</code> and <code>name</code> in order to know what class to create, and the JMX name to register it under.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_resource_2">Resource</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The resource can be defined in <code>META-INF/resources.xml</code> as follows:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><Resources>
+ <Resource id="Hello" class-name="org.superbiz.resource.jmx.factory.JMXBeanCreator" factory-name="create">
+ code org.superbiz.resource.jmx.resources.Hello
+ name superbiz.test:name=Hello
+ count 12345
+ </Resource>
+</Resources></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Note that the class-name attribute refers to the factory class, and not the resource. Once the resource has been created and bound in TomEE’s JNDI tree the factory is no longer used.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_using_resource_for_injection">Using @Resource for injection</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The test case for this example demonstrates injection into an EJB as one way of accessing the resource, and also accessing the resource via JMX.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@RunWith(Arquillian.class)
+public class JMXTest {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@EJB
+private TestEjb ejb;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Deployment
+public static EnterpriseArchive createDeployment() {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>final JavaArchive ejbJar = new Mvn.Builder()
+ .name("jmx-ejb.jar")
+ .build(JavaArchive.class)
+ .addClass(JMXTest.class)
+ .addClass(TestEjb.class);</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jmx.ear")
+ .addAsModule(ejbJar);</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> return ear;
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Test
+public void test() throws Exception {
+ final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ final ObjectName objectName = new ObjectName("superbiz.test:name=Hello");</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Assert.assertNotNull(ejb);</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Assert.assertEquals(0, mbs.getAttribute(objectName, "Count"));
+Assert.assertEquals(0, ejb.getCount());</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>mbs.invoke(objectName, "increment", new Object[0], new String[0]);
+Assert.assertEquals(1, mbs.getAttribute(objectName, "Count"));
+Assert.assertEquals(1, ejb.getCount());</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>ejb.increment();
+Assert.assertEquals(2, mbs.getAttribute(objectName, "Count"));
+Assert.assertEquals(2, ejb.getCount());</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Attribute attribute = new Attribute("Count", 12345);
+mbs.setAttribute(objectName, attribute);
+Assert.assertEquals(12345, mbs.getAttribute(objectName, "Count"));
+Assert.assertEquals(12345, ejb.getCount());</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>ejb.setCount(23456);
+Assert.assertEquals(23456, mbs.getAttribute(objectName, "Count"));
+Assert.assertEquals(23456, ejb.getCount());</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> Assert.assertEquals("Hello, world", mbs.invoke(objectName, "greet", new Object[] { "world" }, new String[] { String.class.getName() }));
+ Assert.assertEquals("Hello, world", ejb.greet("world"));
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Singleton
+@Lock(LockType.READ)
+public static class TestEjb {</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Resource(name="jmx/Hello")
+private HelloMBean helloMBean;</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public String greet(String name) {
+ return helloMBean.greet(name);
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public void setCount(int count) {
+ helloMBean.setCount(count);
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public void increment() {
+ helloMBean.increment();
+}</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre> public int getCount() {
+ return helloMBean.getCount();
+ }
+ }
+}</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The name <code><appname>/<resource-id></code> attribute is used on the <code>@Resource</code> annotation to perform the injection. No further configuration is needed to inject the resource.</p>
+</div>
+</div>
+</div>
+<h1 id="_additional_properties" class="sect0">Additional properties</h1>
+<div class="paragraph">
+<p>In addition to the <code>code</code> and <code>name</code> properties that the code above uses to instantiate the resource, TomEE itself provides some
+properties to provide more control over the creation of resources.</p>
+</div>
+<div class="paragraph">
+<p>Resources are typically discovered, created, and bound to JNDI very early on in the deployment process, as other components depend on them. This may lead to problems where the final classpath for the application has not yet been determined, and therefore TomEE is unable to load your custom resource.</p>
+</div>
+<div class="paragraph">
+<p>The following properties can be used to change this behavior.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Lazy</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>This is a boolean value, which when true, creates a proxy that defers the actual instantiation of the resource until the first time it is looked up from JNDI. This can be useful if the resource requires the application classpath, or to improve startup time by not fully initializing resources that might not be used.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>UseAppClassLoader</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>This boolean value forces a lazily instantiated resource to use the application classloader, instead of the classloader available when the resources were first processed.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>InitializeAfterDeployment</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>This boolean setting forces a resource created with the Lazy property to be instantiated once the application has started, as opposed to waiting for it to be looked up. Use this flag if you require the resource to be loaded, irrespective of whether it is injected into a managed component or manually looked up.</p>
+</div>
+<div class="paragraph">
+<p>By default, all of these settings are <code>false</code>, unless TomEE encounters a custom application resource that cannot be instantiated until the application has started. In this case, it will set these three flags to <code>true</code>, unless the <code>Lazy</code> flag has been explicitly set.</p>
+</div>
+<h1 id="_postconstruct_predestroy" class="sect0">PostConstruct / PreDestroy</h1>
+<div class="paragraph">
+<p>As an alternative to using a factory method, you can use @PostConstruct and @PreDestroy methods within your resource class (note that you cannot use this within a factory class) to manage any additional creation or cleanup activities. TomEE will automatically call these methods when the application is started and destroyed. Using @PostConstruct will effectively force a lazily loaded resource to be instantiated when the application is starting - in the same way that the <code>InitializeAfterDeployment</code> property does.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class Alternative implements AlternativeMBean {
+
+ private static Logger LOGGER = Logger.getLogger(Alternative.class.getName());
+ private Properties properties;
+
+ @PostConstruct
+ public void postConstruct() throws MBeanRegistrationException {
+ // initialize the bean
+
+ final String code = properties.getProperty("code");
+ final String name = properties.getProperty("name");
+
+ requireNotNull(code);
+ requireNotNull(name);
+
+ try {
+ final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ final ObjectName objectName = new ObjectName(name);
+ mbs.registerMBean(this, objectName);
+ } catch (final MalformedObjectNameException e) {
+ LOGGER.severe("Malformed MBean name: " + name);
+ throw new MBeanRegistrationException(e);
+ } catch (final InstanceAlreadyExistsException e) {
+ LOGGER.severe("Instance already exists: " + name);
+ throw new MBeanRegistrationException(e);
+ } catch (final NotCompliantMBeanException e) {
+ LOGGER.severe("Class is not a valid MBean: " + code);
+ throw new MBeanRegistrationException(e);
+ } catch (final javax.management.MBeanRegistrationException e) {
+ LOGGER.severe("Error registering " + name + ", " + code);
+ throw new MBeanRegistrationException(e);
+ }
+ }
+
+ @PreDestroy
+ public void preDestroy() throws MBeanRegistrationException {
+ final String name = properties.getProperty("name");
+ requireNotNull(name);
+
+ try {
+ final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ final ObjectName objectName = new ObjectName(name);
+ mbs.unregisterMBean(objectName);
+ } catch (final MalformedObjectNameException e) {
+ LOGGER.severe("Malformed MBean name: " + name);
+ throw new MBeanRegistrationException(e);
+ } catch (final javax.management.MBeanRegistrationException e) {
+ LOGGER.severe("Error unregistering " + name);
+ throw new MBeanRegistrationException(e);
+ } catch (InstanceNotFoundException e) {
+ LOGGER.severe("Error unregistering " + name);
+ throw new MBeanRegistrationException(e);
+ }
+ }
+
+ private void requireNotNull(final String object) throws MBeanRegistrationException {
+ if (object == null) {
+ throw new MBeanRegistrationException("code property not specified, stopping");
+ }
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(final Properties properties) {
+ this.properties = properties;
+ }
+
+ private int count = 0;
+
+ @Override
+ public String greet(String name) {
+ if (name == null) {
+ throw new NullPointerException("Name cannot be null");
+ }
+
+ return "Hello, " + name;
+ }
+
+ @Override
+ public int getCount() {
+ return count;
+ }
+
+ @Override
+ public void setCount(int value) {
+ count = value;
+ }
+
+ @Override
+ public void increment() {
+ count++;
+ }
+}</code></pre>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>Running the example can be done from maven with a simple 'mvn clean install' command run from the 'resources-jmx-example' directory.</p>
+</div>
+<div class="paragraph">
+<p>When run you should see output similar to the following.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.resource.jmx.JMXTest
+Apr 15, 2015 12:40:09 PM org.jboss.arquillian.container.impl.MapObject populate
+WARNING: Configuration contain properties not supported by the backing object org.apache.tomee.arquillian.remote.RemoteTomEEConfiguration
+Unused property entries: {openejbVersion=${tomee.version}, tomcatVersion=}
+Supported property names: [additionalLibs, httpPort, httpsPort, stopCommand, portRange, conf, debug, exportConfAsSystemProperty, type, unpackWars, version, serverXml, preloadClasses, dir, deployerProperties, stopPort, singleDumpByArchiveName, appWorkingDir, host, cleanOnStartUp, quickSession, ajpPort, artifactId, properties, singleDeploymentByArchiveName, groupId, stopHost, lib, catalina_opts, debugPort, webContextToUseWithEars, simpleLog, removeUnusedWebapps, keepServerXmlAsThis, classifier, bin]
+Apr 15, 2015 12:40:09 PM org.apache.openejb.arquillian.common.Setup findHome
+INFO: Unable to find home in: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote
+Apr 15, 2015 12:40:09 PM org.apache.openejb.arquillian.common.MavenCache getArtifact
+INFO: Downloading org.apache.openejb:apache-tomee:7.0.0-SNAPSHOT:zip:plus please wait...
+Apr 15, 2015 12:40:10 PM org.apache.openejb.arquillian.common.Zips unzip
+INFO: Extracting '/Users/jgallimore/.m2/repository/org/apache/openejb/apache-tomee/7.0.0-SNAPSHOT/apache-tomee-7.0.0-SNAPSHOT-plus.zip' to '/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote'
+Apr 15, 2015 12:40:12 PM org.apache.tomee.arquillian.remote.RemoteTomEEContainer configure
+INFO: Downloaded container to: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT
+Started server process on port: 61309
+objc[20102]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Server version: Apache Tomcat (TomEE)/7.0.61 (7.0.0-SNAPSHOT)
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Server built: Mar 27 2015 12:03:56 UTC
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Server number: 7.0.61.0
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: OS Name: Mac OS X
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: OS Version: 10.9.5
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Architecture: x86_64
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Java Home: /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: JVM Version: 1.7.0_71-b14
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: JVM Vendor: Oracle Corporation
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: CATALINA_BASE: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: CATALINA_HOME: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -XX:+HeapDumpOnOutOfMemoryError
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -XX:PermSize=64m
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -XX:MaxPermSize=256m
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Xmx512m
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Xms256m
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -XX:ReservedCodeCacheSize=64m
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Dtomee.httpPort=61309
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Dorg.apache.openejb.servlet.filters=org.apache.openejb.arquillian.common.ArquillianFilterRunner=/ArquillianServletRunner
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Djava.util.logging.config.file=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT/conf/logging.properties
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -javaagent:/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT/lib/openejb-javaagent.jar
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Djava.io.tmpdir=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT/temp
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Djava.endorsed.dirs=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT/endorsed
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Dcatalina.base=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Dcatalina.home=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Dcatalina.ext.dirs=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT/lib
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -Dorg.apache.tomcat.util.http.ServerCookie.ALLOW_HTTP_SEPARATORS_IN_V0=true
+Apr 15, 2015 12:40:14 PM org.apache.catalina.startup.VersionLoggerListener log
+INFO: Command line argument: -ea
+Apr 15, 2015 12:40:14 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
+INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/jgallimore/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
+Apr 15, 2015 12:40:14 PM org.apache.coyote.AbstractProtocol init
+INFO: Initializing ProtocolHandler ["http-bio-61309"]
+Apr 15, 2015 12:40:14 PM org.apache.coyote.AbstractProtocol init
+INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
+Apr 15, 2015 12:40:16 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: ********************************************************************************
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: OpenEJB http://tomee.apache.org/
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: Startup: Wed Apr 15 12:40:16 BST 2015
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: Version: 7.0.0-SNAPSHOT
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: Build date: 20150415
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: Build time: 11:37
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: ********************************************************************************
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: openejb.home = /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT
+Apr 15, 2015 12:40:16 PM org.apache.openejb.OpenEJB$Instance <init>
+INFO: openejb.base = /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT
+Apr 15, 2015 12:40:16 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
+INFO: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@4a00b74b
+Apr 15, 2015 12:40:16 PM org.apache.openejb.cdi.CdiBuilder initializeOWB
+INFO: Succeeded in installing singleton service
+Apr 15, 2015 12:40:17 PM org.apache.openejb.config.ConfigurationFactory init
+INFO: openejb configuration file is '/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT/conf/tomee.xml'
+Apr 15, 2015 12:40:17 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
+Apr 15, 2015 12:40:17 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+Apr 15, 2015 12:40:17 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.system.apps=true'
+Apr 15, 2015 12:40:17 PM org.apache.openejb.config.ConfigurationFactory configureApplication
+INFO: Configuring enterprise application: openejb
+Apr 15, 2015 12:40:17 PM org.apache.openejb.config.InitEjbDeployments deploy
+INFO: Using openejb.deploymentId.format '{ejbName}'
+Apr 15, 2015 12:40:17 PM org.apache.openejb.config.InitEjbDeployments deploy
+INFO: Auto-deploying ejb openejb/Deployer: EjbDeployment(deployment-id=openejb/Deployer)
+Apr 15, 2015 12:40:17 PM org.apache.openejb.config.InitEjbDeployments deploy
+INFO: Auto-deploying ejb openejb/ConfigurationInfo: EjbDeployment(deployment-id=openejb/ConfigurationInfo)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.config.InitEjbDeployments deploy
+INFO: Auto-deploying ejb MEJB: EjbDeployment(deployment-id=MEJB)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.config.AutoConfig createContainer
+INFO: Auto-creating a container for bean openejb/Deployer: Container(type=STATELESS, id=Default Stateless Container)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.config.AppInfoBuilder build
+INFO: Enterprise application "openejb" loaded.
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating TransactionManager(id=Default Transaction Manager)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating SecurityService(id=Tomcat Security Service)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating Container(id=Default Stateless Container)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createAppClassLoader
+INFO: Not creating another application classloader for openejb
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.Assembler createApplication
+INFO: Assembling app: openejb
+Apr 15, 2015 12:40:18 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.jndiname.format={deploymentId}{interfaceType.openejbLegacyName}'
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=openejb/DeployerBusinessRemote) --> Ejb(deployment-id=openejb/Deployer)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/openejb/openejb/Deployer!org.apache.openejb.assembler.Deployer) --> Ejb(deployment-id=openejb/Deployer)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/openejb/openejb/Deployer) --> Ejb(deployment-id=openejb/Deployer)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=openejb/ConfigurationInfoBusinessRemote) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/openejb/openejb/ConfigurationInfo!org.apache.openejb.assembler.classic.cmd.ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+Apr 15, 2015 12:40:18 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/openejb/openejb/ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=MEJB) --> Ejb(deployment-id=MEJB)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/openejb/MEJB!javax.management.j2ee.ManagementHome) --> Ejb(deployment-id=MEJB)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/openejb/MEJB) --> Ejb(deployment-id=MEJB)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Created Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Created Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Created Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Started Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=Default Stateless Container)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Started Ejb(deployment-id=MEJB, ejb-name=MEJB, container=Default Stateless Container)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Started Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=Default Stateless Container)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler deployMBean
+INFO: Deployed MBean(openejb.user.mbeans:application=openejb,group=org.apache.openejb.assembler.monitoring,name=JMXDeployer)
+Apr 15, 2015 12:40:19 PM org.apache.openejb.assembler.classic.Assembler createApplication
+INFO: Deployed Application(path=openejb)
+Apr 15, 2015 12:40:20 PM org.apache.openejb.server.ServiceManager initServer
+INFO: Creating ServerService(id=cxf)
+Apr 15, 2015 12:40:20 PM org.apache.openejb.server.ServiceManager initServer
+INFO: Creating ServerService(id=cxf-rs)
+Apr 15, 2015 12:40:20 PM org.apache.openejb.server.SimpleServiceManager start
+INFO: ** Bound Services **
+Apr 15, 2015 12:40:20 PM org.apache.openejb.server.SimpleServiceManager printRow
+INFO: NAME IP PORT
+Apr 15, 2015 12:40:20 PM org.apache.openejb.server.SimpleServiceManager start
+INFO: -------
+Apr 15, 2015 12:40:20 PM org.apache.openejb.server.SimpleServiceManager start
+INFO: Ready!
+Apr 15, 2015 12:40:20 PM org.apache.catalina.startup.Catalina load
+INFO: Initialization processed in 7621 ms
+Apr 15, 2015 12:40:20 PM org.apache.tomee.catalina.OpenEJBNamingContextListener bindResource
+INFO: Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
+Apr 15, 2015 12:40:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating Resource(id=UserDatabase)
+Apr 15, 2015 12:40:20 PM org.apache.catalina.core.StandardService startInternal
+INFO: Starting service Catalina
+Apr 15, 2015 12:40:20 PM org.apache.catalina.core.StandardEngine startInternal
+INFO: Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.61 (7.0.0-SNAPSHOT)
+Apr 15, 2015 12:40:21 PM org.apache.coyote.AbstractProtocol start
+INFO: Starting ProtocolHandler ["http-bio-61309"]
+Apr 15, 2015 12:40:21 PM org.apache.coyote.AbstractProtocol start
+INFO: Starting ProtocolHandler ["ajp-bio-8009"]
+Apr 15, 2015 12:40:21 PM org.apache.catalina.startup.Catalina start
+INFO: Server startup in 247 ms
+Apr 15, 2015 12:40:21 PM org.apache.openejb.client.EventLogger log
+INFO: RemoteInitialContextCreated{providerUri=http://localhost:61309/tomee/ejb}
+Apr 15, 2015 12:40:21 PM org.apache.openejb.util.JarExtractor extract
+INFO: Extracting jar: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx.ear
+Apr 15, 2015 12:40:21 PM org.apache.openejb.util.JarExtractor extract
+INFO: Extracted path: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+Apr 15, 2015 12:40:21 PM org.apache.openejb.util.JarExtractor extract
+INFO: Extracting jar: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx/arquillian-protocol.war
+Apr 15, 2015 12:40:21 PM org.apache.openejb.util.JarExtractor extract
+INFO: Extracted path: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx/arquillian-protocol
+Apr 15, 2015 12:40:21 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.deployments.classpath.filter.systemapps=false'
+Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+Apr 15, 2015 12:40:23 PM org.apache.openejb.config.DeploymentsResolver processUrls
+INFO: Found EjbModule in classpath: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx/jmx-ejb.jar
+Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+Apr 15, 2015 12:40:23 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.default.deployment-module=org.apache.openejb.config.WebModule'
+Apr 15, 2015 12:40:23 PM org.apache.openejb.config.DeploymentsResolver loadFromClasspath
+INFO: Searched 6 classpath urls in 1605 milliseconds. Average 267 milliseconds per url.
+Apr 15, 2015 12:40:23 PM org.apache.openejb.config.ConfigurationFactory configureApplication
+INFO: Configuring enterprise application: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.InitEjbDeployments deploy
+INFO: Auto-deploying ejb TestEjb: EjbDeployment(deployment-id=TestEjb)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=jmx/Hello, type=Resource, provider-id=jmx/Hello)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig createContainer
+INFO: Auto-creating a container for bean jmx-ejb.Comp1256115069: Container(type=MANAGED, id=Default Managed Container)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating Container(id=Default Managed Container)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.core.managed.SimplePassivater init
+INFO: Using directory /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/apache-tomee-remote/apache-tomee-plus-7.0.0-SNAPSHOT/temp for stateful session passivation
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'java:comp/env/jmx/Hello' in bean jmx-ejb.Comp1256115069 to Resource(id=jmx/Hello)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'openejb/Resource/jmx/Hello' in bean jmx-ejb.Comp1256115069 to Resource(id=Hello)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'openejb/Resource/Hello' in bean jmx-ejb.Comp1256115069 to Resource(id=Hello)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig createContainer
+INFO: Auto-creating a container for bean TestEjb: Container(type=SINGLETON, id=Default Singleton Container)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating Container(id=Default Singleton Container)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'java:comp/env/jmx/Hello' in bean TestEjb to Resource(id=jmx/Hello)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'openejb/Resource/jmx/Hello' in bean TestEjb to Resource(id=Hello)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'openejb/Resource/Hello' in bean TestEjb to Resource(id=Hello)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'openejb/Resource/jmx/Hello' in bean jmx_org.superbiz.resource.jmx.JMXTest to Resource(id=Hello)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AutoConfig processResourceRef
+INFO: Auto-linking resource-ref 'openejb/Resource/Hello' in bean jmx_org.superbiz.resource.jmx.JMXTest to Resource(id=Hello)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.config.AppInfoBuilder build
+INFO: Enterprise application "/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx" loaded.
+Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.Assembler createAppClassLoader
+INFO: Creating dedicated application classloader for jmx
+Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.Assembler createApplication
+INFO: Assembling app: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=TestEjbLocalBean) --> Ejb(deployment-id=TestEjb)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/jmx/jmx-ejb/TestEjb!org.superbiz.resource.jmx.JMXTest$TestEjb) --> Ejb(deployment-id=TestEjb)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.assembler.classic.JndiBuilder bind
+INFO: Jndi(name=global/jmx/jmx-ejb/TestEjb) --> Ejb(deployment-id=TestEjb)
+Apr 15, 2015 12:40:24 PM org.apache.openejb.cdi.CdiBuilder initSingleton
+INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@4a00b74b
+Apr 15, 2015 12:40:24 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+INFO: OpenWebBeans Container is starting...
+Apr 15, 2015 12:40:24 PM org.apache.webbeans.plugins.PluginLoader startUp
+INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
+Apr 15, 2015 12:40:24 PM org.apache.webbeans.plugins.PluginLoader startUp
+Apr 15, 2015 12:40:25 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
+INFO: All injection points were validated successfully.
+Apr 15, 2015 12:40:25 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+INFO: OpenWebBeans Container has started, it took 186 ms.
+Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Created Ejb(deployment-id=TestEjb, ejb-name=TestEjb, container=Default Singleton Container)
+Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler startEjbs
+INFO: Started Ejb(deployment-id=TestEjb, ejb-name=TestEjb, container=Default Singleton Container)
+Apr 15, 2015 12:40:25 PM org.apache.tomee.catalina.TomcatWebAppBuilder deployWebApps
+INFO: using default host: localhost
+Apr 15, 2015 12:40:25 PM org.apache.tomee.catalina.TomcatWebAppBuilder init
+INFO: ------------------------- localhost -> /arquillian-protocol
+Apr 15, 2015 12:40:25 PM org.apache.openejb.util.OptionsLog info
+INFO: Using 'openejb.session.manager=org.apache.tomee.catalina.session.QuickSessionManager'
+Apr 15, 2015 12:40:25 PM org.apache.openejb.cdi.CdiBuilder initSingleton
+INFO: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@4a00b74b
+Apr 15, 2015 12:40:25 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+INFO: OpenWebBeans Container is starting...
+Apr 15, 2015 12:40:25 PM org.apache.webbeans.plugins.PluginLoader startUp
+INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
+Apr 15, 2015 12:40:25 PM org.apache.webbeans.plugins.PluginLoader startUp
+Apr 15, 2015 12:40:25 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints
+INFO: All injection points were validated successfully.
+Apr 15, 2015 12:40:25 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication
+INFO: OpenWebBeans Container has started, it took 17 ms.
+Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler createRecipe
+INFO: Creating Resource(id=jmx/Hello, aliases=Hello)
+Apr 15, 2015 12:40:25 PM org.superbiz.resource.jmx.factory.JMXBeanCreator create
+INFO: Unable to set value 12345 on field count
+Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler logUnusedProperties
+WARNING: Property "code" not supported by "jmx/Hello"
+Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler logUnusedProperties
+WARNING: Property "name" not supported by "jmx/Hello"
+Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler logUnusedProperties
+WARNING: Property "count" not supported by "jmx/Hello"
+Apr 15, 2015 12:40:25 PM org.apache.openejb.assembler.classic.Assembler createApplication
+INFO: Deployed Application(path=/Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx)
+Apr 15, 2015 12:40:26 PM org.apache.openejb.client.EventLogger log
+INFO: RemoteInitialContextCreated{providerUri=http://localhost:61309/tomee/ejb}
+Apr 15, 2015 12:40:26 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
+INFO: Undeploying app: /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+Apr 15, 2015 12:40:27 PM org.apache.openejb.arquillian.common.TomEEContainer undeploy
+INFO: cleaning /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx.ear
+Apr 15, 2015 12:40:27 PM org.apache.openejb.arquillian.common.TomEEContainer undeploy
+INFO: cleaning /Users/jgallimore/tmp/tomee-1.7.x/examples/resources-jmx-example/resources-jmx-ejb/target/arquillian-test-working-dir/0/jmx
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 18.464 sec
+Apr 15, 2015 12:40:27 PM org.apache.catalina.core.StandardServer await
+INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
+Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol pause
+INFO: Pausing ProtocolHandler ["http-bio-61309"]
+Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol pause
+INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
+Apr 15, 2015 12:40:27 PM org.apache.catalina.core.StandardService stopInternal
+INFO: Stopping service Catalina
+Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol stop
+INFO: Stopping ProtocolHandler ["http-bio-61309"]
+Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol stop
+INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
+Apr 15, 2015 12:40:27 PM org.apache.openejb.server.SimpleServiceManager stop
+INFO: Stopping server services
+Apr 15, 2015 12:40:27 PM org.apache.openejb.assembler.classic.Assembler destroyApplication
+INFO: Undeploying app: openejb
+Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol destroy
+INFO: Destroying ProtocolHandler ["http-bio-61309"]
+Apr 15, 2015 12:40:27 PM org.apache.coyote.AbstractProtocol destroy
+INFO: Destroying ProtocolHandler ["ajp-bio-8009"]</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Results :</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Note the following lines showing the creation of the resource.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Apr 15, 2015 12:40:24 PM org.apache.openejb.config.ConfigurationFactory configureService
+INFO: Configuring Service(id=jmx/Hello, type=Resource, provider-id=jmx/Hello)</pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/resources-jmx-example.pdf b/content/examples/resources-jmx-example.pdf
new file mode 100644
index 0000000..e1975bb
--- /dev/null
+++ b/content/examples/resources-jmx-example.pdf
Binary files differ
diff --git a/content/examples/rest-applicationcomposer-mockito.html b/content/examples/rest-applicationcomposer-mockito.html
new file mode 100644
index 0000000..d068df1
--- /dev/null
+++ b/content/examples/rest-applicationcomposer-mockito.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/rest-applicationcomposer-mockito.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>rest-applicationcomposer-mockito</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example rest-applicationcomposer-mockito can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/rest-applicationcomposer-mockito" class="bare">https://github.com/apache/tomee/tree/master/examples/rest-applicationcomposer-mockito</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/rest-applicationcomposer-mockito.pdf b/content/examples/rest-applicationcomposer-mockito.pdf
new file mode 100644
index 0000000..98eee50
--- /dev/null
+++ b/content/examples/rest-applicationcomposer-mockito.pdf
Binary files differ
diff --git a/content/examples/rest-applicationcomposer-mockito/pom.xml b/content/examples/rest-applicationcomposer-mockito/pom.xml
new file mode 100755
index 0000000..1fa6876
--- /dev/null
+++ b/content/examples/rest-applicationcomposer-mockito/pom.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>rest-applicationcomposer-mockito</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: REST, Mockito and Application Composer</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-mockito</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/rest-applicationcomposer-mockito/src/main/java/org/superbiz/composed/rest/GreetingService.java b/content/examples/rest-applicationcomposer-mockito/src/main/java/org/superbiz/composed/rest/GreetingService.java
new file mode 100755
index 0000000..f5cffc4
--- /dev/null
+++ b/content/examples/rest-applicationcomposer-mockito/src/main/java/org/superbiz/composed/rest/GreetingService.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed.rest;
+
+import javax.ejb.Singleton;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Singleton
+@Path("/greeting")
+public class GreetingService {
+
+ @Inject
+ private Messager messager;
+
+ @GET
+ public String message() {
+ return messager.message();
+ }
+}
diff --git a/content/examples/rest-applicationcomposer-mockito/src/main/java/org/superbiz/composed/rest/Messager.java b/content/examples/rest-applicationcomposer-mockito/src/main/java/org/superbiz/composed/rest/Messager.java
new file mode 100755
index 0000000..64d5cd7
--- /dev/null
+++ b/content/examples/rest-applicationcomposer-mockito/src/main/java/org/superbiz/composed/rest/Messager.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed.rest;
+
+public interface Messager {
+
+ String message();
+}
diff --git a/content/examples/rest-applicationcomposer-mockito/src/main/resources/META-INF/beans.xml b/content/examples/rest-applicationcomposer-mockito/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..36b0a5d
--- /dev/null
+++ b/content/examples/rest-applicationcomposer-mockito/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans/>
diff --git a/content/examples/rest-applicationcomposer-mockito/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java b/content/examples/rest-applicationcomposer-mockito/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java
new file mode 100755
index 0000000..d66832a
--- /dev/null
+++ b/content/examples/rest-applicationcomposer-mockito/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed.rest;
+
+import org.apache.openejb.OpenEjbContainer;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.loader.IO;
+import org.apache.openejb.mockito.MockitoInjector;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.MockInjector;
+import org.apache.openejb.testing.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+
+ @Mock
+ private Messager messager;
+
+ @Configuration
+ public Properties configuration() {
+ return new Properties() {{
+ setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, Boolean.TRUE.toString());
+ }};
+ }
+
+ @MockInjector
+ public Class<?> mockitoInjector() {
+ return MockitoInjector.class;
+ }
+
+ @Module
+ public Class<?>[] app() {
+ return new Class<?>[]{GreetingService.class, Messager.class};
+ }
+
+ @Test
+ public void checkMockIsUsed() throws IOException {
+ when(messager.message()).thenReturn("mockito");
+
+ final String message = IO.slurp(new URL("http://localhost:4204/GreetingServiceTest/greeting/"));
+ assertEquals("mockito", message);
+ }
+}
diff --git a/content/examples/rest-applicationcomposer-mockito/src/test/resources/META-INF/beans.xml b/content/examples/rest-applicationcomposer-mockito/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..36b0a5d
--- /dev/null
+++ b/content/examples/rest-applicationcomposer-mockito/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans/>
diff --git a/content/examples/rest-applicationcomposer.html b/content/examples/rest-applicationcomposer.html
new file mode 100644
index 0000000..9cccc28
--- /dev/null
+++ b/content/examples/rest-applicationcomposer.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/rest-applicationcomposer.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>rest-applicationcomposer</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example rest-applicationcomposer can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/rest-applicationcomposer" class="bare">https://github.com/apache/tomee/tree/master/examples/rest-applicationcomposer</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/rest-applicationcomposer.pdf b/content/examples/rest-applicationcomposer.pdf
new file mode 100644
index 0000000..6e9c261
--- /dev/null
+++ b/content/examples/rest-applicationcomposer.pdf
Binary files differ
diff --git a/content/examples/rest-applicationcomposer/pom.xml b/content/examples/rest-applicationcomposer/pom.xml
new file mode 100755
index 0000000..b2fa1ac
--- /dev/null
+++ b/content/examples/rest-applicationcomposer/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>rest-applicationcomposer</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: REST and Application Composer</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/GreetingService.java b/content/examples/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/GreetingService.java
new file mode 100755
index 0000000..8435e7d
--- /dev/null
+++ b/content/examples/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/GreetingService.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("/greeting")
+public class GreetingService {
+
+ @GET
+ public String message() {
+ throw new IllegalArgumentException("this exception is handled by an exception mapper");
+ }
+}
diff --git a/content/examples/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/IllegalArgumentExceptionMapper.java b/content/examples/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/IllegalArgumentExceptionMapper.java
new file mode 100755
index 0000000..d7d35f0
--- /dev/null
+++ b/content/examples/rest-applicationcomposer/src/main/java/org/superbiz/composed/rest/IllegalArgumentExceptionMapper.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed.rest;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class IllegalArgumentExceptionMapper implements ExceptionMapper<java.lang.IllegalArgumentException> {
+
+ @Override
+ public Response toResponse(final java.lang.IllegalArgumentException throwable) {
+ return Response.ok(throwable.getMessage()).build();
+ }
+}
diff --git a/content/examples/rest-applicationcomposer/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java b/content/examples/rest-applicationcomposer/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java
new file mode 100755
index 0000000..2e86e3b
--- /dev/null
+++ b/content/examples/rest-applicationcomposer/src/test/java/org/superbiz/composed/rest/GreetingServiceTest.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.composed.rest;
+
+import org.apache.openejb.OpenEjbContainer;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.jee.oejb3.EjbDeployment;
+import org.apache.openejb.jee.oejb3.OpenejbJar;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.loader.IO;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+
+ @Configuration
+ public Properties configuration() {
+ return new Properties() {{
+ setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, Boolean.TRUE.toString());
+ }};
+ }
+
+ @Module
+ public EjbModule app() {
+ final SingletonBean bean = (SingletonBean) new SingletonBean(GreetingService.class).localBean();
+ bean.setRestService(true);
+
+ // now create an ejbjar and an openejb-jar to hold the provider config
+
+ final EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(bean);
+
+ final OpenejbJar openejbJar = new OpenejbJar();
+ openejbJar.addEjbDeployment(new EjbDeployment(ejbJar.getEnterpriseBeans()[0]));
+
+ final Properties properties = openejbJar.getEjbDeployment().iterator().next().getProperties();
+ properties.setProperty("cxf.jaxrs.providers", IllegalArgumentExceptionMapper.class.getName());
+
+ // link all and return this module
+
+ final EjbModule module = new EjbModule(ejbJar);
+ module.setOpenejbJar(openejbJar);
+
+ return module;
+ }
+
+ @Test
+ public void checkProviderIsUsed() throws IOException {
+ final String message = IO.slurp(new URL("http://localhost:4204/GreetingServiceTest/greeting/"));
+ assertEquals("this exception is handled by an exception mapper", message);
+ }
+}
diff --git a/content/examples/rest-cdi.html b/content/examples/rest-cdi.html
new file mode 100644
index 0000000..a9c708f
--- /dev/null
+++ b/content/examples/rest-cdi.html
@@ -0,0 +1,593 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/rest-cdi.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple REST with CDI</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example rest-cdi can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/rest-cdi" class="bare">https://github.com/apache/tomee/tree/master/examples/rest-cdi</a></p>
+</div>
+<div class="paragraph">
+<p>Defining a REST service is pretty easy, simply ad @Path annotation to a class then define on methods
+the HTTP method to use (@GET, @POST, …​).</p>
+</div>
+</div>
+</div>
+<h1 id="_the_code" class="sect0">The Code</h1>
+<div class="sect1">
+<h2 id="_the_rest_service_path_produces_consumes">The REST service: @Path, @Produces, @Consumes</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.</p>
+</div>
+<div class="paragraph">
+<p>Actually lines:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+
+are optional since it is the default configuration. And these lines can be configured by method too
+if you need to be more precise.
+
+@Path("/greeting")
+@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+public class GreetingService {
+ @GET
+ public Response message() {
+ return new Response("Hi REST!");
+ }
+
+ @POST
+ public Response lowerCase(final Request message) {
+ return new Response(message.getValue().toLowerCase());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_testing" class="sect0">Testing</h1>
+<div class="sect1">
+<h2 id="_test_for_the_jaxrs_service">Test for the JAXRS service</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The test uses the OpenEJB ApplicationComposer to make it trivial.</p>
+</div>
+<div class="paragraph">
+<p>The idea is first to activate the jaxrs services. This is done using @EnableServices annotation.</p>
+</div>
+<div class="paragraph">
+<p>Then we create on the fly the application simply returning an object representing the web.xml. Here we simply
+use it to define the context root but you can use it to define your REST Application too. And to complete the
+application definition we add @Classes annotation to define the set of classes to use in this app.</p>
+</div>
+<div class="paragraph">
+<p>Finally to test it we use cxf client API to call the REST service in get() and post() methods.</p>
+</div>
+<div class="paragraph">
+<p>Side note: to show we use JSON or XML depending on the test method we activated on EnableServices the attribute httpDebug
+which prints the http messages in the logs.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Classes;
+import org.apache.openejb.junit.EnableServices;
+import org.apache.openejb.junit.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs", httpDebug = true)
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+ @Module
+ @Classes(value = {GreetingService.class, Greeting.class}, cdi = true) //This enables the CDI magic
+ public WebApp app() {
+ return new WebApp().contextRoot("test");
+ }
+
+ @Test
+ public void getXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+
+ @Test
+ public void getJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>Running the example is fairly simple. In the "rest-cdi" directory run:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>$ mvn clean install</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Which should create output like the following.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>/opt/softs/java/jdk1.6.0_30/bin/java -ea -Didea.launcher.port=7534 -Didea.launcher.bin.path=/opt/softs/idea/bin -Dfile.encoding=UTF-8 -classpath /opt/softs/idea/lib/idea_rt.jar:/opt/softs/idea/plugins/junit/lib/junit-rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/plugin.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/javaws.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jce.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/charsets.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/resources.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/deploy.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/management-agent.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jsse.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/localedata.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunjce_provider.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunpkcs11.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/dnsns.jar:/opt/dev/openejb/openejb-trunk/examples/rest-cdi/target/test-classes:/opt/dev/openejb/openejb-trunk/examples/rest-cdi/target/classes:/home/rmannibucau/.m2/repository/org/apache/openejb/javaee-api/6.0-4/javaee-api-6.0-4.jar:/home/rmannibucau/.m2/repository/junit/junit/4.10/junit-4.10.jar:/home/rmannibucau/.m2/repository/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-rs/4.5.1/openejb-cxf-rs-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-http/4.5.1/openejb-http-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-core/4.5.1/openejb-core-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/mbean-annotation-api/4.5.1/mbean-annotation-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jpa-integration/4.5.1/openejb-jpa-integration-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-api/4.5.1/openejb-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-loader/4.5.1/openejb-loader-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-javaagent/4.5.1/openejb-javaagent-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jee/4.5.1/openejb-jee-4.5.1.jar:/home/rmannibucau/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.13/jaxb-impl-2.1.13.jar:/home/rmannibucau/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-ra/5.7.0/activemq-ra-5.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-core/5.7.0/activemq-core-5.7.0.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/kahadb/5.7.0/kahadb-5.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/protobuf/activemq-protobuf/1.1/activemq-protobuf-1.1.jar:/home/rmannibucau/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/rmannibucau/.m2/repository/commons-net/commons-net/3.1/commons-net-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-connector/3.1.1/geronimo-connector-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-transaction/3.1.1/geronimo-transaction-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/specs/geronimo-j2ee-connector_1.6_spec/1.0/geronimo-j2ee-connector_1.6_spec-1.0.jar:/home/rmannibucau/.m2/repository/org/objectweb/howl/howl/1.0.1-1/howl-1.0.1-1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/1.8.2/geronimo-javamail_1.4_mail-1.8.2.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-asm-shaded/3.12/xbean-asm-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-finder-shaded/3.12/xbean-finder-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-reflect/3.12/xbean-reflect-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-naming/3.12/xbean-naming-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-bundleutils/3.12/xbean-bundleutils-3.12.jar:/home/rmannibucau/.m2/repository/org/hsqldb/hsqldb/2.2.8/hsqldb-2.2.8.jar:/home/rmannibucau/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar:/home/rmannibucau/.m2/repository/commons-pool/commons-pool/1.5.7/commons-pool-1.5.7.jar:/home/rmannibucau/.m2/repository/org/codehaus/swizzle/swizzle-stream/1.6.1/swizzle-stream-1.6.1.jar:/home/rmannibucau/.m2/repository/wsdl4j/wsdl4j/1.6.2/wsdl4j-1.6.2.jar:/home/rmannibucau/.m2/repository/org/quartz-scheduler/quartz/2.1.6/quartz-2.1.6.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-jdk14/1.7.2/slf4j-jdk14-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-impl/1.1.6/openwebbeans-impl-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-spi/1.1.6/openwebbeans-spi-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ejb/1.1.6/openwebbeans-ejb-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee/1.1.6/openwebbeans-ee-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee-common/1.1.6/openwebbeans-ee-common-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-web/1.1.6/openwebbeans-web-1.1.6.jar:/home/rmannibucau/.m2/repository/org/javassist/javassist/3.15.0-GA/javassist-3.15.0-GA.jar:/home/rmannibucau/.m2/repository/org/apache/openjpa/openjpa/2.2.0/openjpa-2.2.0.jar:/home/rmannibucau/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:/home/rmannibucau/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/rmannibucau/.m2/repository/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar:/home/rmannibucau/.m2/repository/asm/asm/3.2/asm-3.2.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-core/0.5/bval-core-0.5.jar:/home/rmannibucau/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.3/commons-beanutils-core-1.8.3.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-jsr303/0.5/bval-jsr303-0.5.jar:/home/rmannibucau/.m2/repository/org/fusesource/jansi/jansi/1.8/jansi-1.8.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-server/4.5.1/openejb-server-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-client/4.5.1/openejb-client-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-ejbd/4.5.1/openejb-ejbd-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-rest/4.5.1/openejb-rest-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-transport/4.5.1/openejb-cxf-transport-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-transports-http/2.7.0/cxf-rt-transports-http-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-api/2.7.0/cxf-api-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/ws/xmlschema/xmlschema-core/2.0.3/xmlschema-core-2.0.3.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-core/2.7.0/cxf-rt-core-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-frontend-jaxrs/2.7.0/cxf-rt-frontend-jaxrs-2.7.0.jar:/home/rmannibucau/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.0-m10/javax.ws.rs-api-2.0-m10.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-bindings-xml/2.7.0/cxf-rt-bindings-xml-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-providers/2.7.0/cxf-rt-rs-extension-providers-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-search/2.7.0/cxf-rt-rs-extension-search-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-cors/2.7.0/cxf-rt-rs-security-cors-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-oauth2/2.7.0/cxf-rt-rs-security-oauth2-2.7.0.jar:/home/rmannibucau/.m2/repository/org/codehaus/jettison/jettison/1.3/jettison-1.3.jar:/home/rmannibucau/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 org.superbiz.rest.GreetingServiceTest
+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 - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Using 'print=true'
+INFO - Using 'indent.xml=true'
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+INFO - Starting service httpejbd
+INFO - Started service httpejbd
+INFO - Starting service cxf-rs
+INFO - Started service cxf-rs
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Existing thread singleton service in SystemInstance() null
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+INFO - Succeeded in installing singleton service
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 102 ms.
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+FINE - ******************* REQUEST ******************
+GET http://localhost:4204/test/greeting/
+Host=localhost:4204
+User-Agent=Apache CXF 2.7.0
+Connection=keep-alive
+Accept=application/xml
+Content-Type=*/*
+Pragma=no-cache
+Cache-Control=no-cache</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>**********************************************</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>FINE - HTTP/1.1 200 OK
+Date: Fri, 09 Nov 2012 11:59:00 GMT
+Content-Length: 44
+Set-Cookie: EJBSESSIONID=fc5037fa-641c-495d-95ca-0755cfa50beb; Path=/
+Content-Type: application/xml
+Connection: close
+Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)</pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><response><value>Hi REST!</value></response>
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Stopping network services
+INFO - Stopping server services
+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 - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Using 'print=true'
+INFO - Using 'indent.xml=true'
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+INFO - Starting service httpejbd
+INFO - Started service httpejbd
+INFO - Starting service cxf-rs
+INFO - Started service cxf-rs
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Existing thread singleton service in SystemInstance() null
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+INFO - Succeeded in installing singleton service
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 11 ms.
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+FINE - ******************* REQUEST ******************
+POST http://localhost:4204/test/greeting/
+Host=localhost:4204
+Content-Length=97
+User-Agent=Apache CXF 2.7.0
+Connection=keep-alive
+Accept=application/xml
+Content-Type=application/xml
+Pragma=no-cache
+Cache-Control=no-cache
+
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+**********************************************
+
+FINE - HTTP/1.1 200 OK
+Date: Fri, 09 Nov 2012 11:59:00 GMT
+Content-Length: 44
+Set-Cookie: EJBSESSIONID=7cb2246d-5738-4a85-aac5-c0fb5340d36a; Path=/
+Content-Type: application/xml
+Connection: close
+Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+<response><value>hi rest!</value></response>
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Stopping network services
+INFO - Stopping server services
+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 - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Using 'print=true'
+INFO - Using 'indent.xml=true'
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+INFO - Starting service httpejbd
+INFO - Started service httpejbd
+INFO - Starting service cxf-rs
+INFO - Started service cxf-rs
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Existing thread singleton service in SystemInstance() null
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+INFO - Succeeded in installing singleton service
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 10 ms.
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+FINE - ******************* REQUEST ******************
+GET http://localhost:4204/test/greeting/
+Host=localhost:4204
+User-Agent=Apache CXF 2.7.0
+Connection=keep-alive
+Accept=application/json
+Content-Type=*/*
+Pragma=no-cache
+Cache-Control=no-cache
+
+
+**********************************************
+
+FINE - HTTP/1.1 200 OK
+Date: Fri, 09 Nov 2012 11:59:00 GMT
+Content-Length: 33
+Set-Cookie: EJBSESSIONID=7112a057-fc4c-4f52-a556-1617320d2275; Path=/
+Content-Type: application/json
+Connection: close
+Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+{"response":{"value":"Hi REST!"}}
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Stopping network services
+INFO - Stopping server services
+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 - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Using 'print=true'
+INFO - Using 'indent.xml=true'
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+INFO - Starting service httpejbd
+INFO - Started service httpejbd
+INFO - Starting service cxf-rs
+INFO - Started service cxf-rs
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Existing thread singleton service in SystemInstance() null
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+INFO - Succeeded in installing singleton service
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 10 ms.
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+FINE - ******************* REQUEST ******************
+POST http://localhost:4204/test/greeting/
+Host=localhost:4204
+Content-Length=97
+User-Agent=Apache CXF 2.7.0
+Connection=keep-alive
+Accept=application/json
+Content-Type=application/xml
+Pragma=no-cache
+Cache-Control=no-cache
+
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+**********************************************
+
+FINE - HTTP/1.1 200 OK
+Date: Fri, 09 Nov 2012 11:59:01 GMT
+Content-Length: 33
+Set-Cookie: EJBSESSIONID=50cf1d2b-a940-4afb-8993-fff7f9cc6d83; Path=/
+Content-Type: application/json
+Connection: close
+Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+{"response":{"value":"hi rest!"}}
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Stopping network services
+INFO - Stopping server services</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/rest-cdi.pdf b/content/examples/rest-cdi.pdf
new file mode 100644
index 0000000..af8730e
--- /dev/null
+++ b/content/examples/rest-cdi.pdf
Binary files differ
diff --git a/content/examples/rest-cdi/README.md b/content/examples/rest-cdi/README.md
new file mode 100755
index 0000000..7a0375b
--- /dev/null
+++ b/content/examples/rest-cdi/README.md
@@ -0,0 +1,373 @@
+Title: Simple REST with CDI
+
+Defining a REST service is pretty easy, simply ad @Path annotation to a class then define on methods
+the HTTP method to use (@GET, @POST, ...).
+
+#The Code
+
+## The REST service: @Path, @Produces, @Consumes
+
+Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.
+
+Actually lines:
+
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+
+are optional since it is the default configuration. And these lines can be configured by method too
+if you need to be more precise.
+
+ @Path("/greeting")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public class GreetingService {
+ @GET
+ public Response message() {
+ return new Response("Hi REST!");
+ }
+
+ @POST
+ public Response lowerCase(final Request message) {
+ return new Response(message.getValue().toLowerCase());
+ }
+ }
+
+# Testing
+
+## Test for the JAXRS service
+
+The test uses the OpenEJB ApplicationComposer to make it trivial.
+
+The idea is first to activate the jaxrs services. This is done using @EnableServices annotation.
+
+Then we create on the fly the application simply returning an object representing the web.xml. Here we simply
+use it to define the context root but you can use it to define your REST Application too. And to complete the
+application definition we add @Classes annotation to define the set of classes to use in this app.
+
+Finally to test it we use cxf client API to call the REST service in get() and post() methods.
+
+Side note: to show we use JSON or XML depending on the test method we activated on EnableServices the attribute httpDebug
+which prints the http messages in the logs.
+
+ package org.superbiz.rest;
+
+ import org.apache.cxf.jaxrs.client.WebClient;
+ import org.apache.openejb.jee.WebApp;
+ import org.apache.openejb.junit.ApplicationComposer;
+ import org.apache.openejb.junit.Classes;
+ import org.apache.openejb.junit.EnableServices;
+ import org.apache.openejb.junit.Module;
+ import org.junit.Test;
+ import org.junit.runner.RunWith;
+
+ import javax.ws.rs.core.MediaType;
+ import java.io.IOException;
+
+ import static org.junit.Assert.assertEquals;
+
+ @EnableServices(value = "jaxrs", httpDebug = true)
+ @RunWith(ApplicationComposer.class)
+ public class GreetingServiceTest {
+ @Module
+ @Classes(value = {GreetingService.class, Greeting.class}, cdi = true) //This enables the CDI magic
+ public WebApp app() {
+ return new WebApp().contextRoot("test");
+ }
+
+ @Test
+ public void getXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+
+ @Test
+ public void getJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+ }
+
+
+#Running
+
+Running the example is fairly simple. In the "rest-cdi" directory run:
+
+ $ mvn clean install
+
+Which should create output like the following.
+
+ /opt/softs/java/jdk1.6.0_30/bin/java -ea -Didea.launcher.port=7534 -Didea.launcher.bin.path=/opt/softs/idea/bin -Dfile.encoding=UTF-8 -classpath /opt/softs/idea/lib/idea_rt.jar:/opt/softs/idea/plugins/junit/lib/junit-rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/plugin.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/javaws.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jce.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/charsets.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/resources.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/deploy.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/management-agent.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jsse.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/localedata.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunjce_provider.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunpkcs11.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/dnsns.jar:/opt/dev/openejb/openejb-trunk/examples/rest-cdi/target/test-classes:/opt/dev/openejb/openejb-trunk/examples/rest-cdi/target/classes:/home/rmannibucau/.m2/repository/org/apache/openejb/javaee-api/6.0-4/javaee-api-6.0-4.jar:/home/rmannibucau/.m2/repository/junit/junit/4.10/junit-4.10.jar:/home/rmannibucau/.m2/repository/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-rs/4.5.1/openejb-cxf-rs-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-http/4.5.1/openejb-http-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-core/4.5.1/openejb-core-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/mbean-annotation-api/4.5.1/mbean-annotation-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jpa-integration/4.5.1/openejb-jpa-integration-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-api/4.5.1/openejb-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-loader/4.5.1/openejb-loader-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-javaagent/4.5.1/openejb-javaagent-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jee/4.5.1/openejb-jee-4.5.1.jar:/home/rmannibucau/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.13/jaxb-impl-2.1.13.jar:/home/rmannibucau/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-ra/5.7.0/activemq-ra-5.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-core/5.7.0/activemq-core-5.7.0.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/kahadb/5.7.0/kahadb-5.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/protobuf/activemq-protobuf/1.1/activemq-protobuf-1.1.jar:/home/rmannibucau/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/rmannibucau/.m2/repository/commons-net/commons-net/3.1/commons-net-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-connector/3.1.1/geronimo-connector-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-transaction/3.1.1/geronimo-transaction-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/specs/geronimo-j2ee-connector_1.6_spec/1.0/geronimo-j2ee-connector_1.6_spec-1.0.jar:/home/rmannibucau/.m2/repository/org/objectweb/howl/howl/1.0.1-1/howl-1.0.1-1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/1.8.2/geronimo-javamail_1.4_mail-1.8.2.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-asm-shaded/3.12/xbean-asm-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-finder-shaded/3.12/xbean-finder-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-reflect/3.12/xbean-reflect-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-naming/3.12/xbean-naming-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-bundleutils/3.12/xbean-bundleutils-3.12.jar:/home/rmannibucau/.m2/repository/org/hsqldb/hsqldb/2.2.8/hsqldb-2.2.8.jar:/home/rmannibucau/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar:/home/rmannibucau/.m2/repository/commons-pool/commons-pool/1.5.7/commons-pool-1.5.7.jar:/home/rmannibucau/.m2/repository/org/codehaus/swizzle/swizzle-stream/1.6.1/swizzle-stream-1.6.1.jar:/home/rmannibucau/.m2/repository/wsdl4j/wsdl4j/1.6.2/wsdl4j-1.6.2.jar:/home/rmannibucau/.m2/repository/org/quartz-scheduler/quartz/2.1.6/quartz-2.1.6.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-jdk14/1.7.2/slf4j-jdk14-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-impl/1.1.6/openwebbeans-impl-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-spi/1.1.6/openwebbeans-spi-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ejb/1.1.6/openwebbeans-ejb-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee/1.1.6/openwebbeans-ee-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee-common/1.1.6/openwebbeans-ee-common-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-web/1.1.6/openwebbeans-web-1.1.6.jar:/home/rmannibucau/.m2/repository/org/javassist/javassist/3.15.0-GA/javassist-3.15.0-GA.jar:/home/rmannibucau/.m2/repository/org/apache/openjpa/openjpa/2.2.0/openjpa-2.2.0.jar:/home/rmannibucau/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:/home/rmannibucau/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/rmannibucau/.m2/repository/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar:/home/rmannibucau/.m2/repository/asm/asm/3.2/asm-3.2.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-core/0.5/bval-core-0.5.jar:/home/rmannibucau/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.3/commons-beanutils-core-1.8.3.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-jsr303/0.5/bval-jsr303-0.5.jar:/home/rmannibucau/.m2/repository/org/fusesource/jansi/jansi/1.8/jansi-1.8.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-server/4.5.1/openejb-server-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-client/4.5.1/openejb-client-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-ejbd/4.5.1/openejb-ejbd-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-rest/4.5.1/openejb-rest-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-transport/4.5.1/openejb-cxf-transport-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-transports-http/2.7.0/cxf-rt-transports-http-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-api/2.7.0/cxf-api-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/ws/xmlschema/xmlschema-core/2.0.3/xmlschema-core-2.0.3.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-core/2.7.0/cxf-rt-core-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-frontend-jaxrs/2.7.0/cxf-rt-frontend-jaxrs-2.7.0.jar:/home/rmannibucau/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.0-m10/javax.ws.rs-api-2.0-m10.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-bindings-xml/2.7.0/cxf-rt-bindings-xml-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-providers/2.7.0/cxf-rt-rs-extension-providers-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-search/2.7.0/cxf-rt-rs-extension-search-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-cors/2.7.0/cxf-rt-rs-security-cors-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-oauth2/2.7.0/cxf-rt-rs-security-oauth2-2.7.0.jar:/home/rmannibucau/.m2/repository/org/codehaus/jettison/jettison/1.3/jettison-1.3.jar:/home/rmannibucau/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 org.superbiz.rest.GreetingServiceTest
+ 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 - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Using 'print=true'
+ INFO - Using 'indent.xml=true'
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ INFO - Starting service httpejbd
+ INFO - Started service httpejbd
+ INFO - Starting service cxf-rs
+ INFO - Started service cxf-rs
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - -------
+ INFO - Ready!
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Existing thread singleton service in SystemInstance() null
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+ INFO - Succeeded in installing singleton service
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 102 ms.
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+ INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+ INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+ FINE - ******************* REQUEST ******************
+ GET http://localhost:4204/test/greeting/
+ Host=localhost:4204
+ User-Agent=Apache CXF 2.7.0
+ Connection=keep-alive
+ Accept=application/xml
+ Content-Type=*/*
+ Pragma=no-cache
+ Cache-Control=no-cache
+
+
+ **********************************************
+
+ FINE - HTTP/1.1 200 OK
+ Date: Fri, 09 Nov 2012 11:59:00 GMT
+ Content-Length: 44
+ Set-Cookie: EJBSESSIONID=fc5037fa-641c-495d-95ca-0755cfa50beb; Path=/
+ Content-Type: application/xml
+ Connection: close
+ Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+ <response><value>Hi REST!</value></response>
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Stopping network services
+ INFO - Stopping server services
+ 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 - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Using 'print=true'
+ INFO - Using 'indent.xml=true'
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ INFO - Starting service httpejbd
+ INFO - Started service httpejbd
+ INFO - Starting service cxf-rs
+ INFO - Started service cxf-rs
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - -------
+ INFO - Ready!
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Existing thread singleton service in SystemInstance() null
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+ INFO - Succeeded in installing singleton service
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 11 ms.
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+ INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+ INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+ FINE - ******************* REQUEST ******************
+ POST http://localhost:4204/test/greeting/
+ Host=localhost:4204
+ Content-Length=97
+ User-Agent=Apache CXF 2.7.0
+ Connection=keep-alive
+ Accept=application/xml
+ Content-Type=application/xml
+ Pragma=no-cache
+ Cache-Control=no-cache
+
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+ **********************************************
+
+ FINE - HTTP/1.1 200 OK
+ Date: Fri, 09 Nov 2012 11:59:00 GMT
+ Content-Length: 44
+ Set-Cookie: EJBSESSIONID=7cb2246d-5738-4a85-aac5-c0fb5340d36a; Path=/
+ Content-Type: application/xml
+ Connection: close
+ Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+ <response><value>hi rest!</value></response>
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Stopping network services
+ INFO - Stopping server services
+ 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 - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Using 'print=true'
+ INFO - Using 'indent.xml=true'
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ INFO - Starting service httpejbd
+ INFO - Started service httpejbd
+ INFO - Starting service cxf-rs
+ INFO - Started service cxf-rs
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - -------
+ INFO - Ready!
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Existing thread singleton service in SystemInstance() null
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+ INFO - Succeeded in installing singleton service
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 10 ms.
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+ INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+ INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+ FINE - ******************* REQUEST ******************
+ GET http://localhost:4204/test/greeting/
+ Host=localhost:4204
+ User-Agent=Apache CXF 2.7.0
+ Connection=keep-alive
+ Accept=application/json
+ Content-Type=*/*
+ Pragma=no-cache
+ Cache-Control=no-cache
+
+
+ **********************************************
+
+ FINE - HTTP/1.1 200 OK
+ Date: Fri, 09 Nov 2012 11:59:00 GMT
+ Content-Length: 33
+ Set-Cookie: EJBSESSIONID=7112a057-fc4c-4f52-a556-1617320d2275; Path=/
+ Content-Type: application/json
+ Connection: close
+ Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+ {"response":{"value":"Hi REST!"}}
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Stopping network services
+ INFO - Stopping server services
+ 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 - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Using 'print=true'
+ INFO - Using 'indent.xml=true'
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ INFO - Starting service httpejbd
+ INFO - Started service httpejbd
+ INFO - Starting service cxf-rs
+ INFO - Started service cxf-rs
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - -------
+ INFO - Ready!
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Existing thread singleton service in SystemInstance() null
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+ INFO - Succeeded in installing singleton service
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 10 ms.
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+ INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+ INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+ FINE - ******************* REQUEST ******************
+ POST http://localhost:4204/test/greeting/
+ Host=localhost:4204
+ Content-Length=97
+ User-Agent=Apache CXF 2.7.0
+ Connection=keep-alive
+ Accept=application/json
+ Content-Type=application/xml
+ Pragma=no-cache
+ Cache-Control=no-cache
+
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+ **********************************************
+
+ FINE - HTTP/1.1 200 OK
+ Date: Fri, 09 Nov 2012 11:59:01 GMT
+ Content-Length: 33
+ Set-Cookie: EJBSESSIONID=50cf1d2b-a940-4afb-8993-fff7f9cc6d83; Path=/
+ Content-Type: application/json
+ Connection: close
+ Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+ {"response":{"value":"hi rest!"}}
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Stopping network services
+ INFO - Stopping server services
+
+
+
+
diff --git a/content/examples/rest-cdi/pom.xml b/content/examples/rest-cdi/pom.xml
new file mode 100755
index 0000000..d918e90
--- /dev/null
+++ b/content/examples/rest-cdi/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>rest-cdi</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: REST XML JSON</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/rest-cdi/src/main/java/org/superbiz/rest/Greeting.java b/content/examples/rest-cdi/src/main/java/org/superbiz/rest/Greeting.java
new file mode 100755
index 0000000..f6c4379
--- /dev/null
+++ b/content/examples/rest-cdi/src/main/java/org/superbiz/rest/Greeting.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+public class Greeting {
+
+ public String doSomething(final String value) {
+ return value.toLowerCase();
+ }
+}
diff --git a/content/examples/rest-cdi/src/main/java/org/superbiz/rest/GreetingService.java b/content/examples/rest-cdi/src/main/java/org/superbiz/rest/GreetingService.java
new file mode 100755
index 0000000..5086e48
--- /dev/null
+++ b/content/examples/rest-cdi/src/main/java/org/superbiz/rest/GreetingService.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/greeting")
+@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+public class GreetingService {
+
+ @Inject
+ Greeting greeting;
+
+ @GET
+ public Response message() {
+ return new Response("Hi REST!");
+ }
+
+ @POST
+ public Response lowerCase(final Request message) {
+ return new Response(greeting.doSomething(message.getValue()));
+ }
+}
diff --git a/content/examples/rest-cdi/src/main/java/org/superbiz/rest/Request.java b/content/examples/rest-cdi/src/main/java/org/superbiz/rest/Request.java
new file mode 100755
index 0000000..cac8e74
--- /dev/null
+++ b/content/examples/rest-cdi/src/main/java/org/superbiz/rest/Request.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Request {
+
+ private String value;
+
+ public Request() {
+ //no-op
+ }
+
+ public Request(final String s) {
+ value = s;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/content/examples/rest-cdi/src/main/java/org/superbiz/rest/Response.java b/content/examples/rest-cdi/src/main/java/org/superbiz/rest/Response.java
new file mode 100755
index 0000000..4c2319d
--- /dev/null
+++ b/content/examples/rest-cdi/src/main/java/org/superbiz/rest/Response.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Response {
+
+ private String value;
+
+ public Response() {
+ // no-op
+ }
+
+ public Response(final String s) {
+ value = s;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/content/examples/rest-cdi/src/test/java/org/superbiz/rest/GreetingServiceTest.java b/content/examples/rest-cdi/src/test/java/org/superbiz/rest/GreetingServiceTest.java
new file mode 100755
index 0000000..fba1168
--- /dev/null
+++ b/content/examples/rest-cdi/src/test/java/org/superbiz/rest/GreetingServiceTest.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.apache.openejb.util.NetworkUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs", httpDebug = true)
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+
+ private static int port = -1;
+
+ @BeforeClass
+ public static void beforeClass() {
+ port = NetworkUtil.getNextAvailablePort();
+ }
+
+ @Configuration
+ public Properties props() {
+ return new PropertiesBuilder().p("httpejbd.port", Integer.toString(port)).build();
+ }
+
+ @Module
+ @Classes(value = {GreetingService.class, Greeting.class}, cdi = true) //This enables the CDI magic
+ public WebApp app() {
+ return new WebApp().contextRoot("test");
+ }
+
+ @Test
+ public void getXml() throws IOException {
+ final String message = WebClient.create("http://localhost:" + port).path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postXml() throws IOException {
+ final String message = WebClient.create("http://localhost:" + port).path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+
+ @Test
+ public void getJson() throws IOException {
+ final String message = WebClient.create("http://localhost:" + port).path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postJson() throws IOException {
+ final String message = WebClient.create("http://localhost:" + port).path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+}
diff --git a/content/examples/rest-example-with-application.html b/content/examples/rest-example-with-application.html
new file mode 100644
index 0000000..1995124
--- /dev/null
+++ b/content/examples/rest-example-with-application.html
@@ -0,0 +1,279 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/rest-example-with-application.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>REST Example with Application</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example rest-example-with-application can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/rest-example-with-application" class="bare">https://github.com/apache/tomee/tree/master/examples/rest-example-with-application</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_applicationconfig">ApplicationConfig</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+@ApplicationPath("/rest-prefix")
+public class ApplicationConfig extends Application {
+ public Set<Class<?>> getClasses() {
+ return new HashSet<Class<?>>(Arrays.asList(SimpleRESTPojo.class, SimpleRESTEJB.class));
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_simplerestejb">SimpleRESTEJB</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import java.util.Date;
+
+@Singleton
+@Lock(LockType.READ)
+@Path("/ejb")
+public class SimpleRESTEJB {
+ @GET
+ public String ejb() {
+ return "ejb ok @ " + new Date().toString();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_simplerestpojo">SimpleRESTPojo</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import java.util.Date;
+
+@Path("/pojo")
+public class SimpleRESTPojo {
+ @GET
+ public String pojo() {
+ return "pojo ok @ " + new Date().toString();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_web_xml">web.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB REST Example</display-name>
+</web-app></code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/rest-example-with-application.pdf b/content/examples/rest-example-with-application.pdf
new file mode 100644
index 0000000..a649cff
--- /dev/null
+++ b/content/examples/rest-example-with-application.pdf
Binary files differ
diff --git a/content/examples/rest-example-with-application/README.md b/content/examples/rest-example-with-application/README.md
new file mode 100755
index 0000000..55b5c84
--- /dev/null
+++ b/content/examples/rest-example-with-application/README.md
@@ -0,0 +1,63 @@
+Title: REST Example with Application
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## ApplicationConfig
+
+ import javax.ws.rs.ApplicationPath;
+ import javax.ws.rs.core.Application;
+ import java.util.Arrays;
+ import java.util.HashSet;
+ import java.util.Set;
+
+ @ApplicationPath("/rest-prefix")
+ public class ApplicationConfig extends Application {
+ public Set<Class<?>> getClasses() {
+ return new HashSet<Class<?>>(Arrays.asList(SimpleRESTPojo.class, SimpleRESTEJB.class));
+ }
+ }
+
+## SimpleRESTEJB
+
+ import javax.ejb.Lock;
+ import javax.ejb.LockType;
+ import javax.ejb.Singleton;
+ import javax.ws.rs.GET;
+ import javax.ws.rs.Path;
+ import java.util.Date;
+
+ @Singleton
+ @Lock(LockType.READ)
+ @Path("/ejb")
+ public class SimpleRESTEJB {
+ @GET
+ public String ejb() {
+ return "ejb ok @ " + new Date().toString();
+ }
+ }
+
+## SimpleRESTPojo
+
+ import javax.ws.rs.GET;
+ import javax.ws.rs.Path;
+ import java.util.Date;
+
+ @Path("/pojo")
+ public class SimpleRESTPojo {
+ @GET
+ public String pojo() {
+ return "pojo ok @ " + new Date().toString();
+ }
+ }
+
+## web.xml
+
+ <web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB REST Example</display-name>
+ </web-app>
+
diff --git a/content/examples/rest-example-with-application/pom.xml b/content/examples/rest-example-with-application/pom.xml
new file mode 100755
index 0000000..f2e4938
--- /dev/null
+++ b/content/examples/rest-example-with-application/pom.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>rest-example-with-application</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: REST Example With Application</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ <tomee.version>1.7.1</tomee.version>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ <repository>
+ <id>tomcat-m2-repo</id>
+ <name>Tomcat Dev Repository</name>
+ <url>http://tomcat.apache.org/dev/dist/m2-repository/</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <build>
+ <defaultGoal>package</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1.1</version>
+ <configuration>
+ <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.googlecode.t7mp</groupId>
+ <artifactId>maven-t7-plugin</artifactId>
+ <version>0.9.7</version>
+ <configuration>
+ <tomcatHttpPort>1234</tomcatHttpPort>
+ <tomcatShutdownPort>13245</tomcatShutdownPort>
+ <tomcatVersion>7.0.27</tomcatVersion>
+ <webapps>
+ <webappArtifact>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-plus-webapp</artifactId>
+ <version>${tomee.version}</version>
+ <contextPath>openejb</contextPath>
+ </webappArtifact>
+ </webapps>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>local-release-repo</id>
+ <url>file://${project.build.outputDirectory}/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>local-snapshot-repo</id>
+ <url>file://${project.build.outputDirectory}/repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/rest-example-with-application/src/main/java/org/superbiz/rest/application/ApplicationConfig.java b/content/examples/rest-example-with-application/src/main/java/org/superbiz/rest/application/ApplicationConfig.java
new file mode 100755
index 0000000..1ccfe1d
--- /dev/null
+++ b/content/examples/rest-example-with-application/src/main/java/org/superbiz/rest/application/ApplicationConfig.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.application;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+@ApplicationPath("/rest-prefix")
+public class ApplicationConfig extends Application {
+
+ public Set<Class<?>> getClasses() {
+ return new HashSet<Class<?>>(Arrays.asList(SimpleRESTPojo.class, SimpleRESTEJB.class));
+ }
+}
diff --git a/content/examples/rest-example-with-application/src/main/java/org/superbiz/rest/application/SimpleRESTEJB.java b/content/examples/rest-example-with-application/src/main/java/org/superbiz/rest/application/SimpleRESTEJB.java
new file mode 100755
index 0000000..5fdd694
--- /dev/null
+++ b/content/examples/rest-example-with-application/src/main/java/org/superbiz/rest/application/SimpleRESTEJB.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.application;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import java.util.Date;
+
+@Singleton
+@Lock(LockType.READ)
+@Path("/ejb")
+public class SimpleRESTEJB {
+
+ @GET
+ public String ejb() {
+ return "ejb ok @ " + new Date().toString();
+ }
+}
diff --git a/content/examples/rest-example-with-application/src/main/java/org/superbiz/rest/application/SimpleRESTPojo.java b/content/examples/rest-example-with-application/src/main/java/org/superbiz/rest/application/SimpleRESTPojo.java
new file mode 100755
index 0000000..669a8fb
--- /dev/null
+++ b/content/examples/rest-example-with-application/src/main/java/org/superbiz/rest/application/SimpleRESTPojo.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.application;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import java.util.Date;
+
+@Path("/pojo")
+public class SimpleRESTPojo {
+
+ @GET
+ public String pojo() {
+ return "pojo ok @ " + new Date().toString();
+ }
+}
diff --git a/content/examples/rest-example-with-application/src/main/webapp/WEB-INF/web.xml b/content/examples/rest-example-with-application/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..f326724
--- /dev/null
+++ b/content/examples/rest-example-with-application/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB REST Example</display-name>
+</web-app>
diff --git a/content/examples/rest-example-with-application/src/main/webapp/index.html b/content/examples/rest-example-with-application/src/main/webapp/index.html
new file mode 100755
index 0000000..bbf2d2d
--- /dev/null
+++ b/content/examples/rest-example-with-application/src/main/webapp/index.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html lang="en">
+<head>
+ <title>OpenEJB REST Example</title>
+</head>
+<body>
+<p>
+ Two rest services are deployed:
+<ul>
+ <li>A simple Pojo one: http://localhost:1234/rest-example-with-application-1.1.1-SNAPSHOT/rest-prefix/pojo</li>
+ <li>An EJB one: http://localhost:1234/rest-example-with-application-1.1.1-SNAPSHOT/rest-prefix/ejb</li>
+</ul>
+</p>
+<p>
+ Both are define to be deployed through the ApplicationConfig class.
+</p>
+</body>
+</html>
diff --git a/content/examples/rest-example.html b/content/examples/rest-example.html
new file mode 100644
index 0000000..a7d23d7
--- /dev/null
+++ b/content/examples/rest-example.html
@@ -0,0 +1,842 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/rest-example.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>REST Example</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example rest-example can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/rest-example" class="bare">https://github.com/apache/tomee/tree/master/examples/rest-example</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_commentdao">CommentDAO</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.dao;
+
+import org.superbiz.rest.model.Comment;
+import org.superbiz.rest.model.Post;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import java.util.Collections;
+import java.util.List;
+
+@Stateless
+public class CommentDAO extends DAO {
+ @EJB
+ private DAO dao;
+
+ public List<Comment> list(long postId) {
+ Post post = dao.find(Post.class, postId);
+ if (post == null) {
+ throw new IllegalArgumentException("post with id " + postId + " not found");
+ }
+ return Collections.unmodifiableList(post.getComments());
+ }
+
+ public Comment create(String author, String content, long postId) {
+ Post post = dao.find(Post.class, postId);
+ if (post == null) {
+ throw new IllegalArgumentException("post with id " + postId + " not found");
+ }
+
+ Comment comment = new Comment();
+ comment.setAuthor(author);
+ comment.setContent(content);
+ dao.create(comment);
+ comment.setPost(post);
+ return comment;
+ }
+
+ public void delete(long id) {
+ dao.delete(Comment.class, id);
+ }
+
+ public Comment update(long id, String author, String content) {
+ Comment comment = dao.find(Comment.class, id);
+ if (comment == null) {
+ throw new IllegalArgumentException("comment with id " + id + " not found");
+ }
+
+ comment.setAuthor(author);
+ comment.setContent(content);
+ return dao.update(comment);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_dao">DAO</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.dao;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.util.List;
+
+/**
+ * Simply maps the entitymanager.
+ * It simplifies refactoring (unitName change) and wraps some logic (limited queries).
+ *
+ */
+@Stateless
+public class DAO {
+ @PersistenceContext(unitName = "blog")
+ private EntityManager em;
+
+ public <E> E create(E e) {
+ em.persist(e);
+ return e;
+ }
+
+ public <E> E update(E e) {
+ return em.merge(e);
+ }
+
+ public <E> void delete(Class<E> clazz, long id) {
+ em.remove(em.find(clazz, id));
+ }
+
+ public <E> E find(Class<E> clazz, long id) {
+ return em.find(clazz, id);
+ }
+
+ public <E> List<E> find(Class<E> clazz, String query, int min, int max) {
+ return queryRange(em.createQuery(query, clazz), min, max).getResultList();
+ }
+
+ public <E> List<E> namedFind(Class<E> clazz, String query, int min, int max) {
+ return queryRange(em.createNamedQuery(query, clazz), min, max).getResultList();
+ }
+
+ private static Query queryRange(Query query, int min, int max) {
+ if (max >= 0) {
+ query.setMaxResults(max);
+ }
+ if (min >= 0) {
+ query.setFirstResult(min);
+ }
+ return query;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_postdao">PostDAO</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.dao;
+
+import org.superbiz.rest.model.Post;
+import org.superbiz.rest.model.User;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import java.util.List;
+
+@Stateless
+public class PostDAO {
+ @EJB
+ private DAO dao;
+
+ public Post create(String title, String content, long userId) {
+ User user = dao.find(User.class, userId);
+ Post post = new Post();
+ post.setTitle(title);
+ post.setContent(content);
+ post.setUser(user);
+ return dao.create(post);
+ }
+
+ public Post find(long id) {
+ return dao.find(Post.class, id);
+ }
+
+ public List<Post> list(int first, int max) {
+ return dao.namedFind(Post.class, "post.list", first, max);
+ }
+
+ public void delete(long id) {
+ dao.delete(Post.class, id);
+ }
+
+ public Post update(long id, long userId, String title, String content) {
+ User user = dao.find(User.class, userId);
+ if (user == null) {
+ throw new IllegalArgumentException("user id " + id + " not found");
+ }
+
+ Post post = dao.find(Post.class, id);
+ if (post == null) {
+ throw new IllegalArgumentException("post id " + id + " not found");
+ }
+
+ post.setTitle(title);
+ post.setContent(content);
+ post.setUser(user);
+ return dao.update(post);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_userdao">UserDAO</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.dao;
+
+import org.superbiz.rest.model.User;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import java.util.List;
+
+@Stateless
+public class UserDAO {
+ @EJB
+ private DAO dao;
+
+ public User create(String name, String pwd, String mail) {
+ User user = new User();
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ return dao.create(user);
+ }
+
+ public List<User> list(int first, int max) {
+ return dao.namedFind(User.class, "user.list", first, max);
+ }
+
+ public User find(long id) {
+ return dao.find(User.class, id);
+ }
+
+ public void delete(long id) {
+ dao.delete(User.class, id);
+ }
+
+ public User update(long id, String name, String pwd, String mail) {
+ User user = dao.find(User.class, id);
+ if (user == null) {
+ throw new IllegalArgumentException("setUser id " + id + " not found");
+ }
+
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ return dao.update(user);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_comment">Comment</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.model;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "comment.list", query = "select c from Comment c")
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_datedmodel">DatedModel</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.model;
+
+import javax.persistence.MappedSuperclass;
+import javax.persistence.PrePersist;
+import java.util.Date;
+
+@MappedSuperclass
+public abstract class DatedModel extends Model {
+ private Date created;
+
+ @PrePersist
+ public void create() {
+ created = new Date();
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_model">Model</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.model;
+
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+@MappedSuperclass
+@Access(AccessType.FIELD)
+@XmlAccessorType(XmlAccessType.FIELD)
+public abstract class Model {
+
+ @Id
+ @GeneratedValue
+ protected long id;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_post">Post</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.model;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "post.list", query = "select p from Post p")
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_user">User</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.model;
+
+import javax.persistence.Entity;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "user.list", query = "select u from User u")
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_commentservice">CommentService</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.service;
+
+import org.superbiz.rest.dao.CommentDAO;
+import org.superbiz.rest.model.Comment;
+
+import javax.ejb.EJB;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("/api/comment")
+@Produces({"text/xml", "application/json"})
+public class CommentService {
+ @EJB
+ private CommentDAO commentDao;
+
+ @Path("/create")
+ @PUT
+ public Comment create(@QueryParam("author") String author,
+ @QueryParam("content") String content,
+ @QueryParam("postId") long postId) {
+ return commentDao.create(author, content, postId);
+ }
+
+ @Path("/list/{postId}")
+ @GET
+ public List<Comment> list(@PathParam("postId") long postId) {
+ return commentDao.list(postId);
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ commentDao.delete(id);
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public Comment update(@PathParam("id") long id,
+ @QueryParam("author") String author,
+ @QueryParam("content") String content) {
+ return commentDao.update(id, author, content);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_postservice">PostService</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.service;
+
+import org.superbiz.rest.dao.PostDAO;
+import org.superbiz.rest.model.Post;
+
+import javax.ejb.EJB;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("/api/post")
+@Produces({"text/xml", "application/json"})
+public class PostService {
+ @EJB
+ private PostDAO dao;
+
+ @Path("/create")
+ @PUT
+ public Post create(@QueryParam("title") String title,
+ @QueryParam("content") String content,
+ @QueryParam("userId") long userId) {
+ return dao.create(title, content, userId);
+ }
+
+ @Path("/list")
+ @GET
+ public List<Post> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
+ return dao.list(first, max);
+ }
+
+ @Path("/show/{id}")
+ @GET
+ public Post show(@PathParam("id") long id) {
+ return dao.find(id);
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ dao.delete(id);
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public Post update(@PathParam("id") long id,
+ @QueryParam("userId") long userId,
+ @QueryParam("title") String title,
+ @QueryParam("content") String content) {
+ return dao.update(id, userId, title, content);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_userservice">UserService</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest.service;
+
+import org.superbiz.rest.dao.UserDAO;
+import org.superbiz.rest.model.User;
+
+import javax.ejb.EJB;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("/api/user")
+@Produces({"text/xml", "application/json"})
+public class UserService {
+ @EJB
+ private UserDAO dao;
+
+ @Path("/create")
+ @PUT
+ public User create(@QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ return dao.create(name, pwd, mail);
+ }
+
+ @Path("/list")
+ @GET
+ public List<User> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
+ return dao.list(first, max);
+ }
+
+ @Path("/show/{id}")
+ @GET
+ public User show(@PathParam("id") long id) {
+ return dao.find(id);
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ dao.delete(id);
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public User update(@PathParam("id") long id,
+ @QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ return dao.update(id, name, pwd, mail);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="blog">
+ <jta-data-source>My DataSource</jta-data-source>
+ <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
+ <class>org.superbiz.rest.model.User</class>
+ <class>org.superbiz.rest.model.Post</class>
+ <class>org.superbiz.rest.model.Comment</class>
+ <class>org.superbiz.rest.model.Model</class>
+ <class>org.superbiz.rest.model.DatedModel</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_web_xml">web.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB REST Example</display-name>
+</web-app></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_userdaotest">UserDaoTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">packagenull
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_userservicetest">UserServiceTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">packagenull
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/rest-example.pdf b/content/examples/rest-example.pdf
new file mode 100644
index 0000000..4c6a8f0
--- /dev/null
+++ b/content/examples/rest-example.pdf
Binary files differ
diff --git a/content/examples/rest-example/README.md b/content/examples/rest-example/README.md
new file mode 100755
index 0000000..019c503
--- /dev/null
+++ b/content/examples/rest-example/README.md
@@ -0,0 +1,554 @@
+Title: REST Example
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## CommentDAO
+
+ package org.superbiz.rest.dao;
+
+ import org.superbiz.rest.model.Comment;
+ import org.superbiz.rest.model.Post;
+
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+ import java.util.Collections;
+ import java.util.List;
+
+ @Stateless
+ public class CommentDAO extends DAO {
+ @EJB
+ private DAO dao;
+
+ public List<Comment> list(long postId) {
+ Post post = dao.find(Post.class, postId);
+ if (post == null) {
+ throw new IllegalArgumentException("post with id " + postId + " not found");
+ }
+ return Collections.unmodifiableList(post.getComments());
+ }
+
+ public Comment create(String author, String content, long postId) {
+ Post post = dao.find(Post.class, postId);
+ if (post == null) {
+ throw new IllegalArgumentException("post with id " + postId + " not found");
+ }
+
+ Comment comment = new Comment();
+ comment.setAuthor(author);
+ comment.setContent(content);
+ dao.create(comment);
+ comment.setPost(post);
+ return comment;
+ }
+
+ public void delete(long id) {
+ dao.delete(Comment.class, id);
+ }
+
+ public Comment update(long id, String author, String content) {
+ Comment comment = dao.find(Comment.class, id);
+ if (comment == null) {
+ throw new IllegalArgumentException("comment with id " + id + " not found");
+ }
+
+ comment.setAuthor(author);
+ comment.setContent(content);
+ return dao.update(comment);
+ }
+ }
+
+## DAO
+
+ package org.superbiz.rest.dao;
+
+ import javax.ejb.Stateless;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ /**
+ * Simply maps the entitymanager.
+ * It simplifies refactoring (unitName change) and wraps some logic (limited queries).
+ *
+ */
+ @Stateless
+ public class DAO {
+ @PersistenceContext(unitName = "blog")
+ private EntityManager em;
+
+ public <E> E create(E e) {
+ em.persist(e);
+ return e;
+ }
+
+ public <E> E update(E e) {
+ return em.merge(e);
+ }
+
+ public <E> void delete(Class<E> clazz, long id) {
+ em.remove(em.find(clazz, id));
+ }
+
+ public <E> E find(Class<E> clazz, long id) {
+ return em.find(clazz, id);
+ }
+
+ public <E> List<E> find(Class<E> clazz, String query, int min, int max) {
+ return queryRange(em.createQuery(query, clazz), min, max).getResultList();
+ }
+
+ public <E> List<E> namedFind(Class<E> clazz, String query, int min, int max) {
+ return queryRange(em.createNamedQuery(query, clazz), min, max).getResultList();
+ }
+
+ private static Query queryRange(Query query, int min, int max) {
+ if (max >= 0) {
+ query.setMaxResults(max);
+ }
+ if (min >= 0) {
+ query.setFirstResult(min);
+ }
+ return query;
+ }
+ }
+
+## PostDAO
+
+ package org.superbiz.rest.dao;
+
+ import org.superbiz.rest.model.Post;
+ import org.superbiz.rest.model.User;
+
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+ import java.util.List;
+
+ @Stateless
+ public class PostDAO {
+ @EJB
+ private DAO dao;
+
+ public Post create(String title, String content, long userId) {
+ User user = dao.find(User.class, userId);
+ Post post = new Post();
+ post.setTitle(title);
+ post.setContent(content);
+ post.setUser(user);
+ return dao.create(post);
+ }
+
+ public Post find(long id) {
+ return dao.find(Post.class, id);
+ }
+
+ public List<Post> list(int first, int max) {
+ return dao.namedFind(Post.class, "post.list", first, max);
+ }
+
+ public void delete(long id) {
+ dao.delete(Post.class, id);
+ }
+
+ public Post update(long id, long userId, String title, String content) {
+ User user = dao.find(User.class, userId);
+ if (user == null) {
+ throw new IllegalArgumentException("user id " + id + " not found");
+ }
+
+ Post post = dao.find(Post.class, id);
+ if (post == null) {
+ throw new IllegalArgumentException("post id " + id + " not found");
+ }
+
+ post.setTitle(title);
+ post.setContent(content);
+ post.setUser(user);
+ return dao.update(post);
+ }
+ }
+
+## UserDAO
+
+ package org.superbiz.rest.dao;
+
+ import org.superbiz.rest.model.User;
+
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+ import java.util.List;
+
+ @Stateless
+ public class UserDAO {
+ @EJB
+ private DAO dao;
+
+ public User create(String name, String pwd, String mail) {
+ User user = new User();
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ return dao.create(user);
+ }
+
+ public List<User> list(int first, int max) {
+ return dao.namedFind(User.class, "user.list", first, max);
+ }
+
+ public User find(long id) {
+ return dao.find(User.class, id);
+ }
+
+ public void delete(long id) {
+ dao.delete(User.class, id);
+ }
+
+ public User update(long id, String name, String pwd, String mail) {
+ User user = dao.find(User.class, id);
+ if (user == null) {
+ throw new IllegalArgumentException("setUser id " + id + " not found");
+ }
+
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ return dao.update(user);
+ }
+ }
+
+## Comment
+
+ package org.superbiz.rest.model;
+
+ import javax.persistence.Entity;
+ import javax.persistence.JoinColumn;
+ import javax.persistence.Lob;
+ import javax.persistence.ManyToOne;
+ import javax.persistence.NamedQueries;
+ import javax.persistence.NamedQuery;
+ import javax.validation.Valid;
+ import javax.validation.constraints.NotNull;
+ import javax.validation.constraints.Size;
+ import javax.xml.bind.annotation.XmlRootElement;
+ import javax.xml.bind.annotation.XmlTransient;
+
+ @Entity
+ @NamedQueries({
+ @NamedQuery(name = "comment.list", query = "select c from Comment c")
+ }
+
+## DatedModel
+
+ package org.superbiz.rest.model;
+
+ import javax.persistence.MappedSuperclass;
+ import javax.persistence.PrePersist;
+ import java.util.Date;
+
+ @MappedSuperclass
+ public abstract class DatedModel extends Model {
+ private Date created;
+
+ @PrePersist
+ public void create() {
+ created = new Date();
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+ }
+
+## Model
+
+ package org.superbiz.rest.model;
+
+ import javax.persistence.Access;
+ import javax.persistence.AccessType;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.Id;
+ import javax.persistence.MappedSuperclass;
+ import javax.xml.bind.annotation.XmlAccessType;
+ import javax.xml.bind.annotation.XmlAccessorType;
+
+ @MappedSuperclass
+ @Access(AccessType.FIELD)
+ @XmlAccessorType(XmlAccessType.FIELD)
+ public abstract class Model {
+
+ @Id
+ @GeneratedValue
+ protected long id;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+ }
+
+## Post
+
+ package org.superbiz.rest.model;
+
+ import javax.persistence.Entity;
+ import javax.persistence.FetchType;
+ import javax.persistence.Lob;
+ import javax.persistence.ManyToOne;
+ import javax.persistence.NamedQueries;
+ import javax.persistence.NamedQuery;
+ import javax.persistence.OneToMany;
+ import javax.validation.Valid;
+ import javax.validation.constraints.NotNull;
+ import javax.validation.constraints.Size;
+ import javax.xml.bind.annotation.XmlRootElement;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ @Entity
+ @NamedQueries({
+ @NamedQuery(name = "post.list", query = "select p from Post p")
+ }
+
+## User
+
+ package org.superbiz.rest.model;
+
+ import javax.persistence.Entity;
+ import javax.persistence.NamedQueries;
+ import javax.persistence.NamedQuery;
+ import javax.validation.constraints.NotNull;
+ import javax.validation.constraints.Pattern;
+ import javax.validation.constraints.Size;
+ import javax.xml.bind.annotation.XmlRootElement;
+
+ @Entity
+ @NamedQueries({
+ @NamedQuery(name = "user.list", query = "select u from User u")
+ }
+
+## CommentService
+
+ package org.superbiz.rest.service;
+
+ import org.superbiz.rest.dao.CommentDAO;
+ import org.superbiz.rest.model.Comment;
+
+ import javax.ejb.EJB;
+ import javax.ws.rs.DELETE;
+ import javax.ws.rs.GET;
+ import javax.ws.rs.POST;
+ import javax.ws.rs.PUT;
+ import javax.ws.rs.Path;
+ import javax.ws.rs.PathParam;
+ import javax.ws.rs.Produces;
+ import javax.ws.rs.QueryParam;
+ import java.util.List;
+
+ @Path("/api/comment")
+ @Produces({"text/xml", "application/json"})
+ public class CommentService {
+ @EJB
+ private CommentDAO commentDao;
+
+ @Path("/create")
+ @PUT
+ public Comment create(@QueryParam("author") String author,
+ @QueryParam("content") String content,
+ @QueryParam("postId") long postId) {
+ return commentDao.create(author, content, postId);
+ }
+
+ @Path("/list/{postId}")
+ @GET
+ public List<Comment> list(@PathParam("postId") long postId) {
+ return commentDao.list(postId);
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ commentDao.delete(id);
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public Comment update(@PathParam("id") long id,
+ @QueryParam("author") String author,
+ @QueryParam("content") String content) {
+ return commentDao.update(id, author, content);
+ }
+ }
+
+## PostService
+
+ package org.superbiz.rest.service;
+
+ import org.superbiz.rest.dao.PostDAO;
+ import org.superbiz.rest.model.Post;
+
+ import javax.ejb.EJB;
+ import javax.ws.rs.DELETE;
+ import javax.ws.rs.DefaultValue;
+ import javax.ws.rs.GET;
+ import javax.ws.rs.POST;
+ import javax.ws.rs.PUT;
+ import javax.ws.rs.Path;
+ import javax.ws.rs.PathParam;
+ import javax.ws.rs.Produces;
+ import javax.ws.rs.QueryParam;
+ import java.util.List;
+
+ @Path("/api/post")
+ @Produces({"text/xml", "application/json"})
+ public class PostService {
+ @EJB
+ private PostDAO dao;
+
+ @Path("/create")
+ @PUT
+ public Post create(@QueryParam("title") String title,
+ @QueryParam("content") String content,
+ @QueryParam("userId") long userId) {
+ return dao.create(title, content, userId);
+ }
+
+ @Path("/list")
+ @GET
+ public List<Post> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
+ return dao.list(first, max);
+ }
+
+ @Path("/show/{id}")
+ @GET
+ public Post show(@PathParam("id") long id) {
+ return dao.find(id);
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ dao.delete(id);
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public Post update(@PathParam("id") long id,
+ @QueryParam("userId") long userId,
+ @QueryParam("title") String title,
+ @QueryParam("content") String content) {
+ return dao.update(id, userId, title, content);
+ }
+ }
+
+## UserService
+
+ package org.superbiz.rest.service;
+
+ import org.superbiz.rest.dao.UserDAO;
+ import org.superbiz.rest.model.User;
+
+ import javax.ejb.EJB;
+ import javax.ws.rs.DELETE;
+ import javax.ws.rs.DefaultValue;
+ import javax.ws.rs.GET;
+ import javax.ws.rs.POST;
+ import javax.ws.rs.PUT;
+ import javax.ws.rs.Path;
+ import javax.ws.rs.PathParam;
+ import javax.ws.rs.Produces;
+ import javax.ws.rs.QueryParam;
+ import java.util.List;
+
+ @Path("/api/user")
+ @Produces({"text/xml", "application/json"})
+ public class UserService {
+ @EJB
+ private UserDAO dao;
+
+ @Path("/create")
+ @PUT
+ public User create(@QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ return dao.create(name, pwd, mail);
+ }
+
+ @Path("/list")
+ @GET
+ public List<User> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
+ return dao.list(first, max);
+ }
+
+ @Path("/show/{id}")
+ @GET
+ public User show(@PathParam("id") long id) {
+ return dao.find(id);
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ dao.delete(id);
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public User update(@PathParam("id") long id,
+ @QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ return dao.update(id, name, pwd, mail);
+ }
+ }
+
+## persistence.xml
+
+ <persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="blog">
+ <jta-data-source>My DataSource</jta-data-source>
+ <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
+ <class>org.superbiz.rest.model.User</class>
+ <class>org.superbiz.rest.model.Post</class>
+ <class>org.superbiz.rest.model.Comment</class>
+ <class>org.superbiz.rest.model.Model</class>
+ <class>org.superbiz.rest.model.DatedModel</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## web.xml
+
+ <web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB REST Example</display-name>
+ </web-app>
+
+
+## UserDaoTest
+
+ packagenull
+ }
+
+## UserServiceTest
+
+ packagenull
+ }
diff --git a/content/examples/rest-example/init.sh b/content/examples/rest-example/init.sh
new file mode 100755
index 0000000..8a95ca7
--- /dev/null
+++ b/content/examples/rest-example/init.sh
@@ -0,0 +1,31 @@
+#! /bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+base=http://localhost:8080/rest-example
+
+for i in {1..3}; do
+ curl -i -H "Accept: application/json" -X PUT "$base/api/user/create?name=Wizard$i&pwd=simplest&&mail=supername$i@supercompany.com"
+done
+
+for i in {1..30}; do
+ curl -i -H "Accept: application/json" -X PUT "$base/api/post/create?title=Title$i&content=Content&userId=$((RANDOM % 3 + 1 ))"
+done
+
+for i in {1..1000}; do
+ curl -i -H "Accept: application/json" -X PUT "$base/api/comment/create?author=Author$i&content=Content$i&postId=$((RANDOM % 30 + 51 ))"
+done
+
diff --git a/content/examples/rest-example/pom.xml b/content/examples/rest-example/pom.xml
new file mode 100755
index 0000000..2da499d
--- /dev/null
+++ b/content/examples/rest-example/pom.xml
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>rest-example</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: REST Example</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ <tomee.version>1.7.1</tomee.version>
+ <version.openjpa>2.3.0</version.openjpa>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ <repository>
+ <id>tomcat-m2-repo</id>
+ <name>Tomcat Dev Repository</name>
+ <url>http://tomcat.apache.org/dev/dist/m2-repository/</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <defaultGoal>package</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1.1</version>
+ <configuration>
+ <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>${tomee.version}</version>
+ <configuration>
+ <simpleLog>true</simpleLog>
+ <tomeeVersion>${tomee.version}</tomeeVersion>
+ <tomeeClassifier>plus</tomeeClassifier>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-embedded-maven-plugin</artifactId>
+ <version>${tomee.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-jaxrs</artifactId>
+ <version>${tomee.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>com.googlecode.t7mp</groupId>
+ <artifactId>maven-t7-plugin</artifactId>
+ <version>0.9.7</version>
+ <configuration>
+ <tomcatHttpPort>1234</tomcatHttpPort>
+ <tomcatShutdownPort>13245</tomcatShutdownPort>
+ <tomcatVersion>7.0.53</tomcatVersion>
+ <webapps>
+ <webappArtifact>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-plus-webapp</artifactId>
+ <version>${tomee.version}</version>
+ <contextPath>openejb</contextPath>
+ </webappArtifact>
+ </webapps>
+ </configuration>
+ </plugin>
+ <plugin> <!-- needed otherwise it will not work at runtime -->
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>${version.openjpa}</version>
+ <configuration>
+ <includes>org/superbiz/rest/model/*.class</includes>
+ <addDefaultConstructor>true</addDefaultConstructor>
+ <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+ </configuration>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>${version.openjpa}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-embedded</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>${openejb.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-jaxrs</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>ziplock</artifactId>
+ <version>${tomee.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>local-release-repo</id>
+ <url>file://${project.build.outputDirectory}/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>local-snapshot-repo</id>
+ <url>file://${project.build.outputDirectory}/repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/batcher/SampleDataManager.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/batcher/SampleDataManager.java
new file mode 100755
index 0000000..91ef8d6
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/batcher/SampleDataManager.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.batcher;
+
+import org.superbiz.rest.dao.CommentDAO;
+import org.superbiz.rest.dao.PostDAO;
+import org.superbiz.rest.dao.UserDAO;
+import org.superbiz.rest.model.Post;
+import org.superbiz.rest.model.User;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.DependsOn;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Schedule;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.util.logging.Logger;
+
+@Startup
+@DependsOn({"CommentDAO", "PostDAO", "UserDAO"})
+@Singleton
+@Lock(LockType.READ)
+public class SampleDataManager {
+
+ private static final Logger LOGGER = Logger.getLogger(SampleDataManager.class.getName());
+
+ @PersistenceContext(unitName = "blog")
+ private EntityManager em;
+
+ @Inject
+ private CommentDAO comments;
+
+ @Inject
+ private PostDAO posts;
+
+ @Inject
+ private UserDAO users;
+
+ @PostConstruct
+ public void createSomeData() {
+ final User tomee = users.create("tomee", "tomee", "tomee@apache.org");
+ final User openejb = users.create("openejb", "openejb", "openejb@apache.org");
+ final Post tomeePost = posts.create("TomEE", "TomEE is a cool JEE App Server", tomee.getId());
+ posts.create("OpenEJB", "OpenEJB is a cool embedded container", openejb.getId());
+ comments.create("visitor", "nice post!", tomeePost.getId());
+ }
+
+ // a bit ugly but at least we clean data
+ @Schedule(second = "0", minute = "30", hour = "*", persistent = false)
+ private void cleanData() {
+ LOGGER.info("cleaning data");
+ deleteAll();
+ createSomeData();
+ LOGGER.info("data resetted");
+ }
+
+ private void deleteAll() {
+ em.createQuery("delete From Comment").executeUpdate();
+ em.createQuery("delete From Post").executeUpdate();
+ em.createQuery("delete From User").executeUpdate();
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/CommentDAO.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/CommentDAO.java
new file mode 100755
index 0000000..6f5b328
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/CommentDAO.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.dao;
+
+import org.superbiz.rest.model.Comment;
+import org.superbiz.rest.model.Post;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.inject.Inject;
+import java.util.Collections;
+import java.util.List;
+
+@Singleton
+@Lock(LockType.READ)
+public class CommentDAO {
+
+ @Inject
+ private DAO dao;
+
+ public List<Comment> list(long postId) {
+ Post post = dao.find(Post.class, postId);
+ if (post == null) {
+ throw new IllegalArgumentException("post with id " + postId + " not found");
+ }
+ return Collections.unmodifiableList(post.getComments());
+ }
+
+ public Comment create(String author, String content, long postId) {
+ Post post = dao.find(Post.class, postId);
+ if (post == null) {
+ throw new IllegalArgumentException("post with id " + postId + " not found");
+ }
+
+ Comment comment = new Comment();
+ comment.setAuthor(author);
+ comment.setContent(content);
+ dao.create(comment);
+ comment.setPost(post);
+ return comment;
+ }
+
+ public void delete(long id) {
+ dao.delete(Comment.class, id);
+ }
+
+ public Comment update(long id, String author, String content) {
+ Comment comment = dao.find(Comment.class, id);
+ if (comment == null) {
+ throw new IllegalArgumentException("comment with id " + id + " not found");
+ }
+
+ comment.setAuthor(author);
+ comment.setContent(content);
+ return dao.update(comment);
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/DAO.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/DAO.java
new file mode 100755
index 0000000..ab64324
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/DAO.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.dao;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.util.List;
+
+/**
+ * Simply maps the entitymanager.
+ * It simplifies refactoring (unitName change) and wraps some logic (limited queries).
+ */
+@Singleton
+@Lock(LockType.READ)
+public class DAO {
+
+ @PersistenceContext(unitName = "blog")
+ private EntityManager em;
+
+ public <E> E create(E e) {
+ em.persist(e);
+ return e;
+ }
+
+ public <E> E update(E e) {
+ return em.merge(e);
+ }
+
+ public <E> void delete(Class<E> clazz, long id) {
+ em.remove(em.find(clazz, id));
+ }
+
+ public <E> E find(Class<E> clazz, long id) {
+ return em.find(clazz, id);
+ }
+
+ public <E> List<E> find(Class<E> clazz, String query, int min, int max) {
+ return queryRange(em.createQuery(query, clazz), min, max).getResultList();
+ }
+
+ public <E> List<E> namedFind(Class<E> clazz, String query, int min, int max) {
+ return queryRange(em.createNamedQuery(query, clazz), min, max).getResultList();
+ }
+
+ private static Query queryRange(Query query, int min, int max) {
+ if (max >= 0) {
+ query.setMaxResults(max);
+ }
+ if (min >= 0) {
+ query.setFirstResult(min);
+ }
+ return query;
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/PostDAO.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/PostDAO.java
new file mode 100755
index 0000000..1b164b3
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/PostDAO.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.dao;
+
+import org.superbiz.rest.model.Post;
+import org.superbiz.rest.model.User;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.inject.Inject;
+import java.util.List;
+
+@Singleton
+@Lock(LockType.READ)
+public class PostDAO {
+
+ @Inject
+ private DAO dao;
+
+ public Post create(String title, String content, long userId) {
+ User user = dao.find(User.class, userId);
+ Post post = new Post();
+ post.setTitle(title);
+ post.setContent(content);
+ post.setUser(user);
+ return dao.create(post);
+ }
+
+ public Post find(long id) {
+ return dao.find(Post.class, id);
+ }
+
+ public List<Post> list(int first, int max) {
+ return dao.namedFind(Post.class, "post.list", first, max);
+ }
+
+ public void delete(long id) {
+ dao.delete(Post.class, id);
+ }
+
+ public Post update(long id, long userId, String title, String content) {
+ User user = dao.find(User.class, userId);
+ if (user == null) {
+ throw new IllegalArgumentException("user id " + id + " not found");
+ }
+
+ Post post = dao.find(Post.class, id);
+ if (post == null) {
+ throw new IllegalArgumentException("post id " + id + " not found");
+ }
+
+ post.setTitle(title);
+ post.setContent(content);
+ post.setUser(user);
+ return dao.update(post);
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/UserDAO.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/UserDAO.java
new file mode 100755
index 0000000..75135e4
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/dao/UserDAO.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.dao;
+
+import org.superbiz.rest.model.User;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.inject.Inject;
+import java.util.List;
+
+@Singleton
+@Lock(LockType.READ)
+public class UserDAO {
+
+ @Inject
+ private DAO dao;
+
+ public User create(String name, String pwd, String mail) {
+ User user = new User();
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ return dao.create(user);
+ }
+
+ public List<User> list(int first, int max) {
+ return dao.namedFind(User.class, "user.list", first, max);
+ }
+
+ public User find(long id) {
+ return dao.find(User.class, id);
+ }
+
+ public void delete(long id) {
+ dao.delete(User.class, id);
+ }
+
+ public User update(long id, String name, String pwd, String mail) {
+ User user = dao.find(User.class, id);
+ if (user == null) {
+ throw new IllegalArgumentException("setUser id " + id + " not found");
+ }
+
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ return dao.update(user);
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/model/Comment.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/Comment.java
new file mode 100755
index 0000000..71ec450
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/Comment.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.model;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "comment.list", query = "select c from Comment c")
+ })
+@XmlRootElement(name = "comment")
+public class Comment extends Model {
+
+ @NotNull
+ @Size(min = 1)
+ private String author;
+ @NotNull
+ @Size(min = 1)
+ @Lob
+ private String content;
+ @ManyToOne
+ @JoinColumn(name = "post_id")
+ @Valid
+ @XmlTransient
+ private Post post;
+
+ public void setAuthor(final String author) {
+ this.author = author;
+ }
+
+ public void setContent(final String content) {
+ this.content = content;
+ }
+
+ public void setPost(Post post) {
+ post.addComment(this);
+ this.post = post;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public Post getPost() {
+ return post;
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/model/DatedModel.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/DatedModel.java
new file mode 100755
index 0000000..217cc30
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/DatedModel.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.model;
+
+import javax.persistence.MappedSuperclass;
+import javax.persistence.PrePersist;
+import java.util.Date;
+
+@MappedSuperclass
+public abstract class DatedModel extends Model {
+
+ private Date created;
+
+ @PrePersist
+ public void create() {
+ created = new Date();
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/model/Model.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/Model.java
new file mode 100755
index 0000000..73e5f31
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/Model.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.model;
+
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+@MappedSuperclass
+@Access(AccessType.FIELD)
+@XmlAccessorType(XmlAccessType.FIELD)
+public abstract class Model {
+
+ @Id
+ @GeneratedValue
+ protected long id;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/model/Post.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/Post.java
new file mode 100755
index 0000000..9d720b6
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/Post.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.model;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "post.list", query = "select p from Post p")
+ })
+@XmlRootElement(name = "post")
+public class Post extends DatedModel {
+
+ @NotNull
+ @Size(min = 1)
+ private String title;
+
+ @NotNull
+ @Size(min = 1)
+ @Lob
+ private String content;
+
+ @ManyToOne
+ @Valid
+ private User user;
+
+ @OneToMany(mappedBy = "post", fetch = FetchType.EAGER)
+ private List<Comment> comments = new ArrayList<Comment>();
+
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
+ public void setContent(final String content) {
+ this.content = content;
+ }
+
+ public void setUser(final User user) {
+ this.user = user;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public List<Comment> getComments() {
+ return comments;
+ }
+
+ public void setComments(List<Comment> comments) {
+ this.comments = comments;
+ }
+
+ public void addComment(final Comment comment) {
+ getComments().add(comment);
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/model/User.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/User.java
new file mode 100755
index 0000000..30eec97
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/model/User.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.model;
+
+import javax.persistence.Entity;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "user.list", query = "select u from User u")
+ })
+@XmlRootElement(name = "user")
+public class User extends Model {
+
+ @NotNull
+ @Size(min = 3, max = 15)
+ private String fullname;
+
+ @NotNull
+ @Size(min = 5, max = 15)
+ private String password;
+
+ @NotNull
+ @Pattern(regexp = ".+@.+\\.[a-z]+")
+ private String email;
+
+ public void setFullname(final String fullname) {
+ this.fullname = fullname;
+ }
+
+ public void setPassword(final String password) {
+ this.password = password;
+ }
+
+ public void setEmail(final String email) {
+ this.email = email;
+ }
+
+ public String getFullname() {
+ return fullname;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/service/CommentService.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/service/CommentService.java
new file mode 100755
index 0000000..4d83dc9
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/service/CommentService.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.rest.service;
+
+import org.superbiz.rest.dao.CommentDAO;
+import org.superbiz.rest.model.Comment;
+
+import javax.ejb.EJB;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("/api/comment")
+@Produces({"text/xml", "application/json"})
+public class CommentService {
+
+ @EJB
+ private CommentDAO commentDao;
+
+ @Path("/create")
+ @PUT
+ public Comment create(@QueryParam("author") String author,
+ @QueryParam("content") String content,
+ @QueryParam("postId") long postId) {
+ return commentDao.create(author, content, postId);
+ }
+
+ @Path("/list/{postId}")
+ @GET
+ public List<Comment> list(@PathParam("postId") long postId) {
+ return commentDao.list(postId);
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ commentDao.delete(id);
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public Comment update(@PathParam("id") long id,
+ @QueryParam("author") String author,
+ @QueryParam("content") String content) {
+ return commentDao.update(id, author, content);
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/service/PostService.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/service/PostService.java
new file mode 100755
index 0000000..0151faa
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/service/PostService.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.service;
+
+import org.superbiz.rest.dao.PostDAO;
+import org.superbiz.rest.model.Post;
+
+import javax.ejb.EJB;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("/api/post")
+@Produces({"text/xml", "application/json"})
+public class PostService {
+
+ @EJB
+ private PostDAO dao;
+
+ @Path("/create")
+ @PUT
+ public Post create(@QueryParam("title") String title,
+ @QueryParam("content") String content,
+ @QueryParam("userId") long userId) {
+ return dao.create(title, content, userId);
+ }
+
+ @Path("/list")
+ @GET
+ public List<Post> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
+ return dao.list(first, max);
+ }
+
+ @Path("/show/{id}")
+ @GET
+ public Post show(@PathParam("id") long id) {
+ return dao.find(id);
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ dao.delete(id);
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public Post update(@PathParam("id") long id,
+ @QueryParam("userId") long userId,
+ @QueryParam("title") String title,
+ @QueryParam("content") String content) {
+ return dao.update(id, userId, title, content);
+ }
+}
diff --git a/content/examples/rest-example/src/main/java/org/superbiz/rest/service/UserService.java b/content/examples/rest-example/src/main/java/org/superbiz/rest/service/UserService.java
new file mode 100755
index 0000000..e4bada9
--- /dev/null
+++ b/content/examples/rest-example/src/main/java/org/superbiz/rest/service/UserService.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.service;
+
+import org.superbiz.rest.dao.UserDAO;
+import org.superbiz.rest.model.User;
+
+import javax.ejb.EJB;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("/api/user")
+@Produces({"text/xml", "application/json"})
+public class UserService {
+
+ @EJB
+ private UserDAO dao;
+
+ @Path("/create")
+ @PUT
+ public User create(@QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ return dao.create(name, pwd, mail);
+ }
+
+ @Path("/list")
+ @GET
+ public List<User> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
+ return dao.list(first, max);
+ }
+
+ @Path("/show/{id}")
+ @GET
+ public User show(@PathParam("id") long id) {
+ return dao.find(id);
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ dao.delete(id);
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public User update(@PathParam("id") long id,
+ @QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ return dao.update(id, name, pwd, mail);
+ }
+}
diff --git a/content/examples/rest-example/src/main/resources/META-INF/beans.xml b/content/examples/rest-example/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..9b0b74f
--- /dev/null
+++ b/content/examples/rest-example/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,18 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans/>
diff --git a/content/examples/rest-example/src/main/resources/META-INF/persistence.xml b/content/examples/rest-example/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..705e33b
--- /dev/null
+++ b/content/examples/rest-example/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="blog">
+ <jta-data-source>jdbc/blog</jta-data-source>
+ <non-jta-data-source>jdbc/blog-unmanaged</non-jta-data-source>
+ <class>org.superbiz.rest.model.User</class>
+ <class>org.superbiz.rest.model.Post</class>
+ <class>org.superbiz.rest.model.Comment</class>
+ <class>org.superbiz.rest.model.Model</class>
+ <class>org.superbiz.rest.model.DatedModel</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/rest-example/src/main/resources/META-INF/resources.xml b/content/examples/rest-example/src/main/resources/META-INF/resources.xml
new file mode 100755
index 0000000..f6ff886
--- /dev/null
+++ b/content/examples/rest-example/src/main/resources/META-INF/resources.xml
@@ -0,0 +1,35 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <Resource id="jdbc/blog" type="javax.sql.DataSource">
+ JdbcDriver = org.hsqldb.jdbcDriver
+ JdbcUrl = jdbc:hsqldb:mem:blog
+ UserName = SA
+ Password =
+ JtaManaged = true
+ </Resource>
+
+
+ <Resource id="jdbc/blog-unmanaged" type="javax.sql.DataSource">
+ JdbcDriver = org.hsqldb.jdbcDriver
+ JdbcUrl = jdbc:hsqldb:mem:blog
+ UserName = SA
+ Password =
+ JtaManaged = false
+ </Resource>
+</resources>
diff --git a/content/examples/rest-example/src/main/webapp/WEB-INF/beans.xml b/content/examples/rest-example/src/main/webapp/WEB-INF/beans.xml
new file mode 100755
index 0000000..bbc3399
--- /dev/null
+++ b/content/examples/rest-example/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,17 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<beans/>
diff --git a/content/examples/rest-example/src/main/webapp/WEB-INF/web.xml b/content/examples/rest-example/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..f326724
--- /dev/null
+++ b/content/examples/rest-example/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<web-app 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/web-app_2_5.xsd"
+ metadata-complete="false"
+ version="2.5">
+
+ <display-name>OpenEJB REST Example</display-name>
+</web-app>
diff --git a/content/examples/rest-example/src/main/webapp/index.html b/content/examples/rest-example/src/main/webapp/index.html
new file mode 100755
index 0000000..c74b4ad
--- /dev/null
+++ b/content/examples/rest-example/src/main/webapp/index.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html lang="en">
+<head>
+ <title>OpenEJB REST Example</title>
+</head>
+<body>
+<p>
+ Here are the REST services (all return xml or json).
+<ul>
+ <li><em>Note 1: for all services base is http://localhost:1234/rest-example/</em></li>
+ <li><em>Note 3: for all services base is http://localhost:1234/rest-example/</em></li>
+</ul>
+
+<table border="1">
+ <tbody>
+ <tr>
+ <th><em>Entity</em></th>
+ <th><b>User</b></th>
+ <th><b>Post</b></th>
+ <th><b>Comment</b></th>
+ </tr>
+ <tr>
+ <td><em>create</em></td>
+ <td>PUT /api/user/create?name=NAME&pwd=PASSWORD&mail=EMAIL</td>
+ <td>PUT /api/post/create?title=TITLE&content=CONTENT&userId=USER_ID</td>
+ <td>PUT /api/comment/create?author=NAME&content=CONTENT&postId=POST_ID</td>
+ </tr>
+ <tr>
+ <td><em>update</em></td>
+ <td>POST /api/user/update/USER_ID?name=NAME&pwd=PASSWOR&mail=MAIL</td>
+ <td>POST /api/post/update/POST_ID?userId=USER_ID&title=TITLE&content=CONTENT</td>
+ <td>POST /api/comment/update/COMMENT_ID?author=NAME&content=CONTENT</td>
+ </tr>
+ <tr>
+ <td><em>delete</em></td>
+ <td>DELETE /api/user/USER_ID</td>
+ <td>DELETE /api/post/POST_ID</td>
+ <td>DELETE /api/comment/COMMENT_ID</td>
+ </tr>
+ <tr>
+ <td><em>list</em></td>
+ <td>GET /api/user/list</td>
+ <td>GET /api/post/list</td>
+ <td>GET /api/comment/list/POST_ID</td>
+ </tr>
+ </tbody>
+</table>
+</p>
+</body>
+</html>
diff --git a/content/examples/rest-example/src/test/java/org/superbiz/rest/dao/UserDaoTest.java b/content/examples/rest-example/src/test/java/org/superbiz/rest/dao/UserDaoTest.java
new file mode 100755
index 0000000..39be059
--- /dev/null
+++ b/content/examples/rest-example/src/test/java/org/superbiz/rest/dao/UserDaoTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.dao;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.superbiz.rest.model.User;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.NamingException;
+
+import static org.junit.Assert.assertNotNull;
+
+public class UserDaoTest {
+
+ private static EJBContainer container;
+
+ @BeforeClass
+ public static void start() {
+ container = EJBContainer.createEJBContainer();
+ }
+
+ @AfterClass
+ public static void stop() {
+ if (container != null) {
+ container.close();
+ }
+ }
+
+ @Test
+ public void create() throws NamingException {
+ final UserDAO dao = (UserDAO) container.getContext().lookup("java:global/rest-example/UserDAO");
+ final User user = dao.create("foo", "dummy", "foo@bar.org");
+ assertNotNull(dao.find(user.getId()));
+ }
+}
diff --git a/content/examples/rest-example/src/test/java/org/superbiz/rest/dao/UserServiceTest.java b/content/examples/rest-example/src/test/java/org/superbiz/rest/dao/UserServiceTest.java
new file mode 100755
index 0000000..04a985a
--- /dev/null
+++ b/content/examples/rest-example/src/test/java/org/superbiz/rest/dao/UserServiceTest.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest.dao;
+
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+import org.apache.tomee.embedded.EmbeddedTomEEContainer;
+import org.apache.ziplock.Archive;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.superbiz.rest.model.User;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.NamingException;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.apache.openejb.loader.JarLocation.jarLocation;
+
+public class UserServiceTest {
+
+ private static EJBContainer container;
+
+ @BeforeClass
+ public static void start() throws IOException {
+ final File webApp = Archive.archive().copyTo("WEB-INF/classes", jarLocation(UserDAO.class)).asDir();
+ final Properties p = new Properties();
+ p.setProperty(EJBContainer.APP_NAME, "rest-example");
+ p.setProperty(EJBContainer.PROVIDER, "tomee-embedded"); // need web feature
+ p.setProperty(EJBContainer.MODULES, webApp.getAbsolutePath());
+ p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, "-1"); // random port
+ container = EJBContainer.createEJBContainer(p);
+ }
+
+ @AfterClass
+ public static void stop() {
+ if (container != null) {
+ container.close();
+ }
+ }
+
+ @Test
+ public void create() throws NamingException {
+ final UserDAO dao = (UserDAO) container.getContext().lookup("java:global/rest-example/UserDAO");
+ final User user = dao.create("foo", "dummy", "foo@dummy.org");
+ assertNotNull(dao.find(user.getId()));
+
+ final String uri = "http://127.0.0.1:" + System.getProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT) + "/rest-example";
+ final UserServiceClientAPI client = JAXRSClientFactory.create(uri, UserServiceClientAPI.class);
+ final User retrievedUser = client.show(user.getId());
+ assertNotNull(retrievedUser);
+ assertEquals("foo", retrievedUser.getFullname());
+ assertEquals("dummy", retrievedUser.getPassword());
+ assertEquals("foo@dummy.org", retrievedUser.getEmail());
+ }
+
+ /**
+ * a simple copy of the unique method i want to use from my service.
+ * It allows to use cxf proxy to call remotely our rest service.
+ * Any other way to do it is good.
+ */
+ @Path("/api/user")
+ @Produces({"text/xml", "application/json"})
+ public static interface UserServiceClientAPI {
+
+ @Path("/show/{id}")
+ @GET
+ User show(@PathParam("id") long id);
+ }
+}
diff --git a/content/examples/rest-jaas.html b/content/examples/rest-jaas.html
new file mode 100644
index 0000000..afea401
--- /dev/null
+++ b/content/examples/rest-jaas.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/rest-jaas.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>rest-jaas</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example rest-jaas can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/rest-jaas" class="bare">https://github.com/apache/tomee/tree/master/examples/rest-jaas</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/rest-jaas.pdf b/content/examples/rest-jaas.pdf
new file mode 100644
index 0000000..72e85e3
--- /dev/null
+++ b/content/examples/rest-jaas.pdf
Binary files differ
diff --git a/content/examples/rest-jaas/pom.xml b/content/examples/rest-jaas/pom.xml
new file mode 100755
index 0000000..e9ac144
--- /dev/null
+++ b/content/examples/rest-jaas/pom.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>rest-jaas</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>OpenEJB :: Examples :: JAXRS and JAAS</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ <configuration>
+ <systemVariables>
+ <java.security.auth.login.config>${project.build.directory}/apache-tomee/conf/login.config</java.security.auth.login.config>
+ </systemVariables>
+ <context>ROOT</context>
+ <tomeeClassifier>jaxrs</tomeeClassifier>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot-plugin</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+</project>
diff --git a/content/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/jaas/JAASSecuredRestEndpoint.java b/content/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/jaas/JAASSecuredRestEndpoint.java
new file mode 100755
index 0000000..420ef2f
--- /dev/null
+++ b/content/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/jaas/JAASSecuredRestEndpoint.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.jaxrs.jaas;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.SessionContext;
+import javax.ejb.Singleton;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("rest")
+@Singleton
+@Lock(LockType.READ)
+public class JAASSecuredRestEndpoint {
+
+ @Resource
+ private SessionContext ctx;
+
+ @GET
+ @Path("jaas")
+ @RolesAllowed("superUser")
+ public String getPrincipalName() {
+ return ctx.getCallerPrincipal().getName();
+ }
+}
diff --git a/content/examples/rest-jaas/src/main/tomee/conf/groups.properties b/content/examples/rest-jaas/src/main/tomee/conf/groups.properties
new file mode 100755
index 0000000..f75cde4
--- /dev/null
+++ b/content/examples/rest-jaas/src/main/tomee/conf/groups.properties
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+admin=tomee,adminOnly
+superUser=tomee
diff --git a/content/examples/rest-jaas/src/main/tomee/conf/login.config b/content/examples/rest-jaas/src/main/tomee/conf/login.config
new file mode 100755
index 0000000..6665d32
--- /dev/null
+++ b/content/examples/rest-jaas/src/main/tomee/conf/login.config
@@ -0,0 +1,6 @@
+PropertiesLoginModule {
+ org.apache.openejb.core.security.jaas.PropertiesLoginModule required
+ Debug=false
+ UsersFile="users.properties"
+ GroupsFile="groups.properties";
+};
diff --git a/content/examples/rest-jaas/src/main/tomee/conf/server.xml b/content/examples/rest-jaas/src/main/tomee/conf/server.xml
new file mode 100755
index 0000000..d93765f
--- /dev/null
+++ b/content/examples/rest-jaas/src/main/tomee/conf/server.xml
@@ -0,0 +1,36 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<Server port="8005" shutdown="SHUTDOWN">
+ <Listener className="org.apache.tomee.catalina.ServerListener"/>
+ <Listener className="org.apache.catalina.security.SecurityListener"/>
+
+ <Service name="Catalina">
+ <Connector port="8080" protocol="HTTP/1.1"/>
+ <Engine name="Catalina" defaultHost="localhost">
+
+ <Realm className="org.apache.catalina.realm.JAASRealm" appName="PropertiesLoginModule"
+ userClassNames="org.apache.openejb.core.security.jaas.UserPrincipal"
+ roleClassNames="org.apache.openejb.core.security.jaas.GroupPrincipal">
+ </Realm>
+
+ <Host name="localhost" appBase="webapps"/>
+ </Engine>
+ </Service>
+</Server>
diff --git a/content/examples/rest-jaas/src/main/tomee/conf/users.properties b/content/examples/rest-jaas/src/main/tomee/conf/users.properties
new file mode 100755
index 0000000..1d7c951
--- /dev/null
+++ b/content/examples/rest-jaas/src/main/tomee/conf/users.properties
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+tomee=tomee
+adminOnly=adminOnly
diff --git a/content/examples/rest-jaas/src/main/webapp/WEB-INF/web.xml b/content/examples/rest-jaas/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..6e61ac2
--- /dev/null
+++ b/content/examples/rest-jaas/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<web-app 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/web-app_3_0.xsd"
+ version="3.0">
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>PropertiesLoginModule</realm-name>
+ </login-config>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Secured REST Service with JAAS</web-resource-name>
+ <url-pattern>/rest/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>*</role-name>
+ <!-- we'll use JAAS so don't filter too much here -->
+ </auth-constraint>
+ </security-constraint>
+
+ <security-role>
+ <role-name>admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>superUser</role-name>
+ </security-role>
+</web-app>
diff --git a/content/examples/rest-on-ejb.html b/content/examples/rest-on-ejb.html
new file mode 100644
index 0000000..243d014
--- /dev/null
+++ b/content/examples/rest-on-ejb.html
@@ -0,0 +1,545 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/rest-on-ejb.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>REST on EJB</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example rest-on-ejb can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/rest-on-ejb" class="bare">https://github.com/apache/tomee/tree/master/examples/rest-on-ejb</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_user">User</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "user.list", query = "select u from User u")
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_userservice">UserService</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Outputs are copied because of the enhancement of OpenJPA.
+ *
+ */
+@Singleton
+@Lock(LockType.WRITE)
+@Path("/user")
+@Produces(MediaType.APPLICATION_XML)
+public class UserService {
+ @PersistenceContext
+ private EntityManager em;
+
+ @Path("/create")
+ @PUT
+ public User create(@QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ User user = new User();
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ em.persist(user);
+ return user;
+ }
+
+ @Path("/list")
+ @GET
+ public List<User> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
+ List<User> users = new ArrayList<User>();
+ List<User> found = em.createNamedQuery("user.list", User.class).setFirstResult(first).setMaxResults(max).getResultList();
+ for (User u : found) {
+ users.add(u.copy());
+ }
+ return users;
+ }
+
+ @Path("/show/{id}")
+ @GET
+ public User find(@PathParam("id") long id) {
+ User user = em.find(User.class, id);
+ if (user == null) {
+ return null;
+ }
+ return user.copy();
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ User user = em.find(User.class, id);
+ if (user != null) {
+ em.remove(user);
+ }
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public Response update(@PathParam("id") long id,
+ @QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ User user = em.find(User.class, id);
+ if (user == null) {
+ throw new IllegalArgumentException("user id " + id + " not found");
+ }
+
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ em.merge(user);
+
+ return Response.ok(user.copy()).build();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="user">
+ <jta-data-source>My DataSource</jta-data-source>
+ <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
+ <class>org.superbiz.rest.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_userservicetest">UserServiceTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.OpenEjbContainer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.fail;
+
+public class UserServiceTest {
+ private static Context context;
+ private static UserService service;
+ private static List<User> users = new ArrayList<User>();
+
+ @BeforeClass
+ public static void start() throws NamingException {
+ Properties properties = new Properties();
+ properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
+ context = EJBContainer.createEJBContainer(properties).getContext();
+
+ // create some records
+ service = (UserService) context.lookup("java:global/rest-on-ejb/UserService");
+ users.add(service.create("foo", "foopwd", "foo@foo.com"));
+ users.add(service.create("bar", "barpwd", "bar@bar.com"));
+ }
+
+ @AfterClass
+ public static void close() throws NamingException {
+ if (context != null) {
+ context.close();
+ }
+ }
+
+ @Test
+ public void create() {
+ int expected = service.list(0, 100).size() + 1;
+ Response response = WebClient.create("http://localhost:4204")
+ .path("/user/create")
+ .query("name", "dummy")
+ .query("pwd", "unbreakable")
+ .query("mail", "foo@bar.fr")
+ .put(null);
+ List<User> list = service.list(0, 100);
+ for (User u : list) {
+ if (!users.contains(u)) {
+ service.delete(u.getId());
+ return;
+ }
+ }
+ fail("user was not added");
+ }
+
+ @Test
+ public void delete() throws Exception {
+ User user = service.create("todelete", "dontforget", "delete@me.com");
+
+ WebClient.create("http://localhost:4204").path("/user/delete/" + user.getId()).delete();
+
+ user = service.find(user.getId());
+ assertNull(user);
+ }
+
+ @Test
+ public void show() {
+ User user = WebClient.create("http://localhost:4204")
+ .path("/user/show/" + users.iterator().next().getId())
+ .get(User.class);
+ assertEquals("foo", user.getFullname());
+ assertEquals("foopwd", user.getPassword());
+ assertEquals("foo@foo.com", user.getEmail());
+ }
+
+ @Test
+ public void list() throws Exception {
+ String users = WebClient.create("http://localhost:4204")
+ .path("/user/list")
+ .get(String.class);
+ assertEquals(
+ "<users>" +
+ "<user>" +
+ "<email>foo@foo.com</email>" +
+ "<fullname>foo</fullname>" +
+ "<id>1</id>" +
+ "<password>foopwd</password>" +
+ "</user>" +
+ "<user>" +
+ "<email>bar@bar.com</email>" +
+ "<fullname>bar</fullname>" +
+ "<id>2</id>" +
+ "<password>barpwd</password>" +
+ "</user>" +
+ "</users>", users);
+ }
+
+ @Test
+ public void update() throws Exception {
+ User created = service.create("name", "pwd", "mail");
+ Response response = WebClient.create("http://localhost:4204")
+ .path("/user/update/" + created.getId())
+ .query("name", "corrected")
+ .query("pwd", "userpwd")
+ .query("mail", "it@is.ok")
+ .post(null);
+
+ JAXBContext ctx = JAXBContext.newInstance(User.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ User modified = (User) unmarshaller.unmarshal(InputStream.class.cast(response.getEntity()));
+
+ assertEquals("corrected", modified.getFullname());
+ assertEquals("userpwd", modified.getPassword());
+ assertEquals("it@is.ok", modified.getEmail());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.rest.UserServiceTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/rest-on-ejb
+INFO - openejb.base = /Users/dblevins/examples/rest-on-ejb
+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/rest-on-ejb/target/classes
+INFO - Beginning load: /Users/dblevins/examples/rest-on-ejb/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/rest-on-ejb
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean UserService: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.UserServiceTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=user)
+INFO - Configuring Service(id=Default JDBC Database, type=Resource, provider-id=Default JDBC Database)
+INFO - Auto-creating a Resource with id 'Default JDBC Database' of type 'DataSource for 'user'.
+INFO - Configuring Service(id=Default Unmanaged JDBC Database, type=Resource, provider-id=Default Unmanaged JDBC Database)
+INFO - Auto-creating a Resource with id 'Default Unmanaged JDBC Database' of type 'DataSource for 'user'.
+INFO - Adjusting PersistenceUnit user <jta-data-source> to Resource ID 'Default JDBC Database' from 'My DataSource'
+INFO - Adjusting PersistenceUnit user <non-jta-data-source> to Resource ID 'Default Unmanaged JDBC Database' from 'My Unmanaged DataSource'
+INFO - Enterprise application "/Users/dblevins/examples/rest-on-ejb" loaded.
+INFO - Assembling app: /Users/dblevins/examples/rest-on-ejb
+INFO - PersistenceUnit(name=user, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 407ms
+INFO - Jndi(name="java:global/rest-on-ejb/UserService!org.superbiz.rest.UserService")
+INFO - Jndi(name="java:global/rest-on-ejb/UserService")
+INFO - Jndi(name="java:global/EjbModule1789767313/org.superbiz.rest.UserServiceTest!org.superbiz.rest.UserServiceTest")
+INFO - Jndi(name="java:global/EjbModule1789767313/org.superbiz.rest.UserServiceTest")
+INFO - Created Ejb(deployment-id=org.superbiz.rest.UserServiceTest, ejb-name=org.superbiz.rest.UserServiceTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=UserService, ejb-name=UserService, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=org.superbiz.rest.UserServiceTest, ejb-name=org.superbiz.rest.UserServiceTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=UserService, ejb-name=UserService, container=Default Singleton Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/rest-on-ejb)
+INFO - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Creating ServerService(id=admin)
+INFO - Creating ServerService(id=ejbd)
+INFO - Creating ServerService(id=ejbds)
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+-------
+Ready!
+WARN - Query "select u from User u" is removed from cache excluded permanently. Query "select u from User u" is not cached because it uses pagination..
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.102 sec
+
+Results :
+
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/rest-on-ejb.pdf b/content/examples/rest-on-ejb.pdf
new file mode 100644
index 0000000..e6cefad
--- /dev/null
+++ b/content/examples/rest-on-ejb.pdf
Binary files differ
diff --git a/content/examples/rest-on-ejb/README.md b/content/examples/rest-on-ejb/README.md
new file mode 100755
index 0000000..6ebcf1f
--- /dev/null
+++ b/content/examples/rest-on-ejb/README.md
@@ -0,0 +1,328 @@
+Title: REST on EJB
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## User
+
+ package org.superbiz.rest;
+
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.Id;
+ import javax.persistence.NamedQueries;
+ import javax.persistence.NamedQuery;
+ import javax.xml.bind.annotation.XmlRootElement;
+
+ @Entity
+ @NamedQueries({
+ @NamedQuery(name = "user.list", query = "select u from User u")
+ }
+
+## UserService
+
+ package org.superbiz.rest;
+
+ import javax.ejb.Lock;
+ import javax.ejb.LockType;
+ import javax.ejb.Singleton;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.ws.rs.DELETE;
+ import javax.ws.rs.DefaultValue;
+ import javax.ws.rs.GET;
+ import javax.ws.rs.POST;
+ import javax.ws.rs.PUT;
+ import javax.ws.rs.Path;
+ import javax.ws.rs.PathParam;
+ import javax.ws.rs.Produces;
+ import javax.ws.rs.QueryParam;
+ import javax.ws.rs.core.MediaType;
+ import javax.ws.rs.core.Response;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ /**
+ * Outputs are copied because of the enhancement of OpenJPA.
+ *
+ */
+ @Singleton
+ @Lock(LockType.WRITE)
+ @Path("/user")
+ @Produces(MediaType.APPLICATION_XML)
+ public class UserService {
+ @PersistenceContext
+ private EntityManager em;
+
+ @Path("/create")
+ @PUT
+ public User create(@QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ User user = new User();
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ em.persist(user);
+ return user;
+ }
+
+ @Path("/list")
+ @GET
+ public List<User> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
+ List<User> users = new ArrayList<User>();
+ List<User> found = em.createNamedQuery("user.list", User.class).setFirstResult(first).setMaxResults(max).getResultList();
+ for (User u : found) {
+ users.add(u.copy());
+ }
+ return users;
+ }
+
+ @Path("/show/{id}")
+ @GET
+ public User find(@PathParam("id") long id) {
+ User user = em.find(User.class, id);
+ if (user == null) {
+ return null;
+ }
+ return user.copy();
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ User user = em.find(User.class, id);
+ if (user != null) {
+ em.remove(user);
+ }
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public Response update(@PathParam("id") long id,
+ @QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ User user = em.find(User.class, id);
+ if (user == null) {
+ throw new IllegalArgumentException("user id " + id + " not found");
+ }
+
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ em.merge(user);
+
+ return Response.ok(user.copy()).build();
+ }
+ }
+
+## persistence.xml
+
+ <persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="user">
+ <jta-data-source>My DataSource</jta-data-source>
+ <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
+ <class>org.superbiz.rest.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## UserServiceTest
+
+ package org.superbiz.rest;
+
+ import org.apache.cxf.jaxrs.client.WebClient;
+ import org.apache.openejb.OpenEjbContainer;
+ import org.junit.AfterClass;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import javax.naming.NamingException;
+ import javax.ws.rs.core.Response;
+ import javax.xml.bind.JAXBContext;
+ import javax.xml.bind.Unmarshaller;
+ import java.io.InputStream;
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Properties;
+
+ import static junit.framework.Assert.assertEquals;
+ import static junit.framework.Assert.assertNull;
+ import static junit.framework.Assert.fail;
+
+ public class UserServiceTest {
+ private static Context context;
+ private static UserService service;
+ private static List<User> users = new ArrayList<User>();
+
+ @BeforeClass
+ public static void start() throws NamingException {
+ Properties properties = new Properties();
+ properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
+ context = EJBContainer.createEJBContainer(properties).getContext();
+
+ // create some records
+ service = (UserService) context.lookup("java:global/rest-on-ejb/UserService");
+ users.add(service.create("foo", "foopwd", "foo@foo.com"));
+ users.add(service.create("bar", "barpwd", "bar@bar.com"));
+ }
+
+ @AfterClass
+ public static void close() throws NamingException {
+ if (context != null) {
+ context.close();
+ }
+ }
+
+ @Test
+ public void create() {
+ int expected = service.list(0, 100).size() + 1;
+ Response response = WebClient.create("http://localhost:4204")
+ .path("/user/create")
+ .query("name", "dummy")
+ .query("pwd", "unbreakable")
+ .query("mail", "foo@bar.fr")
+ .put(null);
+ List<User> list = service.list(0, 100);
+ for (User u : list) {
+ if (!users.contains(u)) {
+ service.delete(u.getId());
+ return;
+ }
+ }
+ fail("user was not added");
+ }
+
+ @Test
+ public void delete() throws Exception {
+ User user = service.create("todelete", "dontforget", "delete@me.com");
+
+ WebClient.create("http://localhost:4204").path("/user/delete/" + user.getId()).delete();
+
+ user = service.find(user.getId());
+ assertNull(user);
+ }
+
+ @Test
+ public void show() {
+ User user = WebClient.create("http://localhost:4204")
+ .path("/user/show/" + users.iterator().next().getId())
+ .get(User.class);
+ assertEquals("foo", user.getFullname());
+ assertEquals("foopwd", user.getPassword());
+ assertEquals("foo@foo.com", user.getEmail());
+ }
+
+ @Test
+ public void list() throws Exception {
+ String users = WebClient.create("http://localhost:4204")
+ .path("/user/list")
+ .get(String.class);
+ assertEquals(
+ "<users>" +
+ "<user>" +
+ "<email>foo@foo.com</email>" +
+ "<fullname>foo</fullname>" +
+ "<id>1</id>" +
+ "<password>foopwd</password>" +
+ "</user>" +
+ "<user>" +
+ "<email>bar@bar.com</email>" +
+ "<fullname>bar</fullname>" +
+ "<id>2</id>" +
+ "<password>barpwd</password>" +
+ "</user>" +
+ "</users>", users);
+ }
+
+ @Test
+ public void update() throws Exception {
+ User created = service.create("name", "pwd", "mail");
+ Response response = WebClient.create("http://localhost:4204")
+ .path("/user/update/" + created.getId())
+ .query("name", "corrected")
+ .query("pwd", "userpwd")
+ .query("mail", "it@is.ok")
+ .post(null);
+
+ JAXBContext ctx = JAXBContext.newInstance(User.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ User modified = (User) unmarshaller.unmarshal(InputStream.class.cast(response.getEntity()));
+
+ assertEquals("corrected", modified.getFullname());
+ assertEquals("userpwd", modified.getPassword());
+ assertEquals("it@is.ok", modified.getEmail());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.rest.UserServiceTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/rest-on-ejb
+ INFO - openejb.base = /Users/dblevins/examples/rest-on-ejb
+ 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/rest-on-ejb/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/rest-on-ejb/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/rest-on-ejb
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean UserService: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.UserServiceTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=user)
+ INFO - Configuring Service(id=Default JDBC Database, type=Resource, provider-id=Default JDBC Database)
+ INFO - Auto-creating a Resource with id 'Default JDBC Database' of type 'DataSource for 'user'.
+ INFO - Configuring Service(id=Default Unmanaged JDBC Database, type=Resource, provider-id=Default Unmanaged JDBC Database)
+ INFO - Auto-creating a Resource with id 'Default Unmanaged JDBC Database' of type 'DataSource for 'user'.
+ INFO - Adjusting PersistenceUnit user <jta-data-source> to Resource ID 'Default JDBC Database' from 'My DataSource'
+ INFO - Adjusting PersistenceUnit user <non-jta-data-source> to Resource ID 'Default Unmanaged JDBC Database' from 'My Unmanaged DataSource'
+ INFO - Enterprise application "/Users/dblevins/examples/rest-on-ejb" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/rest-on-ejb
+ INFO - PersistenceUnit(name=user, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 407ms
+ INFO - Jndi(name="java:global/rest-on-ejb/UserService!org.superbiz.rest.UserService")
+ INFO - Jndi(name="java:global/rest-on-ejb/UserService")
+ INFO - Jndi(name="java:global/EjbModule1789767313/org.superbiz.rest.UserServiceTest!org.superbiz.rest.UserServiceTest")
+ INFO - Jndi(name="java:global/EjbModule1789767313/org.superbiz.rest.UserServiceTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.rest.UserServiceTest, ejb-name=org.superbiz.rest.UserServiceTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=UserService, ejb-name=UserService, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.rest.UserServiceTest, ejb-name=org.superbiz.rest.UserServiceTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=UserService, ejb-name=UserService, container=Default Singleton Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/rest-on-ejb)
+ INFO - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Creating ServerService(id=admin)
+ INFO - Creating ServerService(id=ejbd)
+ INFO - Creating ServerService(id=ejbds)
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+ -------
+ Ready!
+ WARN - Query "select u from User u" is removed from cache excluded permanently. Query "select u from User u" is not cached because it uses pagination..
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.102 sec
+
+ Results :
+
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/rest-on-ejb/pom.xml b/content/examples/rest-on-ejb/pom.xml
new file mode 100755
index 0000000..90bd347
--- /dev/null
+++ b/content/examples/rest-on-ejb/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 16:49:26 +0200 (dim., 10 avr. 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>rest-on-ejb</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: REST and EJB</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/rest-on-ejb/src/main/java/org/superbiz/rest/User.java b/content/examples/rest-on-ejb/src/main/java/org/superbiz/rest/User.java
new file mode 100755
index 0000000..87227f5
--- /dev/null
+++ b/content/examples/rest-on-ejb/src/main/java/org/superbiz/rest/User.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.rest;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "user.list", query = "select u from User u order by u.fullname")
+ })
+@XmlRootElement(name = "user")
+public class User implements Cloneable {
+
+ @Id
+ @GeneratedValue
+ private long id;
+ private String fullname;
+ private String password;
+ private String email;
+
+ public void setFullname(final String fullname) {
+ this.fullname = fullname;
+ }
+
+ public void setPassword(final String password) {
+ this.password = password;
+ }
+
+ public void setEmail(final String email) {
+ this.email = email;
+ }
+
+ public String getFullname() {
+ return fullname;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public User copy() {
+ User user = new User();
+ user.setEmail(getEmail());
+ user.setFullname(getFullname());
+ user.setPassword(getPassword());
+ user.setId(getId());
+ return user;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || !User.class.isAssignableFrom(o.getClass())) {
+ return false;
+ }
+
+ User user = (User) o;
+
+ return id == user.id;
+ }
+
+ @Override
+ public int hashCode() {
+ return (int) (id ^ (id >>> 32));
+ }
+}
diff --git a/content/examples/rest-on-ejb/src/main/java/org/superbiz/rest/UserService.java b/content/examples/rest-on-ejb/src/main/java/org/superbiz/rest/UserService.java
new file mode 100755
index 0000000..deb40d7
--- /dev/null
+++ b/content/examples/rest-on-ejb/src/main/java/org/superbiz/rest/UserService.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Outputs are copied because of the enhancement of OpenJPA.
+ */
+@Singleton
+@Lock(LockType.WRITE)
+@Path("/user")
+@Produces(MediaType.APPLICATION_XML)
+public class UserService {
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Path("/create")
+ @PUT
+ public User create(@QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ User user = new User();
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ em.persist(user);
+ return user;
+ }
+
+ @Path("/list")
+ @GET
+ public List<User> list(@QueryParam("first") @DefaultValue("0") int first,
+ @QueryParam("max") @DefaultValue("20") int max) {
+ List<User> users = new ArrayList<User>();
+ List<User> found = em.createNamedQuery("user.list", User.class).setFirstResult(first).setMaxResults(max).getResultList();
+ for (User u : found) {
+ users.add(u.copy());
+ }
+ return users;
+ }
+
+ @Path("/show/{id}")
+ @GET
+ public User find(@PathParam("id") long id) {
+ User user = em.find(User.class, id);
+ if (user == null) {
+ return null;
+ }
+ return user.copy();
+
+ }
+
+ @Path("/delete/{id}")
+ @DELETE
+ public void delete(@PathParam("id") long id) {
+ User user = em.find(User.class, id);
+ if (user != null) {
+ em.remove(user);
+ }
+ }
+
+ @Path("/update/{id}")
+ @POST
+ public Response update(@PathParam("id") long id,
+ @QueryParam("name") String name,
+ @QueryParam("pwd") String pwd,
+ @QueryParam("mail") String mail) {
+ User user = em.find(User.class, id);
+ if (user == null) {
+ throw new IllegalArgumentException("user id " + id + " not found");
+ }
+
+ user.setFullname(name);
+ user.setPassword(pwd);
+ user.setEmail(mail);
+ em.merge(user);
+
+ return Response.ok(user.copy()).build();
+ }
+}
diff --git a/content/examples/rest-on-ejb/src/main/resources/META-INF/persistence.xml b/content/examples/rest-on-ejb/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..1e1495b
--- /dev/null
+++ b/content/examples/rest-on-ejb/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="user">
+ <jta-data-source>My DataSource</jta-data-source>
+ <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
+ <class>org.superbiz.rest.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/rest-on-ejb/src/test/java/org/superbiz/rest/UserServiceTest.java b/content/examples/rest-on-ejb/src/test/java/org/superbiz/rest/UserServiceTest.java
new file mode 100755
index 0000000..618aec3
--- /dev/null
+++ b/content/examples/rest-on-ejb/src/test/java/org/superbiz/rest/UserServiceTest.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.OpenEjbContainer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+public class UserServiceTest {
+
+ private static Context context;
+ private static UserService service;
+ private static List<User> users = new ArrayList<User>();
+
+ @BeforeClass
+ public static void start() throws NamingException {
+ Properties properties = new Properties();
+ properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
+ context = EJBContainer.createEJBContainer(properties).getContext();
+
+ // create some records
+ service = (UserService) context.lookup("java:global/rest-on-ejb/UserService");
+ users.add(service.create("foo", "foopwd", "foo@foo.com"));
+ users.add(service.create("bar", "barpwd", "bar@bar.com"));
+ }
+
+ @AfterClass
+ public static void close() throws NamingException {
+ if (context != null) {
+ context.close();
+ }
+ }
+
+ @Test
+ public void create() {
+ int expected = service.list(0, 100).size() + 1;
+ Response response = WebClient.create("http://localhost:4204/rest-on-ejb")
+ .path("/user/create")
+ .query("name", "dummy")
+ .query("pwd", "unbreakable")
+ .query("mail", "foo@bar.fr")
+ .put(null);
+ List<User> list = service.list(0, 100);
+ for (User u : list) {
+ if (!users.contains(u)) {
+ service.delete(u.getId());
+ return;
+ }
+ }
+ fail("user was not added");
+ }
+
+ @Test
+ public void delete() throws Exception {
+ User user = service.create("todelete", "dontforget", "delete@me.com");
+
+ WebClient.create("http://localhost:4204/rest-on-ejb").path("/user/delete/" + user.getId()).delete();
+
+ user = service.find(user.getId());
+ assertNull(user);
+ }
+
+ @Test
+ public void show() {
+ User user = WebClient.create("http://localhost:4204/rest-on-ejb")
+ .path("/user/show/" + users.iterator().next().getId())
+ .get(User.class);
+ assertEquals("foo", user.getFullname());
+ assertEquals("foopwd", user.getPassword());
+ assertEquals("foo@foo.com", user.getEmail());
+ }
+
+ @Test
+ public void list() throws Exception {
+ String users = WebClient.create("http://localhost:4204/rest-on-ejb")
+ .path("/user/list")
+ .get(String.class);
+ assertEquals(users,
+ inline("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<users>" +
+ " <user>" +
+ " <email>bar@bar.com</email>" +
+ " <fullname>bar</fullname>" +
+ " <id>2</id>" +
+ " <password>barpwd</password>" +
+ " </user>" +
+ " <user>" +
+ " <email>foo@foo.com</email>" +
+ " <fullname>foo</fullname>" +
+ " <id>1</id>" +
+ " <password>foopwd</password>" +
+ " </user>" +
+ "</users>"), inline(users)
+ );
+ }
+
+ private static String inline(String s) {
+ return s.replace(System.getProperty("line.separator"), "").replace("\n", "")
+ .replace(" ", "").replace("\t", "");
+ }
+
+ @Test
+ public void update() throws Exception {
+ User created = service.create("name", "pwd", "mail");
+ Response response = WebClient.create("http://localhost:4204/rest-on-ejb")
+ .path("/user/update/" + created.getId())
+ .query("name", "corrected")
+ .query("pwd", "userpwd")
+ .query("mail", "it@is.ok")
+ .post(null);
+
+ JAXBContext ctx = JAXBContext.newInstance(User.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ User modified = (User) unmarshaller.unmarshal(InputStream.class.cast(response.getEntity()));
+
+ assertEquals("corrected", modified.getFullname());
+ assertEquals("userpwd", modified.getPassword());
+ assertEquals("it@is.ok", modified.getEmail());
+ service.delete(created.getId());
+ }
+}
diff --git a/content/examples/rest-xml-json.html b/content/examples/rest-xml-json.html
new file mode 100644
index 0000000..adaf3d3
--- /dev/null
+++ b/content/examples/rest-xml-json.html
@@ -0,0 +1,593 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/rest-xml-json.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple REST</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example rest-xml-json can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/rest-xml-json" class="bare">https://github.com/apache/tomee/tree/master/examples/rest-xml-json</a></p>
+</div>
+<div class="paragraph">
+<p>Defining a REST service is pretty easy, simply ad @Path annotation to a class then define on methods
+the HTTP method to use (@GET, @POST, …​).</p>
+</div>
+</div>
+</div>
+<h1 id="_the_code" class="sect0">The Code</h1>
+<div class="sect1">
+<h2 id="_the_rest_service_path_produces_consumes">The REST service: @Path, @Produces, @Consumes</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.</p>
+</div>
+<div class="paragraph">
+<p>Actually lines:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+
+are optional since it is the default configuration. And these lines can be configured by method too
+if you need to be more precise.
+
+@Path("/greeting")
+@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+public class GreetingService {
+ @GET
+ public Response message() {
+ return new Response("Hi REST!");
+ }
+
+ @POST
+ public Response lowerCase(final Request message) {
+ return new Response(message.getValue().toLowerCase());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_testing" class="sect0">Testing</h1>
+<div class="sect1">
+<h2 id="_test_for_the_jaxrs_service">Test for the JAXRS service</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The test uses the OpenEJB ApplicationComposer to make it trivial.</p>
+</div>
+<div class="paragraph">
+<p>The idea is first to activate the jaxrs services. This is done using @EnableServices annotation.</p>
+</div>
+<div class="paragraph">
+<p>Then we create on the fly the application simply returning an object representing the web.xml. Here we simply
+use it to define the context root but you can use it to define your REST Application too. And to complete the
+application definition we add @Classes annotation to define the set of classes to use in this app.</p>
+</div>
+<div class="paragraph">
+<p>Finally to test it we use cxf client API to call the REST service in get() and post() methods.</p>
+</div>
+<div class="paragraph">
+<p>Side note: to show we use JSON or XML depending on the test method we activated on EnableServices the attribute httpDebug
+which prints the http messages in the logs.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.Classes;
+import org.apache.openejb.junit.EnableServices;
+import org.apache.openejb.junit.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs", httpDebug = true)
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+ @Module
+ @Classes(GreetingService.class)
+ public WebApp app() {
+ return new WebApp().contextRoot("test");
+ }
+
+ @Test
+ public void getXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+
+ @Test
+ public void getJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>Running the example is fairly simple. In the "rest-xml-json" directory run:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>$ mvn clean install</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Which should create output like the following.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>/opt/softs/java/jdk1.6.0_30/bin/java -ea -Didea.launcher.port=7534 -Didea.launcher.bin.path=/opt/softs/idea/bin -Dfile.encoding=UTF-8 -classpath /opt/softs/idea/lib/idea_rt.jar:/opt/softs/idea/plugins/junit/lib/junit-rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/plugin.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/javaws.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jce.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/charsets.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/resources.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/deploy.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/management-agent.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jsse.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/localedata.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunjce_provider.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunpkcs11.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/dnsns.jar:/opt/dev/openejb/openejb-trunk/examples/rest-xml-json/target/test-classes:/opt/dev/openejb/openejb-trunk/examples/rest-xml-json/target/classes:/home/rmannibucau/.m2/repository/org/apache/openejb/javaee-api/6.0-4/javaee-api-6.0-4.jar:/home/rmannibucau/.m2/repository/junit/junit/4.10/junit-4.10.jar:/home/rmannibucau/.m2/repository/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-rs/4.5.1/openejb-cxf-rs-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-http/4.5.1/openejb-http-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-core/4.5.1/openejb-core-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/mbean-annotation-api/4.5.1/mbean-annotation-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jpa-integration/4.5.1/openejb-jpa-integration-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-api/4.5.1/openejb-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-loader/4.5.1/openejb-loader-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-javaagent/4.5.1/openejb-javaagent-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jee/4.5.1/openejb-jee-4.5.1.jar:/home/rmannibucau/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.13/jaxb-impl-2.1.13.jar:/home/rmannibucau/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-ra/5.7.0/activemq-ra-5.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-core/5.7.0/activemq-core-5.7.0.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/kahadb/5.7.0/kahadb-5.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/protobuf/activemq-protobuf/1.1/activemq-protobuf-1.1.jar:/home/rmannibucau/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/rmannibucau/.m2/repository/commons-net/commons-net/3.1/commons-net-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-connector/3.1.1/geronimo-connector-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-transaction/3.1.1/geronimo-transaction-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/specs/geronimo-j2ee-connector_1.6_spec/1.0/geronimo-j2ee-connector_1.6_spec-1.0.jar:/home/rmannibucau/.m2/repository/org/objectweb/howl/howl/1.0.1-1/howl-1.0.1-1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/1.8.2/geronimo-javamail_1.4_mail-1.8.2.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-asm-shaded/3.12/xbean-asm-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-finder-shaded/3.12/xbean-finder-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-reflect/3.12/xbean-reflect-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-naming/3.12/xbean-naming-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-bundleutils/3.12/xbean-bundleutils-3.12.jar:/home/rmannibucau/.m2/repository/org/hsqldb/hsqldb/2.2.8/hsqldb-2.2.8.jar:/home/rmannibucau/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar:/home/rmannibucau/.m2/repository/commons-pool/commons-pool/1.5.7/commons-pool-1.5.7.jar:/home/rmannibucau/.m2/repository/org/codehaus/swizzle/swizzle-stream/1.6.1/swizzle-stream-1.6.1.jar:/home/rmannibucau/.m2/repository/wsdl4j/wsdl4j/1.6.2/wsdl4j-1.6.2.jar:/home/rmannibucau/.m2/repository/org/quartz-scheduler/quartz/2.1.6/quartz-2.1.6.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-jdk14/1.7.2/slf4j-jdk14-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-impl/1.1.6/openwebbeans-impl-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-spi/1.1.6/openwebbeans-spi-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ejb/1.1.6/openwebbeans-ejb-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee/1.1.6/openwebbeans-ee-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee-common/1.1.6/openwebbeans-ee-common-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-web/1.1.6/openwebbeans-web-1.1.6.jar:/home/rmannibucau/.m2/repository/org/javassist/javassist/3.15.0-GA/javassist-3.15.0-GA.jar:/home/rmannibucau/.m2/repository/org/apache/openjpa/openjpa/2.2.0/openjpa-2.2.0.jar:/home/rmannibucau/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:/home/rmannibucau/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/rmannibucau/.m2/repository/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar:/home/rmannibucau/.m2/repository/asm/asm/3.2/asm-3.2.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-core/0.5/bval-core-0.5.jar:/home/rmannibucau/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.3/commons-beanutils-core-1.8.3.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-jsr303/0.5/bval-jsr303-0.5.jar:/home/rmannibucau/.m2/repository/org/fusesource/jansi/jansi/1.8/jansi-1.8.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-server/4.5.1/openejb-server-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-client/4.5.1/openejb-client-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-ejbd/4.5.1/openejb-ejbd-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-rest/4.5.1/openejb-rest-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-transport/4.5.1/openejb-cxf-transport-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-transports-http/2.7.0/cxf-rt-transports-http-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-api/2.7.0/cxf-api-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/ws/xmlschema/xmlschema-core/2.0.3/xmlschema-core-2.0.3.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-core/2.7.0/cxf-rt-core-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-frontend-jaxrs/2.7.0/cxf-rt-frontend-jaxrs-2.7.0.jar:/home/rmannibucau/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.0-m10/javax.ws.rs-api-2.0-m10.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-bindings-xml/2.7.0/cxf-rt-bindings-xml-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-providers/2.7.0/cxf-rt-rs-extension-providers-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-search/2.7.0/cxf-rt-rs-extension-search-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-cors/2.7.0/cxf-rt-rs-security-cors-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-oauth2/2.7.0/cxf-rt-rs-security-oauth2-2.7.0.jar:/home/rmannibucau/.m2/repository/org/codehaus/jettison/jettison/1.3/jettison-1.3.jar:/home/rmannibucau/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 org.superbiz.rest.GreetingServiceTest
+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 - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Using 'print=true'
+INFO - Using 'indent.xml=true'
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+INFO - Starting service httpejbd
+INFO - Started service httpejbd
+INFO - Starting service cxf-rs
+INFO - Started service cxf-rs
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Existing thread singleton service in SystemInstance() null
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+INFO - Succeeded in installing singleton service
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 102 ms.
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+FINE - ******************* REQUEST ******************
+GET http://localhost:4204/test/greeting/
+Host=localhost:4204
+User-Agent=Apache CXF 2.7.0
+Connection=keep-alive
+Accept=application/xml
+Content-Type=*/*
+Pragma=no-cache
+Cache-Control=no-cache</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>**********************************************</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>FINE - HTTP/1.1 200 OK
+Date: Fri, 09 Nov 2012 11:59:00 GMT
+Content-Length: 44
+Set-Cookie: EJBSESSIONID=fc5037fa-641c-495d-95ca-0755cfa50beb; Path=/
+Content-Type: application/xml
+Connection: close
+Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)</pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><response><value>Hi REST!</value></response>
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Stopping network services
+INFO - Stopping server services
+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 - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Using 'print=true'
+INFO - Using 'indent.xml=true'
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+INFO - Starting service httpejbd
+INFO - Started service httpejbd
+INFO - Starting service cxf-rs
+INFO - Started service cxf-rs
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Existing thread singleton service in SystemInstance() null
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+INFO - Succeeded in installing singleton service
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 11 ms.
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+FINE - ******************* REQUEST ******************
+POST http://localhost:4204/test/greeting/
+Host=localhost:4204
+Content-Length=97
+User-Agent=Apache CXF 2.7.0
+Connection=keep-alive
+Accept=application/xml
+Content-Type=application/xml
+Pragma=no-cache
+Cache-Control=no-cache
+
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+**********************************************
+
+FINE - HTTP/1.1 200 OK
+Date: Fri, 09 Nov 2012 11:59:00 GMT
+Content-Length: 44
+Set-Cookie: EJBSESSIONID=7cb2246d-5738-4a85-aac5-c0fb5340d36a; Path=/
+Content-Type: application/xml
+Connection: close
+Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+<response><value>hi rest!</value></response>
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Stopping network services
+INFO - Stopping server services
+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 - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Using 'print=true'
+INFO - Using 'indent.xml=true'
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+INFO - Starting service httpejbd
+INFO - Started service httpejbd
+INFO - Starting service cxf-rs
+INFO - Started service cxf-rs
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Existing thread singleton service in SystemInstance() null
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+INFO - Succeeded in installing singleton service
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 10 ms.
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+FINE - ******************* REQUEST ******************
+GET http://localhost:4204/test/greeting/
+Host=localhost:4204
+User-Agent=Apache CXF 2.7.0
+Connection=keep-alive
+Accept=application/json
+Content-Type=*/*
+Pragma=no-cache
+Cache-Control=no-cache
+
+
+**********************************************
+
+FINE - HTTP/1.1 200 OK
+Date: Fri, 09 Nov 2012 11:59:00 GMT
+Content-Length: 33
+Set-Cookie: EJBSESSIONID=7112a057-fc4c-4f52-a556-1617320d2275; Path=/
+Content-Type: application/json
+Connection: close
+Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+{"response":{"value":"Hi REST!"}}
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Stopping network services
+INFO - Stopping server services
+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 - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Using 'print=true'
+INFO - Using 'indent.xml=true'
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+INFO - Starting service httpejbd
+INFO - Started service httpejbd
+INFO - Starting service cxf-rs
+INFO - Started service cxf-rs
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Existing thread singleton service in SystemInstance() null
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+INFO - Succeeded in installing singleton service
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 10 ms.
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+FINE - ******************* REQUEST ******************
+POST http://localhost:4204/test/greeting/
+Host=localhost:4204
+Content-Length=97
+User-Agent=Apache CXF 2.7.0
+Connection=keep-alive
+Accept=application/json
+Content-Type=application/xml
+Pragma=no-cache
+Cache-Control=no-cache
+
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+**********************************************
+
+FINE - HTTP/1.1 200 OK
+Date: Fri, 09 Nov 2012 11:59:01 GMT
+Content-Length: 33
+Set-Cookie: EJBSESSIONID=50cf1d2b-a940-4afb-8993-fff7f9cc6d83; Path=/
+Content-Type: application/json
+Connection: close
+Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+{"response":{"value":"hi rest!"}}
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Stopping network services
+INFO - Stopping server services</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/rest-xml-json.pdf b/content/examples/rest-xml-json.pdf
new file mode 100644
index 0000000..3897e1e
--- /dev/null
+++ b/content/examples/rest-xml-json.pdf
Binary files differ
diff --git a/content/examples/rest-xml-json/README.md b/content/examples/rest-xml-json/README.md
new file mode 100755
index 0000000..1704797
--- /dev/null
+++ b/content/examples/rest-xml-json/README.md
@@ -0,0 +1,373 @@
+Title: Simple REST
+
+Defining a REST service is pretty easy, simply ad @Path annotation to a class then define on methods
+the HTTP method to use (@GET, @POST, ...).
+
+#The Code
+
+## The REST service: @Path, @Produces, @Consumes
+
+Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.
+
+Actually lines:
+
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+
+are optional since it is the default configuration. And these lines can be configured by method too
+if you need to be more precise.
+
+ @Path("/greeting")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public class GreetingService {
+ @GET
+ public Response message() {
+ return new Response("Hi REST!");
+ }
+
+ @POST
+ public Response lowerCase(final Request message) {
+ return new Response(message.getValue().toLowerCase());
+ }
+ }
+
+# Testing
+
+## Test for the JAXRS service
+
+The test uses the OpenEJB ApplicationComposer to make it trivial.
+
+The idea is first to activate the jaxrs services. This is done using @EnableServices annotation.
+
+Then we create on the fly the application simply returning an object representing the web.xml. Here we simply
+use it to define the context root but you can use it to define your REST Application too. And to complete the
+application definition we add @Classes annotation to define the set of classes to use in this app.
+
+Finally to test it we use cxf client API to call the REST service in get() and post() methods.
+
+Side note: to show we use JSON or XML depending on the test method we activated on EnableServices the attribute httpDebug
+which prints the http messages in the logs.
+
+ package org.superbiz.rest;
+
+ import org.apache.cxf.jaxrs.client.WebClient;
+ import org.apache.openejb.jee.WebApp;
+ import org.apache.openejb.junit.ApplicationComposer;
+ import org.apache.openejb.junit.Classes;
+ import org.apache.openejb.junit.EnableServices;
+ import org.apache.openejb.junit.Module;
+ import org.junit.Test;
+ import org.junit.runner.RunWith;
+
+ import javax.ws.rs.core.MediaType;
+ import java.io.IOException;
+
+ import static org.junit.Assert.assertEquals;
+
+ @EnableServices(value = "jaxrs", httpDebug = true)
+ @RunWith(ApplicationComposer.class)
+ public class GreetingServiceTest {
+ @Module
+ @Classes(GreetingService.class)
+ public WebApp app() {
+ return new WebApp().contextRoot("test");
+ }
+
+ @Test
+ public void getXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+
+ @Test
+ public void getJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+ }
+
+
+#Running
+
+Running the example is fairly simple. In the "rest-xml-json" directory run:
+
+ $ mvn clean install
+
+Which should create output like the following.
+
+ /opt/softs/java/jdk1.6.0_30/bin/java -ea -Didea.launcher.port=7534 -Didea.launcher.bin.path=/opt/softs/idea/bin -Dfile.encoding=UTF-8 -classpath /opt/softs/idea/lib/idea_rt.jar:/opt/softs/idea/plugins/junit/lib/junit-rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/plugin.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/javaws.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jce.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/charsets.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/resources.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/deploy.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/management-agent.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/jsse.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/rt.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/localedata.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunjce_provider.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/sunpkcs11.jar:/opt/softs/java/jdk1.6.0_30/jre/lib/ext/dnsns.jar:/opt/dev/openejb/openejb-trunk/examples/rest-xml-json/target/test-classes:/opt/dev/openejb/openejb-trunk/examples/rest-xml-json/target/classes:/home/rmannibucau/.m2/repository/org/apache/openejb/javaee-api/6.0-4/javaee-api-6.0-4.jar:/home/rmannibucau/.m2/repository/junit/junit/4.10/junit-4.10.jar:/home/rmannibucau/.m2/repository/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-rs/4.5.1/openejb-cxf-rs-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-http/4.5.1/openejb-http-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-core/4.5.1/openejb-core-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/mbean-annotation-api/4.5.1/mbean-annotation-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jpa-integration/4.5.1/openejb-jpa-integration-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-api/4.5.1/openejb-api-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-loader/4.5.1/openejb-loader-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-javaagent/4.5.1/openejb-javaagent-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-jee/4.5.1/openejb-jee-4.5.1.jar:/home/rmannibucau/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.13/jaxb-impl-2.1.13.jar:/home/rmannibucau/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-ra/5.7.0/activemq-ra-5.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/activemq-core/5.7.0/activemq-core-5.7.0.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/kahadb/5.7.0/kahadb-5.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/activemq/protobuf/activemq-protobuf/1.1/activemq-protobuf-1.1.jar:/home/rmannibucau/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/rmannibucau/.m2/repository/commons-net/commons-net/3.1/commons-net-3.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-connector/3.1.1/geronimo-connector-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/components/geronimo-transaction/3.1.1/geronimo-transaction-3.1.1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/specs/geronimo-j2ee-connector_1.6_spec/1.0/geronimo-j2ee-connector_1.6_spec-1.0.jar:/home/rmannibucau/.m2/repository/org/objectweb/howl/howl/1.0.1-1/howl-1.0.1-1.jar:/home/rmannibucau/.m2/repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/1.8.2/geronimo-javamail_1.4_mail-1.8.2.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-asm-shaded/3.12/xbean-asm-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-finder-shaded/3.12/xbean-finder-shaded-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-reflect/3.12/xbean-reflect-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-naming/3.12/xbean-naming-3.12.jar:/home/rmannibucau/.m2/repository/org/apache/xbean/xbean-bundleutils/3.12/xbean-bundleutils-3.12.jar:/home/rmannibucau/.m2/repository/org/hsqldb/hsqldb/2.2.8/hsqldb-2.2.8.jar:/home/rmannibucau/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar:/home/rmannibucau/.m2/repository/commons-pool/commons-pool/1.5.7/commons-pool-1.5.7.jar:/home/rmannibucau/.m2/repository/org/codehaus/swizzle/swizzle-stream/1.6.1/swizzle-stream-1.6.1.jar:/home/rmannibucau/.m2/repository/wsdl4j/wsdl4j/1.6.2/wsdl4j-1.6.2.jar:/home/rmannibucau/.m2/repository/org/quartz-scheduler/quartz/2.1.6/quartz-2.1.6.jar:/home/rmannibucau/.m2/repository/org/slf4j/slf4j-jdk14/1.7.2/slf4j-jdk14-1.7.2.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-impl/1.1.6/openwebbeans-impl-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-spi/1.1.6/openwebbeans-spi-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ejb/1.1.6/openwebbeans-ejb-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee/1.1.6/openwebbeans-ee-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-ee-common/1.1.6/openwebbeans-ee-common-1.1.6.jar:/home/rmannibucau/.m2/repository/org/apache/openwebbeans/openwebbeans-web/1.1.6/openwebbeans-web-1.1.6.jar:/home/rmannibucau/.m2/repository/org/javassist/javassist/3.15.0-GA/javassist-3.15.0-GA.jar:/home/rmannibucau/.m2/repository/org/apache/openjpa/openjpa/2.2.0/openjpa-2.2.0.jar:/home/rmannibucau/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:/home/rmannibucau/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/rmannibucau/.m2/repository/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar:/home/rmannibucau/.m2/repository/asm/asm/3.2/asm-3.2.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-core/0.5/bval-core-0.5.jar:/home/rmannibucau/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.3/commons-beanutils-core-1.8.3.jar:/home/rmannibucau/.m2/repository/org/apache/bval/bval-jsr303/0.5/bval-jsr303-0.5.jar:/home/rmannibucau/.m2/repository/org/fusesource/jansi/jansi/1.8/jansi-1.8.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-server/4.5.1/openejb-server-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-client/4.5.1/openejb-client-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-ejbd/4.5.1/openejb-ejbd-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-rest/4.5.1/openejb-rest-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/openejb/openejb-cxf-transport/4.5.1/openejb-cxf-transport-4.5.1.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-transports-http/2.7.0/cxf-rt-transports-http-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-api/2.7.0/cxf-api-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/ws/xmlschema/xmlschema-core/2.0.3/xmlschema-core-2.0.3.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-core/2.7.0/cxf-rt-core-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-frontend-jaxrs/2.7.0/cxf-rt-frontend-jaxrs-2.7.0.jar:/home/rmannibucau/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.0-m10/javax.ws.rs-api-2.0-m10.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-bindings-xml/2.7.0/cxf-rt-bindings-xml-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-providers/2.7.0/cxf-rt-rs-extension-providers-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-extension-search/2.7.0/cxf-rt-rs-extension-search-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-cors/2.7.0/cxf-rt-rs-security-cors-2.7.0.jar:/home/rmannibucau/.m2/repository/org/apache/cxf/cxf-rt-rs-security-oauth2/2.7.0/cxf-rt-rs-security-oauth2-2.7.0.jar:/home/rmannibucau/.m2/repository/org/codehaus/jettison/jettison/1.3/jettison-1.3.jar:/home/rmannibucau/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 org.superbiz.rest.GreetingServiceTest
+ 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 - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Using 'print=true'
+ INFO - Using 'indent.xml=true'
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ INFO - Starting service httpejbd
+ INFO - Started service httpejbd
+ INFO - Starting service cxf-rs
+ INFO - Started service cxf-rs
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - -------
+ INFO - Ready!
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Existing thread singleton service in SystemInstance() null
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+ INFO - Succeeded in installing singleton service
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 102 ms.
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+ INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+ INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+ FINE - ******************* REQUEST ******************
+ GET http://localhost:4204/test/greeting/
+ Host=localhost:4204
+ User-Agent=Apache CXF 2.7.0
+ Connection=keep-alive
+ Accept=application/xml
+ Content-Type=*/*
+ Pragma=no-cache
+ Cache-Control=no-cache
+
+
+ **********************************************
+
+ FINE - HTTP/1.1 200 OK
+ Date: Fri, 09 Nov 2012 11:59:00 GMT
+ Content-Length: 44
+ Set-Cookie: EJBSESSIONID=fc5037fa-641c-495d-95ca-0755cfa50beb; Path=/
+ Content-Type: application/xml
+ Connection: close
+ Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+ <response><value>Hi REST!</value></response>
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Stopping network services
+ INFO - Stopping server services
+ 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 - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Using 'print=true'
+ INFO - Using 'indent.xml=true'
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ INFO - Starting service httpejbd
+ INFO - Started service httpejbd
+ INFO - Starting service cxf-rs
+ INFO - Started service cxf-rs
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - -------
+ INFO - Ready!
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Existing thread singleton service in SystemInstance() null
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+ INFO - Succeeded in installing singleton service
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 11 ms.
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+ INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+ INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+ FINE - ******************* REQUEST ******************
+ POST http://localhost:4204/test/greeting/
+ Host=localhost:4204
+ Content-Length=97
+ User-Agent=Apache CXF 2.7.0
+ Connection=keep-alive
+ Accept=application/xml
+ Content-Type=application/xml
+ Pragma=no-cache
+ Cache-Control=no-cache
+
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+ **********************************************
+
+ FINE - HTTP/1.1 200 OK
+ Date: Fri, 09 Nov 2012 11:59:00 GMT
+ Content-Length: 44
+ Set-Cookie: EJBSESSIONID=7cb2246d-5738-4a85-aac5-c0fb5340d36a; Path=/
+ Content-Type: application/xml
+ Connection: close
+ Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+ <response><value>hi rest!</value></response>
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Stopping network services
+ INFO - Stopping server services
+ 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 - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Using 'print=true'
+ INFO - Using 'indent.xml=true'
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ INFO - Starting service httpejbd
+ INFO - Started service httpejbd
+ INFO - Starting service cxf-rs
+ INFO - Started service cxf-rs
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - -------
+ INFO - Ready!
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Existing thread singleton service in SystemInstance() null
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+ INFO - Succeeded in installing singleton service
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 10 ms.
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+ INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+ INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+ FINE - ******************* REQUEST ******************
+ GET http://localhost:4204/test/greeting/
+ Host=localhost:4204
+ User-Agent=Apache CXF 2.7.0
+ Connection=keep-alive
+ Accept=application/json
+ Content-Type=*/*
+ Pragma=no-cache
+ Cache-Control=no-cache
+
+
+ **********************************************
+
+ FINE - HTTP/1.1 200 OK
+ Date: Fri, 09 Nov 2012 11:59:00 GMT
+ Content-Length: 33
+ Set-Cookie: EJBSESSIONID=7112a057-fc4c-4f52-a556-1617320d2275; Path=/
+ Content-Type: application/json
+ Connection: close
+ Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+ {"response":{"value":"Hi REST!"}}
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Stopping network services
+ INFO - Stopping server services
+ 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 - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Using 'print=true'
+ INFO - Using 'indent.xml=true'
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ INFO - Starting service httpejbd
+ INFO - Started service httpejbd
+ INFO - Starting service cxf-rs
+ INFO - Started service cxf-rs
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - -------
+ INFO - Ready!
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Existing thread singleton service in SystemInstance() null
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@54128635
+ INFO - Succeeded in installing singleton service
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 10 ms.
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+ INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+ INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+ FINE - ******************* REQUEST ******************
+ POST http://localhost:4204/test/greeting/
+ Host=localhost:4204
+ Content-Length=97
+ User-Agent=Apache CXF 2.7.0
+ Connection=keep-alive
+ Accept=application/json
+ Content-Type=application/xml
+ Pragma=no-cache
+ Cache-Control=no-cache
+
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?><request><value>Hi REST!</value></request>
+ **********************************************
+
+ FINE - HTTP/1.1 200 OK
+ Date: Fri, 09 Nov 2012 11:59:01 GMT
+ Content-Length: 33
+ Set-Cookie: EJBSESSIONID=50cf1d2b-a940-4afb-8993-fff7f9cc6d83; Path=/
+ Content-Type: application/json
+ Connection: close
+ Server: OpenEJB/4.5.1 Linux/3.2.0-23-generic (amd64)
+
+ {"response":{"value":"hi rest!"}}
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Stopping network services
+ INFO - Stopping server services
+
+
+
+
diff --git a/content/examples/rest-xml-json/pom.xml b/content/examples/rest-xml-json/pom.xml
new file mode 100755
index 0000000..17e1795
--- /dev/null
+++ b/content/examples/rest-xml-json/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>rest-xml-json</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: REST XML JSON</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/rest-xml-json/src/main/java/org/superbiz/rest/GreetingService.java b/content/examples/rest-xml-json/src/main/java/org/superbiz/rest/GreetingService.java
new file mode 100755
index 0000000..4128e17
--- /dev/null
+++ b/content/examples/rest-xml-json/src/main/java/org/superbiz/rest/GreetingService.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/greeting")
+@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+public class GreetingService {
+
+ @GET
+ public Response message() {
+ return new Response("Hi REST!");
+ }
+
+ @POST
+ public Response lowerCase(final Request message) {
+ return new Response(message.getValue().toLowerCase());
+ }
+}
diff --git a/content/examples/rest-xml-json/src/main/java/org/superbiz/rest/Request.java b/content/examples/rest-xml-json/src/main/java/org/superbiz/rest/Request.java
new file mode 100755
index 0000000..cac8e74
--- /dev/null
+++ b/content/examples/rest-xml-json/src/main/java/org/superbiz/rest/Request.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Request {
+
+ private String value;
+
+ public Request() {
+ //no-op
+ }
+
+ public Request(final String s) {
+ value = s;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/content/examples/rest-xml-json/src/main/java/org/superbiz/rest/Response.java b/content/examples/rest-xml-json/src/main/java/org/superbiz/rest/Response.java
new file mode 100755
index 0000000..4c2319d
--- /dev/null
+++ b/content/examples/rest-xml-json/src/main/java/org/superbiz/rest/Response.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Response {
+
+ private String value;
+
+ public Response() {
+ // no-op
+ }
+
+ public Response(final String s) {
+ value = s;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/content/examples/rest-xml-json/src/test/java/org/superbiz/rest/GreetingServiceTest.java b/content/examples/rest-xml-json/src/test/java/org/superbiz/rest/GreetingServiceTest.java
new file mode 100755
index 0000000..cfad950
--- /dev/null
+++ b/content/examples/rest-xml-json/src/test/java/org/superbiz/rest/GreetingServiceTest.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs", httpDebug = true)
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+
+ @Module
+ @Classes(GreetingService.class)
+ public WebApp app() {
+ return new WebApp().contextRoot("test");
+ }
+
+ @Test
+ public void getXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postXml() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_XML_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+
+ @Test
+ public void getJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .get(Response.class).getValue();
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void postJson() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/")
+ .accept(MediaType.APPLICATION_JSON_TYPE)
+ .post(new Request("Hi REST!"), Response.class).getValue();
+ assertEquals("hi rest!", message);
+ }
+}
diff --git a/content/examples/scala-basic.html b/content/examples/scala-basic.html
new file mode 100644
index 0000000..596c075
--- /dev/null
+++ b/content/examples/scala-basic.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/scala-basic.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>scala-basic</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example scala-basic can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/scala-basic" class="bare">https://github.com/apache/tomee/tree/master/examples/scala-basic</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/scala-basic.pdf b/content/examples/scala-basic.pdf
new file mode 100644
index 0000000..96fe70b
--- /dev/null
+++ b/content/examples/scala-basic.pdf
Binary files differ
diff --git a/content/examples/scala-basic/build.sbt b/content/examples/scala-basic/build.sbt
new file mode 100755
index 0000000..0691830
--- /dev/null
+++ b/content/examples/scala-basic/build.sbt
@@ -0,0 +1,34 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+name := "scala-basic"
+
+version := "1.1.1-SNAPSHOT"
+
+scalaVersion := "2.11.1"
+
+resolvers ++= Seq(
+ "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository",
+ "Apache Snapshots" at "https://repository.apache.org/content/groups/snapshots/"
+)
+
+libraryDependencies ++= Seq(
+ "org.apache.openejb" % "javaee-api" % "6.0-6",
+ "org.apache.openejb" % "openejb-core" % "4.7.0-SNAPSHOT" % "test",
+ "org.scalatest" %% "scalatest_2.11" % "2.2.0" % "test"
+)
+
diff --git a/content/examples/scala-basic/pom.xml b/content/examples/scala-basic/pom.xml
new file mode 100755
index 0000000..16641fc
--- /dev/null
+++ b/content/examples/scala-basic/pom.xml
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>scala-basic</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Basic Scala</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <!--<scala.version>2.9.1</scala.version>-->
+ <scala.version>2.11</scala.version>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <sourceDirectory>src/main/scala</sourceDirectory>
+ <testSourceDirectory>src/test/scala</testSourceDirectory>
+
+ <plugins>
+ <!-- compile scala sources -->
+ <plugin>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <version>3.1.6</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <scalaVersion>${scala.version}</scalaVersion>
+ </configuration>
+ </plugin>
+
+ <!-- disable surefire because we use scalatest -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ <!-- enable scalatest as a replacement for surefire -->
+ <plugin>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest-maven-plugin</artifactId>
+ <version>1.0</version>
+ <configuration>
+ <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
+ <junitxml>.</junitxml>
+ <filereports>TestSuite.txt</filereports>
+ </configuration>
+ <executions>
+ <execution>
+ <id>test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- scala dependencies for run and testing -->
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>${scala.version}.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest_${scala.version}</artifactId>
+ <version>2.2.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- other "classical" dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/scala-basic/src/main/resources/META-INF/beans.xml b/content/examples/scala-basic/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..9b0b74f
--- /dev/null
+++ b/content/examples/scala-basic/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,18 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans/>
diff --git a/content/examples/scala-basic/src/main/scala/org/superbiz/GreetingService.scala b/content/examples/scala-basic/src/main/scala/org/superbiz/GreetingService.scala
new file mode 100755
index 0000000..1550ab7
--- /dev/null
+++ b/content/examples/scala-basic/src/main/scala/org/superbiz/GreetingService.scala
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz
+
+import javax.ejb.{LocalBean, Lock, LockType, Singleton}
+
+object GreetingService {
+ val DefaultName = "Scala"
+}
+
+@LocalBean
+@Singleton
+@Lock(LockType.READ)
+class GreetingService {
+ def hi(name: String = GreetingService.DefaultName) = {
+ if (name != null) {
+ "hi " + name
+ } else {
+ "hi " + GreetingService.DefaultName
+ }
+ }
+}
diff --git a/content/examples/scala-basic/src/test/scala/org/superbiz/GreetingServiceTest.scala b/content/examples/scala-basic/src/test/scala/org/superbiz/GreetingServiceTest.scala
new file mode 100755
index 0000000..e3d3dd4
--- /dev/null
+++ b/content/examples/scala-basic/src/test/scala/org/superbiz/GreetingServiceTest.scala
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz
+
+import javax.ejb.embeddable.EJBContainer
+import javax.inject.Inject
+
+import org.scalatest._
+
+class GreetingServiceTest extends FunSuite with BeforeAndAfterAll with BeforeAndAfterEach {
+ @Inject
+ private var service: GreetingService = null
+
+ test("Hi scala") {
+ val message = service hi "scala"
+ assert(message == "hi scala")
+ }
+
+ test("Default Hi") {
+ val message = service.hi()
+ assert(message == "hi Scala")
+ }
+
+ test("Hi null") {
+ val message = service.hi(null)
+ assert(message == "hi Scala") // when called with null we use default name
+ }
+
+ /** *************************************************************/
+ /** the OpenEJB Hook to be able to inject beans in this class **/
+ /** kind of internal of this test class, "hidden" being last **/
+ /** *************************************************************/
+
+ private var container: EJBContainer = null
+
+ override def beforeAll() {
+ container = EJBContainer.createEJBContainer()
+ }
+
+ override def beforeEach() {
+ container.getContext().bind("inject", this)
+ }
+
+ override def afterAll() {
+ if (container != null) {
+ container.close()
+ }
+ }
+}
diff --git a/content/examples/schedule-events.html b/content/examples/schedule-events.html
new file mode 100644
index 0000000..5b49164
--- /dev/null
+++ b/content/examples/schedule-events.html
@@ -0,0 +1,393 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/schedule-events.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Schedule CDI Events</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example schedule-events can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/schedule-events" class="bare">https://github.com/apache/tomee/tree/master/examples/schedule-events</a></p>
+</div>
+<div class="paragraph">
+<p>This example uses a nice CDI/EJB combination to schedule CDI Events. This is useful if you want CDI Events that fire regularly or at a specific time or calendar date.</p>
+</div>
+<div class="paragraph">
+<p>Effectively this is a simple wrapper around the <code>BeanManager.fireEvent(Object,Annotations…​)</code> method that adds <code>ScheduleExpression</code> into the mix.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_scheduleexpression_and_timeout">ScheduleExpression and @Timeout</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The logic here is simple, we effecitvely expose a method identical to <code>BeanManager.fireEvent(Object, Annotations…​)</code> and wrap it as <code>scheduleEvent(ScheduleExpression, Object, Annotation…​)</code></p>
+</div>
+<div class="paragraph">
+<p>To do that we use the EJB <code>TimerService</code> (under the covers this is Quartz) and create an <code>@Timeout</code> method which will be run when the <code>ScheduleExpression</code> activates.</p>
+</div>
+<div class="paragraph">
+<p>The <code>@Timeout</code> method, simply called <code>timeout</code>, takes the event and fires it.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Singleton
+@Lock(LockType.READ)
+public class Scheduler {
+
+ @Resource
+ private TimerService timerService;
+
+ @Resource
+ private BeanManager beanManager;
+
+ public void scheduleEvent(ScheduleExpression schedule, Object event, Annotation... qualifiers) {
+
+ timerService.createCalendarTimer(schedule, new TimerConfig(new EventConfig(event, qualifiers), false));
+ }
+
+ @Timeout
+ private void timeout(Timer timer) {
+ final EventConfig config = (EventConfig) timer.getInfo();
+
+ beanManager.fireEvent(config.getEvent(), config.getQualifiers());
+ }
+
+ // Doesn't actually need to be serializable, just has to implement it
+ private final class EventConfig implements Serializable {
+
+ private final Object event;
+ private final Annotation[] qualifiers;
+
+ private EventConfig(Object event, Annotation[] qualifiers) {
+ this.event = event;
+ this.qualifiers = qualifiers;
+ }
+
+ public Object getEvent() {
+ return event;
+ }
+
+ public Annotation[] getQualifiers() {
+ return qualifiers;
+ }
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Then to use it, have <code>Scheduler</code> injected as an EJB and enjoy.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class SomeBean {
+
+ @EJB
+ private Scheduler scheduler;
+
+ public void doit() throws Exception {
+
+ // every five minutes
+ final ScheduleExpression schedule = new ScheduleExpression()
+ .hour("*")
+ .minute("*")
+ .second("*/5");
+
+ scheduler.scheduleEvent(schedule, new TestEvent("five"));
+ }
+
+ /**
+ * Event will fire every five minutes
+ */
+ public void observe(@Observes TestEvent event) {
+ // process the event
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_test_case">Test Case</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>A working test case for the above would be as follows:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.AccessTimeout;
+import javax.ejb.EJB;
+import javax.ejb.ScheduleExpression;
+import javax.ejb.embeddable.EJBContainer;
+import javax.enterprise.event.Observes;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class SchedulerTest {
+
+ public static final CountDownLatch events = new CountDownLatch(3);
+
+ @EJB
+ private Scheduler scheduler;
+
+ @Test
+ public void test() throws Exception {
+
+ final ScheduleExpression schedule = new ScheduleExpression()
+ .hour("*")
+ .minute("*")
+ .second("*/5");
+
+ scheduler.scheduleEvent(schedule, new TestEvent("five"));
+
+ Assert.assertTrue(events.await(1, TimeUnit.MINUTES));
+ }
+
+
+ @AccessTimeout(value = 1, unit = TimeUnit.MINUTES)
+ public void observe(@Observes TestEvent event) {
+ if ("five".equals(event.getMessage())) {
+ events.countDown();
+ }
+ }
+
+ public static class TestEvent {
+ private final String message;
+
+ public TestEvent(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+ }
+
+ @Before
+ public void setup() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_you_must_know">You must know</h2>
+<div class="sectionbody">
+<div class="ulist">
+<ul>
+<li>
+<p>CDI Events are not multi-treaded</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>If there are 10 observers and each of them take 7 minutes to execute, then the total execution time for the one event is 70 minutes. It would do you absolutely no good to schedule that event to fire more frequently than 70 minutes.</p>
+</div>
+<div class="paragraph">
+<p>What would happen if you did? Depends on the <code>@Singleton</code> <code>@Lock</code> policy</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><code>@Lock(WRITE)</code> is the default. In this mode the <code>timeout</code> method would essentially be locked until the previous invocation completes. Having it fire every 5 minutes even though you can only process one every 70 minutes would eventually cause all the pooled timer threads to be waiting on your Singleton.</p>
+</li>
+<li>
+<p><code>@Lock(READ)</code> allows for parallel execution of the <code>timeout</code> method. Events will fire in parallel for a while. However since they actually are taking 70 minutes each, within an hour or so we’ll run out of threads in the timer pool just like above.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>The elegant solution is to use <code>@Lock(WRITE)</code> then specify some short timeout like <code>@AccessTimeout(value = 1, unit = TimeUnit.MINUTES)</code> on the <code>timeout</code> method. When the next 5 minute invocation is triggered, it will wait up until 1 minute to get access to the Singleton before giving up. This will keep your timer pool from filling up with backed up jobs — the "overflow" is simply discarded.</p>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/schedule-events.pdf b/content/examples/schedule-events.pdf
new file mode 100644
index 0000000..9946e7a
--- /dev/null
+++ b/content/examples/schedule-events.pdf
Binary files differ
diff --git a/content/examples/schedule-events/README.md b/content/examples/schedule-events/README.md
new file mode 100755
index 0000000..da064ff
--- /dev/null
+++ b/content/examples/schedule-events/README.md
@@ -0,0 +1,163 @@
+Title: Schedule CDI Events
+
+This example uses a nice CDI/EJB combination to schedule CDI Events. This is useful if you want CDI Events that fire regularly or at a specific time or calendar date.
+
+Effectively this is a simple wrapper around the `BeanManager.fireEvent(Object,Annotations...)` method that adds `ScheduleExpression` into the mix.
+
+## ScheduleExpression and @Timeout
+
+The logic here is simple, we effecitvely expose a method identical to `BeanManager.fireEvent(Object, Annotations...)` and wrap it as `scheduleEvent(ScheduleExpression, Object, Annotation...)`
+
+To do that we use the EJB `TimerService` (under the covers this is Quartz) and create an `@Timeout` method which will be run when the `ScheduleExpression` activates.
+
+The `@Timeout` method, simply called `timeout`, takes the event and fires it.
+
+ @Singleton
+ @Lock(LockType.READ)
+ public class Scheduler {
+
+ @Resource
+ private TimerService timerService;
+
+ @Resource
+ private BeanManager beanManager;
+
+ public void scheduleEvent(ScheduleExpression schedule, Object event, Annotation... qualifiers) {
+
+ timerService.createCalendarTimer(schedule, new TimerConfig(new EventConfig(event, qualifiers), false));
+ }
+
+ @Timeout
+ private void timeout(Timer timer) {
+ final EventConfig config = (EventConfig) timer.getInfo();
+
+ beanManager.fireEvent(config.getEvent(), config.getQualifiers());
+ }
+
+ // Doesn't actually need to be serializable, just has to implement it
+ private final class EventConfig implements Serializable {
+
+ private final Object event;
+ private final Annotation[] qualifiers;
+
+ private EventConfig(Object event, Annotation[] qualifiers) {
+ this.event = event;
+ this.qualifiers = qualifiers;
+ }
+
+ public Object getEvent() {
+ return event;
+ }
+
+ public Annotation[] getQualifiers() {
+ return qualifiers;
+ }
+ }
+ }
+
+Then to use it, have `Scheduler` injected as an EJB and enjoy.
+
+ public class SomeBean {
+
+ @EJB
+ private Scheduler scheduler;
+
+ public void doit() throws Exception {
+
+ // every five minutes
+ final ScheduleExpression schedule = new ScheduleExpression()
+ .hour("*")
+ .minute("*")
+ .second("*/5");
+
+ scheduler.scheduleEvent(schedule, new TestEvent("five"));
+ }
+
+ /**
+ * Event will fire every five minutes
+ */
+ public void observe(@Observes TestEvent event) {
+ // process the event
+ }
+
+ }
+
+## Test Case
+
+A working test case for the above would be as follows:
+
+ import org.junit.Assert;
+ import org.junit.Before;
+ import org.junit.Test;
+
+ import javax.ejb.AccessTimeout;
+ import javax.ejb.EJB;
+ import javax.ejb.ScheduleExpression;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.enterprise.event.Observes;
+ import java.util.concurrent.CountDownLatch;
+ import java.util.concurrent.TimeUnit;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class SchedulerTest {
+
+ public static final CountDownLatch events = new CountDownLatch(3);
+
+ @EJB
+ private Scheduler scheduler;
+
+ @Test
+ public void test() throws Exception {
+
+ final ScheduleExpression schedule = new ScheduleExpression()
+ .hour("*")
+ .minute("*")
+ .second("*/5");
+
+ scheduler.scheduleEvent(schedule, new TestEvent("five"));
+
+ Assert.assertTrue(events.await(1, TimeUnit.MINUTES));
+ }
+
+
+ @AccessTimeout(value = 1, unit = TimeUnit.MINUTES)
+ public void observe(@Observes TestEvent event) {
+ if ("five".equals(event.getMessage())) {
+ events.countDown();
+ }
+ }
+
+ public static class TestEvent {
+ private final String message;
+
+ public TestEvent(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+ }
+
+ @Before
+ public void setup() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+ }
+ }
+
+
+## You must know
+
+ - CDI Events are not multi-treaded
+
+If there are 10 observers and each of them take 7 minutes to execute, then the total execution time for the one event is 70 minutes. It would do you absolutely no good to schedule that event to fire more frequently than 70 minutes.
+
+What would happen if you did? Depends on the `@Singleton` `@Lock` policy
+
+ - `@Lock(WRITE)` is the default. In this mode the `timeout` method would essentially be locked until the previous invocation completes. Having it fire every 5 minutes even though you can only process one every 70 minutes would eventually cause all the pooled timer threads to be waiting on your Singleton.
+ - `@Lock(READ)` allows for parallel execution of the `timeout` method. Events will fire in parallel for a while. However since they actually are taking 70 minutes each, within an hour or so we'll run out of threads in the timer pool just like above.
+
+The elegant solution is to use `@Lock(WRITE)` then specify some short timeout like `@AccessTimeout(value = 1, unit = TimeUnit.MINUTES)` on the `timeout` method. When the next 5 minute invocation is triggered, it will wait up until 1 minute to get access to the Singleton before giving up. This will keep your timer pool from filling up with backed up jobs -- the "overflow" is simply discarded.
+
diff --git a/content/examples/schedule-events/pom.xml b/content/examples/schedule-events/pom.xml
new file mode 100755
index 0000000..b1199e8
--- /dev/null
+++ b/content/examples/schedule-events/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1387962 $ $Date: 2012-09-20 05:53:17 -0500 (Thu, 20 Sep 2012) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>schedule-events</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @Schedule Events</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/schedule-events/src/main/java/org/superbiz/schedule/events/Scheduler.java b/content/examples/schedule-events/src/main/java/org/superbiz/schedule/events/Scheduler.java
new file mode 100755
index 0000000..bf1de80
--- /dev/null
+++ b/content/examples/schedule-events/src/main/java/org/superbiz/schedule/events/Scheduler.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.schedule.events;
+
+import javax.annotation.Resource;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.ScheduleExpression;
+import javax.ejb.Singleton;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerConfig;
+import javax.ejb.TimerService;
+import javax.enterprise.inject.spi.BeanManager;
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+/**
+ * @version $Revision$ $Date$
+ */
+@Singleton
+@Lock(LockType.READ)
+public class Scheduler {
+
+ @Resource
+ private TimerService timerService;
+
+ @Resource
+ private BeanManager beanManager;
+
+ public void scheduleEvent(ScheduleExpression schedule, Object event, Annotation... qualifiers) {
+
+ timerService.createCalendarTimer(schedule, new TimerConfig(new EventConfig(event, qualifiers), false));
+ }
+
+ @Timeout
+ private void timeout(Timer timer) {
+ final EventConfig config = (EventConfig) timer.getInfo();
+
+ beanManager.fireEvent(config.getEvent(), config.getQualifiers());
+ }
+
+ // Doesn't actually need to be serializable, just has to implement it
+ private final class EventConfig implements Serializable {
+
+ private final Object event;
+ private final Annotation[] qualifiers;
+
+ private EventConfig(Object event, Annotation[] qualifiers) {
+ this.event = event;
+ this.qualifiers = qualifiers;
+ }
+
+ public Object getEvent() {
+ return event;
+ }
+
+ public Annotation[] getQualifiers() {
+ return qualifiers;
+ }
+ }
+}
diff --git a/content/examples/schedule-events/src/test/java/org/superbiz/schedule/events/SchedulerTest.java b/content/examples/schedule-events/src/test/java/org/superbiz/schedule/events/SchedulerTest.java
new file mode 100755
index 0000000..66b78d0
--- /dev/null
+++ b/content/examples/schedule-events/src/test/java/org/superbiz/schedule/events/SchedulerTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.schedule.events;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.AccessTimeout;
+import javax.ejb.EJB;
+import javax.ejb.ScheduleExpression;
+import javax.ejb.embeddable.EJBContainer;
+import javax.enterprise.event.Observes;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class SchedulerTest {
+
+ public static final CountDownLatch events = new CountDownLatch(3);
+
+ @EJB
+ private Scheduler scheduler;
+
+ @Test
+ public void test() throws Exception {
+
+ final ScheduleExpression schedule = new ScheduleExpression()
+ .hour("*")
+ .minute("*")
+ .second("*/5");
+
+ scheduler.scheduleEvent(schedule, new TestEvent("five"));
+
+ Assert.assertTrue(events.await(1, TimeUnit.MINUTES));
+ }
+
+ @AccessTimeout(value = 1, unit = TimeUnit.MINUTES)
+ public void observe(@Observes TestEvent event) {
+ if ("five".equals(event.getMessage())) {
+ events.countDown();
+ }
+ }
+
+ public static class TestEvent {
+
+ private final String message;
+
+ public TestEvent(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+ }
+
+ @Before
+ public void setup() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+ }
+}
diff --git a/content/examples/schedule-events/src/test/resources/META-INF/beans.xml b/content/examples/schedule-events/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/schedule-events/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/schedule-expression.html b/content/examples/schedule-expression.html
new file mode 100644
index 0000000..7c47dfa
--- /dev/null
+++ b/content/examples/schedule-expression.html
@@ -0,0 +1,382 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/schedule-expression.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Schedule Expression</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example schedule-expression can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/schedule-expression" class="bare">https://github.com/apache/tomee/tree/master/examples/schedule-expression</a></p>
+</div>
+<div class="paragraph">
+<p>In this example we exercise the <code>TimerService</code>.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+"The TimerService interface provides enterprise bean components with access to the container-provided Timer Service.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>The EJB Timer Service allows entity beans, stateless session beans, and message-driven beans to be registered for timer
+callback events at a specified time, after a specified elapsed time, or after a specified interval."</p>
+</div>
+<div class="paragraph">
+<p>For a complete description of the TimerService, please refer to the Java EE tutorial dedicated to the
+<a href="http://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html">Timer Service</a>.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_farmerbrown">FarmerBrown</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>At <code>PostConstruct</code> we create 5 programmatic timers. First four will most likely not be triggered during the test
+execution, however the last one will timeout a couple of times.</p>
+</div>
+<div class="paragraph">
+<p>Each timer contains an info attribute, which can be inspected at timeout.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.ScheduleExpression;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerConfig;
+import javax.ejb.TimerService;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ *
+ * @version $Revision$ $Date$
+ */
+@Singleton
+@Lock(LockType.READ) // allows timers to execute in parallel
+@Startup
+public class FarmerBrown {
+
+ private final AtomicInteger checks = new AtomicInteger();
+
+ @Resource
+ private TimerService timerService;
+
+ @PostConstruct
+ private void construct() {
+ final TimerConfig plantTheCorn = new TimerConfig("plantTheCorn", false);
+ timerService.createCalendarTimer(new ScheduleExpression().month(5).dayOfMonth("20-Last").minute(0).hour(8), plantTheCorn);
+ timerService.createCalendarTimer(new ScheduleExpression().month(6).dayOfMonth("1-10").minute(0).hour(8), plantTheCorn);
+
+ final TimerConfig harvestTheCorn = new TimerConfig("harvestTheCorn", false);
+ timerService.createCalendarTimer(new ScheduleExpression().month(9).dayOfMonth("20-Last").minute(0).hour(8), harvestTheCorn);
+ timerService.createCalendarTimer(new ScheduleExpression().month(10).dayOfMonth("1-10").minute(0).hour(8), harvestTheCorn);
+
+ final TimerConfig checkOnTheDaughters = new TimerConfig("checkOnTheDaughters", false);
+ timerService.createCalendarTimer(new ScheduleExpression().second("*").minute("*").hour("*"), checkOnTheDaughters);
+ }
+
+ @Timeout
+ public void timeout(Timer timer) {
+ if ("plantTheCorn".equals(timer.getInfo())) {
+ plantTheCorn();
+ } else if ("harvestTheCorn".equals(timer.getInfo())) {
+ harvestTheCorn();
+ } else if ("checkOnTheDaughters".equals(timer.getInfo())) {
+ checkOnTheDaughters();
+ }
+ }
+
+ private void plantTheCorn() {
+ // Dig out the planter!!!
+ }
+
+ private void harvestTheCorn() {
+ // Dig out the combine!!!
+ }
+
+ private void checkOnTheDaughters() {
+ checks.incrementAndGet();
+ }
+
+ public int getChecks() {
+ return checks.get();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_farmerbrowntest">FarmerBrownTest</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The test class acquires an instance from the context and waits for 5 seconds to give the timers a chance to timeout.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class FarmerBrownTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final FarmerBrown farmerBrown = (FarmerBrown) context.lookup("java:global/schedule-expression/FarmerBrown");
+
+ // Give Farmer brown a chance to do some work
+ Thread.sleep(SECONDS.toMillis(5));
+
+ final int checks = farmerBrown.getChecks();
+ assertTrue(checks + "", checks > 4);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.corn.FarmerBrownTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/schedule-expression
+INFO - openejb.base = /Users/dblevins/examples/schedule-expression
+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/schedule-expression/target/classes
+INFO - Beginning load: /Users/dblevins/examples/schedule-expression/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/schedule-expression
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean FarmerBrown: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.corn.FarmerBrownTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/schedule-expression" loaded.
+INFO - Assembling app: /Users/dblevins/examples/schedule-expression
+INFO - Jndi(name="java:global/schedule-expression/FarmerBrown!org.superbiz.corn.FarmerBrown")
+INFO - Jndi(name="java:global/schedule-expression/FarmerBrown")
+INFO - Jndi(name="java:global/EjbModule481105279/org.superbiz.corn.FarmerBrownTest!org.superbiz.corn.FarmerBrownTest")
+INFO - Jndi(name="java:global/EjbModule481105279/org.superbiz.corn.FarmerBrownTest")
+INFO - Created Ejb(deployment-id=org.superbiz.corn.FarmerBrownTest, ejb-name=org.superbiz.corn.FarmerBrownTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=org.superbiz.corn.FarmerBrownTest, ejb-name=org.superbiz.corn.FarmerBrownTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/schedule-expression)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.141 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/schedule-expression.pdf b/content/examples/schedule-expression.pdf
new file mode 100644
index 0000000..05ff626
--- /dev/null
+++ b/content/examples/schedule-expression.pdf
Binary files differ
diff --git a/content/examples/schedule-expression/README.md b/content/examples/schedule-expression/README.md
new file mode 100755
index 0000000..a3b5c4d
--- /dev/null
+++ b/content/examples/schedule-expression/README.md
@@ -0,0 +1,161 @@
+Title: Schedule Expression
+
+In this example we exercise the `TimerService`.
+
+>"The TimerService interface provides enterprise bean components with access to the container-provided Timer Service.
+The EJB Timer Service allows entity beans, stateless session beans, and message-driven beans to be registered for timer
+callback events at a specified time, after a specified elapsed time, or after a specified interval."
+
+For a complete description of the TimerService, please refer to the Java EE tutorial dedicated to the
+[Timer Service](http://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html).
+
+## FarmerBrown
+
+At `PostConstruct` we create 5 programmatic timers. First four will most likely not be triggered during the test
+execution, however the last one will timeout a couple of times.
+
+Each timer contains an info attribute, which can be inspected at timeout.
+
+ package org.superbiz.corn;
+
+ import javax.annotation.PostConstruct;
+ import javax.annotation.Resource;
+ import javax.ejb.Lock;
+ import javax.ejb.LockType;
+ import javax.ejb.ScheduleExpression;
+ import javax.ejb.Singleton;
+ import javax.ejb.Startup;
+ import javax.ejb.Timeout;
+ import javax.ejb.Timer;
+ import javax.ejb.TimerConfig;
+ import javax.ejb.TimerService;
+ import java.util.concurrent.atomic.AtomicInteger;
+
+ /**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ *
+ * @version $Revision$ $Date$
+ */
+ @Singleton
+ @Lock(LockType.READ) // allows timers to execute in parallel
+ @Startup
+ public class FarmerBrown {
+
+ private final AtomicInteger checks = new AtomicInteger();
+
+ @Resource
+ private TimerService timerService;
+
+ @PostConstruct
+ private void construct() {
+ final TimerConfig plantTheCorn = new TimerConfig("plantTheCorn", false);
+ timerService.createCalendarTimer(new ScheduleExpression().month(5).dayOfMonth("20-Last").minute(0).hour(8), plantTheCorn);
+ timerService.createCalendarTimer(new ScheduleExpression().month(6).dayOfMonth("1-10").minute(0).hour(8), plantTheCorn);
+
+ final TimerConfig harvestTheCorn = new TimerConfig("harvestTheCorn", false);
+ timerService.createCalendarTimer(new ScheduleExpression().month(9).dayOfMonth("20-Last").minute(0).hour(8), harvestTheCorn);
+ timerService.createCalendarTimer(new ScheduleExpression().month(10).dayOfMonth("1-10").minute(0).hour(8), harvestTheCorn);
+
+ final TimerConfig checkOnTheDaughters = new TimerConfig("checkOnTheDaughters", false);
+ timerService.createCalendarTimer(new ScheduleExpression().second("*").minute("*").hour("*"), checkOnTheDaughters);
+ }
+
+ @Timeout
+ public void timeout(Timer timer) {
+ if ("plantTheCorn".equals(timer.getInfo())) {
+ plantTheCorn();
+ } else if ("harvestTheCorn".equals(timer.getInfo())) {
+ harvestTheCorn();
+ } else if ("checkOnTheDaughters".equals(timer.getInfo())) {
+ checkOnTheDaughters();
+ }
+ }
+
+ private void plantTheCorn() {
+ // Dig out the planter!!!
+ }
+
+ private void harvestTheCorn() {
+ // Dig out the combine!!!
+ }
+
+ private void checkOnTheDaughters() {
+ checks.incrementAndGet();
+ }
+
+ public int getChecks() {
+ return checks.get();
+ }
+ }
+
+## FarmerBrownTest
+
+The test class acquires an instance from the context and waits for 5 seconds to give the timers a chance to timeout.
+
+ package org.superbiz.corn;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+
+ import static java.util.concurrent.TimeUnit.SECONDS;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class FarmerBrownTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final FarmerBrown farmerBrown = (FarmerBrown) context.lookup("java:global/schedule-expression/FarmerBrown");
+
+ // Give Farmer brown a chance to do some work
+ Thread.sleep(SECONDS.toMillis(5));
+
+ final int checks = farmerBrown.getChecks();
+ assertTrue(checks + "", checks > 4);
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.corn.FarmerBrownTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/schedule-expression
+ INFO - openejb.base = /Users/dblevins/examples/schedule-expression
+ 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/schedule-expression/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/schedule-expression/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/schedule-expression
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean FarmerBrown: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.corn.FarmerBrownTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/schedule-expression" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/schedule-expression
+ INFO - Jndi(name="java:global/schedule-expression/FarmerBrown!org.superbiz.corn.FarmerBrown")
+ INFO - Jndi(name="java:global/schedule-expression/FarmerBrown")
+ INFO - Jndi(name="java:global/EjbModule481105279/org.superbiz.corn.FarmerBrownTest!org.superbiz.corn.FarmerBrownTest")
+ INFO - Jndi(name="java:global/EjbModule481105279/org.superbiz.corn.FarmerBrownTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.corn.FarmerBrownTest, ejb-name=org.superbiz.corn.FarmerBrownTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.corn.FarmerBrownTest, ejb-name=org.superbiz.corn.FarmerBrownTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/schedule-expression)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.141 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/schedule-expression/build.xml b/content/examples/schedule-expression/build.xml
new file mode 100755
index 0000000..a0e0c98
--- /dev/null
+++ b/content/examples/schedule-expression/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1151005 $ $Date: 2011-07-26 00:27:21 -0700 (Tue, 26 Jul 2011) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/schedule-expression/pom.xml b/content/examples/schedule-expression/pom.xml
new file mode 100755
index 0000000..5621d81
--- /dev/null
+++ b/content/examples/schedule-expression/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1159537 $ $Date: 2011-08-19 01:23:36 -0700 (Fri, 19 Aug 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>schedule-expression</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: ScheduleExpression</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/schedule-expression/src/main/java/org/superbiz/corn/FarmerBrown.java b/content/examples/schedule-expression/src/main/java/org/superbiz/corn/FarmerBrown.java
new file mode 100755
index 0000000..8a3e939
--- /dev/null
+++ b/content/examples/schedule-expression/src/main/java/org/superbiz/corn/FarmerBrown.java
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.ScheduleExpression;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerConfig;
+import javax.ejb.TimerService;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ *
+ * @version $Revision$ $Date$
+ */
+@Singleton
+@Lock(LockType.READ) // allows timers to execute in parallel
+@Startup
+public class FarmerBrown {
+
+ private final AtomicInteger checks = new AtomicInteger();
+
+ @Resource
+ private TimerService timerService;
+
+ @PostConstruct
+ private void construct() {
+ final TimerConfig plantTheCorn = new TimerConfig("plantTheCorn", false);
+ timerService.createCalendarTimer(new ScheduleExpression().month(5).dayOfMonth("20-Last").minute(0).hour(8), plantTheCorn);
+ timerService.createCalendarTimer(new ScheduleExpression().month(6).dayOfMonth("1-10").minute(0).hour(8), plantTheCorn);
+
+ final TimerConfig harvestTheCorn = new TimerConfig("harvestTheCorn", false);
+ timerService.createCalendarTimer(new ScheduleExpression().month(9).dayOfMonth("20-Last").minute(0).hour(8), harvestTheCorn);
+ timerService.createCalendarTimer(new ScheduleExpression().month(10).dayOfMonth("1-10").minute(0).hour(8), harvestTheCorn);
+
+ final TimerConfig checkOnTheDaughters = new TimerConfig("checkOnTheDaughters", false);
+ timerService.createCalendarTimer(new ScheduleExpression().second("*").minute("*").hour("*"), checkOnTheDaughters);
+ }
+
+ @Timeout
+ public void timeout(Timer timer) {
+ if ("plantTheCorn".equals(timer.getInfo())) {
+ plantTheCorn();
+ } else if ("harvestTheCorn".equals(timer.getInfo())) {
+ harvestTheCorn();
+ } else if ("checkOnTheDaughters".equals(timer.getInfo())) {
+ checkOnTheDaughters();
+ }
+ }
+
+ private void plantTheCorn() {
+ // Dig out the planter!!!
+ }
+
+ private void harvestTheCorn() {
+ // Dig out the combine!!!
+ }
+
+ private void checkOnTheDaughters() {
+ checks.incrementAndGet();
+ }
+
+ public int getChecks() {
+ return checks.get();
+ }
+}
diff --git a/content/examples/schedule-expression/src/test/java/org/superbiz/corn/FarmerBrownTest.java b/content/examples/schedule-expression/src/test/java/org/superbiz/corn/FarmerBrownTest.java
new file mode 100755
index 0000000..9b008c5
--- /dev/null
+++ b/content/examples/schedule-expression/src/test/java/org/superbiz/corn/FarmerBrownTest.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class FarmerBrownTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final FarmerBrown farmerBrown = (FarmerBrown) context.lookup("java:global/schedule-expression/FarmerBrown");
+
+ // Give Farmer brown a chance to do some work
+ Thread.sleep(SECONDS.toMillis(5));
+
+ final int checks = farmerBrown.getChecks();
+ assertTrue(checks + "", checks > 4);
+ }
+}
diff --git a/content/examples/schedule-methods-meta.html b/content/examples/schedule-methods-meta.html
new file mode 100644
index 0000000..7ca0f75
--- /dev/null
+++ b/content/examples/schedule-methods-meta.html
@@ -0,0 +1,576 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/schedule-methods-meta.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Schedule Methods Meta</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example schedule-methods-meta can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/schedule-methods-meta" class="bare">https://github.com/apache/tomee/tree/master/examples/schedule-methods-meta</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_biannually">BiAnnually</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface BiAnnually {
+ public static interface $ {
+
+ @BiAnnually
+ @Schedule(second = "0", minute = "0", hour = "0", dayOfMonth = "1", month = "1,6")
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_bimonthly">BiMonthly</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface BiMonthly {
+ public static interface $ {
+
+ @BiMonthly
+ @Schedule(second = "0", minute = "0", hour = "0", dayOfMonth = "1,15")
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_daily">Daily</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface Daily {
+ public static interface $ {
+
+ @Daily
+ @Schedule(second = "0", minute = "0", hour = "0", dayOfMonth = "*")
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_harvesttime">HarvestTime</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import javax.ejb.Schedules;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface HarvestTime {
+ public static interface $ {
+
+ @HarvestTime
+ @Schedules({
+ @Schedule(month = "9", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "10", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_hourly">Hourly</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface Hourly {
+ public static interface $ {
+
+ @Hourly
+ @Schedule(second = "0", minute = "0", hour = "*")
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_metatype">Metatype</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Metatype {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_organic">Organic</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta.api;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+
+@Singleton
+@Lock(LockType.READ)
+public @interface Organic {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_plantingtime">PlantingTime</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import javax.ejb.Schedules;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface PlantingTime {
+ public static interface $ {
+
+ @PlantingTime
+ @Schedules({
+ @Schedule(month = "5", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "6", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_secondly">Secondly</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface Secondly {
+ public static interface $ {
+
+ @Secondly
+ @Schedule(second = "*", minute = "*", hour = "*")
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_farmerbrown">FarmerBrown</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta;
+
+import org.superbiz.corn.meta.api.HarvestTime;
+import org.superbiz.corn.meta.api.Organic;
+import org.superbiz.corn.meta.api.PlantingTime;
+import org.superbiz.corn.meta.api.Secondly;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ *
+ * @version $Revision$ $Date$
+ */
+@Organic
+public class FarmerBrown {
+
+ private final AtomicInteger checks = new AtomicInteger();
+
+ @PlantingTime
+ private void plantTheCorn() {
+ // Dig out the planter!!!
+ }
+
+ @HarvestTime
+ private void harvestTheCorn() {
+ // Dig out the combine!!!
+ }
+
+ @Secondly
+ private void checkOnTheDaughters() {
+ checks.incrementAndGet();
+ }
+
+ public int getChecks() {
+ return checks.get();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_farmerbrowntest">FarmerBrownTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn.meta;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class FarmerBrownTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final FarmerBrown farmerBrown = (FarmerBrown) context.lookup("java:global/schedule-methods-meta/FarmerBrown");
+
+ // Give Farmer brown a chance to do some work
+ Thread.sleep(SECONDS.toMillis(5));
+
+ assertTrue(farmerBrown.getChecks() > 4);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.corn.meta.FarmerBrownTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/schedule-methods-meta
+INFO - openejb.base = /Users/dblevins/examples/schedule-methods-meta
+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/schedule-methods-meta/target/classes
+INFO - Beginning load: /Users/dblevins/examples/schedule-methods-meta/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/schedule-methods-meta
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean FarmerBrown: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.corn.meta.FarmerBrownTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/schedule-methods-meta" loaded.
+INFO - Assembling app: /Users/dblevins/examples/schedule-methods-meta
+INFO - Jndi(name="java:global/schedule-methods-meta/FarmerBrown!org.superbiz.corn.meta.FarmerBrown")
+INFO - Jndi(name="java:global/schedule-methods-meta/FarmerBrown")
+INFO - Jndi(name="java:global/EjbModule1809441479/org.superbiz.corn.meta.FarmerBrownTest!org.superbiz.corn.meta.FarmerBrownTest")
+INFO - Jndi(name="java:global/EjbModule1809441479/org.superbiz.corn.meta.FarmerBrownTest")
+INFO - Created Ejb(deployment-id=org.superbiz.corn.meta.FarmerBrownTest, ejb-name=org.superbiz.corn.meta.FarmerBrownTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=org.superbiz.corn.meta.FarmerBrownTest, ejb-name=org.superbiz.corn.meta.FarmerBrownTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/schedule-methods-meta)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.166 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/schedule-methods-meta.pdf b/content/examples/schedule-methods-meta.pdf
new file mode 100644
index 0000000..9e3f34f
--- /dev/null
+++ b/content/examples/schedule-methods-meta.pdf
Binary files differ
diff --git a/content/examples/schedule-methods-meta/README.md b/content/examples/schedule-methods-meta/README.md
new file mode 100755
index 0000000..6400eeb
--- /dev/null
+++ b/content/examples/schedule-methods-meta/README.md
@@ -0,0 +1,317 @@
+Title: Schedule Methods Meta
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## BiAnnually
+
+ package org.superbiz.corn.meta.api;
+
+ import javax.ejb.Schedule;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface BiAnnually {
+ public static interface $ {
+
+ @BiAnnually
+ @Schedule(second = "0", minute = "0", hour = "0", dayOfMonth = "1", month = "1,6")
+ public void method();
+ }
+ }
+
+## BiMonthly
+
+ package org.superbiz.corn.meta.api;
+
+ import javax.ejb.Schedule;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface BiMonthly {
+ public static interface $ {
+
+ @BiMonthly
+ @Schedule(second = "0", minute = "0", hour = "0", dayOfMonth = "1,15")
+ public void method();
+ }
+ }
+
+## Daily
+
+ package org.superbiz.corn.meta.api;
+
+ import javax.ejb.Schedule;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface Daily {
+ public static interface $ {
+
+ @Daily
+ @Schedule(second = "0", minute = "0", hour = "0", dayOfMonth = "*")
+ public void method();
+ }
+ }
+
+## HarvestTime
+
+ package org.superbiz.corn.meta.api;
+
+ import javax.ejb.Schedule;
+ import javax.ejb.Schedules;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface HarvestTime {
+ public static interface $ {
+
+ @HarvestTime
+ @Schedules({
+ @Schedule(month = "9", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "10", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ public void method();
+ }
+ }
+
+## Hourly
+
+ package org.superbiz.corn.meta.api;
+
+ import javax.ejb.Schedule;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface Hourly {
+ public static interface $ {
+
+ @Hourly
+ @Schedule(second = "0", minute = "0", hour = "*")
+ public void method();
+ }
+ }
+
+## Metatype
+
+ package org.superbiz.corn.meta.api;
+
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.ANNOTATION_TYPE)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Metatype {
+ }
+
+## Organic
+
+ package org.superbiz.corn.meta.api;
+
+ import javax.ejb.Lock;
+ import javax.ejb.LockType;
+ import javax.ejb.Singleton;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ @Singleton
+ @Lock(LockType.READ)
+ public @interface Organic {
+ }
+
+## PlantingTime
+
+ package org.superbiz.corn.meta.api;
+
+ import javax.ejb.Schedule;
+ import javax.ejb.Schedules;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface PlantingTime {
+ public static interface $ {
+
+ @PlantingTime
+ @Schedules({
+ @Schedule(month = "5", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "6", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ public void method();
+ }
+ }
+
+## Secondly
+
+ package org.superbiz.corn.meta.api;
+
+ import javax.ejb.Schedule;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface Secondly {
+ public static interface $ {
+
+ @Secondly
+ @Schedule(second = "*", minute = "*", hour = "*")
+ public void method();
+ }
+ }
+
+## FarmerBrown
+
+ package org.superbiz.corn.meta;
+
+ import org.superbiz.corn.meta.api.HarvestTime;
+ import org.superbiz.corn.meta.api.Organic;
+ import org.superbiz.corn.meta.api.PlantingTime;
+ import org.superbiz.corn.meta.api.Secondly;
+
+ import java.util.concurrent.atomic.AtomicInteger;
+
+ /**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ *
+ * @version $Revision$ $Date$
+ */
+ @Organic
+ public class FarmerBrown {
+
+ private final AtomicInteger checks = new AtomicInteger();
+
+ @PlantingTime
+ private void plantTheCorn() {
+ // Dig out the planter!!!
+ }
+
+ @HarvestTime
+ private void harvestTheCorn() {
+ // Dig out the combine!!!
+ }
+
+ @Secondly
+ private void checkOnTheDaughters() {
+ checks.incrementAndGet();
+ }
+
+ public int getChecks() {
+ return checks.get();
+ }
+ }
+
+## FarmerBrownTest
+
+ package org.superbiz.corn.meta;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+
+ import static java.util.concurrent.TimeUnit.SECONDS;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class FarmerBrownTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final FarmerBrown farmerBrown = (FarmerBrown) context.lookup("java:global/schedule-methods-meta/FarmerBrown");
+
+ // Give Farmer brown a chance to do some work
+ Thread.sleep(SECONDS.toMillis(5));
+
+ assertTrue(farmerBrown.getChecks() > 4);
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.corn.meta.FarmerBrownTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/schedule-methods-meta
+ INFO - openejb.base = /Users/dblevins/examples/schedule-methods-meta
+ 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/schedule-methods-meta/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/schedule-methods-meta/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/schedule-methods-meta
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean FarmerBrown: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.corn.meta.FarmerBrownTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/schedule-methods-meta" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/schedule-methods-meta
+ INFO - Jndi(name="java:global/schedule-methods-meta/FarmerBrown!org.superbiz.corn.meta.FarmerBrown")
+ INFO - Jndi(name="java:global/schedule-methods-meta/FarmerBrown")
+ INFO - Jndi(name="java:global/EjbModule1809441479/org.superbiz.corn.meta.FarmerBrownTest!org.superbiz.corn.meta.FarmerBrownTest")
+ INFO - Jndi(name="java:global/EjbModule1809441479/org.superbiz.corn.meta.FarmerBrownTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.corn.meta.FarmerBrownTest, ejb-name=org.superbiz.corn.meta.FarmerBrownTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.corn.meta.FarmerBrownTest, ejb-name=org.superbiz.corn.meta.FarmerBrownTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/schedule-methods-meta)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.166 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/schedule-methods-meta/build.xml b/content/examples/schedule-methods-meta/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/schedule-methods-meta/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/schedule-methods-meta/pom.xml b/content/examples/schedule-methods-meta/pom.xml
new file mode 100755
index 0000000..0619eec
--- /dev/null
+++ b/content/examples/schedule-methods-meta/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>schedule-methods-meta</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @Schedule Methods (Meta)</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/FarmerBrown.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/FarmerBrown.java
new file mode 100755
index 0000000..d9c4016
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/FarmerBrown.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta;
+
+import org.superbiz.corn.meta.api.HarvestTime;
+import org.superbiz.corn.meta.api.Organic;
+import org.superbiz.corn.meta.api.PlantingTime;
+import org.superbiz.corn.meta.api.Secondly;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ *
+ * @version $Revision$ $Date$
+ */
+@Organic
+public class FarmerBrown {
+
+ private final AtomicInteger checks = new AtomicInteger();
+
+ @PlantingTime
+ private void plantTheCorn() {
+ // Dig out the planter!!!
+ }
+
+ @HarvestTime
+ private void harvestTheCorn() {
+ // Dig out the combine!!!
+ }
+
+ @Secondly
+ private void checkOnTheDaughters() {
+ checks.incrementAndGet();
+ }
+
+ public int getChecks() {
+ return checks.get();
+ }
+}
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/BiAnnually.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/BiAnnually.java
new file mode 100755
index 0000000..e2cfd4b
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/BiAnnually.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface BiAnnually {
+
+ public static interface $ {
+
+ @BiAnnually
+ @Schedule(second = "0", minute = "0", hour = "0", dayOfMonth = "1", month = "1,6")
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/BiMonthly.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/BiMonthly.java
new file mode 100755
index 0000000..9241b29
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/BiMonthly.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface BiMonthly {
+
+ public static interface $ {
+
+ @BiMonthly
+ @Schedule(second = "0", minute = "0", hour = "0", dayOfMonth = "1,15")
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Daily.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Daily.java
new file mode 100755
index 0000000..f4747c3
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Daily.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface Daily {
+
+ public static interface $ {
+
+ @Daily
+ @Schedule(second = "0", minute = "0", hour = "0", dayOfMonth = "*")
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/HarvestTime.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/HarvestTime.java
new file mode 100755
index 0000000..9b513d6
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/HarvestTime.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import javax.ejb.Schedules;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface HarvestTime {
+
+ public static interface $ {
+
+ @HarvestTime
+ @Schedules({
+ @Schedule(month = "9", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "10", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Hourly.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Hourly.java
new file mode 100755
index 0000000..91d663b
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Hourly.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface Hourly {
+
+ public static interface $ {
+
+ @Hourly
+ @Schedule(second = "0", minute = "0", hour = "*")
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Metatype.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Metatype.java
new file mode 100755
index 0000000..edac298
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Metatype.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Metatype {
+
+}
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Organic.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Organic.java
new file mode 100755
index 0000000..c6550d8
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Organic.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta.api;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+
+@Singleton
+@Lock(LockType.READ)
+public @interface Organic {
+
+}
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/PlantingTime.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/PlantingTime.java
new file mode 100755
index 0000000..e90f6b2
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/PlantingTime.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import javax.ejb.Schedules;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface PlantingTime {
+
+ public static interface $ {
+
+ @PlantingTime
+ @Schedules({
+ @Schedule(month = "5", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "6", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ public void method();
+ }
+}
diff --git a/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Secondly.java b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Secondly.java
new file mode 100755
index 0000000..2c29c8b
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/main/java/org/superbiz/corn/meta/api/Secondly.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta.api;
+
+import javax.ejb.Schedule;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface Secondly {
+
+ public static interface $ {
+
+ @Secondly
+ @Schedule(second = "*", minute = "*", hour = "*")
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/schedule-methods-meta/src/test/java/org/superbiz/corn/meta/FarmerBrownTest.java b/content/examples/schedule-methods-meta/src/test/java/org/superbiz/corn/meta/FarmerBrownTest.java
new file mode 100755
index 0000000..7cc531a
--- /dev/null
+++ b/content/examples/schedule-methods-meta/src/test/java/org/superbiz/corn/meta/FarmerBrownTest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn.meta;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class FarmerBrownTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final FarmerBrown farmerBrown = (FarmerBrown) context.lookup("java:global/schedule-methods-meta/FarmerBrown");
+
+ // Give Farmer brown a chance to do some work
+ Thread.sleep(SECONDS.toMillis(5));
+
+ assertTrue(farmerBrown.getChecks() > 4);
+ }
+}
diff --git a/content/examples/schedule-methods.html b/content/examples/schedule-methods.html
new file mode 100644
index 0000000..550955b
--- /dev/null
+++ b/content/examples/schedule-methods.html
@@ -0,0 +1,324 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/schedule-methods.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Schedule Methods</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example schedule-methods can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/schedule-methods" class="bare">https://github.com/apache/tomee/tree/master/examples/schedule-methods</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_farmerbrown">FarmerBrown</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Schedule;
+import javax.ejb.Schedules;
+import javax.ejb.Singleton;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ *
+ * @version $Revision$ $Date$
+ */
+@Singleton
+@Lock(LockType.READ) // allows timers to execute in parallel
+public class FarmerBrown {
+
+ private final AtomicInteger checks = new AtomicInteger();
+
+ @Schedules({
+ @Schedule(month = "5", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "6", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ private void plantTheCorn() {
+ // Dig out the planter!!!
+ }
+
+ @Schedules({
+ @Schedule(month = "9", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "10", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ private void harvestTheCorn() {
+ // Dig out the combine!!!
+ }
+
+ @Schedule(second = "*", minute = "*", hour = "*")
+ private void checkOnTheDaughters() {
+ checks.incrementAndGet();
+ }
+
+ public int getChecks() {
+ return checks.get();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_farmerbrowntest">FarmerBrownTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.corn;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class FarmerBrownTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final FarmerBrown farmerBrown = (FarmerBrown) context.lookup("java:global/schedule-methods/FarmerBrown");
+
+ // Give Farmer brown a chance to do some work
+ Thread.sleep(SECONDS.toMillis(5));
+
+ assertTrue(farmerBrown.getChecks() > 4);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.corn.FarmerBrownTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/schedule-methods
+INFO - openejb.base = /Users/dblevins/examples/schedule-methods
+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/schedule-methods/target/classes
+INFO - Beginning load: /Users/dblevins/examples/schedule-methods/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/schedule-methods
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean FarmerBrown: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.corn.FarmerBrownTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/schedule-methods" loaded.
+INFO - Assembling app: /Users/dblevins/examples/schedule-methods
+INFO - Jndi(name="java:global/schedule-methods/FarmerBrown!org.superbiz.corn.FarmerBrown")
+INFO - Jndi(name="java:global/schedule-methods/FarmerBrown")
+INFO - Jndi(name="java:global/EjbModule660493198/org.superbiz.corn.FarmerBrownTest!org.superbiz.corn.FarmerBrownTest")
+INFO - Jndi(name="java:global/EjbModule660493198/org.superbiz.corn.FarmerBrownTest")
+INFO - Created Ejb(deployment-id=org.superbiz.corn.FarmerBrownTest, ejb-name=org.superbiz.corn.FarmerBrownTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=org.superbiz.corn.FarmerBrownTest, ejb-name=org.superbiz.corn.FarmerBrownTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/schedule-methods)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.121 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/schedule-methods.pdf b/content/examples/schedule-methods.pdf
new file mode 100644
index 0000000..cd2b13d
--- /dev/null
+++ b/content/examples/schedule-methods.pdf
Binary files differ
diff --git a/content/examples/schedule-methods/README.md b/content/examples/schedule-methods/README.md
new file mode 100755
index 0000000..90b6ddf
--- /dev/null
+++ b/content/examples/schedule-methods/README.md
@@ -0,0 +1,119 @@
+Title: Schedule Methods
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## FarmerBrown
+
+ package org.superbiz.corn;
+
+ import javax.ejb.Lock;
+ import javax.ejb.LockType;
+ import javax.ejb.Schedule;
+ import javax.ejb.Schedules;
+ import javax.ejb.Singleton;
+ import java.util.concurrent.atomic.AtomicInteger;
+
+ /**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ *
+ * @version $Revision$ $Date$
+ */
+ @Singleton
+ @Lock(LockType.READ) // allows timers to execute in parallel
+ public class FarmerBrown {
+
+ private final AtomicInteger checks = new AtomicInteger();
+
+ @Schedules({
+ @Schedule(month = "5", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "6", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ private void plantTheCorn() {
+ // Dig out the planter!!!
+ }
+
+ @Schedules({
+ @Schedule(month = "9", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "10", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ private void harvestTheCorn() {
+ // Dig out the combine!!!
+ }
+
+ @Schedule(second = "*", minute = "*", hour = "*")
+ private void checkOnTheDaughters() {
+ checks.incrementAndGet();
+ }
+
+ public int getChecks() {
+ return checks.get();
+ }
+ }
+
+## FarmerBrownTest
+
+ package org.superbiz.corn;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+
+ import static java.util.concurrent.TimeUnit.SECONDS;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ public class FarmerBrownTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final FarmerBrown farmerBrown = (FarmerBrown) context.lookup("java:global/schedule-methods/FarmerBrown");
+
+ // Give Farmer brown a chance to do some work
+ Thread.sleep(SECONDS.toMillis(5));
+
+ assertTrue(farmerBrown.getChecks() > 4);
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.corn.FarmerBrownTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/schedule-methods
+ INFO - openejb.base = /Users/dblevins/examples/schedule-methods
+ 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/schedule-methods/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/schedule-methods/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/schedule-methods
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean FarmerBrown: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.corn.FarmerBrownTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/schedule-methods" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/schedule-methods
+ INFO - Jndi(name="java:global/schedule-methods/FarmerBrown!org.superbiz.corn.FarmerBrown")
+ INFO - Jndi(name="java:global/schedule-methods/FarmerBrown")
+ INFO - Jndi(name="java:global/EjbModule660493198/org.superbiz.corn.FarmerBrownTest!org.superbiz.corn.FarmerBrownTest")
+ INFO - Jndi(name="java:global/EjbModule660493198/org.superbiz.corn.FarmerBrownTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.corn.FarmerBrownTest, ejb-name=org.superbiz.corn.FarmerBrownTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.corn.FarmerBrownTest, ejb-name=org.superbiz.corn.FarmerBrownTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=FarmerBrown, ejb-name=FarmerBrown, container=Default Singleton Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/schedule-methods)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.121 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/schedule-methods/build.xml b/content/examples/schedule-methods/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/schedule-methods/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/schedule-methods/pom.xml b/content/examples/schedule-methods/pom.xml
new file mode 100755
index 0000000..8872762
--- /dev/null
+++ b/content/examples/schedule-methods/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>schedule-methods</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @Schedule Methods</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/schedule-methods/src/main/java/org/superbiz/corn/FarmerBrown.java b/content/examples/schedule-methods/src/main/java/org/superbiz/corn/FarmerBrown.java
new file mode 100755
index 0000000..20a2de6
--- /dev/null
+++ b/content/examples/schedule-methods/src/main/java/org/superbiz/corn/FarmerBrown.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Schedule;
+import javax.ejb.Schedules;
+import javax.ejb.Singleton;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * This is where we schedule all of Farmer Brown's corn jobs
+ *
+ * @version $Revision$ $Date$
+ */
+@Singleton
+@Lock(LockType.READ) // allows timers to execute in parallel
+public class FarmerBrown {
+
+ private final AtomicInteger checks = new AtomicInteger();
+
+ @Schedules({
+ @Schedule(month = "5", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "6", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ private void plantTheCorn() {
+ // Dig out the planter!!!
+ }
+
+ @Schedules({
+ @Schedule(month = "9", dayOfMonth = "20-Last", minute = "0", hour = "8"),
+ @Schedule(month = "10", dayOfMonth = "1-10", minute = "0", hour = "8")
+ })
+ private void harvestTheCorn() {
+ // Dig out the combine!!!
+ }
+
+ @Schedule(second = "*", minute = "*", hour = "*")
+ private void checkOnTheDaughters() {
+ checks.incrementAndGet();
+ }
+
+ public int getChecks() {
+ return checks.get();
+ }
+}
diff --git a/content/examples/schedule-methods/src/test/java/org/superbiz/corn/FarmerBrownTest.java b/content/examples/schedule-methods/src/test/java/org/superbiz/corn/FarmerBrownTest.java
new file mode 100755
index 0000000..76d8ca4
--- /dev/null
+++ b/content/examples/schedule-methods/src/test/java/org/superbiz/corn/FarmerBrownTest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.corn;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class FarmerBrownTest extends TestCase {
+
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ final FarmerBrown farmerBrown = (FarmerBrown) context.lookup("java:global/schedule-methods/FarmerBrown");
+
+ // Give Farmer brown a chance to do some work
+ Thread.sleep(SECONDS.toMillis(5));
+
+ assertTrue(farmerBrown.getChecks() > 4);
+ }
+}
diff --git a/content/examples/server-events.html b/content/examples/server-events.html
new file mode 100644
index 0000000..ea044d7
--- /dev/null
+++ b/content/examples/server-events.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/server-events.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>server-events</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example server-events can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/server-events" class="bare">https://github.com/apache/tomee/tree/master/examples/server-events</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/server-events.pdf b/content/examples/server-events.pdf
new file mode 100644
index 0000000..0addd22
--- /dev/null
+++ b/content/examples/server-events.pdf
Binary files differ
diff --git a/content/examples/server-events/pom.xml b/content/examples/server-events/pom.xml
new file mode 100755
index 0000000..d7d4868
--- /dev/null
+++ b/content/examples/server-events/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1346534 $ $Date: 2012-06-05 20:57:54 +0200 (mar. 05 juin 2012) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>server-events</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Server Events</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <!--
+ The <scope>provided</scope> since that's OpenEJB dependent.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- test libs -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>arquillian-openejb-embedded-4</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/server-events/src/main/java/org/superbiz/event/AutoDiscoveredListener.java b/content/examples/server-events/src/main/java/org/superbiz/event/AutoDiscoveredListener.java
new file mode 100755
index 0000000..f548b91
--- /dev/null
+++ b/content/examples/server-events/src/main/java/org/superbiz/event/AutoDiscoveredListener.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.event;
+
+import org.apache.openejb.assembler.classic.event.AssemblerAfterApplicationCreated;
+import org.apache.openejb.observer.Observes;
+
+public class AutoDiscoveredListener {
+
+ private static String appName;
+
+ public void appCreated(@Observes final AssemblerAfterApplicationCreated appCreatedEvent) {
+ appName = appCreatedEvent.getApp().appId;
+ }
+
+ public static String getAppName() {
+ return appName;
+ }
+}
diff --git a/content/examples/server-events/src/main/java/org/superbiz/event/MyListener.java b/content/examples/server-events/src/main/java/org/superbiz/event/MyListener.java
new file mode 100755
index 0000000..c8a4724
--- /dev/null
+++ b/content/examples/server-events/src/main/java/org/superbiz/event/MyListener.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.event;
+
+import org.apache.openejb.observer.Observes;
+
+import java.util.logging.Logger;
+
+/**
+ * registered as service in openejb.xml, tomee.xml, resources.xml or openejb system properties:
+ * <p/>
+ * listener = new://Service?class-name=org.superbiz.event.MyListener
+ * listener.logAllEvent = true
+ */
+public class MyListener {
+
+ private static final Logger LOGGER = Logger.getLogger(MyListener.class.getName());
+
+ private static boolean logAllEvent = false; // static for testing
+
+ public void global(@Observes final Object event) {
+ LOGGER.info(">>> an event occured -> " + event.toString());
+ }
+
+ // configurable
+ public void setLogAllEvent(boolean logAllEvent) {
+ this.logAllEvent = logAllEvent;
+ }
+
+ public static boolean isLogAllEvent() {
+ return logAllEvent;
+ }
+}
diff --git a/content/examples/server-events/src/main/resources/META-INF/org.apache.openejb.extension b/content/examples/server-events/src/main/resources/META-INF/org.apache.openejb.extension
new file mode 100755
index 0000000..97633b3
--- /dev/null
+++ b/content/examples/server-events/src/main/resources/META-INF/org.apache.openejb.extension
@@ -0,0 +1 @@
+org.superbiz.event.AutoDiscoveredListener
diff --git a/content/examples/server-events/src/test/java/org/superbiz/event/ListenerTest.java b/content/examples/server-events/src/test/java/org/superbiz/event/ListenerTest.java
new file mode 100755
index 0000000..4ec1eb9
--- /dev/null
+++ b/content/examples/server-events/src/test/java/org/superbiz/event/ListenerTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.event;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class ListenerTest {
+
+ @Deployment
+ public static JavaArchive jar() {
+ return ShrinkWrap.create(JavaArchive.class, "listener-test.jar")
+ .addClasses(MyListener.class, AutoDiscoveredListener.class)
+ .addAsManifestResource(new StringAsset(AutoDiscoveredListener.class.getName()), ArchivePaths.create("org.apache.openejb.extension"));
+ }
+
+ @Test
+ public void check() {
+ assertEquals("listener-test", AutoDiscoveredListener.getAppName());
+ assertTrue(MyListener.isLogAllEvent());
+ }
+}
diff --git a/content/examples/server-events/src/test/resources/META-INF/ejb-jar.xml b/content/examples/server-events/src/test/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/content/examples/server-events/src/test/resources/META-INF/ejb-jar.xml
diff --git a/content/examples/server-events/src/test/resources/arquillian.xml b/content/examples/server-events/src/test/resources/arquillian.xml
new file mode 100755
index 0000000..acd52d7
--- /dev/null
+++ b/content/examples/server-events/src/test/resources/arquillian.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<arquillian
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ >
+ <container qualifier="openejb" default="true">
+ <configuration>
+ <property name="properties">
+ listener = new://Service?class-name=org.superbiz.event.MyListener
+ listener.logAllEvent = true
+ </property>
+ </configuration>
+ </container>
+</arquillian>
diff --git a/content/examples/simple-cdi-interceptor.html b/content/examples/simple-cdi-interceptor.html
new file mode 100644
index 0000000..564d557
--- /dev/null
+++ b/content/examples/simple-cdi-interceptor.html
@@ -0,0 +1,321 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-cdi-interceptor.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>simple-cdi-interceptor</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-cdi-interceptor can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-cdi-interceptor" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-cdi-interceptor</a></p>
+</div>
+</div>
+</div>
+<h1 id="_simple_cdi_interceptor" class="sect0">Simple CDI Interceptor</h1>
+<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.</p>
+</div>
+<div class="paragraph">
+<p>(Relevant snippets are inlined but you can check out the complete code, from the links provided)</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="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Log
+public void aMethod(){...}
+
+Let's create an annotation that would "mark" a method for interception.
+
+@InterceptorBinding
+@Target({ TYPE, METHOD })
+@Retention(RUNTIME)
+public @interface Log {
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Sure, you haven’t missed the @InterceptorBinding annotation above ! Now that our custom annotation is created, lets attach it (or to use a better term for it, "bind it" )
+to an interceptor.</p>
+</div>
+<div class="paragraph">
+<p>So here’s our logging interceptor. An @AroundInvoke method and we are almost done.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Interceptor
+@Log //binding the interceptor here. now any method annotated with @Log would be intercepted by logMethodEntry
+public class LoggingInterceptor {
+ @AroundInvoke
+ public Object logMethodEntry(InvocationContext ctx) throws Exception {
+ System.out.println("Entering method: " + ctx.getMethod().getName());
+ //or logger.info statement
+ return ctx.proceed();
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Now the @Log annotation we created is bound to this interceptor.</p>
+</div>
+<div class="paragraph">
+<p>That done, let’s annotate at class-level or method-level and have fun intercepting !</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Log
+@Stateful
+public class BookShow 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");
+ return moviesAvailable;
+ }
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ // assume more methods are present
+}</code></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>LoggingInterceptor</code>.</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 [beans.xml file]</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><beans>
+ <interceptors>
+ <class>org.superbiz.cdi.bookshow.interceptors.LoggingInterceptor
+ </class>
+ </interceptors>
+</beans></code></pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>in META-INF</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Those lines in beans.xml not only "enable" the interceptors, but also define the "order of execution" of the interceptors.
+But we’ll see that in another example on multiple-cdi-interceptors.</p>
+</div>
+<div class="paragraph">
+<p>Fire up the test, and we should see a 'Entering method: getMoviesList' printed in the console.</p>
+</div>
+<h1 id="_tests" class="sect0">Tests</h1>
+<div class="literalblock">
+<div class="content">
+<pre>Apache OpenEJB 4.0.0-beta-2 build: 20111103-01:00
+http://tomee.apache.org/
+INFO - openejb.home = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+INFO - openejb.base = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+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: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes
+INFO - Beginning load: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes
+INFO - Configuring enterprise application: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean cdi-simple-interceptors.Comp: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean BookShow: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Enterprise application "/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors" loaded.
+INFO - Assembling app: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow!org.superbiz.cdi.bookshow.beans.BookShow")
+INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow")
+INFO - Created Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container)
+INFO - Deployed Application(path=/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors)
+Entering method: getMoviesList</pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-cdi-interceptor.pdf b/content/examples/simple-cdi-interceptor.pdf
new file mode 100644
index 0000000..b5f9305
--- /dev/null
+++ b/content/examples/simple-cdi-interceptor.pdf
Binary files differ
diff --git a/content/examples/simple-cdi-interceptor/README.md b/content/examples/simple-cdi-interceptor/README.md
new file mode 100755
index 0000000..dd68924
--- /dev/null
+++ b/content/examples/simple-cdi-interceptor/README.md
@@ -0,0 +1,99 @@
+#Simple CDI Interceptor
+
+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.
+
+(Relevant snippets are inlined but you can check out the complete code, from the links provided)
+
+How do we mark which methods are to be intercepted ? Wouldn't it be handy to annotate a method like
+
+ @Log
+ public void aMethod(){...}
+
+Let's create an annotation that would "mark" a method for interception.
+
+ @InterceptorBinding
+ @Target({ TYPE, METHOD })
+ @Retention(RUNTIME)
+ public @interface Log {
+ }
+
+Sure, you haven't missed the @InterceptorBinding annotation above ! Now that our custom annotation is created, lets attach it (or to use a better term for it, "bind it" )
+to an interceptor.
+
+So here's our logging interceptor. An @AroundInvoke method and we are almost done.
+
+ @Interceptor
+ @Log //binding the interceptor here. now any method annotated with @Log would be intercepted by logMethodEntry
+ public class LoggingInterceptor {
+ @AroundInvoke
+ public Object logMethodEntry(InvocationContext ctx) throws Exception {
+ System.out.println("Entering method: " + ctx.getMethod().getName());
+ //or logger.info statement
+ return ctx.proceed();
+ }
+ }
+
+Now the @Log annotation we created is bound to this interceptor.
+
+That done, let's annotate at class-level or method-level and have fun intercepting !
+
+ @Log
+ @Stateful
+ public class BookShow 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");
+ return moviesAvailable;
+ }
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ // assume more methods are present
+ }
+
+The `@Log` annotation applied at class level denotes that all the methods should be intercepted with `LoggingInterceptor`.
+
+Before we say "all done" there's one last thing we are left with ! To enable the interceptors !
+
+Lets quickly put up a [beans.xml file]
+
+ <beans>
+ <interceptors>
+ <class>org.superbiz.cdi.bookshow.interceptors.LoggingInterceptor
+ </class>
+ </interceptors>
+ </beans>
+
+ in META-INF
+
+
+Those lines in beans.xml not only "enable" the interceptors, but also define the "order of execution" of the interceptors.
+But we'll see that in another example on multiple-cdi-interceptors.
+
+Fire up the test, and we should see a 'Entering method: getMoviesList' printed in the console.
+
+#Tests
+ Apache OpenEJB 4.0.0-beta-2 build: 20111103-01:00
+ http://openejb.apache.org/
+ INFO - openejb.home = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+ INFO - openejb.base = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+ 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: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes
+ INFO - Beginning load: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes
+ INFO - Configuring enterprise application: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean cdi-simple-interceptors.Comp: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean BookShow: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Enterprise application "/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors" loaded.
+ INFO - Assembling app: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+ INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow!org.superbiz.cdi.bookshow.beans.BookShow")
+ INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow")
+ INFO - Created Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container)
+ INFO - Deployed Application(path=/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors)
+ Entering method: getMoviesList
diff --git a/content/examples/simple-cdi-interceptor/pom.xml b/content/examples/simple-cdi-interceptor/pom.xml
new file mode 100755
index 0000000..66e75bc
--- /dev/null
+++ b/content/examples/simple-cdi-interceptor/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ You under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011)
+ $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-cdi-interceptor</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple CDI Interceptor</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ <!-- The <scope>test</scope> guarantees that non of your runtime code is
+ dependent on any OpenEJB classes. -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- This section allows you to configure where to publish libraries for
+ sharing. It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/simple-cdi-interceptor/src/main/java/org/superbiz/cdi/bookshow/beans/BookShow.java b/content/examples/simple-cdi-interceptor/src/main/java/org/superbiz/cdi/bookshow/beans/BookShow.java
new file mode 100755
index 0000000..464075d
--- /dev/null
+++ b/content/examples/simple-cdi-interceptor/src/main/java/org/superbiz/cdi/bookshow/beans/BookShow.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.beans;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+
+import javax.ejb.Stateful;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+@Log
+@Stateful
+public class BookShow 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");
+ return moviesAvailable;
+ }
+
+ public Integer getDiscountedPrice(int ticketPrice) {
+ return ticketPrice - 50;
+ }
+ // assume more methods are present
+}
diff --git a/content/examples/simple-cdi-interceptor/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/Log.java b/content/examples/simple-cdi-interceptor/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/Log.java
new file mode 100755
index 0000000..6516dbc
--- /dev/null
+++ b/content/examples/simple-cdi-interceptor/src/main/java/org/superbiz/cdi/bookshow/interceptorbinding/Log.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptorbinding;
+
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+public @interface Log {
+
+}
diff --git a/content/examples/simple-cdi-interceptor/src/main/java/org/superbiz/cdi/bookshow/interceptors/LoggingInterceptor.java b/content/examples/simple-cdi-interceptor/src/main/java/org/superbiz/cdi/bookshow/interceptors/LoggingInterceptor.java
new file mode 100755
index 0000000..cbafcc3
--- /dev/null
+++ b/content/examples/simple-cdi-interceptor/src/main/java/org/superbiz/cdi/bookshow/interceptors/LoggingInterceptor.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptors;
+
+import org.superbiz.cdi.bookshow.interceptorbinding.Log;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+
+@Interceptor
+@Log
+public class LoggingInterceptor implements Serializable {
+
+ private static final long serialVersionUID = 8139854519874743530L;
+
+ @AroundInvoke
+ public Object logMethodEntry(InvocationContext ctx) throws Exception {
+ System.out.println("Entering method: " + ctx.getMethod().getName());
+ return ctx.proceed();
+ }
+}
diff --git a/content/examples/simple-cdi-interceptor/src/main/resources/META-INF/beans.xml b/content/examples/simple-cdi-interceptor/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..b6d9661
--- /dev/null
+++ b/content/examples/simple-cdi-interceptor/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,31 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans>
+ <!-- By default, a bean archive has no enabled interceptors bound via interceptor
+ bindings. An interceptor must be explicitly enabled by listing its class
+ under the element of the beans.xml file of the bean archive. The order of
+ the interceptor declarations determines the interceptor ordering. Interceptors
+ which occur earlier in the list are called first. If the same class is listed
+ twice under the interceptors element, the container automatically detects
+ the problem and treats it as a deployment problem. -->
+
+ <interceptors>
+ <class>org.superbiz.cdi.bookshow.interceptors.LoggingInterceptor
+ </class>
+ </interceptors>
+</beans>
diff --git a/content/examples/simple-cdi-interceptor/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookShowTest.java b/content/examples/simple-cdi-interceptor/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookShowTest.java
new file mode 100755
index 0000000..77af133
--- /dev/null
+++ b/content/examples/simple-cdi-interceptor/src/test/java/org/superbiz/cdi/bookshow/interceptors/BookShowTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cdi.bookshow.interceptors;
+
+import junit.framework.TestCase;
+import org.superbiz.cdi.bookshow.beans.BookShow;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+
+public class BookShowTest extends TestCase {
+
+ @EJB
+ private BookShow bookForAShowBean;
+ EJBContainer ejbContainer;
+
+ /**
+ * Bootstrap the Embedded EJB Container
+ *
+ * @throws Exception
+ */
+ @Override
+ protected void setUp() throws Exception {
+ ejbContainer = EJBContainer.createEJBContainer();
+ ejbContainer.getContext().bind("inject", this);
+ }
+
+ /**
+ * Test basic interception
+ */
+ public void testMethodShouldBeIntercepted() {
+
+ bookForAShowBean.getMoviesList();
+
+ }
+
+}
diff --git a/content/examples/simple-cmp2.html b/content/examples/simple-cmp2.html
new file mode 100644
index 0000000..228cddc
--- /dev/null
+++ b/content/examples/simple-cmp2.html
@@ -0,0 +1,586 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-cmp2.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>EJB 2.1 CMP EntityBeans (CMP2)</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-cmp2 can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-cmp2" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-cmp2</a></p>
+</div>
+<div class="paragraph">
+<p>OpenEJB, the EJB Container for TomEE and Geronimo, does support all of EJB 1.1 to 3.1, including CMP2.</p>
+</div>
+<div class="paragraph">
+<p>The CMP2 implementation is actually done by adapting the CMP2 bean into a JPA Entity dynamically at deploy time.</p>
+</div>
+<div class="paragraph">
+<p>Appropriate subclasses, a JPA persistence.xml file and a mapping.xml file are generated at deployment
+time for the CMP2 EntityBeans and all the Entities will be then run on OpenJPA. This innovative code
+has been used as the sole CMP2 implementation in Geronimo for its J2EE 1.4, JavaEE 5 and JavaEE 6 certifications.</p>
+</div>
+<div class="paragraph">
+<p>The persistence.xml and mapping.xml files generated at deploy time can be saved to disk and included
+in the application, allowing you to:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>gain finer control over persistence options</p>
+</li>
+<li>
+<p>slowly convert individual entities from CMP2 to JPA</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Let’s see an example.</p>
+</div>
+</div>
+</div>
+<h1 id="_movies_application" class="sect0">Movies application</h1>
+<div class="paragraph">
+<p>The following is a basic EJB 2.1 application consisting of one CMP2 Entity. For those that are reading this example
+out of curiosity and are not familiar with CMP2 or EJB 2.x, each CMP2 Entity is composed of two parts</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><strong>A Home interface</strong> which has data access methods like "find", "create", and "remove". This is essentially
+what people use <code>@Stateless</code> beans for today, but with difference that you do not need to supply
+the implementation of the interface — the container will generate one for you. This is partly what inspired
+the creation of the OpenEJB-specific <a href="dynamic-dao-implementation.html">Dynamic DAO</a> feature.</p>
+</li>
+<li>
+<p><strong>An abstract EntityBean class</strong> which declares the persistent "properties" of the entity without actually
+declaring any fields. It is the container’s job to implement the actual methods and create the appropriate
+fields. OpenEJB will implement this bean as a JPA <code>@Entity</code> bean.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>As such a CMP2 EntityBean is really just the description of a persistent object and the description of a
+data-access object. There is no actual code to write.</p>
+</div>
+<div class="paragraph">
+<p>The majority of work in CMP2 is done in the xml:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><strong>ejb-jar.xml</strong> mapping information, which describes the persistent properties of the entity and the queries
+for all <strong>Home</strong> find, create and remove methods. This information will be converted by OpenEJB into
+a JPA mapping.xml file. All queries in the cmp2 part of the ejb-jar.xml are converted
+into named queries in JPA and generally everything is converted to its JPA equivalent.</p>
+</li>
+</ul>
+</div>
+<div class="sect1">
+<h2 id="_cmp2_entitybean_moviebean">CMP2 EntityBean, MovieBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cmp2;
+
+import javax.ejb.EntityBean;
+
+public abstract class MovieBean implements EntityBean {
+
+ public MovieBean() {
+ }
+
+ public Integer ejbCreate(String director, String title, int year) {
+ this.setDirector(director);
+ this.setTitle(title);
+ this.setYear(year);
+ return null;
+ }
+
+ public abstract java.lang.Integer getId();
+
+ public abstract void setId(java.lang.Integer id);
+
+ public abstract String getDirector();
+
+ public abstract void setDirector(String director);
+
+ public abstract String getTitle();
+
+ public abstract void setTitle(String title);
+
+ public abstract int getYear();
+
+ public abstract void setYear(int year);
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_cmp2_home_interface_movies">CMP2 Home interface, Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cmp2;
+
+import javax.ejb.CreateException;
+import javax.ejb.FinderException;
+import java.util.Collection;
+
+/**
+ * @version $Revision$ $Date$
+ */
+interface Movies extends javax.ejb.EJBLocalHome {
+ Movie create(String director, String title, int year) throws CreateException;
+
+ Movie findByPrimaryKey(Integer primarykey) throws FinderException;
+
+ Collection<Movie> findAll() throws FinderException;
+
+ Collection<Movie> findByDirector(String director) throws FinderException;
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_cmp2_mapping_in_ejb_jar_xml">CMP2 mapping in ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar>
+ <enterprise-beans>
+ <entity>
+ <ejb-name>MovieBean</ejb-name>
+ <local-home>org.superbiz.cmp2.Movies</local-home>
+ <local>org.superbiz.cmp2.Movie</local>
+ <ejb-class>org.superbiz.cmp2.MovieBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Integer</prim-key-class>
+ <reentrant>false</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>MovieBean</abstract-schema-name>
+ <cmp-field>
+ <field-name>id</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>director</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>year</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>title</field-name>
+ </cmp-field>
+ <primkey-field>id</primkey-field>
+ <query>
+ <query-method>
+ <method-name>findByDirector</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql>SELECT m FROM MovieBean m WHERE m.director = ?1</ejb-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findAll</method-name>
+ <method-params/>
+ </query-method>
+ <ejb-ql>SELECT m FROM MovieBean as m</ejb-ql>
+ </query>
+ </entity>
+ </enterprise-beans>
+</ejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_openejb_jar_xml">openejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
+ <enterprise-beans>
+ <entity>
+ <ejb-name>MovieBean</ejb-name>
+ <key-generator xmlns="http://www.openejb.org/xml/ns/pkgen-2.1">
+ <uuid/>
+ </key-generator>
+ </entity>
+ </enterprise-beans>
+</openejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.cmp2;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Collection;
+import java.util.Properties;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ p.put("movieDatabaseUnmanaged", "new://Resource?type=DataSource");
+ p.put("movieDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.put("movieDatabaseUnmanaged.JtaManaged", "false");
+
+ Context context = new InitialContext(p);
+
+ Movies movies = (Movies) context.lookup("MovieBeanLocalHome");
+
+ movies.create("Quentin Tarantino", "Reservoir Dogs", 1992);
+ movies.create("Joel Coen", "Fargo", 1996);
+ movies.create("Joel Coen", "The Big Lebowski", 1998);
+
+ Collection<Movie> list = movies.findAll();
+ assertEquals("Collection.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.remove(movie.getPrimaryKey());
+ }
+
+ assertEquals("Movies.findAll()", 0, movies.findAll().size());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.cmp2.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/simple-cmp2/target
+INFO - openejb.base = /Users/dblevins/examples/simple-cmp2/target
+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 - Configuring Service(id=movieDatabaseUnmanaged, type=Resource, provider-id=Default JDBC Database)
+INFO - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/simple-cmp2/target/classes
+INFO - Beginning load: /Users/dblevins/examples/simple-cmp2/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/simple-cmp2/target/classpath.ear
+INFO - Configuring Service(id=Default CMP Container, type=Container, provider-id=Default CMP Container)
+INFO - Auto-creating a container for bean MovieBean: Container(type=CMP_ENTITY, id=Default CMP Container)
+INFO - Configuring PersistenceUnit(name=cmp)
+INFO - Adjusting PersistenceUnit cmp <jta-data-source> to Resource ID 'movieDatabase' from 'null'
+INFO - Adjusting PersistenceUnit cmp <non-jta-data-source> to Resource ID 'movieDatabaseUnmanaged' from 'null'
+INFO - Enterprise application "/Users/dblevins/examples/simple-cmp2/target/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/simple-cmp2/target/classpath.ear
+INFO - PersistenceUnit(name=cmp, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 160ms
+INFO - Jndi(name=MovieBeanLocalHome) --> Ejb(deployment-id=MovieBean)
+INFO - Jndi(name=global/classpath.ear/simple-cmp2/MovieBean!org.superbiz.cmp2.Movies) --> Ejb(deployment-id=MovieBean)
+INFO - Jndi(name=global/classpath.ear/simple-cmp2/MovieBean) --> Ejb(deployment-id=MovieBean)
+INFO - Created Ejb(deployment-id=MovieBean, ejb-name=MovieBean, container=Default CMP Container)
+INFO - Started Ejb(deployment-id=MovieBean, ejb-name=MovieBean, container=Default CMP Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/simple-cmp2/target/classpath.ear)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.919 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+<h1 id="_cmp2_to_jpa" class="sect0">CMP2 to JPA</h1>
+<div class="paragraph">
+<p>As mentioned OpenEJB will implement the abstract CMP2 <code>EntityBean</code> as a JPA <code>@Entity</code>, create a <code>persistence.xml</code> file and convert all <code>ejb-jar.xml</code> mapping and queries to
+a JPA <code>entity-mappings.xml</code> file.</p>
+</div>
+<div class="paragraph">
+<p>Both of these files will be written to disk by setting the system property <code>openejb.descriptors.output</code> to <code>true</code>. In the testcase
+above, this can be done via the <code>InitialContext</code> parameters via code like this:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Properties p = new Properties();
+p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>// setup the data sources as usual...</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>// write the generated descriptors
+p.put("openejb.descriptors.output", "true");</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Context context = new InitialContext(p);</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Below are the generated <code>persistence.xml</code> and <code>mapping.xml</code> files for our CMP2 <code>EntityBean</code></p>
+</div>
+<div class="sect1">
+<h2 id="_cmp2_to_jpa_generated_persistence_xml_file">CMP2 to JPA generated persistence.xml file</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit name="cmp" transaction-type="JTA">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <mapping-file>META-INF/openejb-cmp-generated-orm.xml</mapping-file>
+ <class>openejb.org.superbiz.cmp2.MovieBean</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings"
+ value="buildSchema(ForeignKeys=true, Indexes=false, IgnoreErrors=true)"/>
+ <property name="openjpa.Log" value="DefaultLevel=INFO"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>All of this <code>persitence.xml</code> can be changed, however the <code>persistence-unit</code> must have the <code>name</code> fixed to <code>cmp</code>.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_cmp2_to_jpa_generated_mapping_file">CMP2 to JPA generated mapping file</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Note that the <code>persistence.xml</code> above refers to this mappings file as <code>META-INF/openejb-cmp-generated-orm.xml</code>. It is possible
+to rename this file to whatever name you prefer, just make sure to update the <code><mapping-file></code> element of the <code>cmp</code> persistence unit
+accordingly.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0">
+ <entity class="openejb.org.superbiz.cmp2.MovieBean" name="MovieBean">
+ <description>simple-cmp2#MovieBean</description>
+ <table/>
+ <named-query name="MovieBean.findByDirector(java.lang.String)">
+ <query>SELECT m FROM MovieBean m WHERE m.director = ?1</query>
+ </named-query>
+ <named-query name="MovieBean.findAll">
+ <query>SELECT m FROM MovieBean as m</query>
+ </named-query>
+ <attributes>
+ <id name="id">
+ <generated-value strategy="IDENTITY"/>
+ </id>
+ <basic name="director"/>
+ <basic name="year"/>
+ <basic name="title"/>
+ </attributes>
+ </entity>
+</entity-mappings></code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-cmp2.pdf b/content/examples/simple-cmp2.pdf
new file mode 100644
index 0000000..52b0846
--- /dev/null
+++ b/content/examples/simple-cmp2.pdf
Binary files differ
diff --git a/content/examples/simple-cmp2/README.md b/content/examples/simple-cmp2/README.md
new file mode 100755
index 0000000..24f2bf7
--- /dev/null
+++ b/content/examples/simple-cmp2/README.md
@@ -0,0 +1,314 @@
+Title: EJB 2.1 CMP EntityBeans (CMP2)
+
+
+
+OpenEJB, the EJB Container for TomEE and Geronimo, does support all of EJB 1.1 to 3.1, including CMP2.
+
+The CMP2 implementation is actually done by adapting the CMP2 bean into a JPA Entity dynamically at deploy time.
+
+Appropriate subclasses, a JPA persistence.xml file and a mapping.xml file are generated at deployment
+time for the CMP2 EntityBeans and all the Entities will be then run on OpenJPA. This innovative code
+has been used as the sole CMP2 implementation in Geronimo for its J2EE 1.4, JavaEE 5 and JavaEE 6 certifications.
+
+The persistence.xml and mapping.xml files generated at deploy time can be saved to disk and included
+in the application, allowing you to:
+
+ - gain finer control over persistence options
+ - slowly convert individual entities from CMP2 to JPA
+
+Let's see an example.
+
+# Movies application
+
+The following is a basic EJB 2.1 application consisting of one CMP2 Entity. For those that are reading this example
+out of curiosity and are not familiar with CMP2 or EJB 2.x, each CMP2 Entity is composed of two parts
+
+ - **A Home interface** which has data access methods like "find", "create", and "remove". This is essentially
+ what people use `@Stateless` beans for today, but with difference that you do not need to supply
+ the implementation of the interface -- the container will generate one for you. This is partly what inspired
+ the creation of the OpenEJB-specific [Dynamic DAO](../dynamic-dao-implementation/README.html) feature.
+
+ - **An abstract EntityBean class** which declares the persistent "properties" of the entity without actually
+declaring any fields. It is the container's job to implement the actual methods and create the appropriate
+fields. OpenEJB will implement this bean as a JPA `@Entity` bean.
+
+As such a CMP2 EntityBean is really just the description of a persistent object and the description of a
+data-access object. There is no actual code to write.
+
+The majority of work in CMP2 is done in the xml:
+
+ - **ejb-jar.xml** mapping information, which describes the persistent properties of the entity and the queries
+ for all *Home* find, create and remove methods. This information will be converted by OpenEJB into
+ a JPA mapping.xml file. All queries in the cmp2 part of the ejb-jar.xml are converted
+ into named queries in JPA and generally everything is converted to its JPA equivalent.
+
+## CMP2 EntityBean, MovieBean
+
+ package org.superbiz.cmp2;
+
+ import javax.ejb.EntityBean;
+
+ public abstract class MovieBean implements EntityBean {
+
+ public MovieBean() {
+ }
+
+ public Integer ejbCreate(String director, String title, int year) {
+ this.setDirector(director);
+ this.setTitle(title);
+ this.setYear(year);
+ return null;
+ }
+
+ public abstract java.lang.Integer getId();
+
+ public abstract void setId(java.lang.Integer id);
+
+ public abstract String getDirector();
+
+ public abstract void setDirector(String director);
+
+ public abstract String getTitle();
+
+ public abstract void setTitle(String title);
+
+ public abstract int getYear();
+
+ public abstract void setYear(int year);
+
+ }
+
+## CMP2 Home interface, Movies
+
+ package org.superbiz.cmp2;
+
+ import javax.ejb.CreateException;
+ import javax.ejb.FinderException;
+ import java.util.Collection;
+
+ /**
+ * @version $Revision$ $Date$
+ */
+ interface Movies extends javax.ejb.EJBLocalHome {
+ Movie create(String director, String title, int year) throws CreateException;
+
+ Movie findByPrimaryKey(Integer primarykey) throws FinderException;
+
+ Collection<Movie> findAll() throws FinderException;
+
+ Collection<Movie> findByDirector(String director) throws FinderException;
+ }
+
+## CMP2 mapping in ejb-jar.xml
+
+ <ejb-jar>
+ <enterprise-beans>
+ <entity>
+ <ejb-name>MovieBean</ejb-name>
+ <local-home>org.superbiz.cmp2.Movies</local-home>
+ <local>org.superbiz.cmp2.Movie</local>
+ <ejb-class>org.superbiz.cmp2.MovieBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Integer</prim-key-class>
+ <reentrant>false</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>MovieBean</abstract-schema-name>
+ <cmp-field>
+ <field-name>id</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>director</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>year</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>title</field-name>
+ </cmp-field>
+ <primkey-field>id</primkey-field>
+ <query>
+ <query-method>
+ <method-name>findByDirector</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql>SELECT m FROM MovieBean m WHERE m.director = ?1</ejb-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findAll</method-name>
+ <method-params/>
+ </query-method>
+ <ejb-ql>SELECT m FROM MovieBean as m</ejb-ql>
+ </query>
+ </entity>
+ </enterprise-beans>
+ </ejb-jar>
+
+
+## openejb-jar.xml
+
+ <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
+ <enterprise-beans>
+ <entity>
+ <ejb-name>MovieBean</ejb-name>
+ <key-generator xmlns="http://www.openejb.org/xml/ns/pkgen-2.1">
+ <uuid/>
+ </key-generator>
+ </entity>
+ </enterprise-beans>
+ </openejb-jar>
+
+
+## MoviesTest
+
+ package org.superbiz.cmp2;
+
+ import junit.framework.TestCase;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.Collection;
+ import java.util.Properties;
+
+ /**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+ public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ p.put("movieDatabaseUnmanaged", "new://Resource?type=DataSource");
+ p.put("movieDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.put("movieDatabaseUnmanaged.JtaManaged", "false");
+
+ Context context = new InitialContext(p);
+
+ Movies movies = (Movies) context.lookup("MovieBeanLocalHome");
+
+ movies.create("Quentin Tarantino", "Reservoir Dogs", 1992);
+ movies.create("Joel Coen", "Fargo", 1996);
+ movies.create("Joel Coen", "The Big Lebowski", 1998);
+
+ Collection<Movie> list = movies.findAll();
+ assertEquals("Collection.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.remove(movie.getPrimaryKey());
+ }
+
+ assertEquals("Movies.findAll()", 0, movies.findAll().size());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.cmp2.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/simple-cmp2/target
+ INFO - openejb.base = /Users/dblevins/examples/simple-cmp2/target
+ 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 - Configuring Service(id=movieDatabaseUnmanaged, type=Resource, provider-id=Default JDBC Database)
+ INFO - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/simple-cmp2/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/simple-cmp2/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/simple-cmp2/target/classpath.ear
+ INFO - Configuring Service(id=Default CMP Container, type=Container, provider-id=Default CMP Container)
+ INFO - Auto-creating a container for bean MovieBean: Container(type=CMP_ENTITY, id=Default CMP Container)
+ INFO - Configuring PersistenceUnit(name=cmp)
+ INFO - Adjusting PersistenceUnit cmp <jta-data-source> to Resource ID 'movieDatabase' from 'null'
+ INFO - Adjusting PersistenceUnit cmp <non-jta-data-source> to Resource ID 'movieDatabaseUnmanaged' from 'null'
+ INFO - Enterprise application "/Users/dblevins/examples/simple-cmp2/target/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/simple-cmp2/target/classpath.ear
+ INFO - PersistenceUnit(name=cmp, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 160ms
+ INFO - Jndi(name=MovieBeanLocalHome) --> Ejb(deployment-id=MovieBean)
+ INFO - Jndi(name=global/classpath.ear/simple-cmp2/MovieBean!org.superbiz.cmp2.Movies) --> Ejb(deployment-id=MovieBean)
+ INFO - Jndi(name=global/classpath.ear/simple-cmp2/MovieBean) --> Ejb(deployment-id=MovieBean)
+ INFO - Created Ejb(deployment-id=MovieBean, ejb-name=MovieBean, container=Default CMP Container)
+ INFO - Started Ejb(deployment-id=MovieBean, ejb-name=MovieBean, container=Default CMP Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/simple-cmp2/target/classpath.ear)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.919 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+# CMP2 to JPA
+
+As mentioned OpenEJB will implement the abstract CMP2 `EntityBean` as a JPA `@Entity`, create a `persistence.xml` file and convert all `ejb-jar.xml` mapping and queries to
+a JPA `entity-mappings.xml` file.
+
+Both of these files will be written to disk by setting the system property `openejb.descriptors.output` to `true`. In the testcase
+above, this can be done via the `InitialContext` parameters via code like this:
+
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ // setup the data sources as usual...
+
+ // write the generated descriptors
+ p.put("openejb.descriptors.output", "true");
+
+ Context context = new InitialContext(p);
+
+Below are the generated `persistence.xml` and `mapping.xml` files for our CMP2 `EntityBean`
+
+## CMP2 to JPA generated persistence.xml file
+
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+ <persistence-unit name="cmp" transaction-type="JTA">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <mapping-file>META-INF/openejb-cmp-generated-orm.xml</mapping-file>
+ <class>openejb.org.superbiz.cmp2.MovieBean</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings"
+ value="buildSchema(ForeignKeys=true, Indexes=false, IgnoreErrors=true)"/>
+ <property name="openjpa.Log" value="DefaultLevel=INFO"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+All of this `persitence.xml` can be changed, however the `persistence-unit` must have the `name` fixed to `cmp`.
+
+## CMP2 to JPA generated mapping file
+
+Note that the `persistence.xml` above refers to this mappings file as `META-INF/openejb-cmp-generated-orm.xml`. It is possible
+to rename this file to whatever name you prefer, just make sure to update the `<mapping-file>` element of the `cmp` persistence unit
+accordingly.
+
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0">
+ <entity class="openejb.org.superbiz.cmp2.MovieBean" name="MovieBean">
+ <description>simple-cmp2#MovieBean</description>
+ <table/>
+ <named-query name="MovieBean.findByDirector(java.lang.String)">
+ <query>SELECT m FROM MovieBean m WHERE m.director = ?1</query>
+ </named-query>
+ <named-query name="MovieBean.findAll">
+ <query>SELECT m FROM MovieBean as m</query>
+ </named-query>
+ <attributes>
+ <id name="id">
+ <generated-value strategy="IDENTITY"/>
+ </id>
+ <basic name="director"/>
+ <basic name="year"/>
+ <basic name="title"/>
+ </attributes>
+ </entity>
+ </entity-mappings>
diff --git a/content/examples/simple-cmp2/pom.xml b/content/examples/simple-cmp2/pom.xml
new file mode 100755
index 0000000..e9db68e
--- /dev/null
+++ b/content/examples/simple-cmp2/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-cmp2</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple CMP2 Entity</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <openejb.version>4.7.1</openejb.version>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ <argLine>-javaagent:${basedir}/target/openejb-javaagent-${openejb.version}.jar</argLine>
+ <workingDirectory>${basedir}/target</workingDirectory>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-javaagent</artifactId>
+ <version>${openejb.version}</version>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+
+ <!-- spec apis such as javax.persistence -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- openejb container for running tests -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/simple-cmp2/src/main/java/org/superbiz/cmp2/Movie.java b/content/examples/simple-cmp2/src/main/java/org/superbiz/cmp2/Movie.java
new file mode 100755
index 0000000..a79d4a3
--- /dev/null
+++ b/content/examples/simple-cmp2/src/main/java/org/superbiz/cmp2/Movie.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cmp2;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public interface Movie extends javax.ejb.EJBLocalObject {
+
+ java.lang.Integer getId();
+
+ void setId(java.lang.Integer id);
+
+ String getDirector();
+
+ void setDirector(String director);
+
+ String getTitle();
+
+ void setTitle(String title);
+
+ int getYear();
+
+ void setYear(int year);
+}
diff --git a/content/examples/simple-cmp2/src/main/java/org/superbiz/cmp2/MovieBean.java b/content/examples/simple-cmp2/src/main/java/org/superbiz/cmp2/MovieBean.java
new file mode 100755
index 0000000..965da70
--- /dev/null
+++ b/content/examples/simple-cmp2/src/main/java/org/superbiz/cmp2/MovieBean.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cmp2;
+
+import javax.ejb.EntityBean;
+
+public abstract class MovieBean implements EntityBean {
+
+ public MovieBean() {
+ }
+
+ public Integer ejbCreate(String director, String title, int year) {
+ this.setDirector(director);
+ this.setTitle(title);
+ this.setYear(year);
+ return null;
+ }
+
+ public abstract java.lang.Integer getId();
+
+ public abstract void setId(java.lang.Integer id);
+
+ public abstract String getDirector();
+
+ public abstract void setDirector(String director);
+
+ public abstract String getTitle();
+
+ public abstract void setTitle(String title);
+
+ public abstract int getYear();
+
+ public abstract void setYear(int year);
+
+}
diff --git a/content/examples/simple-cmp2/src/main/java/org/superbiz/cmp2/Movies.java b/content/examples/simple-cmp2/src/main/java/org/superbiz/cmp2/Movies.java
new file mode 100755
index 0000000..8877449
--- /dev/null
+++ b/content/examples/simple-cmp2/src/main/java/org/superbiz/cmp2/Movies.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cmp2;
+
+import javax.ejb.CreateException;
+import javax.ejb.FinderException;
+import java.util.Collection;
+
+/**
+ * @version $Revision$ $Date$
+ */
+interface Movies extends javax.ejb.EJBLocalHome {
+
+ Movie create(String director, String title, int year) throws CreateException;
+
+ Movie findByPrimaryKey(Integer primarykey) throws FinderException;
+
+ Collection<Movie> findAll() throws FinderException;
+
+ Collection<Movie> findByDirector(String director) throws FinderException;
+}
diff --git a/content/examples/simple-cmp2/src/main/resources/META-INF/ejb-jar.xml b/content/examples/simple-cmp2/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..c6fd3da
--- /dev/null
+++ b/content/examples/simple-cmp2/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ejb-jar>
+ <enterprise-beans>
+ <entity>
+ <ejb-name>MovieBean</ejb-name>
+ <local-home>org.superbiz.cmp2.Movies</local-home>
+ <local>org.superbiz.cmp2.Movie</local>
+ <ejb-class>org.superbiz.cmp2.MovieBean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Integer</prim-key-class>
+ <reentrant>false</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>MovieBean</abstract-schema-name>
+ <cmp-field>
+ <field-name>id</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>director</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>year</field-name>
+ </cmp-field>
+ <cmp-field>
+ <field-name>title</field-name>
+ </cmp-field>
+ <primkey-field>id</primkey-field>
+ <query>
+ <query-method>
+ <method-name>findByDirector</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql>SELECT m FROM MovieBean m WHERE m.director = ?1</ejb-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findAll</method-name>
+ <method-params/>
+ </query-method>
+ <ejb-ql>SELECT m FROM MovieBean as m</ejb-ql>
+ </query>
+ </entity>
+ </enterprise-beans>
+</ejb-jar>
diff --git a/content/examples/simple-cmp2/src/main/resources/META-INF/openejb-jar.xml b/content/examples/simple-cmp2/src/main/resources/META-INF/openejb-jar.xml
new file mode 100755
index 0000000..d55e23f
--- /dev/null
+++ b/content/examples/simple-cmp2/src/main/resources/META-INF/openejb-jar.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
+ <enterprise-beans>
+ <entity>
+ <ejb-name>MovieBean</ejb-name>
+ <key-generator xmlns="http://www.openejb.org/xml/ns/pkgen-2.1">
+ <uuid/>
+ </key-generator>
+ </entity>
+ </enterprise-beans>
+</openejb-jar>
diff --git a/content/examples/simple-cmp2/src/test/java/org/superbiz/cmp2/MoviesTest.java b/content/examples/simple-cmp2/src/test/java/org/superbiz/cmp2/MoviesTest.java
new file mode 100755
index 0000000..04333dc
--- /dev/null
+++ b/content/examples/simple-cmp2/src/test/java/org/superbiz/cmp2/MoviesTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.cmp2;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Collection;
+import java.util.Properties;
+
+/**
+ * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $
+ */
+public class MoviesTest extends TestCase {
+
+ public void test() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ p.put("movieDatabaseUnmanaged", "new://Resource?type=DataSource");
+ p.put("movieDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.put("movieDatabaseUnmanaged.JtaManaged", "false");
+
+ Context context = new InitialContext(p);
+
+ Movies movies = (Movies) context.lookup("MovieBeanLocalHome");
+
+ movies.create("Quentin Tarantino", "Reservoir Dogs", 1992);
+ movies.create("Joel Coen", "Fargo", 1996);
+ movies.create("Joel Coen", "The Big Lebowski", 1998);
+
+ Collection<Movie> list = movies.findAll();
+ assertEquals("Collection.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.remove(movie.getPrimaryKey());
+ }
+
+ assertEquals("Movies.findAll()", 0, movies.findAll().size());
+ }
+}
diff --git a/content/examples/simple-mdb-and-cdi.html b/content/examples/simple-mdb-and-cdi.html
new file mode 100644
index 0000000..73fc0c3
--- /dev/null
+++ b/content/examples/simple-mdb-and-cdi.html
@@ -0,0 +1,400 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-mdb-and-cdi.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple MDB and CDI</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-mdb-and-cdi can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-mdb-and-cdi" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-mdb-and-cdi</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chatbean">ChatBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.mdb;
+
+import javax.annotation.Resource;
+import javax.ejb.MessageDriven;
+import javax.inject.Inject;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+@MessageDriven
+public class ChatBean implements MessageListener {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ @Inject
+ private ChatRespondCreator responder;
+
+ public void onMessage(Message message) {
+ try {
+
+ final TextMessage textMessage = (TextMessage) message;
+ final String question = textMessage.getText();
+ final String response = responder.respond(question);
+
+ if (response != null) {
+ respond(response);
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chatrespondcreator">ChatRespondCreator</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.mdb;
+
+public class ChatRespondCreator {
+ public String respond(String question) {
+ if ("Hello World!".equals(question)) {
+ return "Hello, Test Case!";
+ } else if ("How are you?".equals(question)) {
+ return "I'm doing well.";
+ } else if ("Still spinning?".equals(question)) {
+ return "Once every day, as usual.";
+ }
+ return null;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_beans_xml">beans.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans/></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chatbeantest">ChatBeanTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.mdb;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.embeddable.EJBContainer;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+public class ChatBeanTest extends TestCase {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ChatBean")
+ private Queue questionQueue;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+
+ final Connection connection = connectionFactory.createConnection();
+
+ connection.start();
+
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ final MessageProducer questions = session.createProducer(questionQueue);
+
+ final MessageConsumer answers = session.createConsumer(answerQueue);
+
+
+ sendText("Hello World!", questions, session);
+
+ assertEquals("Hello, Test Case!", receiveText(answers));
+
+
+ sendText("How are you?", questions, session);
+
+ assertEquals("I'm doing well.", receiveText(answers));
+
+
+ sendText("Still spinning?", questions, session);
+
+ assertEquals("Once every day, as usual.", receiveText(answers));
+ }
+
+ private void sendText(String text, MessageProducer questions, Session session) throws JMSException {
+
+ questions.send(session.createTextMessage(text));
+ }
+
+ private String receiveText(MessageConsumer answers) throws JMSException {
+
+ return ((TextMessage) answers.receive(1000)).getText();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-mdb-and-cdi.pdf b/content/examples/simple-mdb-and-cdi.pdf
new file mode 100644
index 0000000..b47d84b
--- /dev/null
+++ b/content/examples/simple-mdb-and-cdi.pdf
Binary files differ
diff --git a/content/examples/simple-mdb-and-cdi/README.md b/content/examples/simple-mdb-and-cdi/README.md
new file mode 100755
index 0000000..ae1fdfe
--- /dev/null
+++ b/content/examples/simple-mdb-and-cdi/README.md
@@ -0,0 +1,185 @@
+Title: Simple MDB and CDI
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## ChatBean
+
+ package org.superbiz.mdb;
+
+ import javax.annotation.Resource;
+ import javax.ejb.MessageDriven;
+ import javax.inject.Inject;
+ import javax.jms.Connection;
+ import javax.jms.ConnectionFactory;
+ import javax.jms.DeliveryMode;
+ import javax.jms.JMSException;
+ import javax.jms.Message;
+ import javax.jms.MessageListener;
+ import javax.jms.MessageProducer;
+ import javax.jms.Queue;
+ import javax.jms.Session;
+ import javax.jms.TextMessage;
+
+ @MessageDriven
+ public class ChatBean implements MessageListener {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ @Inject
+ private ChatRespondCreator responder;
+
+ public void onMessage(Message message) {
+ try {
+
+ final TextMessage textMessage = (TextMessage) message;
+ final String question = textMessage.getText();
+ final String response = responder.respond(question);
+
+ if (response != null) {
+ respond(response);
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+ }
+
+## ChatRespondCreator
+
+ package org.superbiz.mdb;
+
+ public class ChatRespondCreator {
+ public String respond(String question) {
+ if ("Hello World!".equals(question)) {
+ return "Hello, Test Case!";
+ } else if ("How are you?".equals(question)) {
+ return "I'm doing well.";
+ } else if ("Still spinning?".equals(question)) {
+ return "Once every day, as usual.";
+ }
+ return null;
+ }
+ }
+
+## beans.xml
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+ <beans/>
+
+
+## ChatBeanTest
+
+ package org.superbiz.mdb;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.Resource;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.jms.Connection;
+ import javax.jms.ConnectionFactory;
+ import javax.jms.JMSException;
+ import javax.jms.MessageConsumer;
+ import javax.jms.MessageProducer;
+ import javax.jms.Queue;
+ import javax.jms.Session;
+ import javax.jms.TextMessage;
+
+ public class ChatBeanTest extends TestCase {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ChatBean")
+ private Queue questionQueue;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+
+ final Connection connection = connectionFactory.createConnection();
+
+ connection.start();
+
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ final MessageProducer questions = session.createProducer(questionQueue);
+
+ final MessageConsumer answers = session.createConsumer(answerQueue);
+
+
+ sendText("Hello World!", questions, session);
+
+ assertEquals("Hello, Test Case!", receiveText(answers));
+
+
+ sendText("How are you?", questions, session);
+
+ assertEquals("I'm doing well.", receiveText(answers));
+
+
+ sendText("Still spinning?", questions, session);
+
+ assertEquals("Once every day, as usual.", receiveText(answers));
+ }
+
+ private void sendText(String text, MessageProducer questions, Session session) throws JMSException {
+
+ questions.send(session.createTextMessage(text));
+ }
+
+ private String receiveText(MessageConsumer answers) throws JMSException {
+
+ return ((TextMessage) answers.receive(1000)).getText();
+ }
+ }
diff --git a/content/examples/simple-mdb-and-cdi/build.xml b/content/examples/simple-mdb-and-cdi/build.xml
new file mode 100755
index 0000000..567603e
--- /dev/null
+++ b/content/examples/simple-mdb-and-cdi/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 635408 $ $Date: 2008-03-09 17:48:40 -0700 (Sun, 09 Mar 2008) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-mdb-and-cdi/pom.xml b/content/examples/simple-mdb-and-cdi/pom.xml
new file mode 100755
index 0000000..409322e
--- /dev/null
+++ b/content/examples/simple-mdb-and-cdi/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 638272 $ $Date: 2008-03-18 01:59:59 -0700 (Tue, 18 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-mdb-and-cdi</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple MDB With a CDI Injection</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/simple-mdb-and-cdi/src/main/java/org/superbiz/mdb/ChatBean.java b/content/examples/simple-mdb-and-cdi/src/main/java/org/superbiz/mdb/ChatBean.java
new file mode 100755
index 0000000..e4b3ee1
--- /dev/null
+++ b/content/examples/simple-mdb-and-cdi/src/main/java/org/superbiz/mdb/ChatBean.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.mdb;
+
+import javax.annotation.Resource;
+import javax.ejb.MessageDriven;
+import javax.inject.Inject;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+@MessageDriven
+public class ChatBean implements MessageListener {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ @Inject
+ private ChatRespondCreator responder;
+
+ public void onMessage(Message message) {
+ try {
+
+ final TextMessage textMessage = (TextMessage) message;
+ final String question = textMessage.getText();
+ final String response = responder.respond(question);
+
+ if (response != null) {
+ respond(response);
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) {
+ session.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-mdb-and-cdi/src/main/java/org/superbiz/mdb/ChatRespondCreator.java b/content/examples/simple-mdb-and-cdi/src/main/java/org/superbiz/mdb/ChatRespondCreator.java
new file mode 100755
index 0000000..739d0cd
--- /dev/null
+++ b/content/examples/simple-mdb-and-cdi/src/main/java/org/superbiz/mdb/ChatRespondCreator.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.mdb;
+
+public class ChatRespondCreator {
+
+ public String respond(String question) {
+ if ("Hello World!".equals(question)) {
+ return "Hello, Test Case!";
+ } else if ("How are you?".equals(question)) {
+ return "I'm doing well.";
+ } else if ("Still spinning?".equals(question)) {
+ return "Once every day, as usual.";
+ }
+ return null;
+ }
+}
diff --git a/content/examples/simple-mdb-and-cdi/src/main/resources/META-INF/beans.xml b/content/examples/simple-mdb-and-cdi/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..3e3c8c6
--- /dev/null
+++ b/content/examples/simple-mdb-and-cdi/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,18 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<beans/>
diff --git a/content/examples/simple-mdb-and-cdi/src/test/java/org/superbiz/mdb/ChatBeanTest.java b/content/examples/simple-mdb-and-cdi/src/test/java/org/superbiz/mdb/ChatBeanTest.java
new file mode 100755
index 0000000..a360d10
--- /dev/null
+++ b/content/examples/simple-mdb-and-cdi/src/test/java/org/superbiz/mdb/ChatBeanTest.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.mdb;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.embeddable.EJBContainer;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+public class ChatBeanTest extends TestCase {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ChatBean")
+ private Queue questionQueue;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ final Connection connection = connectionFactory.createConnection();
+
+ connection.start();
+
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ final MessageProducer questions = session.createProducer(questionQueue);
+
+ final MessageConsumer answers = session.createConsumer(answerQueue);
+
+ sendText("Hello World!", questions, session);
+
+ assertEquals("Hello, Test Case!", receiveText(answers));
+
+ sendText("How are you?", questions, session);
+
+ assertEquals("I'm doing well.", receiveText(answers));
+
+ sendText("Still spinning?", questions, session);
+
+ assertEquals("Once every day, as usual.", receiveText(answers));
+
+ }
+
+ private void sendText(String text, MessageProducer questions, Session session) throws JMSException {
+
+ questions.send(session.createTextMessage(text));
+
+ }
+
+ private String receiveText(MessageConsumer answers) throws JMSException {
+
+ return ((TextMessage) answers.receive(1000)).getText();
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-mdb-with-descriptor.html b/content/examples/simple-mdb-with-descriptor.html
new file mode 100644
index 0000000..bac78c7
--- /dev/null
+++ b/content/examples/simple-mdb-with-descriptor.html
@@ -0,0 +1,451 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-mdb-with-descriptor.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple MDB with Descriptor</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-mdb-with-descriptor can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-mdb-with-descriptor" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-mdb-with-descriptor</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chatbean">ChatBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.mdbdesc;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+public class ChatBean implements MessageListener {
+
+ private ConnectionFactory connectionFactory;
+
+ private Queue answerQueue;
+
+ public void onMessage(Message message) {
+ try {
+
+ final TextMessage textMessage = (TextMessage) message;
+ final String question = textMessage.getText();
+
+ if ("Hello World!".equals(question)) {
+
+ respond("Hello, Test Case!");
+ } else if ("How are you?".equals(question)) {
+
+ respond("I'm doing well.");
+ } else if ("Still spinning?".equals(question)) {
+
+ respond("Once every day, as usual.");
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" metadata-complete="true">
+ <enterprise-beans>
+
+ <message-driven>
+
+ <ejb-name>ChatBean</ejb-name>
+ <ejb-class>org.superbiz.mdbdesc.ChatBean</ejb-class>
+
+ <messaging-type>javax.jms.MessageListener</messaging-type>
+
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>destination</activation-config-property-name>
+ <activation-config-property-value>ChatBean</activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>destinationType</activation-config-property-name>
+ <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+
+ <resource-ref>
+ <res-ref-name>java:comp/env/org.superbiz.mdbdesc.ChatBean/connectionFactory</res-ref-name>
+ <res-type>javax.jms.ConnectionFactory</res-type>
+ <injection-target>
+ <injection-target-class>org.superbiz.mdbdesc.ChatBean</injection-target-class>
+ <injection-target-name>connectionFactory</injection-target-name>
+ </injection-target>
+ </resource-ref>
+
+ <resource-env-ref>
+ <resource-env-ref-name>java:comp/env/AnswerQueue</resource-env-ref-name>
+ <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
+ <mapped-name>AnswerQueue</mapped-name>
+ <injection-target>
+ <injection-target-class>org.superbiz.mdbdesc.ChatBean</injection-target-class>
+ <injection-target-name>answerQueue</injection-target-name>
+ </injection-target>
+ </resource-env-ref>
+
+ </message-driven>
+
+ </enterprise-beans>
+</ejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chatbeantest">ChatBeanTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.mdb;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.embeddable.EJBContainer;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+public class ChatBeanTest extends TestCase {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ChatBean")
+ private Queue questionQueue;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void test() throws Exception {
+
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ final Connection connection = connectionFactory.createConnection();
+
+ connection.start();
+
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ final MessageProducer questions = session.createProducer(questionQueue);
+
+ final MessageConsumer answers = session.createConsumer(answerQueue);
+
+
+ sendText("Hello World!", questions, session);
+
+ assertEquals("Hello, Test Case!", receiveText(answers));
+
+
+ sendText("How are you?", questions, session);
+
+ assertEquals("I'm doing well.", receiveText(answers));
+
+
+ sendText("Still spinning?", questions, session);
+
+ assertEquals("Once every day, as usual.", receiveText(answers));
+ }
+
+ private void sendText(String text, MessageProducer questions, Session session) throws JMSException {
+
+ questions.send(session.createTextMessage(text));
+ }
+
+ private String receiveText(MessageConsumer answers) throws JMSException {
+
+ return ((TextMessage) answers.receive(1000)).getText();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.mdb.ChatBeanTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/simple-mdb-with-descriptor
+INFO - openejb.base = /Users/dblevins/examples/simple-mdb-with-descriptor
+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/simple-mdb-with-descriptor/target/classes
+INFO - Beginning load: /Users/dblevins/examples/simple-mdb-with-descriptor/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/simple-mdb-with-descriptor
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default MDB Container, type=Container, provider-id=Default MDB Container)
+INFO - Auto-creating a container for bean ChatBean: Container(type=MESSAGE, id=Default MDB Container)
+INFO - Configuring Service(id=Default JMS Resource Adapter, type=Resource, provider-id=Default JMS Resource Adapter)
+INFO - Configuring Service(id=Default JMS Connection Factory, type=Resource, provider-id=Default JMS Connection Factory)
+INFO - Auto-creating a Resource with id 'Default JMS Connection Factory' of type 'javax.jms.ConnectionFactory for 'ChatBean'.
+INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.mdbdesc.ChatBean/connectionFactory' in bean ChatBean to Resource(id=Default JMS Connection Factory)
+INFO - Configuring Service(id=AnswerQueue, type=Resource, provider-id=Default Queue)
+INFO - Auto-creating a Resource with id 'AnswerQueue' of type 'javax.jms.Queue for 'ChatBean'.
+INFO - Auto-linking resource-env-ref 'java:comp/env/AnswerQueue' in bean ChatBean to Resource(id=AnswerQueue)
+INFO - Configuring Service(id=ChatBean, type=Resource, provider-id=Default Queue)
+INFO - Auto-creating a Resource with id 'ChatBean' of type 'javax.jms.Queue for 'ChatBean'.
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.mdb.ChatBeanTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.mdb.ChatBeanTest/connectionFactory' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=Default JMS Connection Factory)
+INFO - Auto-linking resource-env-ref 'java:comp/env/AnswerQueue' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=AnswerQueue)
+INFO - Auto-linking resource-env-ref 'java:comp/env/ChatBean' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=ChatBean)
+INFO - Enterprise application "/Users/dblevins/examples/simple-mdb-with-descriptor" loaded.
+INFO - Assembling app: /Users/dblevins/examples/simple-mdb-with-descriptor
+INFO - Jndi(name="java:global/EjbModule1842275169/org.superbiz.mdb.ChatBeanTest!org.superbiz.mdb.ChatBeanTest")
+INFO - Jndi(name="java:global/EjbModule1842275169/org.superbiz.mdb.ChatBeanTest")
+INFO - Created Ejb(deployment-id=org.superbiz.mdb.ChatBeanTest, ejb-name=org.superbiz.mdb.ChatBeanTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=ChatBean, ejb-name=ChatBean, container=Default MDB Container)
+INFO - Started Ejb(deployment-id=org.superbiz.mdb.ChatBeanTest, ejb-name=org.superbiz.mdb.ChatBeanTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=ChatBean, ejb-name=ChatBean, container=Default MDB Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/simple-mdb-with-descriptor)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.914 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-mdb-with-descriptor.pdf b/content/examples/simple-mdb-with-descriptor.pdf
new file mode 100644
index 0000000..4cc0367
--- /dev/null
+++ b/content/examples/simple-mdb-with-descriptor.pdf
Binary files differ
diff --git a/content/examples/simple-mdb-with-descriptor/README.md b/content/examples/simple-mdb-with-descriptor/README.md
new file mode 100755
index 0000000..d2e10a1
--- /dev/null
+++ b/content/examples/simple-mdb-with-descriptor/README.md
@@ -0,0 +1,241 @@
+Title: Simple MDB with Descriptor
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## ChatBean
+
+ package org.superbiz.mdbdesc;
+
+ import javax.jms.Connection;
+ import javax.jms.ConnectionFactory;
+ import javax.jms.DeliveryMode;
+ import javax.jms.JMSException;
+ import javax.jms.Message;
+ import javax.jms.MessageListener;
+ import javax.jms.MessageProducer;
+ import javax.jms.Queue;
+ import javax.jms.Session;
+ import javax.jms.TextMessage;
+
+ public class ChatBean implements MessageListener {
+
+ private ConnectionFactory connectionFactory;
+
+ private Queue answerQueue;
+
+ public void onMessage(Message message) {
+ try {
+
+ final TextMessage textMessage = (TextMessage) message;
+ final String question = textMessage.getText();
+
+ if ("Hello World!".equals(question)) {
+
+ respond("Hello, Test Case!");
+ } else if ("How are you?".equals(question)) {
+
+ respond("I'm doing well.");
+ } else if ("Still spinning?".equals(question)) {
+
+ respond("Once every day, as usual.");
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" metadata-complete="true">
+ <enterprise-beans>
+
+ <message-driven>
+
+ <ejb-name>ChatBean</ejb-name>
+ <ejb-class>org.superbiz.mdbdesc.ChatBean</ejb-class>
+
+ <messaging-type>javax.jms.MessageListener</messaging-type>
+
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>destination</activation-config-property-name>
+ <activation-config-property-value>ChatBean</activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>destinationType</activation-config-property-name>
+ <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+
+ <resource-ref>
+ <res-ref-name>java:comp/env/org.superbiz.mdbdesc.ChatBean/connectionFactory</res-ref-name>
+ <res-type>javax.jms.ConnectionFactory</res-type>
+ <injection-target>
+ <injection-target-class>org.superbiz.mdbdesc.ChatBean</injection-target-class>
+ <injection-target-name>connectionFactory</injection-target-name>
+ </injection-target>
+ </resource-ref>
+
+ <resource-env-ref>
+ <resource-env-ref-name>java:comp/env/AnswerQueue</resource-env-ref-name>
+ <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
+ <mapped-name>AnswerQueue</mapped-name>
+ <injection-target>
+ <injection-target-class>org.superbiz.mdbdesc.ChatBean</injection-target-class>
+ <injection-target-name>answerQueue</injection-target-name>
+ </injection-target>
+ </resource-env-ref>
+
+ </message-driven>
+
+ </enterprise-beans>
+ </ejb-jar>
+
+
+## ChatBeanTest
+
+ package org.superbiz.mdb;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.Resource;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.jms.Connection;
+ import javax.jms.ConnectionFactory;
+ import javax.jms.JMSException;
+ import javax.jms.MessageConsumer;
+ import javax.jms.MessageProducer;
+ import javax.jms.Queue;
+ import javax.jms.Session;
+ import javax.jms.TextMessage;
+
+ public class ChatBeanTest extends TestCase {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ChatBean")
+ private Queue questionQueue;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void test() throws Exception {
+
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ final Connection connection = connectionFactory.createConnection();
+
+ connection.start();
+
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ final MessageProducer questions = session.createProducer(questionQueue);
+
+ final MessageConsumer answers = session.createConsumer(answerQueue);
+
+
+ sendText("Hello World!", questions, session);
+
+ assertEquals("Hello, Test Case!", receiveText(answers));
+
+
+ sendText("How are you?", questions, session);
+
+ assertEquals("I'm doing well.", receiveText(answers));
+
+
+ sendText("Still spinning?", questions, session);
+
+ assertEquals("Once every day, as usual.", receiveText(answers));
+ }
+
+ private void sendText(String text, MessageProducer questions, Session session) throws JMSException {
+
+ questions.send(session.createTextMessage(text));
+ }
+
+ private String receiveText(MessageConsumer answers) throws JMSException {
+
+ return ((TextMessage) answers.receive(1000)).getText();
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.mdb.ChatBeanTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/simple-mdb-with-descriptor
+ INFO - openejb.base = /Users/dblevins/examples/simple-mdb-with-descriptor
+ 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/simple-mdb-with-descriptor/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/simple-mdb-with-descriptor/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/simple-mdb-with-descriptor
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default MDB Container, type=Container, provider-id=Default MDB Container)
+ INFO - Auto-creating a container for bean ChatBean: Container(type=MESSAGE, id=Default MDB Container)
+ INFO - Configuring Service(id=Default JMS Resource Adapter, type=Resource, provider-id=Default JMS Resource Adapter)
+ INFO - Configuring Service(id=Default JMS Connection Factory, type=Resource, provider-id=Default JMS Connection Factory)
+ INFO - Auto-creating a Resource with id 'Default JMS Connection Factory' of type 'javax.jms.ConnectionFactory for 'ChatBean'.
+ INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.mdbdesc.ChatBean/connectionFactory' in bean ChatBean to Resource(id=Default JMS Connection Factory)
+ INFO - Configuring Service(id=AnswerQueue, type=Resource, provider-id=Default Queue)
+ INFO - Auto-creating a Resource with id 'AnswerQueue' of type 'javax.jms.Queue for 'ChatBean'.
+ INFO - Auto-linking resource-env-ref 'java:comp/env/AnswerQueue' in bean ChatBean to Resource(id=AnswerQueue)
+ INFO - Configuring Service(id=ChatBean, type=Resource, provider-id=Default Queue)
+ INFO - Auto-creating a Resource with id 'ChatBean' of type 'javax.jms.Queue for 'ChatBean'.
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.mdb.ChatBeanTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.mdb.ChatBeanTest/connectionFactory' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=Default JMS Connection Factory)
+ INFO - Auto-linking resource-env-ref 'java:comp/env/AnswerQueue' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=AnswerQueue)
+ INFO - Auto-linking resource-env-ref 'java:comp/env/ChatBean' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=ChatBean)
+ INFO - Enterprise application "/Users/dblevins/examples/simple-mdb-with-descriptor" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/simple-mdb-with-descriptor
+ INFO - Jndi(name="java:global/EjbModule1842275169/org.superbiz.mdb.ChatBeanTest!org.superbiz.mdb.ChatBeanTest")
+ INFO - Jndi(name="java:global/EjbModule1842275169/org.superbiz.mdb.ChatBeanTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.mdb.ChatBeanTest, ejb-name=org.superbiz.mdb.ChatBeanTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=ChatBean, ejb-name=ChatBean, container=Default MDB Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.mdb.ChatBeanTest, ejb-name=org.superbiz.mdb.ChatBeanTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=ChatBean, ejb-name=ChatBean, container=Default MDB Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/simple-mdb-with-descriptor)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.914 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/simple-mdb-with-descriptor/build.xml b/content/examples/simple-mdb-with-descriptor/build.xml
new file mode 100755
index 0000000..567603e
--- /dev/null
+++ b/content/examples/simple-mdb-with-descriptor/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 635408 $ $Date: 2008-03-09 17:48:40 -0700 (Sun, 09 Mar 2008) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-mdb-with-descriptor/pom.xml b/content/examples/simple-mdb-with-descriptor/pom.xml
new file mode 100755
index 0000000..6c1b3ae
--- /dev/null
+++ b/content/examples/simple-mdb-with-descriptor/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 638272 $ $Date: 2008-03-18 01:59:59 -0700 (Tue, 18 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-mdb-with-descriptor</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple MDB Using Deployment Descriptor Example</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdbdesc/ChatBean.java b/content/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdbdesc/ChatBean.java
new file mode 100755
index 0000000..138c35f
--- /dev/null
+++ b/content/examples/simple-mdb-with-descriptor/src/main/java/org/superbiz/mdbdesc/ChatBean.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.mdbdesc;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+public class ChatBean implements MessageListener {
+
+ private ConnectionFactory connectionFactory;
+
+ private Queue answerQueue;
+
+ public void onMessage(Message message) {
+ try {
+
+ final TextMessage textMessage = (TextMessage) message;
+ final String question = textMessage.getText();
+
+ if ("Hello World!".equals(question)) {
+
+ respond("Hello, Test Case!");
+
+ } else if ("How are you?".equals(question)) {
+
+ respond("I'm doing well.");
+
+ } else if ("Still spinning?".equals(question)) {
+
+ respond("Once every day, as usual.");
+
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) {
+ session.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-mdb-with-descriptor/src/main/resources/META-INF/ejb-jar.xml b/content/examples/simple-mdb-with-descriptor/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..fcc1264
--- /dev/null
+++ b/content/examples/simple-mdb-with-descriptor/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" metadata-complete="true">
+ <enterprise-beans>
+
+ <message-driven>
+
+ <ejb-name>ChatBean</ejb-name>
+ <ejb-class>org.superbiz.mdbdesc.ChatBean</ejb-class>
+
+ <messaging-type>javax.jms.MessageListener</messaging-type>
+
+ <activation-config>
+ <activation-config-property>
+ <activation-config-property-name>destination</activation-config-property-name>
+ <activation-config-property-value>ChatBean</activation-config-property-value>
+ </activation-config-property>
+ <activation-config-property>
+ <activation-config-property-name>destinationType</activation-config-property-name>
+ <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
+ </activation-config-property>
+ </activation-config>
+
+ <resource-ref>
+ <res-ref-name>java:comp/env/org.superbiz.mdbdesc.ChatBean/connectionFactory</res-ref-name>
+ <res-type>javax.jms.ConnectionFactory</res-type>
+ <injection-target>
+ <injection-target-class>org.superbiz.mdbdesc.ChatBean</injection-target-class>
+ <injection-target-name>connectionFactory</injection-target-name>
+ </injection-target>
+ </resource-ref>
+
+ <resource-env-ref>
+ <resource-env-ref-name>java:comp/env/AnswerQueue</resource-env-ref-name>
+ <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
+ <mapped-name>AnswerQueue</mapped-name>
+ <injection-target>
+ <injection-target-class>org.superbiz.mdbdesc.ChatBean</injection-target-class>
+ <injection-target-name>answerQueue</injection-target-name>
+ </injection-target>
+ </resource-env-ref>
+
+ </message-driven>
+
+ </enterprise-beans>
+</ejb-jar>
diff --git a/content/examples/simple-mdb-with-descriptor/src/test/java/org/superbiz/mdbdesc/ChatBeanTest.java b/content/examples/simple-mdb-with-descriptor/src/test/java/org/superbiz/mdbdesc/ChatBeanTest.java
new file mode 100755
index 0000000..79ee86b
--- /dev/null
+++ b/content/examples/simple-mdb-with-descriptor/src/test/java/org/superbiz/mdbdesc/ChatBeanTest.java
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.mdb;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.embeddable.EJBContainer;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+public class ChatBeanTest extends TestCase {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ChatBean")
+ private Queue questionQueue;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void test() throws Exception {
+
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ final Connection connection = connectionFactory.createConnection();
+
+ connection.start();
+
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ final MessageProducer questions = session.createProducer(questionQueue);
+
+ final MessageConsumer answers = session.createConsumer(answerQueue);
+
+ sendText("Hello World!", questions, session);
+
+ assertEquals("Hello, Test Case!", receiveText(answers));
+
+ sendText("How are you?", questions, session);
+
+ assertEquals("I'm doing well.", receiveText(answers));
+
+ sendText("Still spinning?", questions, session);
+
+ assertEquals("Once every day, as usual.", receiveText(answers));
+
+ }
+
+ private void sendText(String text, MessageProducer questions, Session session) throws JMSException {
+
+ questions.send(session.createTextMessage(text));
+
+ }
+
+ private String receiveText(MessageConsumer answers) throws JMSException {
+
+ return ((TextMessage) answers.receive(1000)).getText();
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-mdb.html b/content/examples/simple-mdb.html
new file mode 100644
index 0000000..1268503
--- /dev/null
+++ b/content/examples/simple-mdb.html
@@ -0,0 +1,422 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-mdb.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple MDB</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-mdb can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-mdb" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-mdb</a></p>
+</div>
+<div class="paragraph">
+<p>Below is a fun app, a chat application that uses JMS. We create a message driven bean, by marking our class with <code>@MessageDriven</code>. A message driven bean has some similarities with a stateless session bean, in the part that it is pooled too.</p>
+</div>
+<div class="paragraph">
+<p>Well, lets tell our chat-app to listen for incoming messages. That we do by implementing <code>MessageListener</code> and overriding the <code>onMessage(Message message)</code>.</p>
+</div>
+<div class="paragraph">
+<p>Then this app "listens" for incoming messages, and the messages picked up are processed by <code>onMessage(Message message)</code> method.</p>
+</div>
+<div class="paragraph">
+<p>That finishes our message driven bean implementation. The "processing" part could be anything that fits your business-requirement.</p>
+</div>
+<div class="paragraph">
+<p>In this case, it is to respond to the user. The <code>respond</code> method shows how a Message can be sent.</p>
+</div>
+<div class="paragraph">
+<p>This sequence diagram shows how a message is sent.</p>
+</div>
+<div class="paragraph">
+<p><img src="../../resources/mdb-flow.png" alt=""/></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chatbean">ChatBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.mdb;
+
+import javax.annotation.Resource;
+import javax.ejb.MessageDriven;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+@MessageDriven
+public class ChatBean implements MessageListener {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void onMessage(Message message) {
+ try {
+
+ final TextMessage textMessage = (TextMessage) message;
+ final String question = textMessage.getText();
+
+ if ("Hello World!".equals(question)) {
+
+ respond("Hello, Test Case!");
+ } else if ("How are you?".equals(question)) {
+
+ respond("I'm doing well.");
+ } else if ("Still spinning?".equals(question)) {
+
+ respond("Once every day, as usual.");
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chatbeantest">ChatBeanTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.mdb;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.embeddable.EJBContainer;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+public class ChatBeanTest extends TestCase {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ChatBean")
+ private Queue questionQueue;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+
+ final Connection connection = connectionFactory.createConnection();
+
+ connection.start();
+
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ final MessageProducer questions = session.createProducer(questionQueue);
+
+ final MessageConsumer answers = session.createConsumer(answerQueue);
+
+
+ sendText("Hello World!", questions, session);
+
+ assertEquals("Hello, Test Case!", receiveText(answers));
+
+
+ sendText("How are you?", questions, session);
+
+ assertEquals("I'm doing well.", receiveText(answers));
+
+
+ sendText("Still spinning?", questions, session);
+
+ assertEquals("Once every day, as usual.", receiveText(answers));
+ }
+
+ private void sendText(String text, MessageProducer questions, Session session) throws JMSException {
+
+ questions.send(session.createTextMessage(text));
+ }
+
+ private String receiveText(MessageConsumer answers) throws JMSException {
+
+ return ((TextMessage) answers.receive(1000)).getText();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.mdb.ChatBeanTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/simple-mdb
+INFO - openejb.base = /Users/dblevins/examples/simple-mdb
+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/simple-mdb/target/classes
+INFO - Beginning load: /Users/dblevins/examples/simple-mdb/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/simple-mdb
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Auto-configuring a message driven bean ChatBean destination ChatBean to be destinationType javax.jms.Queue
+INFO - Configuring Service(id=Default MDB Container, type=Container, provider-id=Default MDB Container)
+INFO - Auto-creating a container for bean ChatBean: Container(type=MESSAGE, id=Default MDB Container)
+INFO - Configuring Service(id=Default JMS Resource Adapter, type=Resource, provider-id=Default JMS Resource Adapter)
+INFO - Configuring Service(id=Default JMS Connection Factory, type=Resource, provider-id=Default JMS Connection Factory)
+INFO - Auto-creating a Resource with id 'Default JMS Connection Factory' of type 'javax.jms.ConnectionFactory for 'ChatBean'.
+INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.mdb.ChatBean/connectionFactory' in bean ChatBean to Resource(id=Default JMS Connection Factory)
+INFO - Configuring Service(id=AnswerQueue, type=Resource, provider-id=Default Queue)
+INFO - Auto-creating a Resource with id 'AnswerQueue' of type 'javax.jms.Queue for 'ChatBean'.
+INFO - Auto-linking resource-env-ref 'java:comp/env/AnswerQueue' in bean ChatBean to Resource(id=AnswerQueue)
+INFO - Configuring Service(id=ChatBean, type=Resource, provider-id=Default Queue)
+INFO - Auto-creating a Resource with id 'ChatBean' of type 'javax.jms.Queue for 'ChatBean'.
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.mdb.ChatBeanTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.mdb.ChatBeanTest/connectionFactory' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=Default JMS Connection Factory)
+INFO - Auto-linking resource-env-ref 'java:comp/env/AnswerQueue' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=AnswerQueue)
+INFO - Auto-linking resource-env-ref 'java:comp/env/ChatBean' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=ChatBean)
+INFO - Enterprise application "/Users/dblevins/examples/simple-mdb" loaded.
+INFO - Assembling app: /Users/dblevins/examples/simple-mdb
+INFO - Jndi(name="java:global/EjbModule1515710343/org.superbiz.mdb.ChatBeanTest!org.superbiz.mdb.ChatBeanTest")
+INFO - Jndi(name="java:global/EjbModule1515710343/org.superbiz.mdb.ChatBeanTest")
+INFO - Created Ejb(deployment-id=org.superbiz.mdb.ChatBeanTest, ejb-name=org.superbiz.mdb.ChatBeanTest, container=Default Managed Container)
+INFO - Created Ejb(deployment-id=ChatBean, ejb-name=ChatBean, container=Default MDB Container)
+INFO - Started Ejb(deployment-id=org.superbiz.mdb.ChatBeanTest, ejb-name=org.superbiz.mdb.ChatBeanTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=ChatBean, ejb-name=ChatBean, container=Default MDB Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/simple-mdb)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.547 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-mdb.pdf b/content/examples/simple-mdb.pdf
new file mode 100644
index 0000000..0247362
--- /dev/null
+++ b/content/examples/simple-mdb.pdf
Binary files differ
diff --git a/content/examples/simple-mdb/README.md b/content/examples/simple-mdb/README.md
new file mode 100755
index 0000000..818c525
--- /dev/null
+++ b/content/examples/simple-mdb/README.md
@@ -0,0 +1,211 @@
+Title: Simple MDB
+
+Below is a fun app, a chat application that uses JMS. We create a message driven bean, by marking our class with `@MessageDriven`. A message driven bean has some similarities with a stateless session bean, in the part that it is pooled too.
+
+Well, lets tell our chat-app to listen for incoming messages. That we do by implementing `MessageListener` and overriding the `onMessage(Message message)`.
+
+Then this app "listens" for incoming messages, and the messages picked up are processed by `onMessage(Message message)` method.
+
+That finishes our message driven bean implementation. The "processing" part could be anything that fits your business-requirement.
+
+In this case, it is to respond to the user. The `respond` method shows how a Message can be sent.
+
+This sequence diagram shows how a message is sent.
+
+<img src="../../images/mdb-flow.png" alt=""/>
+
+## ChatBean
+
+ package org.superbiz.mdb;
+
+ import javax.annotation.Resource;
+ import javax.ejb.MessageDriven;
+ import javax.jms.Connection;
+ import javax.jms.ConnectionFactory;
+ import javax.jms.DeliveryMode;
+ import javax.jms.JMSException;
+ import javax.jms.Message;
+ import javax.jms.MessageListener;
+ import javax.jms.MessageProducer;
+ import javax.jms.Queue;
+ import javax.jms.Session;
+ import javax.jms.TextMessage;
+
+ @MessageDriven
+ public class ChatBean implements MessageListener {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void onMessage(Message message) {
+ try {
+
+ final TextMessage textMessage = (TextMessage) message;
+ final String question = textMessage.getText();
+
+ if ("Hello World!".equals(question)) {
+
+ respond("Hello, Test Case!");
+ } else if ("How are you?".equals(question)) {
+
+ respond("I'm doing well.");
+ } else if ("Still spinning?".equals(question)) {
+
+ respond("Once every day, as usual.");
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) session.close();
+ if (connection != null) connection.close();
+ }
+ }
+ }
+
+## ChatBeanTest
+
+ package org.superbiz.mdb;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.Resource;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.jms.Connection;
+ import javax.jms.ConnectionFactory;
+ import javax.jms.JMSException;
+ import javax.jms.MessageConsumer;
+ import javax.jms.MessageProducer;
+ import javax.jms.Queue;
+ import javax.jms.Session;
+ import javax.jms.TextMessage;
+
+ public class ChatBeanTest extends TestCase {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ChatBean")
+ private Queue questionQueue;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+
+ final Connection connection = connectionFactory.createConnection();
+
+ connection.start();
+
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ final MessageProducer questions = session.createProducer(questionQueue);
+
+ final MessageConsumer answers = session.createConsumer(answerQueue);
+
+
+ sendText("Hello World!", questions, session);
+
+ assertEquals("Hello, Test Case!", receiveText(answers));
+
+
+ sendText("How are you?", questions, session);
+
+ assertEquals("I'm doing well.", receiveText(answers));
+
+
+ sendText("Still spinning?", questions, session);
+
+ assertEquals("Once every day, as usual.", receiveText(answers));
+ }
+
+ private void sendText(String text, MessageProducer questions, Session session) throws JMSException {
+
+ questions.send(session.createTextMessage(text));
+ }
+
+ private String receiveText(MessageConsumer answers) throws JMSException {
+
+ return ((TextMessage) answers.receive(1000)).getText();
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.mdb.ChatBeanTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/simple-mdb
+ INFO - openejb.base = /Users/dblevins/examples/simple-mdb
+ 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/simple-mdb/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/simple-mdb/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/simple-mdb
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Auto-configuring a message driven bean ChatBean destination ChatBean to be destinationType javax.jms.Queue
+ INFO - Configuring Service(id=Default MDB Container, type=Container, provider-id=Default MDB Container)
+ INFO - Auto-creating a container for bean ChatBean: Container(type=MESSAGE, id=Default MDB Container)
+ INFO - Configuring Service(id=Default JMS Resource Adapter, type=Resource, provider-id=Default JMS Resource Adapter)
+ INFO - Configuring Service(id=Default JMS Connection Factory, type=Resource, provider-id=Default JMS Connection Factory)
+ INFO - Auto-creating a Resource with id 'Default JMS Connection Factory' of type 'javax.jms.ConnectionFactory for 'ChatBean'.
+ INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.mdb.ChatBean/connectionFactory' in bean ChatBean to Resource(id=Default JMS Connection Factory)
+ INFO - Configuring Service(id=AnswerQueue, type=Resource, provider-id=Default Queue)
+ INFO - Auto-creating a Resource with id 'AnswerQueue' of type 'javax.jms.Queue for 'ChatBean'.
+ INFO - Auto-linking resource-env-ref 'java:comp/env/AnswerQueue' in bean ChatBean to Resource(id=AnswerQueue)
+ INFO - Configuring Service(id=ChatBean, type=Resource, provider-id=Default Queue)
+ INFO - Auto-creating a Resource with id 'ChatBean' of type 'javax.jms.Queue for 'ChatBean'.
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.mdb.ChatBeanTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Auto-linking resource-ref 'java:comp/env/org.superbiz.mdb.ChatBeanTest/connectionFactory' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=Default JMS Connection Factory)
+ INFO - Auto-linking resource-env-ref 'java:comp/env/AnswerQueue' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=AnswerQueue)
+ INFO - Auto-linking resource-env-ref 'java:comp/env/ChatBean' in bean org.superbiz.mdb.ChatBeanTest to Resource(id=ChatBean)
+ INFO - Enterprise application "/Users/dblevins/examples/simple-mdb" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/simple-mdb
+ INFO - Jndi(name="java:global/EjbModule1515710343/org.superbiz.mdb.ChatBeanTest!org.superbiz.mdb.ChatBeanTest")
+ INFO - Jndi(name="java:global/EjbModule1515710343/org.superbiz.mdb.ChatBeanTest")
+ INFO - Created Ejb(deployment-id=org.superbiz.mdb.ChatBeanTest, ejb-name=org.superbiz.mdb.ChatBeanTest, container=Default Managed Container)
+ INFO - Created Ejb(deployment-id=ChatBean, ejb-name=ChatBean, container=Default MDB Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.mdb.ChatBeanTest, ejb-name=org.superbiz.mdb.ChatBeanTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=ChatBean, ejb-name=ChatBean, container=Default MDB Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/simple-mdb)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.547 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/simple-mdb/build.xml b/content/examples/simple-mdb/build.xml
new file mode 100755
index 0000000..567603e
--- /dev/null
+++ b/content/examples/simple-mdb/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 635408 $ $Date: 2008-03-09 17:48:40 -0700 (Sun, 09 Mar 2008) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-mdb/pom.xml b/content/examples/simple-mdb/pom.xml
new file mode 100755
index 0000000..13c906a
--- /dev/null
+++ b/content/examples/simple-mdb/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 638272 $ $Date: 2008-03-18 01:59:59 -0700 (Tue, 18 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-mdb</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple MDB Example</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/simple-mdb/src/main/java/org/superbiz/mdb/ChatBean.java b/content/examples/simple-mdb/src/main/java/org/superbiz/mdb/ChatBean.java
new file mode 100755
index 0000000..4b5a464
--- /dev/null
+++ b/content/examples/simple-mdb/src/main/java/org/superbiz/mdb/ChatBean.java
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.mdb;
+
+import javax.annotation.Resource;
+import javax.ejb.MessageDriven;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+@MessageDriven
+public class ChatBean implements MessageListener {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void onMessage(Message message) {
+ try {
+
+ final TextMessage textMessage = (TextMessage) message;
+ final String question = textMessage.getText();
+
+ if ("Hello World!".equals(question)) {
+
+ respond("Hello, Test Case!");
+
+ } else if ("How are you?".equals(question)) {
+
+ respond("I'm doing well.");
+
+ } else if ("Still spinning?".equals(question)) {
+
+ respond("Once every day, as usual.");
+
+ }
+ } catch (JMSException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private void respond(String text) throws JMSException {
+
+ Connection connection = null;
+ Session session = null;
+
+ try {
+ connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(answerQueue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+ } finally {
+ // Clean up
+ if (session != null) {
+ session.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-mdb/src/test/java/org/superbiz/mdb/ChatBeanTest.java b/content/examples/simple-mdb/src/test/java/org/superbiz/mdb/ChatBeanTest.java
new file mode 100755
index 0000000..a360d10
--- /dev/null
+++ b/content/examples/simple-mdb/src/test/java/org/superbiz/mdb/ChatBeanTest.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.mdb;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.embeddable.EJBContainer;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+public class ChatBeanTest extends TestCase {
+
+ @Resource
+ private ConnectionFactory connectionFactory;
+
+ @Resource(name = "ChatBean")
+ private Queue questionQueue;
+
+ @Resource(name = "AnswerQueue")
+ private Queue answerQueue;
+
+ public void test() throws Exception {
+ EJBContainer.createEJBContainer().getContext().bind("inject", this);
+
+ final Connection connection = connectionFactory.createConnection();
+
+ connection.start();
+
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ final MessageProducer questions = session.createProducer(questionQueue);
+
+ final MessageConsumer answers = session.createConsumer(answerQueue);
+
+ sendText("Hello World!", questions, session);
+
+ assertEquals("Hello, Test Case!", receiveText(answers));
+
+ sendText("How are you?", questions, session);
+
+ assertEquals("I'm doing well.", receiveText(answers));
+
+ sendText("Still spinning?", questions, session);
+
+ assertEquals("Once every day, as usual.", receiveText(answers));
+
+ }
+
+ private void sendText(String text, MessageProducer questions, Session session) throws JMSException {
+
+ questions.send(session.createTextMessage(text));
+
+ }
+
+ private String receiveText(MessageConsumer answers) throws JMSException {
+
+ return ((TextMessage) answers.receive(1000)).getText();
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-osgi/pom.xml b/content/examples/simple-osgi/pom.xml
new file mode 100755
index 0000000..29ebe23
--- /dev/null
+++ b/content/examples/simple-osgi/pom.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-osgi</artifactId>
+ <packaging>pom</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <modules>
+ <module>simple-osgi-api</module>
+ <module>simple-osgi-core</module>
+ <module>simple-osgi-camel-client</module>
+ <module>simple-osgi-remote-client</module>
+ <module>simple-osgi-local-lookup-client</module>
+ <module>simple-osgi-service-injection</module>
+ <module>standard-ejbd-server</module>
+ </modules>
+ <name>OpenEJB :: Examples :: Simple OSGi Stateless Pojo</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.7</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/simple-osgi/simple-osgi-api/pom.xml b/content/examples/simple-osgi/simple-osgi-api/pom.xml
new file mode 100755
index 0000000..cad4921
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-api/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>simple-osgi</artifactId>
+ <groupId>org.superbiz</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>simple-osgi-api</artifactId>
+ <packaging>bundle</packaging>
+ <name>OpenEJB :: Examples :: Simple OSGi :: API bundle</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.superbiz.osgi.calculator
+ </Export-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ </dependencies>
+
+
+</project>
diff --git a/content/examples/simple-osgi/simple-osgi-api/src/main/java/org/superbiz/osgi/calculator/CalculatorLocal.java b/content/examples/simple-osgi/simple-osgi-api/src/main/java/org/superbiz/osgi/calculator/CalculatorLocal.java
new file mode 100755
index 0000000..69a13a5
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-api/src/main/java/org/superbiz/osgi/calculator/CalculatorLocal.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.osgi.calculator;
+
+import javax.ejb.Local;
+
+@Local
+public interface CalculatorLocal {
+
+ int add(int a, int b);
+
+ int subtract(int a, int b);
+
+ int multiply(int a, int b);
+
+ int divide(int a, int b);
+
+ int remainder(int a, int b);
+
+ String sayHello();
+}
diff --git a/content/examples/simple-osgi/simple-osgi-api/src/main/java/org/superbiz/osgi/calculator/CalculatorRemote.java b/content/examples/simple-osgi/simple-osgi-api/src/main/java/org/superbiz/osgi/calculator/CalculatorRemote.java
new file mode 100755
index 0000000..8482f8b
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-api/src/main/java/org/superbiz/osgi/calculator/CalculatorRemote.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.osgi.calculator;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface CalculatorRemote {
+
+ int add(int a, int b);
+
+ int subtract(int a, int b);
+
+ int multiply(int a, int b);
+
+ int divide(int a, int b);
+
+ int remainder(int a, int b);
+
+ String sayHello();
+}
diff --git a/content/examples/simple-osgi/simple-osgi-camel-client/pom.xml b/content/examples/simple-osgi/simple-osgi-camel-client/pom.xml
new file mode 100755
index 0000000..08961a2
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-camel-client/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>simple-osgi</artifactId>
+ <groupId>org.superbiz</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>simple-osgi-camel-client</artifactId>
+ <packaging>bundle</packaging>
+ <name>OpenEJB :: Examples :: Simple OSGi :: Camel Client</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ javax.ejb,
+ org.superbiz.osgi.calculator,
+ org.apache.openejb.client;version="[4.0,5.0)"
+ </Import-Package>
+ <Include-Resource>${pom.basedir}/src/main/resources</Include-Resource>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>simple-osgi-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- just to keep in mind camel and spring should be installed -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <version>2.8.3</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>3.0.3.RELEASE</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/content/examples/simple-osgi/simple-osgi-camel-client/src/main/resources/META-INF/spring/calculator-camel-ctx.xml b/content/examples/simple-osgi/simple-osgi-camel-client/src/main/resources/META-INF/spring/calculator-camel-ctx.xml
new file mode 100755
index 0000000..0e082ea
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-camel-client/src/main/resources/META-INF/spring/calculator-camel-ctx.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership. The
+ ASF licenses this file to You under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
+ law or agreed to in writing, software distributed under the License is
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.8.3.xsd">
+
+ <camel:camelContext id="helloContext">
+ <camel:route id="TimerHelloRoute">
+ <camel:from uri="timer://helloTimer?fixedRate=true&period=2000"/>
+ <camel:delay>
+ <camel:constant>1000</camel:constant>
+ </camel:delay>
+ <camel:log message="%%% Say Hello"/>
+ </camel:route>
+ </camel:camelContext>
+
+ <camel:camelContext id="calcRoute">
+ <camel:route id="TimerCalcRoute">
+ <camel:from uri="timer://calcTimer?fixedRate=true&period=5000"/>
+ <camel:to uri="bean:org.superbiz.osgi.calculator.CalculatorRemote?method=sayHello"/>
+ <camel:log message=">>> Result : ${body}"/>
+ </camel:route>
+ </camel:camelContext>
+</beans>
diff --git a/content/examples/simple-osgi/simple-osgi-core/pom.xml b/content/examples/simple-osgi/simple-osgi-core/pom.xml
new file mode 100755
index 0000000..71fdcc7
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-core/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>simple-osgi</artifactId>
+ <groupId>org.superbiz</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>simple-osgi-core</artifactId>
+ <packaging>bundle</packaging>
+ <name>OpenEJB :: Examples :: Simple OSGi Stateless Pojo :: Core bundle</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin> <!-- needed otherwise it will not work at runtime -->
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>2.3.0</version>
+ <configuration>
+ <includes>org/superbiz/osgi/moviefun/Movie.class</includes>
+ <addDefaultConstructor>true</addDefaultConstructor>
+ <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+ </configuration>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>simple-osgi-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/calculator/impl/CalculatorBean.java b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/calculator/impl/CalculatorBean.java
new file mode 100755
index 0000000..4b5fefd
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/calculator/impl/CalculatorBean.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.osgi.calculator.impl;
+
+import org.superbiz.osgi.calculator.CalculatorLocal;
+import org.superbiz.osgi.calculator.CalculatorRemote;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class CalculatorBean implements CalculatorLocal, CalculatorRemote {
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+
+ public String sayHello() {
+ return "Hello World!";
+ }
+
+}
\ No newline at end of file
diff --git a/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/AddInterceptor.java b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/AddInterceptor.java
new file mode 100755
index 0000000..a7d74e3
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/AddInterceptor.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.osgi.moviefun;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AddInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Add
+ return context.proceed();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/Bootstrap.java b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/Bootstrap.java
new file mode 100755
index 0000000..5b16089
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/Bootstrap.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.osgi.moviefun;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+
+@Singleton
+@Startup
+public class Bootstrap {
+
+ @EJB
+ private Movies movies;
+
+ @PostConstruct
+ public void init() {
+ try {
+ movies.addMovie(new Movie("OpenEJB", "OpenEJB in OSGi", 2011));
+ System.out.println("found " + movies.getMovies().size() + " movies.");
+ } catch (Exception e) {
+ System.out.println("exception: " + e.getMessage());
+ }
+ }
+}
diff --git a/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/DeleteInterceptor.java b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/DeleteInterceptor.java
new file mode 100755
index 0000000..20e7e22
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/DeleteInterceptor.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.osgi.moviefun;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class DeleteInterceptor {
+
+ @AroundInvoke
+ public Object invoke(InvocationContext context) throws Exception {
+ // Log Delete
+ return context.proceed();
+ }
+}
diff --git a/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/Movie.java b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/Movie.java
new file mode 100755
index 0000000..a94c918
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/Movie.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.osgi.moviefun;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue
+ private long id;
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/Movies.java b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/Movies.java
new file mode 100755
index 0000000..b4f448a
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-core/src/main/java/org/superbiz/osgi/moviefun/Movies.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.osgi.moviefun;
+
+import javax.annotation.security.PermitAll;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.interceptor.Interceptors;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.util.List;
+
+//START SNIPPET: code
+@Stateless
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit")
+ private EntityManager entityManager;
+
+ @Interceptors(AddInterceptor.class)
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @Interceptors(DeleteInterceptor.class)
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-osgi/simple-osgi-core/src/main/resources/META-INF/persistence.xml b/content/examples/simple-osgi/simple-osgi-core/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..4ca5ff7
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-core/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.osgi.moviefun.Movie</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/simple-osgi/simple-osgi-local-lookup-client/pom.xml b/content/examples/simple-osgi/simple-osgi-local-lookup-client/pom.xml
new file mode 100755
index 0000000..4acb067
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-local-lookup-client/pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>simple-osgi</artifactId>
+ <groupId>org.superbiz</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>simple-osgi-local-lookup-client</artifactId>
+ <name>OpenEJB :: Examples :: Simple OSGi :: Local Lookup Client</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <!-- using scope compile to simplify the exec plugin usage -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>simple-osgi-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/content/examples/simple-osgi/simple-osgi-local-lookup-client/src/main/java/org/superbiz/calculator/lookupclient/SingletonCalculatorClient.java b/content/examples/simple-osgi/simple-osgi-local-lookup-client/src/main/java/org/superbiz/calculator/lookupclient/SingletonCalculatorClient.java
new file mode 100755
index 0000000..c319c48
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-local-lookup-client/src/main/java/org/superbiz/calculator/lookupclient/SingletonCalculatorClient.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.calculator.lookupclient;
+
+import org.superbiz.osgi.calculator.CalculatorLocal;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Properties;
+
+@Singleton
+@Startup
+public class SingletonCalculatorClient {
+
+ @EJB
+ private CalculatorLocal calculator;
+
+ @PostConstruct
+ public void logInit() {
+ System.out.println();
+ checkCalculator();
+ tryLookup();
+ System.out.println();
+ }
+
+ private void tryLookup() {
+ Properties p = new Properties();
+ p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ try {
+ Context ctx = new InitialContext(p);
+ CalculatorLocal local = (CalculatorLocal) ctx.lookup("CalculatorBeanLocal");
+ System.out.println("lookup OK: " + local.sayHello());
+ } catch (NamingException e) {
+ System.out.println("can't lookup bean: " + e.getMessage());
+ }
+ }
+
+ private void checkCalculator() {
+ if (calculator == null) {
+ System.out.println(calculator + " is null -> FAILED!");
+ } else {
+ System.out.println("calculator OK: " + calculator.sayHello());
+ }
+ }
+}
diff --git a/content/examples/simple-osgi/simple-osgi-remote-client/pom.xml b/content/examples/simple-osgi/simple-osgi-remote-client/pom.xml
new file mode 100755
index 0000000..ad47266
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-remote-client/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>simple-osgi</artifactId>
+ <groupId>org.superbiz</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>simple-osgi-remote-client</artifactId>
+ <name>OpenEJB :: Examples :: Simple OSGi :: Remote Client</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <!-- using scope compile to simplify the exec plugin usage -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-client</artifactId>
+ <version>4.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>simple-osgi-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.superbiz.calculator.client.RemoteClientMain</mainClass>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Import-Package>*</Import-Package>
+ <Bundle-Activator>org.superbiz.calculator.client.RemoteClientActivator</Bundle-Activator>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/content/examples/simple-osgi/simple-osgi-remote-client/src/main/java/org/superbiz/calculator/client/ClientUtil.java b/content/examples/simple-osgi/simple-osgi-remote-client/src/main/java/org/superbiz/calculator/client/ClientUtil.java
new file mode 100755
index 0000000..5dbc288
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-remote-client/src/main/java/org/superbiz/calculator/client/ClientUtil.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.calculator.client;
+
+import org.apache.openejb.client.RemoteInitialContextFactory;
+import org.superbiz.osgi.calculator.CalculatorRemote;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+public final class ClientUtil {
+
+ private ClientUtil() {
+ // no-op
+ }
+
+ public static void invoke() throws Exception {
+ final Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, RemoteInitialContextFactory.class.getName());
+ properties.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201");
+ Context remoteContext = new InitialContext(properties);
+ CalculatorRemote calculator = (CalculatorRemote) remoteContext.lookup("CalculatorBeanRemote");
+ System.out.println("Server answered: " + calculator.sayHello());
+ }
+}
diff --git a/content/examples/simple-osgi/simple-osgi-remote-client/src/main/java/org/superbiz/calculator/client/RemoteClientActivator.java b/content/examples/simple-osgi/simple-osgi-remote-client/src/main/java/org/superbiz/calculator/client/RemoteClientActivator.java
new file mode 100755
index 0000000..2edb1b2
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-remote-client/src/main/java/org/superbiz/calculator/client/RemoteClientActivator.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.calculator.client;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class RemoteClientActivator implements BundleActivator {
+
+ @Override
+ public void start(BundleContext bundleContext) throws Exception {
+ final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
+ // set the bundle classloader to avoid to go back to AppClassloader and not found imported classes
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ try {
+ ClientUtil.invoke();
+ } catch (Exception e) {
+ System.out.println("error: " + e.getMessage());
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCl);
+ }
+ }
+
+ @Override
+ public void stop(BundleContext bundleContext) throws Exception {
+ // no-op
+ }
+}
diff --git a/content/examples/simple-osgi/simple-osgi-remote-client/src/main/java/org/superbiz/calculator/client/RemoteClientMain.java b/content/examples/simple-osgi/simple-osgi-remote-client/src/main/java/org/superbiz/calculator/client/RemoteClientMain.java
new file mode 100755
index 0000000..0fa148c
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-remote-client/src/main/java/org/superbiz/calculator/client/RemoteClientMain.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.calculator.client;
+
+public final class RemoteClientMain {
+
+ private RemoteClientMain() {
+ // no-op
+ }
+
+ public static void main(String[] args) throws Exception {
+ ClientUtil.invoke();
+ }
+}
diff --git a/content/examples/simple-osgi/simple-osgi-service-injection/pom.xml b/content/examples/simple-osgi/simple-osgi-service-injection/pom.xml
new file mode 100755
index 0000000..2ac8e03
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-service-injection/pom.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>simple-osgi</artifactId>
+ <groupId>org.superbiz</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>simple-osgi-service-injection</artifactId>
+ <name>OpenEJB :: Examples :: Simple OSGi :: OSGi Service Injection</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/content/examples/simple-osgi/simple-osgi-service-injection/src/main/java/org/superbiz/osgi/injection/service/Injected.java b/content/examples/simple-osgi/simple-osgi-service-injection/src/main/java/org/superbiz/osgi/injection/service/Injected.java
new file mode 100755
index 0000000..39233b3
--- /dev/null
+++ b/content/examples/simple-osgi/simple-osgi-service-injection/src/main/java/org/superbiz/osgi/injection/service/Injected.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.osgi.injection.service;
+
+import org.osgi.service.startlevel.StartLevel;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.inject.Inject;
+
+@Singleton
+@Startup
+public class Injected {
+
+ @Inject
+ private StartLevel sl;
+
+ @PostConstruct
+ public void init() {
+ System.out.println();
+ if (sl != null) {
+ System.out.println("start level is " + sl.getStartLevel());
+ } else {
+ System.out.println("start level is null -> FAILED");
+ }
+ }
+}
diff --git a/content/examples/simple-osgi/standard-ejbd-server/pom.xml b/content/examples/simple-osgi/standard-ejbd-server/pom.xml
new file mode 100755
index 0000000..7885e85
--- /dev/null
+++ b/content/examples/simple-osgi/standard-ejbd-server/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>simple-osgi</artifactId>
+ <groupId>org.superbiz</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>standard-ejbd-server</artifactId>
+ <name>OpenEJB :: Examples :: Simple OSGi :: Standard Server</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-ejbd</artifactId>
+ <version>4.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>simple-osgi-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>simple-osgi-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.superbiz.StandardEjbdServer</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/content/examples/simple-osgi/standard-ejbd-server/src/main/java/org/superbiz/StandardEjbdServer.java b/content/examples/simple-osgi/standard-ejbd-server/src/main/java/org/superbiz/StandardEjbdServer.java
new file mode 100755
index 0000000..00b8c95
--- /dev/null
+++ b/content/examples/simple-osgi/standard-ejbd-server/src/main/java/org/superbiz/StandardEjbdServer.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz;
+
+import org.apache.openejb.OpenEjbContainer;
+import org.apache.openejb.core.LocalInitialContextFactory;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+public final class StandardEjbdServer {
+
+ private StandardEjbdServer() {
+ // no-op
+ }
+
+ public static void main(String[] args) throws Exception {
+ final Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
+ properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, Boolean.TRUE.toString());
+ final EJBContainer container = EJBContainer.createEJBContainer(properties);
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ latch.countDown();
+ container.close();
+ }
+ });
+
+ latch.await();
+ }
+}
diff --git a/content/examples/simple-rest.html b/content/examples/simple-rest.html
new file mode 100644
index 0000000..3396297
--- /dev/null
+++ b/content/examples/simple-rest.html
@@ -0,0 +1,351 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-rest.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple REST</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-rest can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-rest" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-rest</a></p>
+</div>
+<div class="paragraph">
+<p>Defining a REST service is pretty easy, simply ad @Path annotation to a class then define on methods
+the HTTP method to use (@GET, @POST, …​).</p>
+</div>
+</div>
+</div>
+<h1 id="_the_code" class="sect0">The Code</h1>
+<div class="sect1">
+<h2 id="_the_rest_service_path_get_post">The REST service: @Path, @GET, @POST</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("/greeting")
+public class GreetingService {
+ @GET
+ public String message() {
+ return "Hi REST!";
+ }
+
+ @POST
+ public String lowerCase(final String message) {
+ return "Hi REST!".toLowerCase();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_testing" class="sect0">Testing</h1>
+<div class="sect1">
+<h2 id="_test_for_the_jaxrs_service">Test for the JAXRS service</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The test uses the OpenEJB ApplicationComposer to make it trivial.</p>
+</div>
+<div class="paragraph">
+<p>The idea is first to activate the jaxrs services. This is done using @EnableServices annotation.</p>
+</div>
+<div class="paragraph">
+<p>Then we create on the fly the application simply returning an object representing the web.xml. Here we simply
+use it to define the context root but you can use it to define your REST Application too. And to complete the
+application definition we add @Classes annotation to define the set of classes to use in this app.</p>
+</div>
+<div class="paragraph">
+<p>Finally to test it we use cxf client API to call the REST service in get() and post() methods.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.junit.EnableServices;
+import org.apache.openejb.junit.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs")
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+ @Module
+ public SingletonBean app() {
+ return (SingletonBean) new SingletonBean(GreetingService.class).localBean();
+ }
+
+ @Test
+ public void get() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/GreetingServiceTest/greeting/").get(String.class);
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void post() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/GreetingServiceTest/greeting/").post("Hi REST!", String.class);
+ assertEquals("hi rest!", message);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>Running the example is fairly simple. In the "simple-rest" directory run:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>$ mvn clean install</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Which should create output like the following.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>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 - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Creating ServerService(id=cxf-rs)
+INFO - Initializing network services
+INFO - Starting service httpejbd
+INFO - Started service httpejbd
+INFO - Starting service cxf-rs
+INFO - Started service cxf-rs
+INFO - ** Bound Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - -------
+INFO - Ready!
+INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Existing thread singleton service in SystemInstance() null
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@12c9b196
+INFO - Succeeded in installing singleton service
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 11 ms.
+INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+INFO - Stopping network services
+INFO - Stopping server services
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Results :</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-rest.pdf b/content/examples/simple-rest.pdf
new file mode 100644
index 0000000..c2f2b23
--- /dev/null
+++ b/content/examples/simple-rest.pdf
Binary files differ
diff --git a/content/examples/simple-rest/README.md b/content/examples/simple-rest/README.md
new file mode 100755
index 0000000..3600272
--- /dev/null
+++ b/content/examples/simple-rest/README.md
@@ -0,0 +1,131 @@
+Title: Simple REST
+
+Defining a REST service is pretty easy, simply ad @Path annotation to a class then define on methods
+the HTTP method to use (@GET, @POST, ...).
+
+#The Code
+
+## The REST service: @Path, @GET, @POST
+
+Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.
+
+ package org.superbiz.rest;
+
+ import javax.ws.rs.GET;
+ import javax.ws.rs.POST;
+ import javax.ws.rs.Path;
+
+ @Path("/greeting")
+ public class GreetingService {
+ @GET
+ public String message() {
+ return "Hi REST!";
+ }
+
+ @POST
+ public String lowerCase(final String message) {
+ return "Hi REST!".toLowerCase();
+ }
+ }
+
+# Testing
+
+## Test for the JAXRS service
+
+The test uses the OpenEJB ApplicationComposer to make it trivial.
+
+The idea is first to activate the jaxrs services. This is done using @EnableServices annotation.
+
+Then we create on the fly the application simply returning an object representing the web.xml. Here we simply
+use it to define the context root but you can use it to define your REST Application too. And to complete the
+application definition we add @Classes annotation to define the set of classes to use in this app.
+
+Finally to test it we use cxf client API to call the REST service in get() and post() methods.
+
+ package org.superbiz.rest;
+
+ import org.apache.cxf.jaxrs.client.WebClient;
+ import org.apache.openejb.jee.SingletonBean;
+ import org.apache.openejb.junit.ApplicationComposer;
+ import org.apache.openejb.junit.EnableServices;
+ import org.apache.openejb.junit.Module;
+ import org.junit.Test;
+ import org.junit.runner.RunWith;
+
+ import java.io.IOException;
+
+ import static org.junit.Assert.assertEquals;
+
+ @EnableServices(value = "jaxrs")
+ @RunWith(ApplicationComposer.class)
+ public class GreetingServiceTest {
+ @Module
+ public SingletonBean app() {
+ return (SingletonBean) new SingletonBean(GreetingService.class).localBean();
+ }
+
+ @Test
+ public void get() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/GreetingServiceTest/greeting/").get(String.class);
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void post() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/GreetingServiceTest/greeting/").post("Hi REST!", String.class);
+ assertEquals("hi rest!", message);
+ }
+ }
+
+#Running
+
+Running the example is fairly simple. In the "simple-rest" directory run:
+
+ $ mvn clean install
+
+Which should create output like the following.
+
+ 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 - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Creating ServerService(id=cxf-rs)
+ INFO - Initializing network services
+ INFO - Starting service httpejbd
+ INFO - Started service httpejbd
+ INFO - Starting service cxf-rs
+ INFO - Started service cxf-rs
+ INFO - ** Bound Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - -------
+ INFO - Ready!
+ INFO - Configuring enterprise application: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.rest.GreetingServiceTest: 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 "/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest" loaded.
+ INFO - Assembling app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Existing thread singleton service in SystemInstance() null
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@12c9b196
+ INFO - Succeeded in installing singleton service
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 11 ms.
+ INFO - Deployed Application(path=/opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest)
+ INFO - Setting the server's publish address to be http://127.0.0.1:4204/test
+ INFO - REST Service: http://127.0.0.1:4204/test/greeting/.* -> Pojo org.superbiz.rest.GreetingService
+ INFO - Undeploying app: /opt/dev/openejb/openejb-trunk/examples/GreetingServiceTest
+ INFO - Stopping network services
+ INFO - Stopping server services
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/simple-rest/pom.xml b/content/examples/simple-rest/pom.xml
new file mode 100755
index 0000000..3f70f10
--- /dev/null
+++ b/content/examples/simple-rest/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-rest</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple REST</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf-rs</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/simple-rest/src/main/java/org/superbiz/rest/GreetingService.java b/content/examples/simple-rest/src/main/java/org/superbiz/rest/GreetingService.java
new file mode 100755
index 0000000..6b1449a
--- /dev/null
+++ b/content/examples/simple-rest/src/main/java/org/superbiz/rest/GreetingService.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+
+@Path("/greeting")
+public class GreetingService {
+
+ @GET
+ public String message() {
+ return "Hi REST!";
+ }
+
+ @POST
+ public String lowerCase(final String message) {
+ return "Hi REST!".toLowerCase();
+ }
+}
diff --git a/content/examples/simple-rest/src/test/java/org/superbiz/rest/GreetingServiceTest.java b/content/examples/simple-rest/src/test/java/org/superbiz/rest/GreetingServiceTest.java
new file mode 100755
index 0000000..8ad7a4d
--- /dev/null
+++ b/content/examples/simple-rest/src/test/java/org/superbiz/rest/GreetingServiceTest.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.rest;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices(value = "jaxrs")
+@RunWith(ApplicationComposer.class)
+public class GreetingServiceTest {
+
+ @Module
+ @Classes(GreetingService.class)
+ public WebApp app() {
+ return new WebApp().contextRoot("test");
+ }
+
+ @Test
+ public void get() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/").get(String.class);
+ assertEquals("Hi REST!", message);
+ }
+
+ @Test
+ public void post() throws IOException {
+ final String message = WebClient.create("http://localhost:4204").path("/test/greeting/").post("Hi REST!", String.class);
+ assertEquals("hi rest!", message);
+ }
+}
diff --git a/content/examples/simple-singleton.html b/content/examples/simple-singleton.html
new file mode 100644
index 0000000..fd92e8d
--- /dev/null
+++ b/content/examples/simple-singleton.html
@@ -0,0 +1,580 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-singleton.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple Singleton</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-singleton can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-singleton" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-singleton</a></p>
+</div>
+<div class="paragraph">
+<p>As the name implies a <code>javax.ejb.Singleton</code> is a session bean with a guarantee that there is at most one instance in the application.</p>
+</div>
+<div class="paragraph">
+<p>What it gives that is completely missing in EJB 3.0 and prior versions is the ability to have an EJB that is notified when the application starts and notified when the application stops. So you can do all sorts of things that you previously could only do with a load-on-startup servlet. It also gives you a place to hold data that pertains to the entire application and all users using it, without the need for a static. Additionally, Singleton beans can be invoked by several threads at one time similar to a Servlet.</p>
+</div>
+<div class="paragraph">
+<p>See the <a href="../../singleton-beans.html">Singleton Beans</a> page for a full description of the javax.ejb.Singleton api.</p>
+</div>
+</div>
+</div>
+<h1 id="_the_code" class="sect0">The Code</h1>
+<div class="sect1">
+<h2 id="_propertyregistry_small_bean_managed_concurrency_small">PropertyRegistry <small>Bean-Managed Concurrency</small></h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.registry;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import java.util.Properties;
+
+import static javax.ejb.ConcurrencyManagementType.BEAN;
+
+@Singleton
+@Startup
+@ConcurrencyManagement(BEAN)
+public class PropertyRegistry {
+
+ // Note the java.util.Properties object is a thread-safe
+ // collections that uses synchronization. If it didn't
+ // you would have to use some form of synchronization
+ // to ensure the PropertyRegistryBean is thread-safe.
+ private final Properties properties = new Properties();
+
+ // The @Startup annotation ensures that this method is
+ // called when the application starts up.
+ @PostConstruct
+ public void applicationStartup() {
+ properties.putAll(System.getProperties());
+ }
+
+ @PreDestroy
+ public void applicationShutdown() {
+ properties.clear();
+ }
+
+ public String getProperty(final String key) {
+ return properties.getProperty(key);
+ }
+
+ public String setProperty(final String key, final String value) {
+ return (String) properties.setProperty(key, value);
+ }
+
+ public String removeProperty(final String key) {
+ return (String) properties.remove(key);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_componentregistry_small_container_managed_concurrency_small">ComponentRegistry <small>Container-Managed Concurrency</small></h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Here we see a bean that uses the Container-Managed Concurrency option, the default. With @ConcurrencyManagement(CONTAINER) the container controls whether multi-threaded access should be allowed to the bean (<code>@Lock(READ)</code>) or if single-threaded access should be enforced (<code>@Lock(WRITE)</code>).</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.registry;
+
+import javax.ejb.Lock;
+import javax.ejb.Singleton;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import static javax.ejb.LockType.READ;
+import static javax.ejb.LockType.WRITE;
+
+@Singleton
+@Lock(READ)
+public class ComponentRegistry {
+
+ private final Map<Class, Object> components = new HashMap<Class, Object>();
+
+ public <T> T getComponent(final Class<T> type) {
+ return (T) components.get(type);
+ }
+
+ public Collection<?> getComponents() {
+ return new ArrayList(components.values());
+ }
+
+ @Lock(WRITE)
+ public <T> T setComponent(final Class<T> type, final T value) {
+ return (T) components.put(type, value);
+ }
+
+ @Lock(WRITE)
+ public <T> T removeComponent(final Class<T> type) {
+ return (T) components.remove(type);
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Unless specified explicitly on the bean class or a method, the default <code>@Lock</code> value is <code>@Lock(WRITE)</code>. The code above uses the <code>@Lock(READ)</code> annotation on bean class to change the default so that multi-threaded access is granted by default. We then only need to apply the <code>@Lock(WRITE)</code> annotation to the methods that modify the state of the bean.</p>
+</div>
+<div class="paragraph">
+<p>Essentially <code>@Lock(READ)</code> allows multithreaded access to the Singleton bean instance unless someone is invoking an <code>@Lock(WRITE)</code> method. With <code>@Lock(WRITE)</code>, the thread invoking the bean will be guaranteed to have exclusive access to the Singleton bean instance for the duration of its invocation. This combination allows the bean instance to use data types that are not normally thread safe. Great care must still be used, though.</p>
+</div>
+<div class="paragraph">
+<p>In the example we see <code>ComponentRegistryBean</code> using a <code>java.util.HashMap</code> which is not synchronized. To make this ok we do three things:</p>
+</div>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Encapsulation. We don’t expose the HashMap instance directly; including its iterators, key set, value set or entry set.</p>
+</li>
+<li>
+<p>We use <code>@Lock(WRITE)</code> on the methods that mutate the map such as the <code>put()</code> and <code>remove()</code> methods.</p>
+</li>
+<li>
+<p>We use <code>@Lock(READ)</code> on the <code>get()</code> and <code>values()</code> methods as they do not change the map state and are guaranteed not to be called at the same as any of the <code>@Lock(WRITE)</code> methods, so we know the state of the HashMap is no being mutated and therefore safe for reading.</p>
+</li>
+</ol>
+</div>
+<div class="paragraph">
+<p>The end result is that the threading model for this bean will switch from multi-threaded access to single-threaded access dynamically as needed, depending on the method being invoked. This gives Singletons a bit of an advantage over Servlets for processing multi-threaded requests.</p>
+</div>
+<div class="paragraph">
+<p>See the <a href="../../singleton-beans.html">Singleton Beans</a> page for more advanced details on Container-Managed Concurrency.</p>
+</div>
+</div>
+</div>
+<h1 id="_testing" class="sect0">Testing</h1>
+<div class="sect1">
+<h2 id="_componentregistrytest">ComponentRegistryTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.registry;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Date;
+
+public class ComponentRegistryTest {
+
+ private final static EJBContainer ejbContainer = EJBContainer.createEJBContainer();
+
+ @Test
+ public void oneInstancePerMultipleReferences() throws Exception {
+
+ final Context context = ejbContainer.getContext();
+
+ // Both references below will point to the exact same instance
+ final ComponentRegistry one = (ComponentRegistry) context.lookup("java:global/simple-singleton/ComponentRegistry");
+ final ComponentRegistry two = (ComponentRegistry) context.lookup("java:global/simple-singleton/ComponentRegistry");
+
+ final URI expectedUri = new URI("foo://bar/baz");
+ one.setComponent(URI.class, expectedUri);
+ final URI actualUri = two.getComponent(URI.class);
+ Assert.assertSame(expectedUri, actualUri);
+
+ two.removeComponent(URI.class);
+ URI uri = one.getComponent(URI.class);
+ Assert.assertNull(uri);
+
+ one.removeComponent(URI.class);
+ uri = two.getComponent(URI.class);
+ Assert.assertNull(uri);
+
+ final Date expectedDate = new Date();
+ two.setComponent(Date.class, expectedDate);
+ final Date actualDate = one.getComponent(Date.class);
+ Assert.assertSame(expectedDate, actualDate);
+
+ Collection<?> collection = one.getComponents();
+ System.out.println(collection);
+ Assert.assertEquals("Reference 'one' - ComponentRegistry contains one record", collection.size(), 1);
+
+ collection = two.getComponents();
+ Assert.assertEquals("Reference 'two' - ComponentRegistry contains one record", collection.size(), 1);
+ }
+
+ @AfterClass
+ public static void closeEjbContainer() {
+ ejbContainer.close();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_propertiesregistrytest">PropertiesRegistryTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.registry;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+public class PropertiesRegistryTest {
+
+ private final static EJBContainer ejbContainer = EJBContainer.createEJBContainer();
+
+ @Test
+ public void oneInstancePerMultipleReferences() throws Exception {
+
+ final Context context = ejbContainer.getContext();
+
+ final PropertyRegistry one = (PropertyRegistry) context.lookup("java:global/simple-singleton/PropertyRegistry");
+ final PropertyRegistry two = (PropertyRegistry) context.lookup("java:global/simple-singleton/PropertyRegistry");
+
+ one.setProperty("url", "http://superbiz.org");
+ String url = two.getProperty("url");
+ Assert.assertSame("http://superbiz.org", url);
+
+ two.removeProperty("url");
+ url = one.getProperty("url");
+ Assert.assertNull(url);
+
+ two.setProperty("version", "1.0.5");
+ String version = one.getProperty("version");
+ Assert.assertSame("1.0.5", version);
+
+ one.removeProperty("version");
+ version = two.getProperty("version");
+ Assert.assertNull(version);
+ }
+
+ @AfterClass
+ public static void closeEjbContainer() {
+ ejbContainer.close();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>Running the example is fairly simple. In the "simple-singleton" directory run:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>$ mvn clean install</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Which should create output like the following.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.registry.ComponentRegistryTest
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Sun Jun 09 03:46:51 IDT 2013
+INFO - Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 7.0.0-SNAPSHOT
+INFO - Build date: 20130608
+INFO - Build time: 04:07
+INFO - ********************************************************************************
+INFO - openejb.home = C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - openejb.base = C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@448ad367
+INFO - Succeeded in installing singleton service
+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 - Found EjbModule in classpath: c:\users\oz\desktop\ee-examples\simple-singleton\target\classes
+INFO - Beginning load: c:\users\oz\desktop\ee-examples\simple-singleton\target\classes
+INFO - Configuring enterprise application: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - Auto-deploying ejb PropertyRegistry: EjbDeployment(deployment-id=PropertyRegistry)
+INFO - Auto-deploying ejb ComponentRegistry: EjbDeployment(deployment-id=ComponentRegistry)
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean PropertyRegistry: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Creating Container(id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.registry.ComponentRegistryTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Using directory C:\Users\Oz\AppData\Local\Temp for stateful session passivation
+INFO - Enterprise application "C:\Users\Oz\Desktop\ee-examples\simple-singleton" loaded.
+INFO - Assembling app: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - Jndi(name="java:global/simple-singleton/PropertyRegistry!org.superbiz.registry.PropertyRegistry")
+INFO - Jndi(name="java:global/simple-singleton/PropertyRegistry")
+INFO - Jndi(name="java:global/simple-singleton/ComponentRegistry!org.superbiz.registry.ComponentRegistry")
+INFO - Jndi(name="java:global/simple-singleton/ComponentRegistry")
+INFO - Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@448ad367
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points were validated successfully.
+INFO - OpenWebBeans Container has started, it took 68 ms.
+INFO - Created Ejb(deployment-id=PropertyRegistry, ejb-name=PropertyRegistry, container=Default Singleton Container)
+INFO - Created Ejb(deployment-id=ComponentRegistry, ejb-name=ComponentRegistry, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=PropertyRegistry, ejb-name=PropertyRegistry, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=ComponentRegistry, ejb-name=ComponentRegistry, container=Default Singleton Container)
+INFO - Deployed Application(path=C:\Users\Oz\Desktop\ee-examples\simple-singleton)
+[Sun Jun 09 03:46:52 IDT 2013]
+INFO - Undeploying app: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - Destroying OpenEJB container
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.431 sec
+Running org.superbiz.registry.PropertiesRegistryTest
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Sun Jun 09 03:46:52 IDT 2013
+INFO - Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 7.0.0-SNAPSHOT
+INFO - Build date: 20130608
+INFO - Build time: 04:07
+INFO - ********************************************************************************
+INFO - openejb.home = C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - openejb.base = C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@448ad367
+INFO - Succeeded in installing singleton service
+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 - Using 'java.security.auth.login.config=jar:file:/C:/Users/Oz/.m2/repository/org/apache/openejb/openejb-core/7.0.0-SNAPSHOT/openejb-core-7.0.0-SNAPSHOT.jar!/login.config'
+INFO - Found EjbModule in classpath: c:\users\oz\desktop\ee-examples\simple-singleton\target\classes
+INFO - Beginning load: c:\users\oz\desktop\ee-examples\simple-singleton\target\classes
+INFO - Configuring enterprise application: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - Auto-deploying ejb ComponentRegistry: EjbDeployment(deployment-id=ComponentRegistry)
+INFO - Auto-deploying ejb PropertyRegistry: EjbDeployment(deployment-id=PropertyRegistry)
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean ComponentRegistry: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Creating Container(id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.registry.PropertiesRegistryTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Using directory C:\Users\Oz\AppData\Local\Temp for stateful session passivation
+INFO - Enterprise application "C:\Users\Oz\Desktop\ee-examples\simple-singleton" loaded.
+INFO - Assembling app: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - Jndi(name="java:global/simple-singleton/ComponentRegistry!org.superbiz.registry.ComponentRegistry")
+INFO - Jndi(name="java:global/simple-singleton/ComponentRegistry")
+INFO - Jndi(name="java:global/simple-singleton/PropertyRegistry!org.superbiz.registry.PropertyRegistry")
+INFO - Jndi(name="java:global/simple-singleton/PropertyRegistry")
+INFO - Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@448ad367
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points were validated successfully.
+INFO - OpenWebBeans Container has started, it took 4 ms.
+INFO - Created Ejb(deployment-id=PropertyRegistry, ejb-name=PropertyRegistry, container=Default Singleton Container)
+INFO - Created Ejb(deployment-id=ComponentRegistry, ejb-name=ComponentRegistry, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=PropertyRegistry, ejb-name=PropertyRegistry, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=ComponentRegistry, ejb-name=ComponentRegistry, container=Default Singleton Container)
+INFO - Deployed Application(path=C:\Users\Oz\Desktop\ee-examples\simple-singleton)
+INFO - Undeploying app: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+INFO - Destroying OpenEJB container
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.171 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-singleton.pdf b/content/examples/simple-singleton.pdf
new file mode 100644
index 0000000..e659319
--- /dev/null
+++ b/content/examples/simple-singleton.pdf
Binary files differ
diff --git a/content/examples/simple-singleton/README.md b/content/examples/simple-singleton/README.md
new file mode 100755
index 0000000..3da9d86
--- /dev/null
+++ b/content/examples/simple-singleton/README.md
@@ -0,0 +1,344 @@
+Title: Simple Singleton
+
+As the name implies a `javax.ejb.Singleton` is a session bean with a guarantee that there is at most one instance in the application.
+
+What it gives that is completely missing in EJB 3.0 and prior versions is the ability to have an EJB that is notified when the application starts and notified when the application stops. So you can do all sorts of things that you previously could only do with a load-on-startup servlet. It also gives you a place to hold data that pertains to the entire application and all users using it, without the need for a static. Additionally, Singleton beans can be invoked by several threads at one time similar to a Servlet.
+
+See the [Singleton Beans](../../singleton-beans.html) page for a full description of the javax.ejb.Singleton api.
+
+#The Code
+
+## PropertyRegistry <small>Bean-Managed Concurrency</small>
+
+Here we see a bean that uses the Bean-Managed Concurrency option as well as the @Startup annotation which causes the bean to be instantiated by the container when the application starts. Singleton beans with @ConcurrencyManagement(BEAN) are responsible for their own thread-safety. The bean shown is a simple properties "registry" and provides a place where options could be set and retrieved by all beans in the application.
+
+ package org.superbiz.registry;
+
+ import javax.annotation.PostConstruct;
+ import javax.annotation.PreDestroy;
+ import javax.ejb.ConcurrencyManagement;
+ import javax.ejb.Singleton;
+ import javax.ejb.Startup;
+ import java.util.Properties;
+
+ import static javax.ejb.ConcurrencyManagementType.BEAN;
+
+ @Singleton
+ @Startup
+ @ConcurrencyManagement(BEAN)
+ public class PropertyRegistry {
+
+ // Note the java.util.Properties object is a thread-safe
+ // collections that uses synchronization. If it didn't
+ // you would have to use some form of synchronization
+ // to ensure the PropertyRegistryBean is thread-safe.
+ private final Properties properties = new Properties();
+
+ // The @Startup annotation ensures that this method is
+ // called when the application starts up.
+ @PostConstruct
+ public void applicationStartup() {
+ properties.putAll(System.getProperties());
+ }
+
+ @PreDestroy
+ public void applicationShutdown() {
+ properties.clear();
+ }
+
+ public String getProperty(final String key) {
+ return properties.getProperty(key);
+ }
+
+ public String setProperty(final String key, final String value) {
+ return (String) properties.setProperty(key, value);
+ }
+
+ public String removeProperty(final String key) {
+ return (String) properties.remove(key);
+ }
+ }
+
+## ComponentRegistry <small>Container-Managed Concurrency</small>
+
+Here we see a bean that uses the Container-Managed Concurrency option, the default. With @ConcurrencyManagement(CONTAINER) the container controls whether multi-threaded access should be allowed to the bean (`@Lock(READ)`) or if single-threaded access should be enforced (`@Lock(WRITE)`).
+
+ package org.superbiz.registry;
+
+ import javax.ejb.Lock;
+ import javax.ejb.Singleton;
+ import java.util.ArrayList;
+ import java.util.Collection;
+ import java.util.HashMap;
+ import java.util.Map;
+
+ import static javax.ejb.LockType.READ;
+ import static javax.ejb.LockType.WRITE;
+
+ @Singleton
+ @Lock(READ)
+ public class ComponentRegistry {
+
+ private final Map<Class, Object> components = new HashMap<Class, Object>();
+
+ public <T> T getComponent(final Class<T> type) {
+ return (T) components.get(type);
+ }
+
+ public Collection<?> getComponents() {
+ return new ArrayList(components.values());
+ }
+
+ @Lock(WRITE)
+ public <T> T setComponent(final Class<T> type, final T value) {
+ return (T) components.put(type, value);
+ }
+
+ @Lock(WRITE)
+ public <T> T removeComponent(final Class<T> type) {
+ return (T) components.remove(type);
+ }
+ }
+
+Unless specified explicitly on the bean class or a method, the default `@Lock` value is `@Lock(WRITE)`. The code above uses the `@Lock(READ)` annotation on bean class to change the default so that multi-threaded access is granted by default. We then only need to apply the `@Lock(WRITE)` annotation to the methods that modify the state of the bean.
+
+Essentially `@Lock(READ)` allows multithreaded access to the Singleton bean instance unless someone is invoking an `@Lock(WRITE)` method. With `@Lock(WRITE)`, the thread invoking the bean will be guaranteed to have exclusive access to the Singleton bean instance for the duration of its invocation. This combination allows the bean instance to use data types that are not normally thread safe. Great care must still be used, though.
+
+In the example we see `ComponentRegistryBean` using a `java.util.HashMap` which is not synchronized. To make this ok we do three things:
+
+ 1. Encapsulation. We don't expose the HashMap instance directly; including its iterators, key set, value set or entry set.
+ 1. We use `@Lock(WRITE)` on the methods that mutate the map such as the `put()` and `remove()` methods.
+ 1. We use `@Lock(READ)` on the `get()` and `values()` methods as they do not change the map state and are guaranteed not to be called at the same as any of the `@Lock(WRITE)` methods, so we know the state of the HashMap is no being mutated and therefore safe for reading.
+
+The end result is that the threading model for this bean will switch from multi-threaded access to single-threaded access dynamically as needed, depending on the method being invoked. This gives Singletons a bit of an advantage over Servlets for processing multi-threaded requests.
+
+See the [Singleton Beans](../../singleton-beans.html) page for more advanced details on Container-Managed Concurrency.
+
+# Testing
+
+
+## ComponentRegistryTest
+
+ package org.superbiz.registry;
+
+ import org.junit.AfterClass;
+ import org.junit.Assert;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import java.net.URI;
+ import java.util.Collection;
+ import java.util.Date;
+
+ public class ComponentRegistryTest {
+
+ private final static EJBContainer ejbContainer = EJBContainer.createEJBContainer();
+
+ @Test
+ public void oneInstancePerMultipleReferences() throws Exception {
+
+ final Context context = ejbContainer.getContext();
+
+ // Both references below will point to the exact same instance
+ final ComponentRegistry one = (ComponentRegistry) context.lookup("java:global/simple-singleton/ComponentRegistry");
+ final ComponentRegistry two = (ComponentRegistry) context.lookup("java:global/simple-singleton/ComponentRegistry");
+
+ final URI expectedUri = new URI("foo://bar/baz");
+ one.setComponent(URI.class, expectedUri);
+ final URI actualUri = two.getComponent(URI.class);
+ Assert.assertSame(expectedUri, actualUri);
+
+ two.removeComponent(URI.class);
+ URI uri = one.getComponent(URI.class);
+ Assert.assertNull(uri);
+
+ one.removeComponent(URI.class);
+ uri = two.getComponent(URI.class);
+ Assert.assertNull(uri);
+
+ final Date expectedDate = new Date();
+ two.setComponent(Date.class, expectedDate);
+ final Date actualDate = one.getComponent(Date.class);
+ Assert.assertSame(expectedDate, actualDate);
+
+ Collection<?> collection = one.getComponents();
+ System.out.println(collection);
+ Assert.assertEquals("Reference 'one' - ComponentRegistry contains one record", collection.size(), 1);
+
+ collection = two.getComponents();
+ Assert.assertEquals("Reference 'two' - ComponentRegistry contains one record", collection.size(), 1);
+ }
+
+ @AfterClass
+ public static void closeEjbContainer() {
+ ejbContainer.close();
+ }
+ }
+
+## PropertiesRegistryTest
+
+ package org.superbiz.registry;
+
+ import org.junit.AfterClass;
+ import org.junit.Assert;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+
+ public class PropertiesRegistryTest {
+
+ private final static EJBContainer ejbContainer = EJBContainer.createEJBContainer();
+
+ @Test
+ public void oneInstancePerMultipleReferences() throws Exception {
+
+ final Context context = ejbContainer.getContext();
+
+ final PropertyRegistry one = (PropertyRegistry) context.lookup("java:global/simple-singleton/PropertyRegistry");
+ final PropertyRegistry two = (PropertyRegistry) context.lookup("java:global/simple-singleton/PropertyRegistry");
+
+ one.setProperty("url", "http://superbiz.org");
+ String url = two.getProperty("url");
+ Assert.assertSame("http://superbiz.org", url);
+
+ two.removeProperty("url");
+ url = one.getProperty("url");
+ Assert.assertNull(url);
+
+ two.setProperty("version", "1.0.5");
+ String version = one.getProperty("version");
+ Assert.assertSame("1.0.5", version);
+
+ one.removeProperty("version");
+ version = two.getProperty("version");
+ Assert.assertNull(version);
+ }
+
+ @AfterClass
+ public static void closeEjbContainer() {
+ ejbContainer.close();
+ }
+ }
+
+
+#Running
+
+Running the example is fairly simple. In the "simple-singleton" directory run:
+
+ $ mvn clean install
+
+Which should create output like the following.
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.registry.ComponentRegistryTest
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://openejb.apache.org/
+ INFO - Startup: Sun Jun 09 03:46:51 IDT 2013
+ INFO - Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 4.6.0-SNAPSHOT
+ INFO - Build date: 20130608
+ INFO - Build time: 04:07
+ INFO - ********************************************************************************
+ INFO - openejb.home = C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - openejb.base = C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@448ad367
+ INFO - Succeeded in installing singleton service
+ 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 - Found EjbModule in classpath: c:\users\oz\desktop\ee-examples\simple-singleton\target\classes
+ INFO - Beginning load: c:\users\oz\desktop\ee-examples\simple-singleton\target\classes
+ INFO - Configuring enterprise application: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - Auto-deploying ejb PropertyRegistry: EjbDeployment(deployment-id=PropertyRegistry)
+ INFO - Auto-deploying ejb ComponentRegistry: EjbDeployment(deployment-id=ComponentRegistry)
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean PropertyRegistry: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Creating Container(id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.registry.ComponentRegistryTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Creating Container(id=Default Managed Container)
+ INFO - Using directory C:\Users\Oz\AppData\Local\Temp for stateful session passivation
+ INFO - Enterprise application "C:\Users\Oz\Desktop\ee-examples\simple-singleton" loaded.
+ INFO - Assembling app: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - Jndi(name="java:global/simple-singleton/PropertyRegistry!org.superbiz.registry.PropertyRegistry")
+ INFO - Jndi(name="java:global/simple-singleton/PropertyRegistry")
+ INFO - Jndi(name="java:global/simple-singleton/ComponentRegistry!org.superbiz.registry.ComponentRegistry")
+ INFO - Jndi(name="java:global/simple-singleton/ComponentRegistry")
+ INFO - Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@448ad367
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points were validated successfully.
+ INFO - OpenWebBeans Container has started, it took 68 ms.
+ INFO - Created Ejb(deployment-id=PropertyRegistry, ejb-name=PropertyRegistry, container=Default Singleton Container)
+ INFO - Created Ejb(deployment-id=ComponentRegistry, ejb-name=ComponentRegistry, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=PropertyRegistry, ejb-name=PropertyRegistry, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=ComponentRegistry, ejb-name=ComponentRegistry, container=Default Singleton Container)
+ INFO - Deployed Application(path=C:\Users\Oz\Desktop\ee-examples\simple-singleton)
+ [Sun Jun 09 03:46:52 IDT 2013]
+ INFO - Undeploying app: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - Destroying OpenEJB container
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.431 sec
+ Running org.superbiz.registry.PropertiesRegistryTest
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://openejb.apache.org/
+ INFO - Startup: Sun Jun 09 03:46:52 IDT 2013
+ INFO - Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 4.6.0-SNAPSHOT
+ INFO - Build date: 20130608
+ INFO - Build time: 04:07
+ INFO - ********************************************************************************
+ INFO - openejb.home = C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - openejb.base = C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@448ad367
+ INFO - Succeeded in installing singleton service
+ 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 - Using 'java.security.auth.login.config=jar:file:/C:/Users/Oz/.m2/repository/org/apache/openejb/openejb-core/4.6.0-SNAPSHOT/openejb-core-4.6.0-SNAPSHOT.jar!/login.config'
+ INFO - Found EjbModule in classpath: c:\users\oz\desktop\ee-examples\simple-singleton\target\classes
+ INFO - Beginning load: c:\users\oz\desktop\ee-examples\simple-singleton\target\classes
+ INFO - Configuring enterprise application: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - Auto-deploying ejb ComponentRegistry: EjbDeployment(deployment-id=ComponentRegistry)
+ INFO - Auto-deploying ejb PropertyRegistry: EjbDeployment(deployment-id=PropertyRegistry)
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean ComponentRegistry: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Creating Container(id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.registry.PropertiesRegistryTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Creating Container(id=Default Managed Container)
+ INFO - Using directory C:\Users\Oz\AppData\Local\Temp for stateful session passivation
+ INFO - Enterprise application "C:\Users\Oz\Desktop\ee-examples\simple-singleton" loaded.
+ INFO - Assembling app: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - Jndi(name="java:global/simple-singleton/ComponentRegistry!org.superbiz.registry.ComponentRegistry")
+ INFO - Jndi(name="java:global/simple-singleton/ComponentRegistry")
+ INFO - Jndi(name="java:global/simple-singleton/PropertyRegistry!org.superbiz.registry.PropertyRegistry")
+ INFO - Jndi(name="java:global/simple-singleton/PropertyRegistry")
+ INFO - Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@448ad367
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points were validated successfully.
+ INFO - OpenWebBeans Container has started, it took 4 ms.
+ INFO - Created Ejb(deployment-id=PropertyRegistry, ejb-name=PropertyRegistry, container=Default Singleton Container)
+ INFO - Created Ejb(deployment-id=ComponentRegistry, ejb-name=ComponentRegistry, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=PropertyRegistry, ejb-name=PropertyRegistry, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=ComponentRegistry, ejb-name=ComponentRegistry, container=Default Singleton Container)
+ INFO - Deployed Application(path=C:\Users\Oz\Desktop\ee-examples\simple-singleton)
+ INFO - Undeploying app: C:\Users\Oz\Desktop\ee-examples\simple-singleton
+ INFO - Destroying OpenEJB container
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.171 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/simple-singleton/build.xml b/content/examples/simple-singleton/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/simple-singleton/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-singleton/pom.xml b/content/examples/simple-singleton/pom.xml
new file mode 100755
index 0000000..11c7ac8
--- /dev/null
+++ b/content/examples/simple-singleton/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-singleton</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple Singleton</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/simple-singleton/src/main/java/org/superbiz/registry/ComponentRegistry.java b/content/examples/simple-singleton/src/main/java/org/superbiz/registry/ComponentRegistry.java
new file mode 100755
index 0000000..8197241
--- /dev/null
+++ b/content/examples/simple-singleton/src/main/java/org/superbiz/registry/ComponentRegistry.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.registry;
+
+import javax.ejb.Lock;
+import javax.ejb.Singleton;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import static javax.ejb.LockType.READ;
+import static javax.ejb.LockType.WRITE;
+
+@Singleton
+@Lock(READ)
+public class ComponentRegistry {
+
+ private final Map<Class, Object> components = new HashMap<Class, Object>();
+
+ public <T> T getComponent(final Class<T> type) {
+ return (T) components.get(type);
+ }
+
+ public Collection<?> getComponents() {
+ return new ArrayList(components.values());
+ }
+
+ @Lock(WRITE)
+ public <T> T setComponent(final Class<T> type, final T value) {
+ return (T) components.put(type, value);
+ }
+
+ @Lock(WRITE)
+ public <T> T removeComponent(final Class<T> type) {
+ return (T) components.remove(type);
+ }
+}
+
diff --git a/content/examples/simple-singleton/src/main/java/org/superbiz/registry/PropertyRegistry.java b/content/examples/simple-singleton/src/main/java/org/superbiz/registry/PropertyRegistry.java
new file mode 100755
index 0000000..56adcb1
--- /dev/null
+++ b/content/examples/simple-singleton/src/main/java/org/superbiz/registry/PropertyRegistry.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.registry;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import java.util.Properties;
+
+import static javax.ejb.ConcurrencyManagementType.BEAN;
+
+@Singleton
+@Startup
+@ConcurrencyManagement(BEAN)
+public class PropertyRegistry {
+
+ // Note the java.util.Properties object is a thread-safe
+ // collections that uses synchronization. If it didn't
+ // you would have to use some form of synchronization
+ // to ensure the PropertyRegistryBean is thread-safe.
+ private final Properties properties = new Properties();
+
+ // The @Startup annotation ensures that this method is
+ // called when the application starts up.
+ @PostConstruct
+ public void applicationStartup() {
+ properties.putAll(System.getProperties());
+ }
+
+ @PreDestroy
+ public void applicationShutdown() {
+ properties.clear();
+ }
+
+ public String getProperty(final String key) {
+ return properties.getProperty(key);
+ }
+
+ public String setProperty(final String key, final String value) {
+ return (String) properties.setProperty(key, value);
+ }
+
+ public String removeProperty(final String key) {
+ return (String) properties.remove(key);
+ }
+}
diff --git a/content/examples/simple-singleton/src/test/java/org/superbiz/registry/ComponentRegistryTest.java b/content/examples/simple-singleton/src/test/java/org/superbiz/registry/ComponentRegistryTest.java
new file mode 100755
index 0000000..e325e42
--- /dev/null
+++ b/content/examples/simple-singleton/src/test/java/org/superbiz/registry/ComponentRegistryTest.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.registry;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Date;
+
+public class ComponentRegistryTest {
+
+ private final static EJBContainer ejbContainer = EJBContainer.createEJBContainer();
+
+ @Test
+ public void oneInstancePerMultipleReferences() throws Exception {
+
+ final Context context = ejbContainer.getContext();
+
+ // Both references below will point to the exact same instance
+ final ComponentRegistry one = (ComponentRegistry) context.lookup("java:global/simple-singleton/ComponentRegistry");
+ final ComponentRegistry two = (ComponentRegistry) context.lookup("java:global/simple-singleton/ComponentRegistry");
+
+ final URI expectedUri = new URI("foo://bar/baz");
+ one.setComponent(URI.class, expectedUri);
+ final URI actualUri = two.getComponent(URI.class);
+ Assert.assertSame(expectedUri, actualUri);
+
+ two.removeComponent(URI.class);
+ URI uri = one.getComponent(URI.class);
+ Assert.assertNull(uri);
+
+ one.removeComponent(URI.class);
+ uri = two.getComponent(URI.class);
+ Assert.assertNull(uri);
+
+ final Date expectedDate = new Date();
+ two.setComponent(Date.class, expectedDate);
+ final Date actualDate = one.getComponent(Date.class);
+ Assert.assertSame(expectedDate, actualDate);
+
+ Collection<?> collection = one.getComponents();
+ System.out.println(collection);
+ Assert.assertEquals("Reference 'one' - ComponentRegistry contains one record", collection.size(), 1);
+
+ collection = two.getComponents();
+ Assert.assertEquals("Reference 'two' - ComponentRegistry contains one record", collection.size(), 1);
+ }
+
+ @AfterClass
+ public static void closeEjbContainer() {
+ ejbContainer.close();
+ }
+}
diff --git a/content/examples/simple-singleton/src/test/java/org/superbiz/registry/PropertiesRegistryTest.java b/content/examples/simple-singleton/src/test/java/org/superbiz/registry/PropertiesRegistryTest.java
new file mode 100755
index 0000000..4b887c7
--- /dev/null
+++ b/content/examples/simple-singleton/src/test/java/org/superbiz/registry/PropertiesRegistryTest.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.registry;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+public class PropertiesRegistryTest {
+
+ private final static EJBContainer ejbContainer = EJBContainer.createEJBContainer();
+
+ @Test
+ public void oneInstancePerMultipleReferences() throws Exception {
+
+ final Context context = ejbContainer.getContext();
+
+ final PropertyRegistry one = (PropertyRegistry) context.lookup("java:global/simple-singleton/PropertyRegistry");
+ final PropertyRegistry two = (PropertyRegistry) context.lookup("java:global/simple-singleton/PropertyRegistry");
+
+ one.setProperty("url", "http://superbiz.org");
+ String url = two.getProperty("url");
+ Assert.assertSame("http://superbiz.org", url);
+
+ two.removeProperty("url");
+ url = one.getProperty("url");
+ Assert.assertNull(url);
+
+ two.setProperty("version", "1.0.5");
+ String version = one.getProperty("version");
+ Assert.assertSame("1.0.5", version);
+
+ one.removeProperty("version");
+ version = two.getProperty("version");
+ Assert.assertNull(version);
+ }
+
+ @AfterClass
+ public static void closeEjbContainer() {
+ ejbContainer.close();
+ }
+}
diff --git a/content/examples/simple-stateful-callbacks.html b/content/examples/simple-stateful-callbacks.html
new file mode 100644
index 0000000..aa5c028
--- /dev/null
+++ b/content/examples/simple-stateful-callbacks.html
@@ -0,0 +1,512 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-stateful-callbacks.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple Stateful with callback methods</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-stateful-callbacks can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-stateful-callbacks" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-stateful-callbacks</a></p>
+</div>
+<div class="paragraph">
+<p>This example shows how to create a stateful session bean that uses the @PrePassivate, @PostActivate, @PostConstruct, @PreDestroy and @AroundInvoke annotations.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_callbackcounter">CallbackCounter</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.counter;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Stateful;
+import javax.ejb.StatefulTimeout;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+import java.util.concurrent.TimeUnit;
+
+@Stateful
+@StatefulTimeout(value = 1, unit = TimeUnit.SECONDS)
+public class CallbackCounter implements Serializable {
+
+ private int count = 0;
+
+ @PrePassivate
+ public void prePassivate() {
+ ExecutionChannel.getInstance().notifyObservers("prePassivate");
+ }
+
+ @PostActivate
+ public void postActivate() {
+ ExecutionChannel.getInstance().notifyObservers("postActivate");
+ }
+
+ @PostConstruct
+ public void postConstruct() {
+ ExecutionChannel.getInstance().notifyObservers("postConstruct");
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ ExecutionChannel.getInstance().notifyObservers("preDestroy");
+ }
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ ExecutionChannel.getInstance().notifyObservers(ctx.getMethod().getName());
+ return ctx.proceed();
+ }
+
+ public int count() {
+ return count;
+ }
+
+ public int increment() {
+ return ++count;
+ }
+
+ public int reset() {
+ return (count = 0);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_executionchannel">ExecutionChannel</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.counter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExecutionChannel {
+ private static final ExecutionChannel INSTANCE = new ExecutionChannel();
+
+ private final List<ExecutionObserver> observers = new ArrayList<ExecutionObserver>();
+
+ public static ExecutionChannel getInstance() {
+ return INSTANCE;
+ }
+
+ public void addObserver(ExecutionObserver observer) {
+ this.observers.add(observer);
+ }
+
+ public void notifyObservers(Object value) {
+ for (ExecutionObserver observer : this.observers) {
+ observer.onExecution(value);
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_executionobserver">ExecutionObserver</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.counter;
+
+public interface ExecutionObserver {
+
+ void onExecution(Object value);
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_countercallbackstest">CounterCallbacksTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.counter;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.*;
+
+public class CounterCallbacksTest implements ExecutionObserver {
+ private static List<Object> received = new ArrayList<Object>();
+
+ public Context getContext() throws NamingException {
+ final Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ return new InitialContext(p);
+
+ }
+
+ @Test
+ public void test() throws Exception {
+ final Map<String, Object> p = new HashMap<String, Object>();
+ p.put("MySTATEFUL", "new://Container?type=STATEFUL");
+ p.put("MySTATEFUL.Capacity", "2"); //How many instances of Stateful beans can our server hold in memory?
+ p.put("MySTATEFUL.Frequency", "1"); //Interval in seconds between checks
+ p.put("MySTATEFUL.BulkPassivate", "0"); //No bulkPassivate - just passivate entities whenever it is needed
+ final EJBContainer container = EJBContainer.createEJBContainer(p);
+
+ //this is going to track the execution
+ ExecutionChannel.getInstance().addObserver(this);
+
+ {
+ final Context context = getContext();
+
+ CallbackCounter counterA = (CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter");
+ Assert.assertNotNull(counterA);
+ Assert.assertEquals("postConstruct", received.remove(0));
+
+ Assert.assertEquals(0, counterA.count());
+ Assert.assertEquals("count", received.remove(0));
+
+ Assert.assertEquals(1, counterA.increment());
+ Assert.assertEquals("increment", received.remove(0));
+
+ Assert.assertEquals(0, counterA.reset());
+ Assert.assertEquals("reset", received.remove(0));
+
+ Assert.assertEquals(1, counterA.increment());
+ Assert.assertEquals("increment", received.remove(0));
+
+ System.out.println("Waiting 2 seconds...");
+ Thread.sleep(2000);
+
+ Assert.assertEquals("preDestroy", received.remove(0));
+
+ try {
+ counterA.increment();
+ Assert.fail("The ejb is not supposed to be there.");
+ } catch (javax.ejb.NoSuchEJBException e) {
+ //excepted
+ }
+
+ context.close();
+ }
+
+ {
+ final Context context = getContext();
+
+ CallbackCounter counterA = (CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter");
+ Assert.assertEquals("postConstruct", received.remove(0));
+
+ Assert.assertEquals(1, counterA.increment());
+ Assert.assertEquals("increment", received.remove(0));
+
+ ((CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter")).count();
+ Assert.assertEquals("postConstruct", received.remove(0));
+ Assert.assertEquals("count", received.remove(0));
+
+ ((CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter")).count();
+ Assert.assertEquals("postConstruct", received.remove(0));
+ Assert.assertEquals("count", received.remove(0));
+
+ System.out.println("Waiting 2 seconds...");
+ Thread.sleep(2000);
+ Assert.assertEquals("prePassivate", received.remove(0));
+
+ context.close();
+ }
+ container.close();
+
+ Assert.assertEquals("preDestroy", received.remove(0));
+ Assert.assertEquals("preDestroy", received.remove(0));
+
+ Assert.assertTrue(received.toString(), received.isEmpty());
+ }
+
+ @Override
+ public void onExecution(Object value) {
+ System.out.println("Test step -> " + value);
+ received.add(value);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.counter.CounterCallbacksTest
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Sat Jul 21 08:18:28 EDT 2012
+INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 4.1.0
+INFO - Build date: 20120721
+INFO - Build time: 04:06
+INFO - ********************************************************************************
+INFO - openejb.home = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+INFO - openejb.base = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+INFO - Succeeded in installing singleton service
+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 - Configuring Service(id=MySTATEFUL, type=Container, provider-id=Default Stateful Container)
+INFO - Creating TransactionManager(id=Default Transaction Manager)
+INFO - Creating SecurityService(id=Default Security Service)
+INFO - Creating Container(id=MySTATEFUL)
+INFO - Using directory /tmp for stateful session passivation
+INFO - Beginning load: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks/target/classes
+INFO - Configuring enterprise application: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+INFO - Auto-deploying ejb CallbackCounter: EjbDeployment(deployment-id=CallbackCounter)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.counter.CounterCallbacksTest: 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/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks" loaded.
+INFO - Assembling app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+INFO - Jndi(name="java:global/simple-stateful-callbacks/CallbackCounter!org.superbiz.counter.CallbackCounter")
+INFO - Jndi(name="java:global/simple-stateful-callbacks/CallbackCounter")
+INFO - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 225 ms.
+INFO - Created Ejb(deployment-id=CallbackCounter, ejb-name=CallbackCounter, container=MySTATEFUL)
+INFO - Started Ejb(deployment-id=CallbackCounter, ejb-name=CallbackCounter, container=MySTATEFUL)
+INFO - Deployed Application(path=/home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks)
+Test step -> postConstruct
+Test step -> count
+Test step -> increment
+Test step -> reset
+Test step -> increment
+Waiting 2 seconds...
+Test step -> preDestroy
+INFO - Removing the timed-out stateful session bean instance 583c10bfdbd326ba:57f94a9b:138a9798adf:-8000
+INFO - Activation failed: file not found /tmp/583c10bfdbd326ba=57f94a9b=138a9798adf=-8000
+Test step -> postConstruct
+Test step -> increment
+Test step -> postConstruct
+Test step -> count
+Test step -> postConstruct
+Test step -> count
+Waiting 2 seconds...
+Test step -> prePassivate
+INFO - Passivating to file /tmp/583c10bfdbd326ba=57f94a9b=138a9798adf=-7fff
+Test step -> preDestroy
+INFO - Removing the timed-out stateful session bean instance 583c10bfdbd326ba:57f94a9b:138a9798adf:-7ffe
+Test step -> preDestroy
+INFO - Removing the timed-out stateful session bean instance 583c10bfdbd326ba:57f94a9b:138a9798adf:-7ffd
+INFO - Undeploying app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.487 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time: 15.803s
+[INFO] Finished at: Sat Jul 21 08:18:35 EDT 2012
+[INFO] Final Memory: 11M/247M
+[INFO] ------------------------------------------------------------------------</pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-stateful-callbacks.pdf b/content/examples/simple-stateful-callbacks.pdf
new file mode 100644
index 0000000..67ed18d
--- /dev/null
+++ b/content/examples/simple-stateful-callbacks.pdf
Binary files differ
diff --git a/content/examples/simple-stateful-callbacks/README.md b/content/examples/simple-stateful-callbacks/README.md
new file mode 100755
index 0000000..04827d1
--- /dev/null
+++ b/content/examples/simple-stateful-callbacks/README.md
@@ -0,0 +1,292 @@
+Title: Simple Stateful with callback methods
+
+This example shows how to create a stateful session bean that uses the @PrePassivate, @PostActivate, @PostConstruct, @PreDestroy and @AroundInvoke annotations.
+
+## CallbackCounter
+
+ package org.superbiz.counter;
+
+ import javax.annotation.PostConstruct;
+ import javax.annotation.PreDestroy;
+ import javax.ejb.PostActivate;
+ import javax.ejb.PrePassivate;
+ import javax.ejb.Stateful;
+ import javax.ejb.StatefulTimeout;
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+ import java.io.Serializable;
+ import java.util.concurrent.TimeUnit;
+
+ @Stateful
+ @StatefulTimeout(value = 1, unit = TimeUnit.SECONDS)
+ public class CallbackCounter implements Serializable {
+
+ private int count = 0;
+
+ @PrePassivate
+ public void prePassivate() {
+ ExecutionChannel.getInstance().notifyObservers("prePassivate");
+ }
+
+ @PostActivate
+ public void postActivate() {
+ ExecutionChannel.getInstance().notifyObservers("postActivate");
+ }
+
+ @PostConstruct
+ public void postConstruct() {
+ ExecutionChannel.getInstance().notifyObservers("postConstruct");
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ ExecutionChannel.getInstance().notifyObservers("preDestroy");
+ }
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ ExecutionChannel.getInstance().notifyObservers(ctx.getMethod().getName());
+ return ctx.proceed();
+ }
+
+ public int count() {
+ return count;
+ }
+
+ public int increment() {
+ return ++count;
+ }
+
+ public int reset() {
+ return (count = 0);
+ }
+ }
+
+## ExecutionChannel
+
+ package org.superbiz.counter;
+
+ import java.util.ArrayList;
+ import java.util.List;
+
+ public class ExecutionChannel {
+ private static final ExecutionChannel INSTANCE = new ExecutionChannel();
+
+ private final List<ExecutionObserver> observers = new ArrayList<ExecutionObserver>();
+
+ public static ExecutionChannel getInstance() {
+ return INSTANCE;
+ }
+
+ public void addObserver(ExecutionObserver observer) {
+ this.observers.add(observer);
+ }
+
+ public void notifyObservers(Object value) {
+ for (ExecutionObserver observer : this.observers) {
+ observer.onExecution(value);
+ }
+ }
+ }
+
+## ExecutionObserver
+
+ package org.superbiz.counter;
+
+ public interface ExecutionObserver {
+
+ void onExecution(Object value);
+
+ }
+
+## CounterCallbacksTest
+
+ package org.superbiz.counter;
+
+ import junit.framework.Assert;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.naming.NamingException;
+ import java.util.*;
+
+ public class CounterCallbacksTest implements ExecutionObserver {
+ private static List<Object> received = new ArrayList<Object>();
+
+ public Context getContext() throws NamingException {
+ final Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ return new InitialContext(p);
+
+ }
+
+ @Test
+ public void test() throws Exception {
+ final Map<String, Object> p = new HashMap<String, Object>();
+ p.put("MySTATEFUL", "new://Container?type=STATEFUL");
+ p.put("MySTATEFUL.Capacity", "2"); //How many instances of Stateful beans can our server hold in memory?
+ p.put("MySTATEFUL.Frequency", "1"); //Interval in seconds between checks
+ p.put("MySTATEFUL.BulkPassivate", "0"); //No bulkPassivate - just passivate entities whenever it is needed
+ final EJBContainer container = EJBContainer.createEJBContainer(p);
+
+ //this is going to track the execution
+ ExecutionChannel.getInstance().addObserver(this);
+
+ {
+ final Context context = getContext();
+
+ CallbackCounter counterA = (CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter");
+ Assert.assertNotNull(counterA);
+ Assert.assertEquals("postConstruct", received.remove(0));
+
+ Assert.assertEquals(0, counterA.count());
+ Assert.assertEquals("count", received.remove(0));
+
+ Assert.assertEquals(1, counterA.increment());
+ Assert.assertEquals("increment", received.remove(0));
+
+ Assert.assertEquals(0, counterA.reset());
+ Assert.assertEquals("reset", received.remove(0));
+
+ Assert.assertEquals(1, counterA.increment());
+ Assert.assertEquals("increment", received.remove(0));
+
+ System.out.println("Waiting 2 seconds...");
+ Thread.sleep(2000);
+
+ Assert.assertEquals("preDestroy", received.remove(0));
+
+ try {
+ counterA.increment();
+ Assert.fail("The ejb is not supposed to be there.");
+ } catch (javax.ejb.NoSuchEJBException e) {
+ //excepted
+ }
+
+ context.close();
+ }
+
+ {
+ final Context context = getContext();
+
+ CallbackCounter counterA = (CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter");
+ Assert.assertEquals("postConstruct", received.remove(0));
+
+ Assert.assertEquals(1, counterA.increment());
+ Assert.assertEquals("increment", received.remove(0));
+
+ ((CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter")).count();
+ Assert.assertEquals("postConstruct", received.remove(0));
+ Assert.assertEquals("count", received.remove(0));
+
+ ((CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter")).count();
+ Assert.assertEquals("postConstruct", received.remove(0));
+ Assert.assertEquals("count", received.remove(0));
+
+ System.out.println("Waiting 2 seconds...");
+ Thread.sleep(2000);
+ Assert.assertEquals("prePassivate", received.remove(0));
+
+ context.close();
+ }
+ container.close();
+
+ Assert.assertEquals("preDestroy", received.remove(0));
+ Assert.assertEquals("preDestroy", received.remove(0));
+
+ Assert.assertTrue(received.toString(), received.isEmpty());
+ }
+
+ @Override
+ public void onExecution(Object value) {
+ System.out.println("Test step -> " + value);
+ received.add(value);
+ }
+ }
+
+# Running
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.counter.CounterCallbacksTest
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://openejb.apache.org/
+ INFO - Startup: Sat Jul 21 08:18:28 EDT 2012
+ INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 4.1.0
+ INFO - Build date: 20120721
+ INFO - Build time: 04:06
+ INFO - ********************************************************************************
+ INFO - openejb.home = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+ INFO - openejb.base = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+ INFO - Succeeded in installing singleton service
+ 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 - Configuring Service(id=MySTATEFUL, type=Container, provider-id=Default Stateful Container)
+ INFO - Creating TransactionManager(id=Default Transaction Manager)
+ INFO - Creating SecurityService(id=Default Security Service)
+ INFO - Creating Container(id=MySTATEFUL)
+ INFO - Using directory /tmp for stateful session passivation
+ INFO - Beginning load: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks/target/classes
+ INFO - Configuring enterprise application: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+ INFO - Auto-deploying ejb CallbackCounter: EjbDeployment(deployment-id=CallbackCounter)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.counter.CounterCallbacksTest: 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/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks" loaded.
+ INFO - Assembling app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+ INFO - Jndi(name="java:global/simple-stateful-callbacks/CallbackCounter!org.superbiz.counter.CallbackCounter")
+ INFO - Jndi(name="java:global/simple-stateful-callbacks/CallbackCounter")
+ INFO - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 225 ms.
+ INFO - Created Ejb(deployment-id=CallbackCounter, ejb-name=CallbackCounter, container=MySTATEFUL)
+ INFO - Started Ejb(deployment-id=CallbackCounter, ejb-name=CallbackCounter, container=MySTATEFUL)
+ INFO - Deployed Application(path=/home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks)
+ Test step -> postConstruct
+ Test step -> count
+ Test step -> increment
+ Test step -> reset
+ Test step -> increment
+ Waiting 2 seconds...
+ Test step -> preDestroy
+ INFO - Removing the timed-out stateful session bean instance 583c10bfdbd326ba:57f94a9b:138a9798adf:-8000
+ INFO - Activation failed: file not found /tmp/583c10bfdbd326ba=57f94a9b=138a9798adf=-8000
+ Test step -> postConstruct
+ Test step -> increment
+ Test step -> postConstruct
+ Test step -> count
+ Test step -> postConstruct
+ Test step -> count
+ Waiting 2 seconds...
+ Test step -> prePassivate
+ INFO - Passivating to file /tmp/583c10bfdbd326ba=57f94a9b=138a9798adf=-7fff
+ Test step -> preDestroy
+ INFO - Removing the timed-out stateful session bean instance 583c10bfdbd326ba:57f94a9b:138a9798adf:-7ffe
+ Test step -> preDestroy
+ INFO - Removing the timed-out stateful session bean instance 583c10bfdbd326ba:57f94a9b:138a9798adf:-7ffd
+ INFO - Undeploying app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateful-callbacks
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.487 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+ [INFO] ------------------------------------------------------------------------
+ [INFO] BUILD SUCCESS
+ [INFO] ------------------------------------------------------------------------
+ [INFO] Total time: 15.803s
+ [INFO] Finished at: Sat Jul 21 08:18:35 EDT 2012
+ [INFO] Final Memory: 11M/247M
+ [INFO] ------------------------------------------------------------------------
+
+
diff --git a/content/examples/simple-stateful-callbacks/build.xml b/content/examples/simple-stateful-callbacks/build.xml
new file mode 100755
index 0000000..65fda54
--- /dev/null
+++ b/content/examples/simple-stateful-callbacks/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 19:48:17 -0500 (Sun, 29 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-stateful-callbacks/pom.xml b/content/examples/simple-stateful-callbacks/pom.xml
new file mode 100755
index 0000000..d3d8556
--- /dev/null
+++ b/content/examples/simple-stateful-callbacks/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1346534 $ $Date: 2012-06-05 14:57:54 -0400 (Tue, 05 Jun 2012) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-stateful-callbacks</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple Stateful Pojo Callbacks</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/simple-stateful-callbacks/src/main/java/org/superbiz/counter/CallbackCounter.java b/content/examples/simple-stateful-callbacks/src/main/java/org/superbiz/counter/CallbackCounter.java
new file mode 100755
index 0000000..8c8b53d
--- /dev/null
+++ b/content/examples/simple-stateful-callbacks/src/main/java/org/superbiz/counter/CallbackCounter.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.counter;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Stateful;
+import javax.ejb.StatefulTimeout;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+import java.util.concurrent.TimeUnit;
+
+@Stateful
+@StatefulTimeout(value = 1, unit = TimeUnit.SECONDS)
+public class CallbackCounter implements Serializable {
+
+ private int count = 0;
+
+ @PrePassivate
+ public void prePassivate() {
+ ExecutionChannel.getInstance().notifyObservers("prePassivate");
+ }
+
+ @PostActivate
+ public void postActivate() {
+ ExecutionChannel.getInstance().notifyObservers("postActivate");
+ }
+
+ @PostConstruct
+ public void postConstruct() {
+ ExecutionChannel.getInstance().notifyObservers("postConstruct");
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ ExecutionChannel.getInstance().notifyObservers("preDestroy");
+ }
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ ExecutionChannel.getInstance().notifyObservers(ctx.getMethod().getName());
+ return ctx.proceed();
+ }
+
+ public int count() {
+ return count;
+ }
+
+ public int increment() {
+ return ++count;
+ }
+
+ public int reset() {
+ return (count = 0);
+ }
+}
diff --git a/content/examples/simple-stateful-callbacks/src/main/java/org/superbiz/counter/ExecutionChannel.java b/content/examples/simple-stateful-callbacks/src/main/java/org/superbiz/counter/ExecutionChannel.java
new file mode 100755
index 0000000..601ccab
--- /dev/null
+++ b/content/examples/simple-stateful-callbacks/src/main/java/org/superbiz/counter/ExecutionChannel.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.counter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExecutionChannel {
+
+ private static final ExecutionChannel INSTANCE = new ExecutionChannel();
+
+ private final List<ExecutionObserver> observers = new ArrayList<ExecutionObserver>();
+
+ public static ExecutionChannel getInstance() {
+ return INSTANCE;
+ }
+
+ public void addObserver(ExecutionObserver observer) {
+ this.observers.add(observer);
+ }
+
+ public void notifyObservers(Object value) {
+ for (ExecutionObserver observer : this.observers) {
+ observer.onExecution(value);
+ }
+ }
+}
diff --git a/content/examples/simple-stateful-callbacks/src/main/java/org/superbiz/counter/ExecutionObserver.java b/content/examples/simple-stateful-callbacks/src/main/java/org/superbiz/counter/ExecutionObserver.java
new file mode 100755
index 0000000..e4a6614
--- /dev/null
+++ b/content/examples/simple-stateful-callbacks/src/main/java/org/superbiz/counter/ExecutionObserver.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.counter;
+
+public interface ExecutionObserver {
+
+ void onExecution(Object value);
+
+}
diff --git a/content/examples/simple-stateful-callbacks/src/test/java/org/superbiz/counter/CounterCallbacksTest.java b/content/examples/simple-stateful-callbacks/src/test/java/org/superbiz/counter/CounterCallbacksTest.java
new file mode 100755
index 0000000..1701a52
--- /dev/null
+++ b/content/examples/simple-stateful-callbacks/src/test/java/org/superbiz/counter/CounterCallbacksTest.java
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.counter;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+public class CounterCallbacksTest implements ExecutionObserver {
+
+ private List<Object> received = new ArrayList<Object>();
+
+ public Context getContext() throws NamingException {
+ final Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ return new InitialContext(p);
+
+ }
+
+ @Test
+ public void test() throws Exception {
+ final Map<String, Object> p = new HashMap<String, Object>();
+ p.put("MySTATEFUL", "new://Container?type=STATEFUL");
+ p.put("MySTATEFUL.Capacity", "2"); //How many instances of Stateful beans can our server hold in memory?
+ p.put("MySTATEFUL.Frequency", "1"); //Interval in seconds between checks
+ p.put("MySTATEFUL.BulkPassivate", "0"); //No bulkPassivate - just passivate entities whenever it is needed
+ final EJBContainer container = EJBContainer.createEJBContainer(p);
+
+ //this is going to track the execution
+ ExecutionChannel.getInstance().addObserver(this);
+
+ {
+ final Context context = getContext();
+
+ CallbackCounter counterA = (CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter");
+ Assert.assertNotNull(counterA);
+ Assert.assertEquals("postConstruct", this.received.remove(0));
+
+ Assert.assertEquals(0, counterA.count());
+ Assert.assertEquals("count", this.received.remove(0));
+
+ Assert.assertEquals(1, counterA.increment());
+ Assert.assertEquals("increment", this.received.remove(0));
+
+ Assert.assertEquals(0, counterA.reset());
+ Assert.assertEquals("reset", this.received.remove(0));
+
+ Assert.assertEquals(1, counterA.increment());
+ Assert.assertEquals("increment", this.received.remove(0));
+
+ System.out.println("Waiting 2 seconds...");
+ Thread.sleep(2000);
+
+ Assert.assertEquals("preDestroy", this.received.remove(0));
+
+ try {
+ counterA.increment();
+ Assert.fail("The ejb is not supposed to be there.");
+ } catch (javax.ejb.NoSuchEJBException e) {
+ //excepted
+ }
+
+ context.close();
+ }
+
+ {
+ final Context context = getContext();
+
+ CallbackCounter counterA = (CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter");
+ Assert.assertEquals("postConstruct", this.received.remove(0));
+
+ Assert.assertEquals(1, counterA.increment());
+ Assert.assertEquals("increment", this.received.remove(0));
+
+ ((CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter")).count();
+ Assert.assertEquals("postConstruct", this.received.remove(0));
+ Assert.assertEquals("count", this.received.remove(0));
+
+ ((CallbackCounter) context.lookup("java:global/simple-stateful-callbacks/CallbackCounter")).count();
+ Assert.assertEquals("postConstruct", this.received.remove(0));
+ Assert.assertEquals("count", this.received.remove(0));
+
+ System.out.println("Waiting 2 seconds...");
+ Thread.sleep(2000);
+ Assert.assertEquals("prePassivate", this.received.remove(0));
+
+ context.close();
+ }
+ container.close();
+
+ Assert.assertEquals("preDestroy", this.received.remove(0));
+ Assert.assertEquals("preDestroy", this.received.remove(0));
+
+ Assert.assertTrue(this.received.toString(), this.received.isEmpty());
+ }
+
+ @Override
+ public void onExecution(Object value) {
+ System.out.println("Test step -> " + value);
+ this.received.add(value);
+ }
+}
diff --git a/content/examples/simple-stateful.html b/content/examples/simple-stateful.html
new file mode 100644
index 0000000..c551e11
--- /dev/null
+++ b/content/examples/simple-stateful.html
@@ -0,0 +1,356 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-stateful.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple Stateful</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-stateful can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-stateful" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-stateful</a></p>
+</div>
+<div class="paragraph">
+<p>This example demonstrates a simple deployment of a Stateful session bean.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+"As its name suggests, a stateful session bean is similar to an interactive session. A stateful session bean is not shared;
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>it can have only one client, in the same way that an interactive session can have only one user.
+When the client terminates, its stateful session bean appears to terminate and is no longer associated with the client."</p>
+</div>
+<div class="paragraph">
+<p>The <code>Counter</code> class is a Stateful session bean that maintains a state in a form of a <code>count</code> integer field.
+It exposes three methods: <code>count()</code>, <code>increment()</code> and <code>reset()</code> to manipulate and view its state.</p>
+</div>
+<div class="paragraph">
+<p>Typically, Stateful and Stateless beans implement Local and/or Remote interfaces to determine which methods should
+be exposed. In this case, the bean is using a no-interface view, which means that all public methods are exposed
+as a local view.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_counter">Counter</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.counter;
+
+import javax.ejb.Stateful;
+
+/**
+ * This is an EJB 3 style pojo stateful session bean
+ * Every stateful session bean implementation must be annotated
+ * using the annotation @Stateful
+ * This EJB has 2 business interfaces: CounterRemote, a remote business
+ * interface, and CounterLocal, a local business interface
+ * <p/>
+ * Per EJB3 rules when the @Remote or @Local annotation isn't present
+ * in the bean class (this class), all interfaces are considered
+ * local unless explicitly annotated otherwise. If you look
+ * in the CounterRemote interface, you'll notice it uses the @Remote
+ * annotation while the CounterLocal interface is not annotated relying
+ * on the EJB3 default rules to make it a local interface.
+ */
+//START SNIPPET: code
+@Stateful
+public class Counter {
+
+ private int count = 0;
+
+ public int count() {
+ return count;
+ }
+
+ public int increment() {
+ return ++count;
+ }
+
+ public int reset() {
+ return (count = 0);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_countertest">CounterTest</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The <code>Counter</code> class is tested by obtaining a <code>Context</code> object and performing a JNDI lookup on it, to retrieve
+an instance of the <code>Counter</code> bean. After some state manipulation, a new instance is fetched from the container
+and we can see that it’s a new instance.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.counter;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+public class CounterTest extends TestCase {
+
+ //START SNIPPET: local
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ Counter counterA = (Counter) context.lookup("java:global/simple-stateful/Counter");
+
+ assertEquals(0, counterA.count());
+ assertEquals(0, counterA.reset());
+ assertEquals(1, counterA.increment());
+ assertEquals(2, counterA.increment());
+ assertEquals(0, counterA.reset());
+
+ counterA.increment();
+ counterA.increment();
+ counterA.increment();
+ counterA.increment();
+
+ assertEquals(4, counterA.count());
+
+ // Get a new counter
+ Counter counterB = (Counter) context.lookup("java:global/simple-stateful/Counter");
+
+ // The new bean instance starts out at 0
+ assertEquals(0, counterB.count());
+ }
+ //END SNIPPET: local
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.counter.CounterTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/simple-stateful
+INFO - openejb.base = /Users/dblevins/examples/simple-stateful
+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/simple-stateful/target/classes
+INFO - Beginning load: /Users/dblevins/examples/simple-stateful/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/simple-stateful
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Counter: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.counter.CounterTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/simple-stateful" loaded.
+INFO - Assembling app: /Users/dblevins/examples/simple-stateful
+INFO - Jndi(name="java:global/simple-stateful/Counter!org.superbiz.counter.Counter")
+INFO - Jndi(name="java:global/simple-stateful/Counter")
+INFO - Jndi(name="java:global/EjbModule309142400/org.superbiz.counter.CounterTest!org.superbiz.counter.CounterTest")
+INFO - Jndi(name="java:global/EjbModule309142400/org.superbiz.counter.CounterTest")
+INFO - Created Ejb(deployment-id=Counter, ejb-name=Counter, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.counter.CounterTest, ejb-name=org.superbiz.counter.CounterTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Counter, ejb-name=Counter, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.counter.CounterTest, ejb-name=org.superbiz.counter.CounterTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/simple-stateful)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.098 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-stateful.pdf b/content/examples/simple-stateful.pdf
new file mode 100644
index 0000000..ebf8935
--- /dev/null
+++ b/content/examples/simple-stateful.pdf
Binary files differ
diff --git a/content/examples/simple-stateful/README.md b/content/examples/simple-stateful/README.md
new file mode 100755
index 0000000..f9203ab
--- /dev/null
+++ b/content/examples/simple-stateful/README.md
@@ -0,0 +1,136 @@
+Title: Simple Stateful
+
+This example demonstrates a simple deployment of a Stateful session bean.
+
+>"As its name suggests, a stateful session bean is similar to an interactive session. A stateful session bean is not shared;
+it can have only one client, in the same way that an interactive session can have only one user.
+When the client terminates, its stateful session bean appears to terminate and is no longer associated with the client."
+
+The `Counter` class is a Stateful session bean that maintains a state in a form of a `count` integer field.
+It exposes three methods: `count()`, `increment()` and `reset()` to manipulate and view its state.
+
+Typically, Stateful and Stateless beans implement Local and/or Remote interfaces to determine which methods should
+be exposed. In this case, the bean is using a no-interface view, which means that all public methods are exposed
+as a local view.
+
+## Counter
+
+ package org.superbiz.counter;
+
+ import javax.ejb.Stateful;
+
+ /**
+ * This is an EJB 3 style pojo stateful session bean
+ * Every stateful session bean implementation must be annotated
+ * using the annotation @Stateful
+ * This EJB has 2 business interfaces: CounterRemote, a remote business
+ * interface, and CounterLocal, a local business interface
+ * <p/>
+ * Per EJB3 rules when the @Remote or @Local annotation isn't present
+ * in the bean class (this class), all interfaces are considered
+ * local unless explicitly annotated otherwise. If you look
+ * in the CounterRemote interface, you'll notice it uses the @Remote
+ * annotation while the CounterLocal interface is not annotated relying
+ * on the EJB3 default rules to make it a local interface.
+ */
+ //START SNIPPET: code
+ @Stateful
+ public class Counter {
+
+ private int count = 0;
+
+ public int count() {
+ return count;
+ }
+
+ public int increment() {
+ return ++count;
+ }
+
+ public int reset() {
+ return (count = 0);
+ }
+ }
+
+## CounterTest
+
+The `Counter` class is tested by obtaining a `Context` object and performing a JNDI lookup on it, to retrieve
+an instance of the `Counter` bean. After some state manipulation, a new instance is fetched from the container
+and we can see that it's a new instance.
+
+ package org.superbiz.counter;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+
+ public class CounterTest extends TestCase {
+
+ //START SNIPPET: local
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ Counter counterA = (Counter) context.lookup("java:global/simple-stateful/Counter");
+
+ assertEquals(0, counterA.count());
+ assertEquals(0, counterA.reset());
+ assertEquals(1, counterA.increment());
+ assertEquals(2, counterA.increment());
+ assertEquals(0, counterA.reset());
+
+ counterA.increment();
+ counterA.increment();
+ counterA.increment();
+ counterA.increment();
+
+ assertEquals(4, counterA.count());
+
+ // Get a new counter
+ Counter counterB = (Counter) context.lookup("java:global/simple-stateful/Counter");
+
+ // The new bean instance starts out at 0
+ assertEquals(0, counterB.count());
+ }
+ //END SNIPPET: local
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.counter.CounterTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/simple-stateful
+ INFO - openejb.base = /Users/dblevins/examples/simple-stateful
+ 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/simple-stateful/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/simple-stateful/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/simple-stateful
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Counter: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.counter.CounterTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/examples/simple-stateful" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/simple-stateful
+ INFO - Jndi(name="java:global/simple-stateful/Counter!org.superbiz.counter.Counter")
+ INFO - Jndi(name="java:global/simple-stateful/Counter")
+ INFO - Jndi(name="java:global/EjbModule309142400/org.superbiz.counter.CounterTest!org.superbiz.counter.CounterTest")
+ INFO - Jndi(name="java:global/EjbModule309142400/org.superbiz.counter.CounterTest")
+ INFO - Created Ejb(deployment-id=Counter, ejb-name=Counter, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.counter.CounterTest, ejb-name=org.superbiz.counter.CounterTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Counter, ejb-name=Counter, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.counter.CounterTest, ejb-name=org.superbiz.counter.CounterTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/simple-stateful)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.098 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/simple-stateful/build.xml b/content/examples/simple-stateful/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/simple-stateful/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-stateful/pom.xml b/content/examples/simple-stateful/pom.xml
new file mode 100755
index 0000000..e56bfc4
--- /dev/null
+++ b/content/examples/simple-stateful/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-stateful</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple Stateful Pojo</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/simple-stateful/src/main/java/org/superbiz/counter/Counter.java b/content/examples/simple-stateful/src/main/java/org/superbiz/counter/Counter.java
new file mode 100755
index 0000000..cee4fe0
--- /dev/null
+++ b/content/examples/simple-stateful/src/main/java/org/superbiz/counter/Counter.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.counter;
+
+import javax.ejb.Stateful;
+
+/**
+ * This is an EJB 3 style pojo stateful session bean
+ * Every stateful session bean implementation must be annotated
+ * using the annotation @Stateful
+ * This EJB has 2 business interfaces: CounterRemote, a remote business
+ * interface, and CounterLocal, a local business interface
+ * <p/>
+ * Per EJB3 rules when the @Remote or @Local annotation isn't present
+ * in the bean class (this class), all interfaces are considered
+ * local unless explicitly annotated otherwise. If you look
+ * in the CounterRemote interface, you'll notice it uses the @Remote
+ * annotation while the CounterLocal interface is not annotated relying
+ * on the EJB3 default rules to make it a local interface.
+ */
+//START SNIPPET: code
+@Stateful
+public class Counter {
+
+ private int count = 0;
+
+ public int count() {
+ return count;
+ }
+
+ public int increment() {
+ return ++count;
+ }
+
+ public int reset() {
+ return (count = 0);
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-stateful/src/test/java/org/superbiz/counter/CounterTest.java b/content/examples/simple-stateful/src/test/java/org/superbiz/counter/CounterTest.java
new file mode 100755
index 0000000..6511821
--- /dev/null
+++ b/content/examples/simple-stateful/src/test/java/org/superbiz/counter/CounterTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.counter;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+public class CounterTest extends TestCase {
+
+ //START SNIPPET: local
+ public void test() throws Exception {
+
+ final Context context = EJBContainer.createEJBContainer().getContext();
+
+ Counter counterA = (Counter) context.lookup("java:global/simple-stateful/Counter");
+
+ assertEquals(0, counterA.count());
+ assertEquals(0, counterA.reset());
+ assertEquals(1, counterA.increment());
+ assertEquals(2, counterA.increment());
+ assertEquals(0, counterA.reset());
+
+ counterA.increment();
+ counterA.increment();
+ counterA.increment();
+ counterA.increment();
+
+ assertEquals(4, counterA.count());
+
+ // Get a new counter
+ Counter counterB = (Counter) context.lookup("java:global/simple-stateful/Counter");
+
+ // The new bean instance starts out at 0
+ assertEquals(0, counterB.count());
+ }
+ //END SNIPPET: local
+
+}
diff --git a/content/examples/simple-stateless-callbacks.html b/content/examples/simple-stateless-callbacks.html
new file mode 100644
index 0000000..1bd6de6
--- /dev/null
+++ b/content/examples/simple-stateless-callbacks.html
@@ -0,0 +1,446 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-stateless-callbacks.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple Stateless with callback methods</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-stateless-callbacks can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-stateless-callbacks" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-stateless-callbacks</a></p>
+</div>
+<div class="paragraph">
+<p>This example shows how to create a stateless session bean that uses the @PostConstruct, @PreDestroy and @AroundInvoke annotations.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorbean">CalculatorBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.stateless.basic;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+@Stateless
+public class CalculatorBean {
+
+ @PostConstruct
+ public void postConstruct() {
+ ExecutionChannel.getInstance().notifyObservers("postConstruct");
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ ExecutionChannel.getInstance().notifyObservers("preDestroy");
+ }
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ ExecutionChannel.getInstance().notifyObservers(ctx.getMethod().getName());
+ return ctx.proceed();
+ }
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_executionchannel">ExecutionChannel</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.counter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExecutionChannel {
+ private static final ExecutionChannel INSTANCE = new ExecutionChannel();
+
+ private final List<ExecutionObserver> observers = new ArrayList<ExecutionObserver>();
+
+ public static ExecutionChannel getInstance() {
+ return INSTANCE;
+ }
+
+ public void addObserver(ExecutionObserver observer) {
+ this.observers.add(observer);
+ }
+
+ public void notifyObservers(Object value) {
+ for (ExecutionObserver observer : this.observers) {
+ observer.onExecution(value);
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_executionobserver">ExecutionObserver</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.counter;
+
+public interface ExecutionObserver {
+
+ void onExecution(Object value);
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatortest">CalculatorTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.stateless.basic;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+public class CalculatorTest implements ExecutionObserver {
+ private static final String JNDI = "java:global/simple-stateless-callbacks/CalculatorBean";
+
+ private List<Object> received = new ArrayList<Object>();
+
+ public Context getContext() throws NamingException {
+ final Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ return new InitialContext(p);
+
+ }
+
+ @Test
+ public void test() throws Exception {
+ ExecutionChannel.getInstance().addObserver(this);
+
+ final EJBContainer container = EJBContainer.createEJBContainer();
+
+ {
+ final CalculatorBean calculator = (CalculatorBean) getContext().lookup(JNDI);
+
+ Assert.assertEquals(10, calculator.add(4, 6));
+
+ //the bean is constructed only when it is used for the first time
+ Assert.assertEquals("postConstruct", this.received.remove(0));
+ Assert.assertEquals("add", this.received.remove(0));
+
+ Assert.assertEquals(-2, calculator.subtract(4, 6));
+ Assert.assertEquals("subtract", this.received.remove(0));
+
+ Assert.assertEquals(24, calculator.multiply(4, 6));
+ Assert.assertEquals("multiply", this.received.remove(0));
+
+ Assert.assertEquals(2, calculator.divide(12, 6));
+ Assert.assertEquals("divide", this.received.remove(0));
+
+ Assert.assertEquals(4, calculator.remainder(46, 6));
+ Assert.assertEquals("remainder", this.received.remove(0));
+ }
+
+ {
+ final CalculatorBean calculator = (CalculatorBean) getContext().lookup(JNDI);
+
+ Assert.assertEquals(10, calculator.add(4, 6));
+ Assert.assertEquals("add", this.received.remove(0));
+
+ }
+
+ container.close();
+ Assert.assertEquals("preDestroy", this.received.remove(0));
+ Assert.assertTrue(this.received.isEmpty());
+ }
+
+ @Override
+ public void onExecution(Object value) {
+ System.out.println("Test step -> " + value);
+ this.received.add(value);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.stateless.basic.CalculatorTest
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Sat Jul 21 09:23:38 EDT 2012
+INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 4.1.0
+INFO - Build date: 20120721
+INFO - Build time: 04:06
+INFO - ********************************************************************************
+INFO - openejb.home = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+INFO - openejb.base = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+INFO - Succeeded in installing singleton service
+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 - Beginning load: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks/target/classes
+INFO - Configuring enterprise application: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+INFO - Auto-deploying ejb CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Creating Container(id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.stateless.basic.CalculatorTest: 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/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks" loaded.
+INFO - Assembling app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+INFO - Jndi(name="java:global/simple-stateless-callbacks/CalculatorBean!org.superbiz.stateless.basic.CalculatorBean")
+INFO - Jndi(name="java:global/simple-stateless-callbacks/CalculatorBean")
+INFO - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 111 ms.
+INFO - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+INFO - Deployed Application(path=/home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks)
+Test step -> postConstruct
+Test step -> add
+Test step -> subtract
+Test step -> multiply
+Test step -> divide
+Test step -> remainder
+Test step -> add
+INFO - Undeploying app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+Test step -> preDestroy
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.884 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-stateless-callbacks.pdf b/content/examples/simple-stateless-callbacks.pdf
new file mode 100644
index 0000000..d598e0a
--- /dev/null
+++ b/content/examples/simple-stateless-callbacks.pdf
Binary files differ
diff --git a/content/examples/simple-stateless-callbacks/README.md b/content/examples/simple-stateless-callbacks/README.md
new file mode 100755
index 0000000..d9a5530
--- /dev/null
+++ b/content/examples/simple-stateless-callbacks/README.md
@@ -0,0 +1,228 @@
+Title: Simple Stateless with callback methods
+
+This example shows how to create a stateless session bean that uses the @PostConstruct, @PreDestroy and @AroundInvoke annotations.
+
+## CalculatorBean
+
+ package org.superbiz.stateless.basic;
+
+ import javax.annotation.PostConstruct;
+ import javax.annotation.PreDestroy;
+ import javax.ejb.Stateless;
+ import javax.interceptor.AroundInvoke;
+ import javax.interceptor.InvocationContext;
+
+ @Stateless
+ public class CalculatorBean {
+
+ @PostConstruct
+ public void postConstruct() {
+ ExecutionChannel.getInstance().notifyObservers("postConstruct");
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ ExecutionChannel.getInstance().notifyObservers("preDestroy");
+ }
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ ExecutionChannel.getInstance().notifyObservers(ctx.getMethod().getName());
+ return ctx.proceed();
+ }
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+
+ }
+
+## ExecutionChannel
+
+ package org.superbiz.counter;
+
+ import java.util.ArrayList;
+ import java.util.List;
+
+ public class ExecutionChannel {
+ private static final ExecutionChannel INSTANCE = new ExecutionChannel();
+
+ private final List<ExecutionObserver> observers = new ArrayList<ExecutionObserver>();
+
+ public static ExecutionChannel getInstance() {
+ return INSTANCE;
+ }
+
+ public void addObserver(ExecutionObserver observer) {
+ this.observers.add(observer);
+ }
+
+ public void notifyObservers(Object value) {
+ for (ExecutionObserver observer : this.observers) {
+ observer.onExecution(value);
+ }
+ }
+ }
+
+## ExecutionObserver
+
+ package org.superbiz.counter;
+
+ public interface ExecutionObserver {
+
+ void onExecution(Object value);
+
+ }
+
+
+## CalculatorTest
+
+ package org.superbiz.stateless.basic;
+
+ import org.junit.Assert;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.naming.NamingException;
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Properties;
+
+ public class CalculatorTest implements ExecutionObserver {
+ private static final String JNDI = "java:global/simple-stateless-callbacks/CalculatorBean";
+
+ private List<Object> received = new ArrayList<Object>();
+
+ public Context getContext() throws NamingException {
+ final Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ return new InitialContext(p);
+
+ }
+
+ @Test
+ public void test() throws Exception {
+ ExecutionChannel.getInstance().addObserver(this);
+
+ final EJBContainer container = EJBContainer.createEJBContainer();
+
+ {
+ final CalculatorBean calculator = (CalculatorBean) getContext().lookup(JNDI);
+
+ Assert.assertEquals(10, calculator.add(4, 6));
+
+ //the bean is constructed only when it is used for the first time
+ Assert.assertEquals("postConstruct", this.received.remove(0));
+ Assert.assertEquals("add", this.received.remove(0));
+
+ Assert.assertEquals(-2, calculator.subtract(4, 6));
+ Assert.assertEquals("subtract", this.received.remove(0));
+
+ Assert.assertEquals(24, calculator.multiply(4, 6));
+ Assert.assertEquals("multiply", this.received.remove(0));
+
+ Assert.assertEquals(2, calculator.divide(12, 6));
+ Assert.assertEquals("divide", this.received.remove(0));
+
+ Assert.assertEquals(4, calculator.remainder(46, 6));
+ Assert.assertEquals("remainder", this.received.remove(0));
+ }
+
+ {
+ final CalculatorBean calculator = (CalculatorBean) getContext().lookup(JNDI);
+
+ Assert.assertEquals(10, calculator.add(4, 6));
+ Assert.assertEquals("add", this.received.remove(0));
+
+ }
+
+ container.close();
+ Assert.assertEquals("preDestroy", this.received.remove(0));
+ Assert.assertTrue(this.received.isEmpty());
+ }
+
+ @Override
+ public void onExecution(Object value) {
+ System.out.println("Test step -> " + value);
+ this.received.add(value);
+ }
+ }
+
+# Running
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.stateless.basic.CalculatorTest
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://openejb.apache.org/
+ INFO - Startup: Sat Jul 21 09:23:38 EDT 2012
+ INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 4.1.0
+ INFO - Build date: 20120721
+ INFO - Build time: 04:06
+ INFO - ********************************************************************************
+ INFO - openejb.home = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+ INFO - openejb.base = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+ INFO - Succeeded in installing singleton service
+ 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 - Beginning load: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks/target/classes
+ INFO - Configuring enterprise application: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+ INFO - Auto-deploying ejb CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Creating Container(id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.stateless.basic.CalculatorTest: 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/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks" loaded.
+ INFO - Assembling app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+ INFO - Jndi(name="java:global/simple-stateless-callbacks/CalculatorBean!org.superbiz.stateless.basic.CalculatorBean")
+ INFO - Jndi(name="java:global/simple-stateless-callbacks/CalculatorBean")
+ INFO - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 111 ms.
+ INFO - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+ INFO - Deployed Application(path=/home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks)
+ Test step -> postConstruct
+ Test step -> add
+ Test step -> subtract
+ Test step -> multiply
+ Test step -> divide
+ Test step -> remainder
+ Test step -> add
+ INFO - Undeploying app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+ Test step -> preDestroy
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.884 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
diff --git a/content/examples/simple-stateless-callbacks/build.xml b/content/examples/simple-stateless-callbacks/build.xml
new file mode 100755
index 0000000..65fda54
--- /dev/null
+++ b/content/examples/simple-stateless-callbacks/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 19:48:17 -0500 (Sun, 29 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-stateless-callbacks/pom.xml b/content/examples/simple-stateless-callbacks/pom.xml
new file mode 100755
index 0000000..93ccbdf
--- /dev/null
+++ b/content/examples/simple-stateless-callbacks/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1346534 $ $Date: 2012-06-05 14:57:54 -0400 (Tue, 05 Jun 2012) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-stateless-callbacks</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple Stateless Pojo Callbacks</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/simple-stateless-callbacks/src/main/java/org/superbiz/stateless/basic/CalculatorBean.java b/content/examples/simple-stateless-callbacks/src/main/java/org/superbiz/stateless/basic/CalculatorBean.java
new file mode 100755
index 0000000..cc85fdb
--- /dev/null
+++ b/content/examples/simple-stateless-callbacks/src/main/java/org/superbiz/stateless/basic/CalculatorBean.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.stateless.basic;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+@Stateless
+public class CalculatorBean {
+
+ @PostConstruct
+ public void postConstruct() {
+ ExecutionChannel.getInstance().notifyObservers("postConstruct");
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ ExecutionChannel.getInstance().notifyObservers("preDestroy");
+ }
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ ExecutionChannel.getInstance().notifyObservers(ctx.getMethod().getName());
+ return ctx.proceed();
+ }
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+
+}
\ No newline at end of file
diff --git a/content/examples/simple-stateless-callbacks/src/main/java/org/superbiz/stateless/basic/ExecutionChannel.java b/content/examples/simple-stateless-callbacks/src/main/java/org/superbiz/stateless/basic/ExecutionChannel.java
new file mode 100755
index 0000000..5c078cf
--- /dev/null
+++ b/content/examples/simple-stateless-callbacks/src/main/java/org/superbiz/stateless/basic/ExecutionChannel.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.stateless.basic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExecutionChannel {
+
+ private static final ExecutionChannel INSTANCE = new ExecutionChannel();
+
+ private final List<ExecutionObserver> observers = new ArrayList<ExecutionObserver>();
+
+ public static ExecutionChannel getInstance() {
+ return INSTANCE;
+ }
+
+ public void addObserver(ExecutionObserver observer) {
+ this.observers.add(observer);
+ }
+
+ public void notifyObservers(Object value) {
+ for (ExecutionObserver observer : this.observers) {
+ observer.onExecution(value);
+ }
+ }
+}
diff --git a/content/examples/simple-stateless-callbacks/src/main/java/org/superbiz/stateless/basic/ExecutionObserver.java b/content/examples/simple-stateless-callbacks/src/main/java/org/superbiz/stateless/basic/ExecutionObserver.java
new file mode 100755
index 0000000..ee2a644
--- /dev/null
+++ b/content/examples/simple-stateless-callbacks/src/main/java/org/superbiz/stateless/basic/ExecutionObserver.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.stateless.basic;
+
+public interface ExecutionObserver {
+
+ void onExecution(Object value);
+
+}
diff --git a/content/examples/simple-stateless-callbacks/src/test/java/org/superbiz/stateless/basic/CalculatorTest.java b/content/examples/simple-stateless-callbacks/src/test/java/org/superbiz/stateless/basic/CalculatorTest.java
new file mode 100755
index 0000000..a42fe8e
--- /dev/null
+++ b/content/examples/simple-stateless-callbacks/src/test/java/org/superbiz/stateless/basic/CalculatorTest.java
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.stateless.basic;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+public class CalculatorTest implements ExecutionObserver {
+
+ private static final String JNDI = "java:global/simple-stateless-callbacks/CalculatorBean";
+
+ private List<Object> received = new ArrayList<Object>();
+
+ public Context getContext() throws NamingException {
+ final Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ return new InitialContext(p);
+
+ }
+
+ @Test
+ public void test() throws Exception {
+ ExecutionChannel.getInstance().addObserver(this);
+
+ final EJBContainer container = EJBContainer.createEJBContainer();
+
+ {
+ final CalculatorBean calculator = (CalculatorBean) getContext().lookup(JNDI);
+
+ Assert.assertEquals(10, calculator.add(4, 6));
+
+ //the bean is constructed only when it is used for the first time
+ Assert.assertEquals("postConstruct", this.received.remove(0));
+ Assert.assertEquals("add", this.received.remove(0));
+
+ Assert.assertEquals(-2, calculator.subtract(4, 6));
+ Assert.assertEquals("subtract", this.received.remove(0));
+
+ Assert.assertEquals(24, calculator.multiply(4, 6));
+ Assert.assertEquals("multiply", this.received.remove(0));
+
+ Assert.assertEquals(2, calculator.divide(12, 6));
+ Assert.assertEquals("divide", this.received.remove(0));
+
+ Assert.assertEquals(4, calculator.remainder(46, 6));
+ Assert.assertEquals("remainder", this.received.remove(0));
+ }
+
+ {
+ final CalculatorBean calculator = (CalculatorBean) getContext().lookup(JNDI);
+
+ Assert.assertEquals(10, calculator.add(4, 6));
+ Assert.assertEquals("add", this.received.remove(0));
+
+ }
+
+ container.close();
+ Assert.assertEquals("preDestroy", this.received.remove(0));
+ Assert.assertTrue(this.received.isEmpty());
+ }
+
+ @Override
+ public void onExecution(Object value) {
+ System.out.println("Test step -> " + value);
+ this.received.add(value);
+ }
+}
diff --git a/content/examples/simple-stateless-with-descriptor.html b/content/examples/simple-stateless-with-descriptor.html
new file mode 100644
index 0000000..1c25dde
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor.html
@@ -0,0 +1,391 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-stateless-with-descriptor.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple Stateless with Descriptor</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-stateless-with-descriptor can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-stateless-with-descriptor" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-stateless-with-descriptor</a></p>
+</div>
+<div class="paragraph">
+<p>This test is similar to simple-stateless, with two major differences. In this case all the classes are regular POJOs without annotations.
+The EJB-specific metadata is provided via an XML descriptor. The second difference is the explicite use of Local and Remote interfaces.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorimpl">CalculatorImpl</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+/**
+ * This is an EJB 3 stateless session bean, configured using an EJB 3
+ * deployment descriptor as opposed to using annotations.
+ * This EJB has 2 business interfaces: CalculatorRemote, a remote business
+ * interface, and CalculatorLocal, a local business interface
+ */
+public class CalculatorImpl implements CalculatorRemote, CalculatorLocal {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorlocal">CalculatorLocal</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+/**
+ * This is an EJB 3 local business interface
+ * This interface is specified using the business-local tag in the deployment descriptor
+ */
+public interface CalculatorLocal {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorremote">CalculatorRemote</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+
+/**
+ * This is an EJB 3 remote business interface
+ * This interface is specified using the business-local tag in the deployment descriptor
+ */
+public interface CalculatorRemote {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The XML descriptor defines the EJB class and both local and remote interfaces.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar 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/ejb-jar_3_0.xsd"
+ version="3.0">
+ <enterprise-beans>
+ <session>
+ <ejb-name>CalculatorImpl</ejb-name>
+ <business-local>org.superbiz.calculator.CalculatorLocal</business-local>
+ <business-remote>org.superbiz.calculator.CalculatorRemote</business-remote>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+</ejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatortest">CalculatorTest</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Two tests obtain a Local and Remote interface to the bean instance. This time an <code>InitialContext</code> object is directly created,
+as opposed to getting the context from <code>EJBContainer</code>, as we did in the previous example.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ initialContext = new InitialContext(properties);
+ }
+
+ /**
+ * Lookup the Calculator bean via its remote home interface
+ *
+ * @throws Exception
+ */
+ public void testCalculatorViaRemoteInterface() throws Exception {
+ Object object = initialContext.lookup("CalculatorImplRemote");
+
+ assertNotNull(object);
+ assertTrue(object instanceof CalculatorRemote);
+ CalculatorRemote calc = (CalculatorRemote) object;
+ assertEquals(10, calc.sum(4, 6));
+ assertEquals(12, calc.multiply(3, 4));
+ }
+
+ /**
+ * Lookup the Calculator bean via its local home interface
+ *
+ * @throws Exception
+ */
+ public void testCalculatorViaLocalInterface() throws Exception {
+ Object object = initialContext.lookup("CalculatorImplLocal");
+
+ assertNotNull(object);
+ assertTrue(object instanceof CalculatorLocal);
+ CalculatorLocal calc = (CalculatorLocal) object;
+ assertEquals(10, calc.sum(4, 6));
+ assertEquals(12, calc.multiply(3, 4));
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.calculator.CalculatorTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/simple-stateless-with-descriptor
+INFO - openejb.base = /Users/dblevins/examples/simple-stateless-with-descriptor
+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/simple-stateless-with-descriptor/target/classes
+INFO - Beginning load: /Users/dblevins/examples/simple-stateless-with-descriptor/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean CalculatorImpl: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "/Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear
+INFO - Jndi(name=CalculatorImplLocal) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/simple-stateless-with-descriptor/CalculatorImpl!org.superbiz.calculator.CalculatorLocal) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=CalculatorImplRemote) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/simple-stateless-with-descriptor/CalculatorImpl!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/simple-stateless-with-descriptor/CalculatorImpl) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Created Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear)
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.475 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-stateless-with-descriptor.pdf b/content/examples/simple-stateless-with-descriptor.pdf
new file mode 100644
index 0000000..1088d26
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor.pdf
Binary files differ
diff --git a/content/examples/simple-stateless-with-descriptor/README.md b/content/examples/simple-stateless-with-descriptor/README.md
new file mode 100755
index 0000000..afb119a
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor/README.md
@@ -0,0 +1,168 @@
+Title: Simple Stateless with Descriptor
+
+This test is similar to simple-stateless, with two major differences. In this case all the classes are regular POJOs without annotations.
+The EJB-specific metadata is provided via an XML descriptor. The second difference is the explicite use of Local and Remote interfaces.
+
+## CalculatorImpl
+
+ package org.superbiz.calculator;
+
+ /**
+ * This is an EJB 3 stateless session bean, configured using an EJB 3
+ * deployment descriptor as opposed to using annotations.
+ * This EJB has 2 business interfaces: CalculatorRemote, a remote business
+ * interface, and CalculatorLocal, a local business interface
+ */
+ public class CalculatorImpl implements CalculatorRemote, CalculatorLocal {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+ }
+
+## CalculatorLocal
+
+ package org.superbiz.calculator;
+
+ /**
+ * This is an EJB 3 local business interface
+ * This interface is specified using the business-local tag in the deployment descriptor
+ */
+ public interface CalculatorLocal {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+ }
+
+## CalculatorRemote
+
+ package org.superbiz.calculator;
+
+
+ /**
+ * This is an EJB 3 remote business interface
+ * This interface is specified using the business-local tag in the deployment descriptor
+ */
+ public interface CalculatorRemote {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+ }
+
+## ejb-jar.xml
+
+The XML descriptor defines the EJB class and both local and remote interfaces.
+
+ <ejb-jar 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/ejb-jar_3_0.xsd"
+ version="3.0">
+ <enterprise-beans>
+ <session>
+ <ejb-name>CalculatorImpl</ejb-name>
+ <business-local>org.superbiz.calculator.CalculatorLocal</business-local>
+ <business-remote>org.superbiz.calculator.CalculatorRemote</business-remote>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+ </ejb-jar>
+
+
+
+## CalculatorTest
+
+Two tests obtain a Local and Remote interface to the bean instance. This time an `InitialContext` object is directly created,
+as opposed to getting the context from `EJBContainer`, as we did in the previous example.
+
+ package org.superbiz.calculator;
+
+ import junit.framework.TestCase;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.Properties;
+
+ public class CalculatorTest extends TestCase {
+
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ initialContext = new InitialContext(properties);
+ }
+
+ /**
+ * Lookup the Calculator bean via its remote home interface
+ *
+ * @throws Exception
+ */
+ public void testCalculatorViaRemoteInterface() throws Exception {
+ Object object = initialContext.lookup("CalculatorImplRemote");
+
+ assertNotNull(object);
+ assertTrue(object instanceof CalculatorRemote);
+ CalculatorRemote calc = (CalculatorRemote) object;
+ assertEquals(10, calc.sum(4, 6));
+ assertEquals(12, calc.multiply(3, 4));
+ }
+
+ /**
+ * Lookup the Calculator bean via its local home interface
+ *
+ * @throws Exception
+ */
+ public void testCalculatorViaLocalInterface() throws Exception {
+ Object object = initialContext.lookup("CalculatorImplLocal");
+
+ assertNotNull(object);
+ assertTrue(object instanceof CalculatorLocal);
+ CalculatorLocal calc = (CalculatorLocal) object;
+ assertEquals(10, calc.sum(4, 6));
+ assertEquals(12, calc.multiply(3, 4));
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.calculator.CalculatorTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/simple-stateless-with-descriptor
+ INFO - openejb.base = /Users/dblevins/examples/simple-stateless-with-descriptor
+ 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/simple-stateless-with-descriptor/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/simple-stateless-with-descriptor/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean CalculatorImpl: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "/Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear
+ INFO - Jndi(name=CalculatorImplLocal) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Jndi(name=global/classpath.ear/simple-stateless-with-descriptor/CalculatorImpl!org.superbiz.calculator.CalculatorLocal) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Jndi(name=CalculatorImplRemote) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Jndi(name=global/classpath.ear/simple-stateless-with-descriptor/CalculatorImpl!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Jndi(name=global/classpath.ear/simple-stateless-with-descriptor/CalculatorImpl) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Created Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear)
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.475 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/simple-stateless-with-descriptor/build.xml b/content/examples/simple-stateless-with-descriptor/build.xml
new file mode 100755
index 0000000..e6dd18b
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 635408 $ $Date: 2008-03-10 00:48:40 +0000 (Mon, 10 Mar 2008) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-stateless-with-descriptor/pom.xml b/content/examples/simple-stateless-with-descriptor/pom.xml
new file mode 100755
index 0000000..82d3e38
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 20:24:02 +0000 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-stateless-with-descriptor</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple Stateless With Deployment Descriptor</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-jee-accessors</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorImpl.java b/content/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorImpl.java
new file mode 100755
index 0000000..347b460
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorImpl.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+/**
+ * This is an EJB 3 stateless session bean, configured using an EJB 3
+ * deployment descriptor as opposed to using annotations.
+ * This EJB has 2 business interfaces: CalculatorRemote, a remote business
+ * interface, and CalculatorLocal, a local business interface
+ */
+//START SNIPPET: code
+public class CalculatorImpl implements CalculatorRemote, CalculatorLocal {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorLocal.java b/content/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorLocal.java
new file mode 100755
index 0000000..ed64e88
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorLocal.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+/**
+ * This is an EJB 3 local business interface
+ * This interface is specified using the business-local tag in the deployment descriptor
+ */
+//START SNIPPET: code
+public interface CalculatorLocal {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorRemote.java b/content/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorRemote.java
new file mode 100755
index 0000000..2e61a11
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor/src/main/java/org/superbiz/calculator/CalculatorRemote.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+/**
+ * This is an EJB 3 remote business interface
+ * This interface is specified using the business-local tag in the deployment descriptor
+ */
+//START SNIPPET: code
+public interface CalculatorRemote {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+
+}
+//END SNIPPET: code
diff --git a/content/examples/simple-stateless-with-descriptor/src/main/resources/META-INF/ejb-jar.xml b/content/examples/simple-stateless-with-descriptor/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..c0b6f5b
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ejb-jar 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/ejb-jar_3_0.xsd"
+ version="3.0">
+ <enterprise-beans>
+ <session>
+ <ejb-name>CalculatorImpl</ejb-name>
+ <business-local>org.superbiz.calculator.CalculatorLocal</business-local>
+ <business-remote>org.superbiz.calculator.CalculatorRemote</business-remote>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+ </enterprise-beans>
+</ejb-jar>
diff --git a/content/examples/simple-stateless-with-descriptor/src/test/java/org/superbiz/calculator/CalculatorTest.java b/content/examples/simple-stateless-with-descriptor/src/test/java/org/superbiz/calculator/CalculatorTest.java
new file mode 100755
index 0000000..ab24ac4
--- /dev/null
+++ b/content/examples/simple-stateless-with-descriptor/src/test/java/org/superbiz/calculator/CalculatorTest.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+ initialContext = new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Lookup the Calculator bean via its remote home interface
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remote
+ public void testCalculatorViaRemoteInterface() throws Exception {
+ Object object = initialContext.lookup("CalculatorImplRemote");
+
+ assertNotNull(object);
+ assertTrue(object instanceof CalculatorRemote);
+ CalculatorRemote calc = (CalculatorRemote) object;
+ assertEquals(10, calc.sum(4, 6));
+ assertEquals(12, calc.multiply(3, 4));
+ }
+ //END SNIPPET: remote
+
+ /**
+ * Lookup the Calculator bean via its local home interface
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: local
+ public void testCalculatorViaLocalInterface() throws Exception {
+ Object object = initialContext.lookup("CalculatorImplLocal");
+
+ assertNotNull(object);
+ assertTrue(object instanceof CalculatorLocal);
+ CalculatorLocal calc = (CalculatorLocal) object;
+ assertEquals(10, calc.sum(4, 6));
+ assertEquals(12, calc.multiply(3, 4));
+ }
+ //END SNIPPET: local
+
+}
diff --git a/content/examples/simple-stateless.html b/content/examples/simple-stateless.html
new file mode 100644
index 0000000..dcd618f
--- /dev/null
+++ b/content/examples/simple-stateless.html
@@ -0,0 +1,415 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-stateless.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple Stateless</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-stateless can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-stateless" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-stateless</a></p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+"Stateless session beans are session beans whose instances have no conversational state.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>This means that all bean instances are equivalent when they are not involved in servicing
+a client-invoked method. The term 'stateless' signifies that an instance has no state for a
+specific client."</p>
+</div>
+<div class="paragraph">
+<p>What this means is quite simply that stateless beans are shared. They do in fact have state
+as you can assign values to the variables, etc. in the bean instance. The only catch is there
+are a pool of identical instances and you are not guaranteed to get the exact same instance on
+every call. For each call, you get whatever instance happens to be available. This is identical
+to checking out a book from the library or renting a movie from the video store. You are essentially
+checking out or renting a new bean instance on each method call.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorbean">CalculatorBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.stateless.basic;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class CalculatorBean {
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatortest">CalculatorTest</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Our <code>CalculatorBean</code> can be easily tested using the <code>EJBContainer</code> API in EJB 3.1</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.stateless.basic;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.NamingException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class CalculatorTest {
+
+ private static EJBContainer ejbContainer;
+
+ private CalculatorBean calculator;
+
+ @BeforeClass
+ public static void startTheContainer() {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @Before
+ public void lookupABean() throws NamingException {
+ Object object = ejbContainer.getContext().lookup("java:global/simple-stateless/CalculatorBean");
+
+ assertTrue(object instanceof CalculatorBean);
+
+ calculator = (CalculatorBean) object;
+ }
+
+ @AfterClass
+ public static void stopTheContainer() {
+ if (ejbContainer != null) {
+ ejbContainer.close();
+ }
+ }
+
+ /**
+ * Test Add method
+ */
+ @Test
+ public void testAdd() {
+
+ assertEquals(10, calculator.add(4, 6));
+
+ }
+
+ /**
+ * Test Subtract method
+ */
+ @Test
+ public void testSubtract() {
+
+ assertEquals(-2, calculator.subtract(4, 6));
+
+ }
+
+ /**
+ * Test Multiply method
+ */
+ @Test
+ public void testMultiply() {
+
+ assertEquals(24, calculator.multiply(4, 6));
+
+ }
+
+ /**
+ * Test Divide method
+ */
+ @Test
+ public void testDivide() {
+
+ assertEquals(2, calculator.divide(12, 6));
+
+ }
+
+ /**
+ * Test Remainder method
+ */
+ @Test
+ public void testRemainder() {
+
+ assertEquals(4, calculator.remainder(46, 6));
+
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>Running the example should generate output similar to the following</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.stateless.basic.CalculatorTest
+Infos - ********************************************************************************
+Infos - OpenEJB http://tomee.apache.org/
+Infos - Startup: Tue Aug 14 13:28:12 CEST 2012
+Infos - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+Infos - Version: 4.1.0
+Infos - Build date: 20120814
+Infos - Build time: 01:06
+Infos - ********************************************************************************
+Infos - openejb.home = /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Infos - openejb.base = /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Infos - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@33bb11
+Infos - Succeeded in installing singleton service
+Infos - Using 'javax.ejb.embeddable.EJBContainer=true'
+Infos - Cannot find the configuration file [conf/openejb.xml]. Will attempt to create one for the beans deployed.
+Infos - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+Infos - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+Infos - Creating TransactionManager(id=Default Transaction Manager)
+Infos - Creating SecurityService(id=Default Security Service)
+Infos - Beginning load: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless/target/classes
+Infos - Configuring enterprise application: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Infos - Auto-deploying ejb CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
+Infos - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+Infos - Auto-creating a container for bean CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
+Infos - Creating Container(id=Default Stateless Container)
+Infos - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+Infos - Auto-creating a container for bean org.superbiz.stateless.basic.CalculatorTest: Container(type=MANAGED, id=Default Managed Container)
+Infos - Creating Container(id=Default Managed Container)
+Infos - Using directory /tmp for stateful session passivation
+Infos - Enterprise application "/home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless" loaded.
+Infos - Assembling app: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Infos - Jndi(name="java:global/simple-stateless/CalculatorBean!org.superbiz.stateless.basic.CalculatorBean")
+Infos - Jndi(name="java:global/simple-stateless/CalculatorBean")
+Infos - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@33bb11
+Infos - OpenWebBeans Container is starting...
+Infos - Adding OpenWebBeansPlugin : [CdiPlugin]
+Infos - All injection points are validated successfully.
+Infos - OpenWebBeans Container has started, it took 135 ms.
+Infos - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+Infos - Started Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+Infos - Deployed Application(path=/home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless)
+Infos - Undeploying app: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.068 sec
+
+Results :
+
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-stateless.pdf b/content/examples/simple-stateless.pdf
new file mode 100644
index 0000000..3fd59d2
--- /dev/null
+++ b/content/examples/simple-stateless.pdf
Binary files differ
diff --git a/content/examples/simple-stateless/README.md b/content/examples/simple-stateless/README.md
new file mode 100755
index 0000000..ccd5e3d
--- /dev/null
+++ b/content/examples/simple-stateless/README.md
@@ -0,0 +1,197 @@
+Title: Simple Stateless
+
+>"Stateless session beans are session beans whose instances have no conversational state.
+This means that all bean instances are equivalent when they are not involved in servicing
+a client-invoked method. The term 'stateless' signifies that an instance has no state for a
+specific client."
+
+What this means is quite simply that stateless beans are shared. They do in fact have state
+as you can assign values to the variables, etc. in the bean instance. The only catch is there
+are a pool of identical instances and you are not guaranteed to get the exact same instance on
+every call. For each call, you get whatever instance happens to be available. This is identical
+to checking out a book from the library or renting a movie from the video store. You are essentially
+checking out or renting a new bean instance on each method call.
+
+## CalculatorBean
+
+ package org.superbiz.stateless.basic;
+
+ import javax.ejb.Stateless;
+
+ @Stateless
+ public class CalculatorBean {
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+ }
+
+## CalculatorTest
+
+Our `CalculatorBean` can be easily tested using the `EJBContainer` API in EJB 3.1
+
+ package org.superbiz.stateless.basic;
+
+ import org.junit.AfterClass;
+ import org.junit.Before;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.NamingException;
+
+ import static org.junit.Assert.assertEquals;
+ import static org.junit.Assert.assertTrue;
+
+ public class CalculatorTest {
+
+ private static EJBContainer ejbContainer;
+
+ private CalculatorBean calculator;
+
+ @BeforeClass
+ public static void startTheContainer() {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @Before
+ public void lookupABean() throws NamingException {
+ Object object = ejbContainer.getContext().lookup("java:global/simple-stateless/CalculatorBean");
+
+ assertTrue(object instanceof CalculatorBean);
+
+ calculator = (CalculatorBean) object;
+ }
+
+ @AfterClass
+ public static void stopTheContainer() {
+ if (ejbContainer != null) {
+ ejbContainer.close();
+ }
+ }
+
+ /**
+ * Test Add method
+ */
+ @Test
+ public void testAdd() {
+
+ assertEquals(10, calculator.add(4, 6));
+
+ }
+
+ /**
+ * Test Subtract method
+ */
+ @Test
+ public void testSubtract() {
+
+ assertEquals(-2, calculator.subtract(4, 6));
+
+ }
+
+ /**
+ * Test Multiply method
+ */
+ @Test
+ public void testMultiply() {
+
+ assertEquals(24, calculator.multiply(4, 6));
+
+ }
+
+ /**
+ * Test Divide method
+ */
+ @Test
+ public void testDivide() {
+
+ assertEquals(2, calculator.divide(12, 6));
+
+ }
+
+ /**
+ * Test Remainder method
+ */
+ @Test
+ public void testRemainder() {
+
+ assertEquals(4, calculator.remainder(46, 6));
+
+ }
+
+ }
+
+# Running
+
+
+Running the example should generate output similar to the following
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.stateless.basic.CalculatorTest
+ Infos - ********************************************************************************
+ Infos - OpenEJB http://openejb.apache.org/
+ Infos - Startup: Tue Aug 14 13:28:12 CEST 2012
+ Infos - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+ Infos - Version: 4.1.0
+ Infos - Build date: 20120814
+ Infos - Build time: 01:06
+ Infos - ********************************************************************************
+ Infos - openejb.home = /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+ Infos - openejb.base = /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+ Infos - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@33bb11
+ Infos - Succeeded in installing singleton service
+ Infos - Using 'javax.ejb.embeddable.EJBContainer=true'
+ Infos - Cannot find the configuration file [conf/openejb.xml]. Will attempt to create one for the beans deployed.
+ Infos - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+ Infos - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+ Infos - Creating TransactionManager(id=Default Transaction Manager)
+ Infos - Creating SecurityService(id=Default Security Service)
+ Infos - Beginning load: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless/target/classes
+ Infos - Configuring enterprise application: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+ Infos - Auto-deploying ejb CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
+ Infos - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ Infos - Auto-creating a container for bean CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
+ Infos - Creating Container(id=Default Stateless Container)
+ Infos - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ Infos - Auto-creating a container for bean org.superbiz.stateless.basic.CalculatorTest: Container(type=MANAGED, id=Default Managed Container)
+ Infos - Creating Container(id=Default Managed Container)
+ Infos - Using directory /tmp for stateful session passivation
+ Infos - Enterprise application "/home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless" loaded.
+ Infos - Assembling app: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+ Infos - Jndi(name="java:global/simple-stateless/CalculatorBean!org.superbiz.stateless.basic.CalculatorBean")
+ Infos - Jndi(name="java:global/simple-stateless/CalculatorBean")
+ Infos - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@33bb11
+ Infos - OpenWebBeans Container is starting...
+ Infos - Adding OpenWebBeansPlugin : [CdiPlugin]
+ Infos - All injection points are validated successfully.
+ Infos - OpenWebBeans Container has started, it took 135 ms.
+ Infos - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+ Infos - Started Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+ Infos - Deployed Application(path=/home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless)
+ Infos - Undeploying app: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.068 sec
+
+ Results :
+
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/simple-stateless/build.xml b/content/examples/simple-stateless/build.xml
new file mode 100755
index 0000000..5b48ad5
--- /dev/null
+++ b/content/examples/simple-stateless/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-stateless/pom.xml b/content/examples/simple-stateless/pom.xml
new file mode 100755
index 0000000..9a4b087
--- /dev/null
+++ b/content/examples/simple-stateless/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-stateless</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple Stateless Pojo</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/simple-stateless/src/main/java/org/superbiz/stateless/basic/CalculatorBean.java b/content/examples/simple-stateless/src/main/java/org/superbiz/stateless/basic/CalculatorBean.java
new file mode 100755
index 0000000..dd3f471
--- /dev/null
+++ b/content/examples/simple-stateless/src/main/java/org/superbiz/stateless/basic/CalculatorBean.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.stateless.basic;
+
+import javax.ejb.Stateless;
+
+/**
+ * This is an EJB 3.1 style pojo Stateless session bean
+ */
+//START SNIPPET: code
+@Stateless
+public class CalculatorBean {
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public int subtract(int a, int b) {
+ return a - b;
+ }
+
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+ public int divide(int a, int b) {
+ return a / b;
+ }
+
+ public int remainder(int a, int b) {
+ return a % b;
+ }
+
+}
+//END SNIPPET: code
\ No newline at end of file
diff --git a/content/examples/simple-stateless/src/test/java/org/superbiz/stateless/basic/CalculatorTest.java b/content/examples/simple-stateless/src/test/java/org/superbiz/stateless/basic/CalculatorTest.java
new file mode 100755
index 0000000..8425883
--- /dev/null
+++ b/content/examples/simple-stateless/src/test/java/org/superbiz/stateless/basic/CalculatorTest.java
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.stateless.basic;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.NamingException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class CalculatorTest {
+
+ private static EJBContainer ejbContainer;
+
+ private CalculatorBean calculator;
+
+ @BeforeClass
+ public static void startTheContainer() {
+ ejbContainer = EJBContainer.createEJBContainer();
+ }
+
+ @Before
+ public void lookupABean() throws NamingException {
+ Object object = ejbContainer.getContext().lookup("java:global/simple-stateless/CalculatorBean");
+
+ assertTrue(object instanceof CalculatorBean);
+
+ calculator = (CalculatorBean) object;
+ }
+
+ @AfterClass
+ public static void stopTheContainer() {
+ if (ejbContainer != null) {
+ ejbContainer.close();
+ }
+ }
+
+ /**
+ * Test Add method
+ */
+ @Test
+ public void testAdd() {
+
+ assertEquals(10, calculator.add(4, 6));
+
+ }
+
+ /**
+ * Test Subtract method
+ */
+ @Test
+ public void testSubtract() {
+
+ assertEquals(-2, calculator.subtract(4, 6));
+
+ }
+
+ /**
+ * Test Multiply method
+ */
+ @Test
+ public void testMultiply() {
+
+ assertEquals(24, calculator.multiply(4, 6));
+
+ }
+
+ /**
+ * Test Divide method
+ */
+ @Test
+ public void testDivide() {
+
+ assertEquals(2, calculator.divide(12, 6));
+
+ }
+
+ /**
+ * Test Remainder method
+ */
+ @Test
+ public void testRemainder() {
+
+ assertEquals(4, calculator.remainder(46, 6));
+
+ }
+
+}
diff --git a/content/examples/simple-webservice-without-interface.html b/content/examples/simple-webservice-without-interface.html
new file mode 100644
index 0000000..7f26f13
--- /dev/null
+++ b/content/examples/simple-webservice-without-interface.html
@@ -0,0 +1,300 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-webservice-without-interface.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Simple Webservice Without Interface</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-webservice-without-interface can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-webservice-without-interface" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-webservice-without-interface</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculator">Calculator</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorWsService",
+ targetNamespace = "http://superbiz.org/wsdl")
+public class Calculator {
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar/></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatortest">CalculatorTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.NamingException;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+
+public class CalculatorTest {
+ private static EJBContainer container;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ container = EJBContainer.createEJBContainer(properties);
+ }
+
+ @Before
+ public void inject() throws NamingException {
+ if (container != null) {
+ container.getContext().bind("inject", this);
+ }
+ }
+
+ @AfterClass
+ public static void close() {
+ if (container != null) {
+ container.close();
+ }
+ }
+
+ @Test
+ public void wsdlExists() throws Exception {
+ final URL url = new URL("http://127.0.0.1:4204/Calculator?wsdl");
+ assertTrue(IOUtils.readLines(url.openStream()).size() > 0);
+ assertTrue(IOUtils.readLines(url.openStream()).toString().contains("CalculatorWsService"));
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml_2">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar/></code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-webservice-without-interface.pdf b/content/examples/simple-webservice-without-interface.pdf
new file mode 100644
index 0000000..d1e879a
--- /dev/null
+++ b/content/examples/simple-webservice-without-interface.pdf
Binary files differ
diff --git a/content/examples/simple-webservice-without-interface/README.md b/content/examples/simple-webservice-without-interface/README.md
new file mode 100755
index 0000000..c315bf1
--- /dev/null
+++ b/content/examples/simple-webservice-without-interface/README.md
@@ -0,0 +1,83 @@
+Title: Simple Webservice Without Interface
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Calculator
+
+ package org.superbiz.calculator;
+
+ import javax.ejb.Stateless;
+ import javax.jws.WebService;
+
+ @Stateless
+ @WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorWsService",
+ targetNamespace = "http://superbiz.org/wsdl")
+ public class Calculator {
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar/>
+
+## CalculatorTest
+
+ package org.superbiz.calculator;
+
+ import org.apache.commons.io.IOUtils;
+ import org.junit.AfterClass;
+ import org.junit.Before;
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.NamingException;
+ import java.net.URL;
+ import java.util.Properties;
+
+ import static org.junit.Assert.assertTrue;
+
+ public class CalculatorTest {
+ private static EJBContainer container;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ container = EJBContainer.createEJBContainer(properties);
+ }
+
+ @Before
+ public void inject() throws NamingException {
+ if (container != null) {
+ container.getContext().bind("inject", this);
+ }
+ }
+
+ @AfterClass
+ public static void close() {
+ if (container != null) {
+ container.close();
+ }
+ }
+
+ @Test
+ public void wsdlExists() throws Exception {
+ final URL url = new URL("http://127.0.0.1:4204/Calculator?wsdl");
+ assertTrue(IOUtils.readLines(url.openStream()).size() > 0);
+ assertTrue(IOUtils.readLines(url.openStream()).toString().contains("CalculatorWsService"));
+ }
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar/>
diff --git a/content/examples/simple-webservice-without-interface/pom.xml b/content/examples/simple-webservice-without-interface/pom.xml
new file mode 100755
index 0000000..19946cb
--- /dev/null
+++ b/content/examples/simple-webservice-without-interface/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1178411 $ $Date: 2011-10-03 15:35:26 +0200 (lun. 03 oct. 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-webservice-without-interface</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple Webservice Without Interface</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- This is required on IBM JDKs (and potentially others) because saaj-impl depends
+ on Sun's internal copy of Xerces. See OPENEJB-1126. -->
+ <dependency>
+ <groupId>com.sun.xml.parsers</groupId>
+ <artifactId>jaxp-ri</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- simply to get the wsdl in tests -->
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.0.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/simple-webservice-without-interface/src/main/java/org/superbiz/calculator/Calculator.java b/content/examples/simple-webservice-without-interface/src/main/java/org/superbiz/calculator/Calculator.java
new file mode 100755
index 0000000..b90e992
--- /dev/null
+++ b/content/examples/simple-webservice-without-interface/src/main/java/org/superbiz/calculator/Calculator.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorWsService",
+ targetNamespace = "http://superbiz.org/wsdl")
+public class Calculator {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}
diff --git a/content/examples/simple-webservice-without-interface/src/main/resources/META-INF/ejb-jar.xml b/content/examples/simple-webservice-without-interface/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..433757b
--- /dev/null
+++ b/content/examples/simple-webservice-without-interface/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
\ No newline at end of file
diff --git a/content/examples/simple-webservice-without-interface/src/test/java/org/superbiz/calculator/CalculatorTest.java b/content/examples/simple-webservice-without-interface/src/test/java/org/superbiz/calculator/CalculatorTest.java
new file mode 100755
index 0000000..a4acd24
--- /dev/null
+++ b/content/examples/simple-webservice-without-interface/src/test/java/org/superbiz/calculator/CalculatorTest.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.NamingException;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+
+public class CalculatorTest {
+
+ private static EJBContainer container;
+
+ //Random port to avoid test conflicts
+ private static final int port = Integer.parseInt(System.getProperty("httpejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ //Just for this test we change the default port from 4204 to avoid conflicts
+ properties.setProperty("httpejbd.port", "" + port);
+
+ container = EJBContainer.createEJBContainer(properties);
+ }
+
+ @Before
+ public void inject() throws NamingException {
+ if (container != null) {
+ container.getContext().bind("inject", this);
+ }
+ }
+
+ @AfterClass
+ public static void close() {
+ if (container != null) {
+ container.close();
+ }
+ }
+
+ @Test
+ public void wsdlExists() throws Exception {
+ final URL url = new URL("http://localhost:" + port + "/simple-webservice-without-interface/Calculator?wsdl");
+ assertTrue(IOUtils.readLines(url.openStream()).size() > 0);
+ assertTrue(IOUtils.readLines(url.openStream()).toString().contains("CalculatorWsService"));
+ }
+}
diff --git a/content/examples/simple-webservice-without-interface/src/test/resources/META-INF/ejb-jar.xml b/content/examples/simple-webservice-without-interface/src/test/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..433757b
--- /dev/null
+++ b/content/examples/simple-webservice-without-interface/src/test/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
\ No newline at end of file
diff --git a/content/examples/simple-webservice.html b/content/examples/simple-webservice.html
new file mode 100644
index 0000000..c1d27cd
--- /dev/null
+++ b/content/examples/simple-webservice.html
@@ -0,0 +1,592 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/simple-webservice.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>JAX-WS @WebService example</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example simple-webservice can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/simple-webservice" class="bare">https://github.com/apache/tomee/tree/master/examples/simple-webservice</a></p>
+</div>
+<div class="paragraph">
+<p>Creating Web Services with JAX-WS is quite easy. Little has to be done aside from annotating a class with <code>@WebService</code>. For
+the purposes of this example we will also annotate our component with <code>@Stateless</code> which takes some of the configuration out of
+the process and gives us some nice options such as transactions and security.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="__webservice">@WebService</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The following is all that is required. No external xml files are needed. This class placed in a jar or war and deployed into a compliant Java EE server like TomEE is enough to have the Calculator class discovered and deployed and the webservice online.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.ws.CalculatorWs")
+public class Calculator implements CalculatorWs {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="__webservice_endpoint_interface">@WebService Endpoint Interface</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Having an endpoint interface is not required, but it can make testing and using the web service from other Java clients far easier.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculator_wsdl">Calculator WSDL</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The wsdl for our service is autmatically created for us and available at <code><a href="http://127.0.0.1:4204/Calculator?wsdl" class="bare">http://127.0.0.1:4204/Calculator?wsdl</a></code>. In TomEE or Tomcat this would be at <code><a href="http://127.0.0.1:8080/simple-webservice/Calculator?wsdl" class="bare">http://127.0.0.1:8080/simple-webservice/Calculator?wsdl</a></code></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="CalculatorService"
+ targetNamespace="http://superbiz.org/wsdl"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://superbiz.org/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
+ targetNamespace="http://superbiz.org/wsdl" xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="multiply" type="tns:multiply"/>
+ <xsd:complexType name="multiply">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="multiplyResponse" type="tns:multiplyResponse"/>
+ <xsd:complexType name="multiplyResponse">
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sum" type="tns:sum"/>
+ <xsd:complexType name="sum">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sumResponse" type="tns:sumResponse"/>
+ <xsd:complexType name="sumResponse">
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="multiplyResponse">
+ <wsdl:part element="tns:multiplyResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="sumResponse">
+ <wsdl:part element="tns:sumResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="sum">
+ <wsdl:part element="tns:sum" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="multiply">
+ <wsdl:part element="tns:multiply" name="parameters"/>
+ </wsdl:message>
+ <wsdl:portType name="CalculatorWs">
+ <wsdl:operation name="multiply">
+ <wsdl:input message="tns:multiply" name="multiply"/>
+ <wsdl:output message="tns:multiplyResponse" name="multiplyResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="sum">
+ <wsdl:input message="tns:sum" name="sum"/>
+ <wsdl:output message="tns:sumResponse" name="sumResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CalculatorServiceSoapBinding" type="tns:CalculatorWs">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="multiply">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="multiply">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="multiplyResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sum">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sum">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sumResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port binding="tns:CalculatorServiceSoapBinding" name="CalculatorPort">
+ <soap:address location="http://127.0.0.1:4204/Calculator?wsdl"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_accessing_the_webservice_with_javax_xml_ws_service">Accessing the @WebService with javax.xml.ws.Service</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>In our testcase we see how to create a client for our <code>Calculator</code> service via the <code>javax.xml.ws.Service</code> class and leveraging our <code>CalculatorWs</code> endpoint interface.</p>
+</div>
+<div class="paragraph">
+<p>With this we can get an implementation of the interfacce generated dynamically for us that can be used to send compliant SOAP messages to our service.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CalculatorTest {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+ //properties.setProperty("httpejbd.print", "true");
+ //properties.setProperty("httpejbd.indent.xml", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void test() throws Exception {
+ Service calculatorService = Service.create(
+ new URL("http://127.0.0.1:4204/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+ assertEquals(10, calculator.sum(4, 6));
+ assertEquals(12, calculator.multiply(3, 4));
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>For easy testing we’ll use the Embeddable EJBContainer API part of EJB 3.1 to boot CXF in our testcase. This will deploy our application in the embedded container and bring the web service online so we can invoke it.</p>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="paragraph">
+<p>Running the example can be done from maven with a simple 'mvn clean install' command run from the 'simple-webservice' directory.</p>
+</div>
+<div class="paragraph">
+<p>When run you should see output similar to the following.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.calculator.ws.CalculatorTest
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Sat Feb 18 19:11:50 PST 2012
+INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 4.0.0-beta-3
+INFO - Build date: 20120218
+INFO - Build time: 03:32
+INFO - ********************************************************************************
+INFO - openejb.home = /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+INFO - openejb.base = /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@16bdb503
+INFO - succeeded in installing singleton service
+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 - Beginning load: /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice/target/classes
+INFO - Using 'openejb.embedded=true'
+INFO - Configuring enterprise application: /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+INFO - Auto-deploying ejb Calculator: EjbDeployment(deployment-id=Calculator)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean Calculator: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Creating Container(id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.calculator.ws.CalculatorTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Using directory /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T for stateful session passivation
+INFO - Enterprise application "/Users/dblevins/work/all/trunk/openejb/examples/simple-webservice" loaded.
+INFO - Assembling app: /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+INFO - ignoreXmlConfiguration == true
+INFO - ignoreXmlConfiguration == true
+INFO - existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@16bdb503
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points were validated successfully.
+INFO - OpenWebBeans Container has started, it took [62] ms.
+INFO - Created Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/work/all/trunk/openejb/examples/simple-webservice)
+INFO - Initializing network services
+INFO - can't find log4j MDC class
+INFO - Creating ServerService(id=httpejbd)
+INFO - Creating ServerService(id=cxf)
+INFO - Creating ServerService(id=admin)
+INFO - Creating ServerService(id=ejbd)
+INFO - Creating ServerService(id=ejbds)
+INFO - Initializing network services
+INFO - ** Starting Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from class org.superbiz.calculator.ws.CalculatorWs
+INFO - Setting the server's publish address to be http://nopath:80
+INFO - Webservice(wsdl=http://127.0.0.1:4204/Calculator, qname={http://superbiz.org/wsdl}CalculatorService) --> Ejb(id=Calculator)
+INFO - admin thread 127.0.0.1 4200
+INFO - ejbd 127.0.0.1 4201
+INFO - ejbd 127.0.0.1 4203
+INFO - -------
+INFO - Ready!
+INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+INFO - Default SAAJ universe not set
+INFO - TX NotSupported: Suspended transaction null
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.584 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_inspecting_the_messages">Inspecting the messages</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The above test case will result in the following SOAP messages being sent between the clien and server.</p>
+</div>
+<div class="sect2">
+<h3 id="_sum_int_int">sum(int, int)</h3>
+<div class="paragraph">
+<p>Request SOAP message:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sum xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>4</arg0>
+ <arg1>6</arg1>
+ </ns1:sum>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Response SOAP message:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <return>10</return>
+ </ns1:sumResponse>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_multiply_int_int">multiply(int, int)</h3>
+<div class="paragraph">
+<p>Request SOAP message:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:multiply xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>3</arg0>
+ <arg1>4</arg1>
+ </ns1:multiply>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Response SOAP message:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:multiplyResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <return>12</return>
+ </ns1:multiplyResponse>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_inside_the_jar">Inside the jar</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>With so much going on it can make things look more complex than they are. It can be hard to believe that so much can happen with such little code. That’s the benefit of having an app server.</p>
+</div>
+<div class="paragraph">
+<p>If we look at the jar built by maven, we’ll see the application itself is quite small:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>$ jar tvf target/simple-webservice-1.1.0-SNAPSHOT.jar
+ 0 Sat Feb 18 19:17:06 PST 2012 META-INF/
+ 127 Sat Feb 18 19:17:04 PST 2012 META-INF/MANIFEST.MF
+ 0 Sat Feb 18 19:17:02 PST 2012 org/
+ 0 Sat Feb 18 19:17:02 PST 2012 org/superbiz/
+ 0 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/
+ 0 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/ws/
+ 855 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/ws/Calculator.class
+ 288 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/ws/CalculatorWs.class</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This single jar could be deployed any any compliant Java EE implementation. In TomEE you’d simply place it in the <code>tomee.home/webapps/</code> directory. No war file necessary. If you did want to create a war, you’d simply place the jar in the <code>WEB-INF/lib/</code> directory of the war.</p>
+</div>
+<div class="paragraph">
+<p>The server already contains the right libraries to run the code, such as Apache CXF, so no need to include anything extra beyond your own application code.</p>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/simple-webservice.pdf b/content/examples/simple-webservice.pdf
new file mode 100644
index 0000000..f7d2c9a
--- /dev/null
+++ b/content/examples/simple-webservice.pdf
Binary files differ
diff --git a/content/examples/simple-webservice/README.md b/content/examples/simple-webservice/README.md
new file mode 100755
index 0000000..5cdba25
--- /dev/null
+++ b/content/examples/simple-webservice/README.md
@@ -0,0 +1,334 @@
+Title: JAX-WS @WebService example
+
+Creating Web Services with JAX-WS is quite easy. Little has to be done aside from annotating a class with `@WebService`. For
+the purposes of this example we will also annotate our component with `@Stateless` which takes some of the configuration out of
+the process and gives us some nice options such as transactions and security.
+
+## @WebService
+
+The following is all that is required. No external xml files are needed. This class placed in a jar or war and deployed into a compliant Java EE server like TomEE is enough to have the Calculator class discovered and deployed and the webservice online.
+
+ import javax.ejb.Stateless;
+ import javax.jws.WebService;
+
+ @Stateless
+ @WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.ws.CalculatorWs")
+ public class Calculator implements CalculatorWs {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+ }
+
+## @WebService Endpoint Interface
+
+Having an endpoint interface is not required, but it can make testing and using the web service from other Java clients far easier.
+
+ import javax.jws.WebService;
+
+ @WebService(targetNamespace = "http://superbiz.org/wsdl")
+ public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+ }
+
+## Calculator WSDL
+
+The wsdl for our service is autmatically created for us and available at `http://127.0.0.1:4204/Calculator?wsdl`. In TomEE or Tomcat this would be at `http://127.0.0.1:8080/simple-webservice/Calculator?wsdl`
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="CalculatorService"
+ targetNamespace="http://superbiz.org/wsdl"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://superbiz.org/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
+ targetNamespace="http://superbiz.org/wsdl" xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="multiply" type="tns:multiply"/>
+ <xsd:complexType name="multiply">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="multiplyResponse" type="tns:multiplyResponse"/>
+ <xsd:complexType name="multiplyResponse">
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sum" type="tns:sum"/>
+ <xsd:complexType name="sum">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sumResponse" type="tns:sumResponse"/>
+ <xsd:complexType name="sumResponse">
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="multiplyResponse">
+ <wsdl:part element="tns:multiplyResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="sumResponse">
+ <wsdl:part element="tns:sumResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="sum">
+ <wsdl:part element="tns:sum" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="multiply">
+ <wsdl:part element="tns:multiply" name="parameters"/>
+ </wsdl:message>
+ <wsdl:portType name="CalculatorWs">
+ <wsdl:operation name="multiply">
+ <wsdl:input message="tns:multiply" name="multiply"/>
+ <wsdl:output message="tns:multiplyResponse" name="multiplyResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="sum">
+ <wsdl:input message="tns:sum" name="sum"/>
+ <wsdl:output message="tns:sumResponse" name="sumResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CalculatorServiceSoapBinding" type="tns:CalculatorWs">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="multiply">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="multiply">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="multiplyResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sum">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sum">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sumResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port binding="tns:CalculatorServiceSoapBinding" name="CalculatorPort">
+ <soap:address location="http://127.0.0.1:4204/Calculator?wsdl"/>
+ </wsdl:port>
+ </wsdl:service>
+ </wsdl:definitions>
+
+## Accessing the @WebService with javax.xml.ws.Service
+
+In our testcase we see how to create a client for our `Calculator` service via the `javax.xml.ws.Service` class and leveraging our `CalculatorWs` endpoint interface.
+
+With this we can get an implementation of the interfacce generated dynamically for us that can be used to send compliant SOAP messages to our service.
+
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.xml.namespace.QName;
+ import javax.xml.ws.Service;
+ import java.net.URL;
+ import java.util.Properties;
+
+ import static org.junit.Assert.assertEquals;
+ import static org.junit.Assert.assertNotNull;
+
+ public class CalculatorTest {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+ //properties.setProperty("httpejbd.print", "true");
+ //properties.setProperty("httpejbd.indent.xml", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void test() throws Exception {
+ Service calculatorService = Service.create(
+ new URL("http://127.0.0.1:4204/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+ assertEquals(10, calculator.sum(4, 6));
+ assertEquals(12, calculator.multiply(3, 4));
+ }
+ }
+
+For easy testing we'll use the Embeddable EJBContainer API part of EJB 3.1 to boot CXF in our testcase. This will deploy our application in the embedded container and bring the web service online so we can invoke it.
+
+# Running
+
+Running the example can be done from maven with a simple 'mvn clean install' command run from the 'simple-webservice' directory.
+
+When run you should see output similar to the following.
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.calculator.ws.CalculatorTest
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://openejb.apache.org/
+ INFO - Startup: Sat Feb 18 19:11:50 PST 2012
+ INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 4.0.0-beta-3
+ INFO - Build date: 20120218
+ INFO - Build time: 03:32
+ INFO - ********************************************************************************
+ INFO - openejb.home = /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+ INFO - openejb.base = /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@16bdb503
+ INFO - succeeded in installing singleton service
+ 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 - Beginning load: /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice/target/classes
+ INFO - Using 'openejb.embedded=true'
+ INFO - Configuring enterprise application: /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+ INFO - Auto-deploying ejb Calculator: EjbDeployment(deployment-id=Calculator)
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean Calculator: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Creating Container(id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.calculator.ws.CalculatorTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Creating Container(id=Default Managed Container)
+ INFO - Using directory /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T for stateful session passivation
+ INFO - Enterprise application "/Users/dblevins/work/all/trunk/openejb/examples/simple-webservice" loaded.
+ INFO - Assembling app: /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+ INFO - ignoreXmlConfiguration == true
+ INFO - ignoreXmlConfiguration == true
+ INFO - existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@16bdb503
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points were validated successfully.
+ INFO - OpenWebBeans Container has started, it took [62] ms.
+ INFO - Created Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/work/all/trunk/openejb/examples/simple-webservice)
+ INFO - Initializing network services
+ INFO - can't find log4j MDC class
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Creating ServerService(id=cxf)
+ INFO - Creating ServerService(id=admin)
+ INFO - Creating ServerService(id=ejbd)
+ INFO - Creating ServerService(id=ejbds)
+ INFO - Initializing network services
+ INFO - ** Starting Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from class org.superbiz.calculator.ws.CalculatorWs
+ INFO - Setting the server's publish address to be http://nopath:80
+ INFO - Webservice(wsdl=http://127.0.0.1:4204/Calculator, qname={http://superbiz.org/wsdl}CalculatorService) --> Ejb(id=Calculator)
+ INFO - admin thread 127.0.0.1 4200
+ INFO - ejbd 127.0.0.1 4201
+ INFO - ejbd 127.0.0.1 4203
+ INFO - -------
+ INFO - Ready!
+ INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+ INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+ INFO - Default SAAJ universe not set
+ INFO - TX NotSupported: Suspended transaction null
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.584 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+## Inspecting the messages
+
+The above test case will result in the following SOAP messages being sent between the clien and server.
+
+### sum(int, int)
+
+Request SOAP message:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sum xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>4</arg0>
+ <arg1>6</arg1>
+ </ns1:sum>
+ </soap:Body>
+ </soap:Envelope>
+
+Response SOAP message:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <return>10</return>
+ </ns1:sumResponse>
+ </soap:Body>
+ </soap:Envelope>
+
+### multiply(int, int)
+
+Request SOAP message:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:multiply xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>3</arg0>
+ <arg1>4</arg1>
+ </ns1:multiply>
+ </soap:Body>
+ </soap:Envelope>
+
+Response SOAP message:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:multiplyResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <return>12</return>
+ </ns1:multiplyResponse>
+ </soap:Body>
+ </soap:Envelope>
+
+## Inside the jar
+
+With so much going on it can make things look more complex than they are. It can be hard to believe that so much can happen with such little code. That's the benefit of having an app server.
+
+If we look at the jar built by maven, we'll see the application itself is quite small:
+
+ $ jar tvf target/simple-webservice-1.1.1-SNAPSHOT.jar
+ 0 Sat Feb 18 19:17:06 PST 2012 META-INF/
+ 127 Sat Feb 18 19:17:04 PST 2012 META-INF/MANIFEST.MF
+ 0 Sat Feb 18 19:17:02 PST 2012 org/
+ 0 Sat Feb 18 19:17:02 PST 2012 org/superbiz/
+ 0 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/
+ 0 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/ws/
+ 855 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/ws/Calculator.class
+ 288 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/ws/CalculatorWs.class
+
+This single jar could be deployed any any compliant Java EE implementation. In TomEE you'd simply place it in the `tomee.home/webapps/` directory. No war file necessary. If you did want to create a war, you'd simply place the jar in the `WEB-INF/lib/` directory of the war.
+
+The server already contains the right libraries to run the code, such as Apache CXF, so no need to include anything extra beyond your own application code.
+
diff --git a/content/examples/simple-webservice/build.xml b/content/examples/simple-webservice/build.xml
new file mode 100755
index 0000000..f8f04fc
--- /dev/null
+++ b/content/examples/simple-webservice/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-cxf" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/simple-webservice/pom.xml b/content/examples/simple-webservice/pom.xml
new file mode 100755
index 0000000..403c5e0
--- /dev/null
+++ b/content/examples/simple-webservice/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>simple-webservice</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Simple Webservice</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- This is required on IBM JDKs (and potentially others) because saaj-impl depends
+ on Sun's internal copy of Xerces. See OPENEJB-1126. -->
+ <dependency>
+ <groupId>com.sun.xml.parsers</groupId>
+ <artifactId>jaxp-ri</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/simple-webservice/src/main/java/org/superbiz/calculator/ws/Calculator.java b/content/examples/simple-webservice/src/main/java/org/superbiz/calculator/ws/Calculator.java
new file mode 100755
index 0000000..8e683a2
--- /dev/null
+++ b/content/examples/simple-webservice/src/main/java/org/superbiz/calculator/ws/Calculator.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator.ws;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.ws.CalculatorWs")
+public class Calculator implements CalculatorWs {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}
diff --git a/content/examples/simple-webservice/src/main/java/org/superbiz/calculator/ws/CalculatorWs.java b/content/examples/simple-webservice/src/main/java/org/superbiz/calculator/ws/CalculatorWs.java
new file mode 100755
index 0000000..d6e633f
--- /dev/null
+++ b/content/examples/simple-webservice/src/main/java/org/superbiz/calculator/ws/CalculatorWs.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator.ws;
+
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}
diff --git a/content/examples/simple-webservice/src/test/java/org/superbiz/calculator/ws/CalculatorTest.java b/content/examples/simple-webservice/src/test/java/org/superbiz/calculator/ws/CalculatorTest.java
new file mode 100755
index 0000000..7ea0cce
--- /dev/null
+++ b/content/examples/simple-webservice/src/test/java/org/superbiz/calculator/ws/CalculatorTest.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator.ws;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CalculatorTest {
+
+ //Random port to avoid test conflicts
+ private static final int port = Integer.parseInt(System.getProperty("httpejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ //Just for this test we change the default port from 4204 to avoid conflicts
+ properties.setProperty("httpejbd.port", "" + port);
+
+ // properties.setProperty("httpejbd.print", "true");
+ // properties.setProperty("httpejbd.indent.xml", "true");
+ // properties.setProperty("logging.level.OpenEJB.server.http", "FINE");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void test() throws Exception {
+ Service calculatorService = Service.create(
+ new URL("http://localhost:" + port + "/simple-webservice/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+ assertEquals(10, calculator.sum(4, 6));
+ assertEquals(12, calculator.multiply(3, 4));
+ }
+}
diff --git a/content/examples/spring-data-proxy-meta.html b/content/examples/spring-data-proxy-meta.html
new file mode 100644
index 0000000..56042a7
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta.html
@@ -0,0 +1,210 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/spring-data-proxy-meta.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>spring-data-proxy-meta</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example spring-data-proxy-meta can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/spring-data-proxy-meta" class="bare">https://github.com/apache/tomee/tree/master/examples/spring-data-proxy-meta</a></p>
+</div>
+</div>
+</div>
+<h1 id="_spring_data_with_meta_sample" class="sect0">Spring Data With Meta sample #</h1>
+<div class="paragraph">
+<p>This example simply simplifies the usage of spring-data sample
+providing a meta annotation @SpringRepository to do all the dynamic procy EJB job.</p>
+</div>
+<div class="paragraph">
+<p>It replaces @Proxy and @Stateless annotations.</p>
+</div>
+<div class="paragraph">
+<p>Isn’t it more comfortable?</p>
+</div>
+<div class="paragraph">
+<p>To do it we defined a meta annotation "Metatype" and used it.</p>
+</div>
+<div class="paragraph">
+<p>The proxy implementation is the same than for spring-data sample.</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/spring-data-proxy-meta.pdf b/content/examples/spring-data-proxy-meta.pdf
new file mode 100644
index 0000000..3138c91
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta.pdf
Binary files differ
diff --git a/content/examples/spring-data-proxy-meta/README.md b/content/examples/spring-data-proxy-meta/README.md
new file mode 100755
index 0000000..bbe0ef3
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/README.md
@@ -0,0 +1,12 @@
+# Spring Data With Meta sample #
+
+This example simply simplifies the usage of spring-data sample
+providing a meta annotation @SpringRepository to do all the dynamic procy EJB job.
+
+It replaces @Proxy and @Stateless annotations.
+
+Isn't it more comfortable?
+
+To do it we defined a meta annotation "Metatype" and used it.
+
+The proxy implementation is the same than for spring-data sample.
diff --git a/content/examples/spring-data-proxy-meta/pom.xml b/content/examples/spring-data-proxy-meta/pom.xml
new file mode 100755
index 0000000..02fcfbc
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>spring-data-proxy-meta</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Spring Data Meta</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-jpa</artifactId>
+ <version>1.0.3.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/User.java b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/User.java
new file mode 100755
index 0000000..855d6cf
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/User.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class User {
+
+ @Id
+ @GeneratedValue
+ private long id;
+ private String name;
+ private int age;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
diff --git a/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/UserSpringDataDao.java b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/UserSpringDataDao.java
new file mode 100755
index 0000000..7b06c2a
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/UserSpringDataDao.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.Param;
+import org.superbiz.dynamic.api.SpringRepository;
+
+@SpringRepository
+public interface UserSpringDataDao extends JpaRepository<User, Long> {
+
+ User findByName(@Param("name") final String name);
+}
diff --git a/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/api/Metatype.java b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/api/Metatype.java
new file mode 100755
index 0000000..6a8fead
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/api/Metatype.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface Metatype {
+
+}
+
diff --git a/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/api/SpringRepository.java b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/api/SpringRepository.java
new file mode 100755
index 0000000..9f905f6
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/api/SpringRepository.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic.api;
+
+import org.apache.openejb.api.Proxy;
+import org.superbiz.dynamic.framework.SpringDataProxy;
+
+import javax.ejb.Stateless;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Stateless
+@Proxy(SpringDataProxy.class)
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface SpringRepository {
+
+}
+
diff --git a/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/framework/SpringDataProxy.java b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/framework/SpringDataProxy.java
new file mode 100755
index 0000000..16f6c6d
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/src/main/java/org/superbiz/dynamic/framework/SpringDataProxy.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic.framework;
+
+import org.springframework.data.jpa.repository.support.JpaRepositoryFactory;
+import org.springframework.data.repository.Repository;
+
+import javax.annotation.Resource;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class SpringDataProxy implements InvocationHandler {
+
+ @PersistenceContext(unitName = "dynamic")
+ private EntityManager em;
+
+ @Resource(name = "implementingInterfaceClass")
+ private Class<Repository<?, ?>> implementingInterfaceClass; // implicitly for this kind of proxy
+
+ private final AtomicReference<Repository<?, ?>> repository = new AtomicReference<Repository<?, ?>>();
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (repository.get() == null) {
+ synchronized (this) {
+ if (repository.get() == null) {
+ repository.set(new JpaRepositoryFactory(em).getRepository(implementingInterfaceClass));
+ }
+ }
+ }
+ return method.invoke(repository.get(), args);
+ }
+}
diff --git a/content/examples/spring-data-proxy-meta/src/main/resources/META-INF/beans.xml b/content/examples/spring-data-proxy-meta/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/spring-data-proxy-meta/src/main/resources/META-INF/persistence.xml b/content/examples/spring-data-proxy-meta/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..97d2ba5
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="dynamic" transaction-type="JTA">
+ <jta-data-source>jdbc/dynamicDB</jta-data-source>
+ <class>org.superbiz.dynamic.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/spring-data-proxy-meta/src/test/java/org/superbiz/dynamic/DynamicUserDaoTest.java b/content/examples/spring-data-proxy-meta/src/test/java/org/superbiz/dynamic/DynamicUserDaoTest.java
new file mode 100755
index 0000000..2115348
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/src/test/java/org/superbiz/dynamic/DynamicUserDaoTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.NamingException;
+import java.util.Collection;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class DynamicUserDaoTest {
+
+ private static EJBContainer container;
+ private static boolean initialized = false;
+
+ @Inject
+ private UserSpringDataDao dao;
+
+ @Test
+ public void findAll() {
+ Collection<User> users = dao.findAll();
+ assertEquals(10, users.size());
+ }
+
+ @Test
+ public void findByName() {
+ User user = dao.findByName("bar-1");
+ assertNotNull(user);
+ assertEquals("bar-1", user.getName());
+ }
+
+ @BeforeClass
+ public static void start() throws Exception {
+ final Properties p = new Properties();
+
+ p.setProperty("openejb.deployments.classpath.include", "spring-data-proxy-meta");
+ p.setProperty("openejb.exclude-include.order", "exclude-include");
+
+ p.setProperty("jdbc/DynamicUserDaoTest", "new://Resource?type=DataSource");
+ p.setProperty("jdbc/DynamicUserDaoTest.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.setProperty("jdbc/DynamicUserDaoTest.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.setProperty("jdbc/DynamicUserDaoTest.UserName", "sa");
+ p.setProperty("jdbc/DynamicUserDaoTest.Password", "");
+
+ container = EJBContainer.createEJBContainer(p);
+ }
+
+ @Before
+ public void injectAndInit() throws NamingException {
+ container.getContext().bind("inject", this);
+ if (!initialized) {
+ for (int i = 0; i < 10; i++) {
+ final User u = new User();
+ u.setAge(i % 4);
+ if (i % 3 == 0) {
+ u.setName("foo");
+ } else {
+ u.setName("bar-" + i);
+ }
+ dao.save(u);
+ }
+ initialized = true;
+ }
+ }
+
+ @AfterClass
+ public static void close() {
+ container.close();
+ }
+}
diff --git a/content/examples/spring-data-proxy-meta/src/test/resources/META-INF/beans.xml b/content/examples/spring-data-proxy-meta/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/spring-data-proxy-meta/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/spring-data-proxy.html b/content/examples/spring-data-proxy.html
new file mode 100644
index 0000000..c0eafe4
--- /dev/null
+++ b/content/examples/spring-data-proxy.html
@@ -0,0 +1,212 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/spring-data-proxy.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>spring-data-proxy</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example spring-data-proxy can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/spring-data-proxy" class="bare">https://github.com/apache/tomee/tree/master/examples/spring-data-proxy</a></p>
+</div>
+</div>
+</div>
+<h1 id="_spring_data_sample" class="sect0">Spring Data sample #</h1>
+<div class="paragraph">
+<p>This example uses OpenEJB hooks to replace an EJB implementation by a proxy
+to uses Spring Data in your preferred container.</p>
+</div>
+<div class="paragraph">
+<p>It is pretty simple: simply provide to OpenEJB an InvocationHandler using delegating to spring data
+and that’s it!</p>
+</div>
+<div class="paragraph">
+<p>It is what is done in org.superbiz.dynamic.SpringDataProxy.</p>
+</div>
+<div class="paragraph">
+<p>It contains a little trick: even if it is not annotated "implementingInterfaceClass" attribute
+is injected by OpenEJB to get the interface.</p>
+</div>
+<div class="paragraph">
+<p>Then we simply create the Spring Data repository and delegate to it.</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/spring-data-proxy.pdf b/content/examples/spring-data-proxy.pdf
new file mode 100644
index 0000000..1fe438f
--- /dev/null
+++ b/content/examples/spring-data-proxy.pdf
Binary files differ
diff --git a/content/examples/spring-data-proxy/README.md b/content/examples/spring-data-proxy/README.md
new file mode 100755
index 0000000..123e4f5
--- /dev/null
+++ b/content/examples/spring-data-proxy/README.md
@@ -0,0 +1,14 @@
+# Spring Data sample #
+
+This example uses OpenEJB hooks to replace an EJB implementation by a proxy
+to uses Spring Data in your preferred container.
+
+It is pretty simple: simply provide to OpenEJB an InvocationHandler using delegating to spring data
+and that's it!
+
+It is what is done in org.superbiz.dynamic.SpringDataProxy.
+
+It contains a little trick: even if it is not annotated "implementingInterfaceClass" attribute
+is injected by OpenEJB to get the interface.
+
+Then we simply create the Spring Data repository and delegate to it.
diff --git a/content/examples/spring-data-proxy/pom.xml b/content/examples/spring-data-proxy/pom.xml
new file mode 100755
index 0000000..2b1a03d
--- /dev/null
+++ b/content/examples/spring-data-proxy/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>spring-data-proxy</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Spring Data</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-jpa</artifactId>
+ <version>1.0.3.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/spring-data-proxy/src/main/java/org/superbiz/dynamic/SpringDataProxy.java b/content/examples/spring-data-proxy/src/main/java/org/superbiz/dynamic/SpringDataProxy.java
new file mode 100755
index 0000000..2704223
--- /dev/null
+++ b/content/examples/spring-data-proxy/src/main/java/org/superbiz/dynamic/SpringDataProxy.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.springframework.data.jpa.repository.support.JpaRepositoryFactory;
+import org.springframework.data.repository.Repository;
+
+import javax.annotation.Resource;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class SpringDataProxy implements InvocationHandler {
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Resource(name = "implementingInterfaceClass")
+ private Class<Repository<?, ?>> implementingInterfaceClass; // implicitly for this kind of proxy
+
+ private final AtomicReference<Repository<?, ?>> repository = new AtomicReference<Repository<?, ?>>();
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (repository.get() == null) {
+ synchronized (this) {
+ if (repository.get() == null) {
+ repository.set(new JpaRepositoryFactory(em).getRepository(implementingInterfaceClass));
+ }
+ }
+ }
+ return method.invoke(repository.get(), args);
+ }
+}
diff --git a/content/examples/spring-data-proxy/src/main/java/org/superbiz/dynamic/User.java b/content/examples/spring-data-proxy/src/main/java/org/superbiz/dynamic/User.java
new file mode 100755
index 0000000..855d6cf
--- /dev/null
+++ b/content/examples/spring-data-proxy/src/main/java/org/superbiz/dynamic/User.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class User {
+
+ @Id
+ @GeneratedValue
+ private long id;
+ private String name;
+ private int age;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
diff --git a/content/examples/spring-data-proxy/src/main/java/org/superbiz/dynamic/UserSpringDataDao.java b/content/examples/spring-data-proxy/src/main/java/org/superbiz/dynamic/UserSpringDataDao.java
new file mode 100755
index 0000000..4491ed3
--- /dev/null
+++ b/content/examples/spring-data-proxy/src/main/java/org/superbiz/dynamic/UserSpringDataDao.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.apache.openejb.api.Proxy;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.Param;
+
+import javax.ejb.Stateless;
+import javax.persistence.PersistenceContext;
+
+@Stateless
+@Proxy(SpringDataProxy.class)
+@PersistenceContext(name = "dynamic")
+public interface UserSpringDataDao extends JpaRepository<User, Long> {
+
+ User findByName(@Param("name") final String name);
+}
diff --git a/content/examples/spring-data-proxy/src/main/resources/META-INF/beans.xml b/content/examples/spring-data-proxy/src/main/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/spring-data-proxy/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/spring-data-proxy/src/main/resources/META-INF/persistence.xml b/content/examples/spring-data-proxy/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..97d2ba5
--- /dev/null
+++ b/content/examples/spring-data-proxy/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="2.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="dynamic" transaction-type="JTA">
+ <jta-data-source>jdbc/dynamicDB</jta-data-source>
+ <class>org.superbiz.dynamic.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/spring-data-proxy/src/test/java/org/superbiz/dynamic/DynamicUserDaoTest.java b/content/examples/spring-data-proxy/src/test/java/org/superbiz/dynamic/DynamicUserDaoTest.java
new file mode 100755
index 0000000..2001849
--- /dev/null
+++ b/content/examples/spring-data-proxy/src/test/java/org/superbiz/dynamic/DynamicUserDaoTest.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+import javax.naming.NamingException;
+import java.util.Collection;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class DynamicUserDaoTest {
+
+ private static EJBContainer container;
+ private static boolean initialized = false;
+
+ @Inject
+ private UserSpringDataDao dao;
+
+ @Test
+ public void findAll() {
+ Collection<User> users = dao.findAll();
+ assertEquals(10, users.size());
+ }
+
+ @Test
+ public void findByName() {
+ User user = dao.findByName("bar-1");
+ assertNotNull(user);
+ assertEquals("bar-1", user.getName());
+ }
+
+ @BeforeClass
+ public static void start() throws Exception {
+ final Properties p = new Properties();
+
+ p.setProperty("openejb.deployments.classpath.include", "spring-data-proxy");
+ p.setProperty("openejb.exclude-include.order", "exclude-include");
+
+ p.setProperty("jdbc/DynamicUserDaoTest", "new://Resource?type=DataSource");
+ p.setProperty("jdbc/DynamicUserDaoTest", "new://Resource?type=DataSource");
+ p.setProperty("jdbc/DynamicUserDaoTest.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.setProperty("jdbc/DynamicUserDaoTest.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+ p.setProperty("jdbc/DynamicUserDaoTest.UserName", "sa");
+ p.setProperty("jdbc/DynamicUserDaoTest.Password", "");
+
+ container = EJBContainer.createEJBContainer(p);
+ }
+
+ @Before
+ public void injectAndInit() throws NamingException {
+ container.getContext().bind("inject", this);
+ if (!initialized) {
+ for (int i = 0; i < 10; i++) {
+ final User u = new User();
+ u.setAge(i % 4);
+ if (i % 3 == 0) {
+ u.setName("foo");
+ } else {
+ u.setName("bar-" + i);
+ }
+ dao.save(u);
+ }
+ initialized = true;
+ }
+ }
+
+ @AfterClass
+ public static void close() {
+ container.close();
+ }
+}
diff --git a/content/examples/spring-data-proxy/src/test/resources/META-INF/beans.xml b/content/examples/spring-data-proxy/src/test/resources/META-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/spring-data-proxy/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/src.xml b/content/examples/src.xml
new file mode 100755
index 0000000..21fba72
--- /dev/null
+++ b/content/examples/src.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<assembly>
+ <id>src</id>
+ <formats>
+ <format>zip</format>
+ <format>tar.gz</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>.</directory>
+ <outputDirectory>/</outputDirectory>
+ <excludes>
+ <exclude>**/target/**</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/content/examples/struts.html b/content/examples/struts.html
new file mode 100644
index 0000000..81f1dbb
--- /dev/null
+++ b/content/examples/struts.html
@@ -0,0 +1,634 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/struts.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Struts</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example struts can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/struts" class="bare">https://github.com/apache/tomee/tree/master/examples/struts</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_adduser">AddUser</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.struts;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+
+public class AddUser {
+
+ private int id;
+ private String firstName;
+ private String lastName;
+ private String errorMessage;
+
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String execute() {
+
+ try {
+ UserService service = null;
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.core.LocalInitialContextFactory");
+ Context ctx = new InitialContext(props);
+ service = (UserService) ctx.lookup("UserServiceImplLocal");
+ service.add(new User(id, firstName, lastName));
+ } catch (Exception e) {
+ this.errorMessage = e.getMessage();
+ return "failure";
+ }
+
+ return "success";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_adduserform">AddUserForm</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.struts;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+
+public class AddUserForm extends ActionSupport {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_finduser">FindUser</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.struts;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+public class FindUser {
+
+ private int id;
+ private String errorMessage;
+ private User user;
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String execute() {
+
+ try {
+ UserService service = null;
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.core.LocalInitialContextFactory");
+ Context ctx = new InitialContext(props);
+ service = (UserService) ctx.lookup("UserServiceImplLocal");
+ this.user = service.find(id);
+ } catch (Exception e) {
+ this.errorMessage = e.getMessage();
+ return "failure";
+ }
+
+ return "success";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_finduserform">FindUserForm</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.struts;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+
+public class FindUserForm extends ActionSupport {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_listallusers">ListAllUsers</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.struts;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.List;
+import java.util.Properties;
+
+public class ListAllUsers {
+
+ private int id;
+ private String errorMessage;
+ private List<User> users;
+
+ public List<User> getUsers() {
+ return users;
+ }
+
+ public void setUsers(List<User> users) {
+ this.users = users;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String execute() {
+
+ try {
+ UserService service = null;
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.core.LocalInitialContextFactory");
+ Context ctx = new InitialContext(props);
+ service = (UserService) ctx.lookup("UserServiceImplLocal");
+ this.users = service.findAll();
+ } catch (Exception e) {
+ this.errorMessage = e.getMessage();
+ return "failure";
+ }
+
+ return "success";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_user">User</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.struts;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "USER")
+public class User implements Serializable {
+ private long id;
+ private String firstName;
+ private String lastName;
+
+ public User(long id, String firstName, String lastName) {
+ super();
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public User() {
+ }
+
+ @Id
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_userservice">UserService</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.struts;
+
+import java.util.List;
+
+public interface UserService {
+ public void add(User user);
+
+ public User find(int id);
+
+ public List<User> findAll();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_userserviceimpl">UserServiceImpl</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.struts;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.util.List;
+
+@Stateless
+public class UserServiceImpl implements UserService {
+
+ @PersistenceContext(unitName = "user")
+ private EntityManager manager;
+
+ public void add(User user) {
+ manager.persist(user);
+ }
+
+ public User find(int id) {
+ return manager.find(User.class, id);
+ }
+
+ public List<User> findAll() {
+ return manager.createQuery("select u from User u").getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"></persistence-unit>
+
+ -->
+</persistence>
+
+## struts.xml
+
+<struts>
+ <constant name="struts.devMode" value="true"></constant>
+ <package name="default" namespace="/" extends="struts-default">
+ <action name="addUserForm" class="org.superbiz.struts.AddUserForm">
+ <result>/addUserForm.jsp</result>
+ </action>
+ <action name="addUser" class="org.superbiz.struts.AddUser">
+ <result name="success">/addedUser.jsp</result>
+ <result name='failure'>/addUserForm.jsp</result>
+ </action>
+ <action name="findUserForm" class="org.superbiz.struts.FindUserForm">
+ <result>/findUserForm.jsp</result>
+ </action>
+ <action name="findUser" class="org.superbiz.struts.FindUser">
+ <result name='success'>/displayUser.jsp</result>
+ <result name='failure'>/findUserForm.jsp</result>
+ </action>
+ <action name="listAllUsers" class="org.superbiz.struts.ListAllUsers">
+ <result>/displayUsers.jsp</result>
+ </action>
+
+ </package>
+</struts>
+
+## decorators.xml
+
+<decorators defaultdir="/decorators">
+ <decorator name="main" page="layout.jsp">
+ <pattern>/*</pattern>
+ </decorator>
+</decorators>
+
+## web.xml
+
+<web-app 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/web-app_2_5.xsd"
+ version="2.5">
+ <display-name>Learn EJB3 and Struts2</display-name>
+ <filter>
+ <filter-name>struts2</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
+ <init-param>
+ <param-name>actionPackages</param-name>
+ <param-value>com.lq</param-value>
+ </init-param>
+ </filter>
+ <filter>
+ <filter-name>struts-cleanup</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
+ </filter>
+ <filter>
+ <filter-name>sitemesh</filter-name>
+ <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>struts-cleanup</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>sitemesh</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>struts2</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+ <jsp-config>
+ <jsp-property-group>
+ <description>JSP configuration of all the JSP's</description>
+ <url-pattern>*.jsp</url-pattern>
+ <include-prelude>/prelude.jspf</include-prelude>
+ </jsp-property-group>
+ </jsp-config>
+</web-app></code></pre>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/struts.pdf b/content/examples/struts.pdf
new file mode 100644
index 0000000..f6940ea
--- /dev/null
+++ b/content/examples/struts.pdf
Binary files differ
diff --git a/content/examples/struts/README.md b/content/examples/struts/README.md
new file mode 100755
index 0000000..1b76318
--- /dev/null
+++ b/content/examples/struts/README.md
@@ -0,0 +1,388 @@
+Title: Struts
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## AddUser
+
+ package org.superbiz.struts;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.Properties;
+
+
+ public class AddUser {
+
+ private int id;
+ private String firstName;
+ private String lastName;
+ private String errorMessage;
+
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String execute() {
+
+ try {
+ UserService service = null;
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.core.LocalInitialContextFactory");
+ Context ctx = new InitialContext(props);
+ service = (UserService) ctx.lookup("UserServiceImplLocal");
+ service.add(new User(id, firstName, lastName));
+ } catch (Exception e) {
+ this.errorMessage = e.getMessage();
+ return "failure";
+ }
+
+ return "success";
+ }
+ }
+
+## AddUserForm
+
+ package org.superbiz.struts;
+
+ import com.opensymphony.xwork2.ActionSupport;
+
+
+ public class AddUserForm extends ActionSupport {
+ }
+
+## FindUser
+
+ package org.superbiz.struts;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.Properties;
+
+ public class FindUser {
+
+ private int id;
+ private String errorMessage;
+ private User user;
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String execute() {
+
+ try {
+ UserService service = null;
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.core.LocalInitialContextFactory");
+ Context ctx = new InitialContext(props);
+ service = (UserService) ctx.lookup("UserServiceImplLocal");
+ this.user = service.find(id);
+ } catch (Exception e) {
+ this.errorMessage = e.getMessage();
+ return "failure";
+ }
+
+ return "success";
+ }
+ }
+
+## FindUserForm
+
+ package org.superbiz.struts;
+
+ import com.opensymphony.xwork2.ActionSupport;
+
+
+ public class FindUserForm extends ActionSupport {
+ }
+
+## ListAllUsers
+
+ package org.superbiz.struts;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.List;
+ import java.util.Properties;
+
+ public class ListAllUsers {
+
+ private int id;
+ private String errorMessage;
+ private List<User> users;
+
+ public List<User> getUsers() {
+ return users;
+ }
+
+ public void setUsers(List<User> users) {
+ this.users = users;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String execute() {
+
+ try {
+ UserService service = null;
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.core.LocalInitialContextFactory");
+ Context ctx = new InitialContext(props);
+ service = (UserService) ctx.lookup("UserServiceImplLocal");
+ this.users = service.findAll();
+ } catch (Exception e) {
+ this.errorMessage = e.getMessage();
+ return "failure";
+ }
+
+ return "success";
+ }
+ }
+
+## User
+
+ package org.superbiz.struts;
+
+ import javax.persistence.Entity;
+ import javax.persistence.Id;
+ import javax.persistence.Table;
+ import java.io.Serializable;
+
+ @Entity
+ @Table(name = "USER")
+ public class User implements Serializable {
+ private long id;
+ private String firstName;
+ private String lastName;
+
+ public User(long id, String firstName, String lastName) {
+ super();
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public User() {
+ }
+
+ @Id
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+ }
+
+## UserService
+
+ package org.superbiz.struts;
+
+ import java.util.List;
+
+ public interface UserService {
+ public void add(User user);
+
+ public User find(int id);
+
+ public List<User> findAll();
+ }
+
+## UserServiceImpl
+
+ package org.superbiz.struts;
+
+ import javax.ejb.Stateless;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import java.util.List;
+
+ @Stateless
+ public class UserServiceImpl implements UserService {
+
+ @PersistenceContext(unitName = "user")
+ private EntityManager manager;
+
+ public void add(User user) {
+ manager.persist(user);
+ }
+
+ public User find(int id) {
+ return manager.find(User.class, id);
+ }
+
+ public List<User> findAll() {
+ return manager.createQuery("select u from User u").getResultList();
+ }
+ }
+
+## persistence.xml
+
+ </persistence-unit>
+
+ -->
+ </persistence>
+
+## struts.xml
+
+ <struts>
+ <constant name="struts.devMode" value="true"></constant>
+ <package name="default" namespace="/" extends="struts-default">
+ <action name="addUserForm" class="org.superbiz.struts.AddUserForm">
+ <result>/addUserForm.jsp</result>
+ </action>
+ <action name="addUser" class="org.superbiz.struts.AddUser">
+ <result name="success">/addedUser.jsp</result>
+ <result name='failure'>/addUserForm.jsp</result>
+ </action>
+ <action name="findUserForm" class="org.superbiz.struts.FindUserForm">
+ <result>/findUserForm.jsp</result>
+ </action>
+ <action name="findUser" class="org.superbiz.struts.FindUser">
+ <result name='success'>/displayUser.jsp</result>
+ <result name='failure'>/findUserForm.jsp</result>
+ </action>
+ <action name="listAllUsers" class="org.superbiz.struts.ListAllUsers">
+ <result>/displayUsers.jsp</result>
+ </action>
+
+ </package>
+ </struts>
+
+## decorators.xml
+
+ <decorators defaultdir="/decorators">
+ <decorator name="main" page="layout.jsp">
+ <pattern>/*</pattern>
+ </decorator>
+ </decorators>
+
+## web.xml
+
+ <web-app 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/web-app_2_5.xsd"
+ version="2.5">
+ <display-name>Learn EJB3 and Struts2</display-name>
+ <filter>
+ <filter-name>struts2</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
+ <init-param>
+ <param-name>actionPackages</param-name>
+ <param-value>com.lq</param-value>
+ </init-param>
+ </filter>
+ <filter>
+ <filter-name>struts-cleanup</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
+ </filter>
+ <filter>
+ <filter-name>sitemesh</filter-name>
+ <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>struts-cleanup</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>sitemesh</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>struts2</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+ <jsp-config>
+ <jsp-property-group>
+ <description>JSP configuration of all the JSP's</description>
+ <url-pattern>*.jsp</url-pattern>
+ <include-prelude>/prelude.jspf</include-prelude>
+ </jsp-property-group>
+ </jsp-config>
+ </web-app>
+
diff --git a/content/examples/struts/README.txt b/content/examples/struts/README.txt
new file mode 100755
index 0000000..86544e6
--- /dev/null
+++ b/content/examples/struts/README.txt
@@ -0,0 +1,25 @@
+A simple web-app showing how to use maven, struts2, site-mesh, mysql/hsqldb,openejb with tomcat
+This application allows you to insert, find and findAll users. It uses one @Entity named User
+and uses a @Local @Stateless session bean to insert, find and find all User's.
+
+To run this example, perform the following steps:-
+1. Install latest Tomcat
+2. Deploy OpenEJB WAR in tomcat
+3. Open <<tomcat-install>>/conf/tomcat-users.xml and add the following user
+ <user username="admin" password="" roles="manager"/>
+4. Run the following command while in the struts directory
+ mvn clean install war:exploded tomcat:deploy
+5. The above will deploy this web application to tomcat.
+6. To test the application, open a web browser and navigate to
+ http://localhost:8080/struts
+7. Use the links on the homepage to add, find and list users
+
+By default this example uses hsqldb database whose data should be stored under
+ <<tomcat-install>>/data
+
+If you want to use mysql, then open persistence.xml (its under src/main/resources/META-INF) and
+comment out the <persistence-unit> section for hsqldb and uncomment the one for mysql. Read the
+comments in persistence.xml for further instructions
+
+Once you make the change, you would need to redeploy the application. Run the following command
+ mvn clean install war:exploded tomcat:redeploy
\ No newline at end of file
diff --git a/content/examples/struts/pom.xml b/content/examples/struts/pom.xml
new file mode 100755
index 0000000..539492d
--- /dev/null
+++ b/content/examples/struts/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz.struts</groupId>
+ <artifactId>struts</artifactId>
+ <packaging>war</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: Struts</name>
+ <url>http://openejb.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+
+ <repository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <id>Codehaus Snapshots</id>
+ <url>http://snapshots.repository.codehaus.org/</url>
+ </repository>
+ </repositories>
+
+ <build>
+ <finalName>struts</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.tomcat.maven</groupId>
+ <artifactId>tomcat7-maven-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <url>http://localhost:8080/manager/html</url>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-core</artifactId>
+ <version>2.1.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-sitemesh-plugin</artifactId>
+ <version>2.1.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.13</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/struts/src/main/java/org/superbiz/struts/AddUser.java b/content/examples/struts/src/main/java/org/superbiz/struts/AddUser.java
new file mode 100755
index 0000000..034feac
--- /dev/null
+++ b/content/examples/struts/src/main/java/org/superbiz/struts/AddUser.java
@@ -0,0 +1,80 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+package org.superbiz.struts;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+public class AddUser {
+
+ private int id;
+ private String firstName;
+ private String lastName;
+ private String errorMessage;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String execute() {
+
+ try {
+ UserService service = null;
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.core.LocalInitialContextFactory");
+ Context ctx = new InitialContext(props);
+ service = (UserService) ctx.lookup("UserServiceImplLocal");
+ service.add(new User(id, firstName, lastName));
+ } catch (Exception e) {
+ this.errorMessage = e.getMessage();
+ return "failure";
+ }
+
+ return "success";
+ }
+}
diff --git a/content/examples/struts/src/main/java/org/superbiz/struts/AddUserForm.java b/content/examples/struts/src/main/java/org/superbiz/struts/AddUserForm.java
new file mode 100755
index 0000000..e132005
--- /dev/null
+++ b/content/examples/struts/src/main/java/org/superbiz/struts/AddUserForm.java
@@ -0,0 +1,24 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+package org.superbiz.struts;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+public class AddUserForm extends ActionSupport {
+
+}
diff --git a/content/examples/struts/src/main/java/org/superbiz/struts/FindUser.java b/content/examples/struts/src/main/java/org/superbiz/struts/FindUser.java
new file mode 100755
index 0000000..2344da9
--- /dev/null
+++ b/content/examples/struts/src/main/java/org/superbiz/struts/FindUser.java
@@ -0,0 +1,71 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+package org.superbiz.struts;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+public class FindUser {
+
+ private int id;
+ private String errorMessage;
+ private User user;
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String execute() {
+
+ try {
+ UserService service = null;
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.core.LocalInitialContextFactory");
+ Context ctx = new InitialContext(props);
+ service = (UserService) ctx.lookup("UserServiceImplLocal");
+ this.user = service.find(id);
+ } catch (Exception e) {
+ this.errorMessage = e.getMessage();
+ return "failure";
+ }
+
+ return "success";
+ }
+}
diff --git a/content/examples/struts/src/main/java/org/superbiz/struts/FindUserForm.java b/content/examples/struts/src/main/java/org/superbiz/struts/FindUserForm.java
new file mode 100755
index 0000000..9f5eb06
--- /dev/null
+++ b/content/examples/struts/src/main/java/org/superbiz/struts/FindUserForm.java
@@ -0,0 +1,24 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+package org.superbiz.struts;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+public class FindUserForm extends ActionSupport {
+
+}
diff --git a/content/examples/struts/src/main/java/org/superbiz/struts/ListAllUsers.java b/content/examples/struts/src/main/java/org/superbiz/struts/ListAllUsers.java
new file mode 100755
index 0000000..2c4d447
--- /dev/null
+++ b/content/examples/struts/src/main/java/org/superbiz/struts/ListAllUsers.java
@@ -0,0 +1,72 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+package org.superbiz.struts;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.List;
+import java.util.Properties;
+
+public class ListAllUsers {
+
+ private int id;
+ private String errorMessage;
+ private List<User> users;
+
+ public List<User> getUsers() {
+ return users;
+ }
+
+ public void setUsers(List<User> users) {
+ this.users = users;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String execute() {
+
+ try {
+ UserService service = null;
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.openejb.core.LocalInitialContextFactory");
+ Context ctx = new InitialContext(props);
+ service = (UserService) ctx.lookup("UserServiceImplLocal");
+ this.users = service.findAll();
+ } catch (Exception e) {
+ this.errorMessage = e.getMessage();
+ return "failure";
+ }
+
+ return "success";
+ }
+}
diff --git a/content/examples/struts/src/main/java/org/superbiz/struts/User.java b/content/examples/struts/src/main/java/org/superbiz/struts/User.java
new file mode 100755
index 0000000..c15bcbd
--- /dev/null
+++ b/content/examples/struts/src/main/java/org/superbiz/struts/User.java
@@ -0,0 +1,68 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+package org.superbiz.struts;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "USER")
+public class User implements Serializable {
+
+ private long id;
+ private String firstName;
+ private String lastName;
+
+ public User(long id, String firstName, String lastName) {
+ super();
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public User() {
+ }
+
+ @Id
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+}
diff --git a/content/examples/struts/src/main/java/org/superbiz/struts/UserService.java b/content/examples/struts/src/main/java/org/superbiz/struts/UserService.java
new file mode 100755
index 0000000..784aaa5
--- /dev/null
+++ b/content/examples/struts/src/main/java/org/superbiz/struts/UserService.java
@@ -0,0 +1,29 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+package org.superbiz.struts;
+
+import java.util.List;
+
+public interface UserService {
+
+ public void add(User user);
+
+ public User find(int id);
+
+ public List<User> findAll();
+}
diff --git a/content/examples/struts/src/main/java/org/superbiz/struts/UserServiceImpl.java b/content/examples/struts/src/main/java/org/superbiz/struts/UserServiceImpl.java
new file mode 100755
index 0000000..1cd1d6d
--- /dev/null
+++ b/content/examples/struts/src/main/java/org/superbiz/struts/UserServiceImpl.java
@@ -0,0 +1,43 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+package org.superbiz.struts;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.util.List;
+
+@Stateless
+public class UserServiceImpl implements UserService {
+
+ @PersistenceContext(unitName = "user")
+ private EntityManager manager;
+
+ public void add(User user) {
+ manager.persist(user);
+ }
+
+ public User find(int id) {
+ return manager.find(User.class, id);
+ }
+
+ public List<User> findAll() {
+ return manager.createQuery("select u from User u").getResultList();
+ }
+
+}
diff --git a/content/examples/struts/src/main/resources/META-INF/persistence.xml b/content/examples/struts/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..079e3f3
--- /dev/null
+++ b/content/examples/struts/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+ http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <!-- Uses HSQLDB which comes bundles with OpenEJB -->
+ <persistence-unit name="user">
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ <jta-data-source>java:openejb/Resource/My DataSource</jta-data-source>
+ <non-jta-data-source>java:openejb/Resource/My Unmanaged DataSource</non-jta-data-source>
+ <class>org.superbiz.struts.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+
+ <!-- Uncomment the below persistence-unit if you want to use MySql. Make sure to comment out the persistence-unit above first.
+ You would need to open <<Tomcat-install>>/conf/openejb.xml and add two Resource elements as shown.
+ You would also need to create a database named userdb
+ <Resource id="mysql_managed" type="DataSource">
+ JdbcDriver com.mysql.jdbc.Driver
+ JdbcUrl jdbc:mysql://localhost/userdb
+ UserName root
+ Password yourpassword
+ JtaManaged true
+ </Resource>
+ <Resource id="mysql_unmanaged" type="DataSource">
+ JdbcDriver com.mysql.jdbc.Driver
+ JdbcUrl jdbc:mysql://localhost/userdb
+ UserName root
+ Password yourpassword
+ JtaManaged false
+ </Resource>
+
+ -->
+ <!--
+<persistence-unit name="user">
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ <jta-data-source>java:openejb/Resource/mysql_managed</jta-data-source>
+ <non-jta-data-source>java:openejb/Resource/mysql_unmanaged</non-jta-data-source>
+ <class>org.superbiz.struts.User</class>
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
+ </properties>
+</persistence-unit>
+
+ -->
+</persistence>
\ No newline at end of file
diff --git a/content/examples/struts/src/main/resources/struts.xml b/content/examples/struts/src/main/resources/struts.xml
new file mode 100755
index 0000000..4c3478d
--- /dev/null
+++ b/content/examples/struts/src/main/resources/struts.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/struts-2.0.dtd">
+
+<struts>
+ <constant name="struts.devMode" value="true"></constant>
+ <package name="default" namespace="/" extends="struts-default">
+ <action name="addUserForm" class="org.superbiz.struts.AddUserForm">
+ <result>/addUserForm.jsp</result>
+ </action>
+ <action name="addUser" class="org.superbiz.struts.AddUser">
+ <result name="success">/addedUser.jsp</result>
+ <result name='failure'>/addUserForm.jsp</result>
+ </action>
+ <action name="findUserForm" class="org.superbiz.struts.FindUserForm">
+ <result>/findUserForm.jsp</result>
+ </action>
+ <action name="findUser" class="org.superbiz.struts.FindUser">
+ <result name='success'>/displayUser.jsp</result>
+ <result name='failure'>/findUserForm.jsp</result>
+ </action>
+ <action name="listAllUsers" class="org.superbiz.struts.ListAllUsers">
+ <result>/displayUsers.jsp</result>
+ </action>
+
+ </package>
+</struts>
\ No newline at end of file
diff --git a/content/examples/struts/src/main/webapp/WEB-INF/decorators.xml b/content/examples/struts/src/main/webapp/WEB-INF/decorators.xml
new file mode 100755
index 0000000..068ce87
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/WEB-INF/decorators.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<decorators defaultdir="/decorators">
+ <decorator name="main" page="layout.jsp">
+ <pattern>/*</pattern>
+ </decorator>
+</decorators>
\ No newline at end of file
diff --git a/content/examples/struts/src/main/webapp/WEB-INF/web.xml b/content/examples/struts/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..9a60a8e
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<web-app 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/web-app_2_5.xsd"
+ version="2.5">
+ <display-name>Learn EJB3 and Struts2</display-name>
+ <filter>
+ <filter-name>struts2</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
+ <init-param>
+ <param-name>actionPackages</param-name>
+ <param-value>com.lq</param-value>
+ </init-param>
+ </filter>
+ <filter>
+ <filter-name>struts-cleanup</filter-name>
+ <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
+ </filter>
+ <filter>
+ <filter-name>sitemesh</filter-name>
+ <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>struts-cleanup</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>sitemesh</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>struts2</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+ <jsp-config>
+ <jsp-property-group>
+ <description>JSP configuration of all the JSP's</description>
+ <url-pattern>*.jsp</url-pattern>
+ <include-prelude>/prelude.jspf</include-prelude>
+ </jsp-property-group>
+ </jsp-config>
+</web-app>
diff --git a/content/examples/struts/src/main/webapp/addUserForm.jsp b/content/examples/struts/src/main/webapp/addUserForm.jsp
new file mode 100755
index 0000000..76f0d95
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/addUserForm.jsp
@@ -0,0 +1,23 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<title>Add User</title>
+<s:form action="addUser">
+ <s:textfield name="id" label="ID *" required="true"/>
+ <s:textfield name="firstName" label="First Name *" required="true"/>
+ <s:textfield name="lastName" label="Last Name *" required="true"/>
+ <s:submit/>
+</s:form>
\ No newline at end of file
diff --git a/content/examples/struts/src/main/webapp/addedUser.jsp b/content/examples/struts/src/main/webapp/addedUser.jsp
new file mode 100755
index 0000000..2260bbd
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/addedUser.jsp
@@ -0,0 +1,19 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<title>User added</title>
+
+<h3>User added successfully</h3>
diff --git a/content/examples/struts/src/main/webapp/decorators/layout.jsp b/content/examples/struts/src/main/webapp/decorators/layout.jsp
new file mode 100755
index 0000000..ddbebfe
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/decorators/layout.jsp
@@ -0,0 +1,43 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator"
+ prefix="decorator" %>
+<%@ taglib uri="http://www.opensymphony.com/sitemesh/page"
+ prefix="pages" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+ <title>My Site - <decorator:title default="Welcome!"/></title>
+ <link rel="stylesheet" type="text/css" href="style/layout.css"/>
+ <decorator:head/>
+</head>
+<body>
+<div id='page'>
+ <div id='header'><a href="addUserForm.action">Add User</a>
+ | <a href="findUserForm.action">Find User</a>
+ | <a href="listAllUsers.action">List all users</a></div>
+ <div id='content'>
+ <p style="color: red"><s:property value="errorMessage"/></p>
+ <decorator:body/>
+
+ </div>
+ <div id='footer'>Footer</div>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/content/examples/struts/src/main/webapp/displayUser.jsp b/content/examples/struts/src/main/webapp/displayUser.jsp
new file mode 100755
index 0000000..900ba4f
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/displayUser.jsp
@@ -0,0 +1,33 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<title>User Details</title>
+
+<h2>User Details </h2>
+<table>
+ <tr>
+ <td><b>ID</b></td>
+ <td>${user.id }</td>
+ </tr>
+ <tr>
+ <td><b>First Name</b></td>
+ <td>${user.firstName }</td>
+ </tr>
+ <tr>
+ <td><b>Last Name</b></td>
+ <td>${user.lastName }</td>
+ </tr>
+</table>
\ No newline at end of file
diff --git a/content/examples/struts/src/main/webapp/displayUsers.jsp b/content/examples/struts/src/main/webapp/displayUsers.jsp
new file mode 100755
index 0000000..16ac1ca
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/displayUsers.jsp
@@ -0,0 +1,32 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<title>All Users</title>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<table>
+ <tr>
+ <th>ID</th>
+ <th>First Name</th>
+ <th>Last Name</th>
+ </tr>
+ <c:forEach items="${users}" var="u">
+ <tr>
+ <td>${u.id }</td>
+ <td>${u.firstName }</td>
+ <td>${u.lastName }</td>
+ </tr>
+ </c:forEach>
+</table>
diff --git a/content/examples/struts/src/main/webapp/findUserForm.jsp b/content/examples/struts/src/main/webapp/findUserForm.jsp
new file mode 100755
index 0000000..2c5a507
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/findUserForm.jsp
@@ -0,0 +1,21 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<title>Find User</title>
+<s:form action="findUser">
+ <s:textfield name="id" label="Enter ID *" required="true"/>
+ <s:submit/>
+</s:form>
\ No newline at end of file
diff --git a/content/examples/struts/src/main/webapp/index.jsp b/content/examples/struts/src/main/webapp/index.jsp
new file mode 100755
index 0000000..4be7b0c
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/index.jsp
@@ -0,0 +1,17 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<title>Main page</title>
diff --git a/content/examples/struts/src/main/webapp/prelude.jspf b/content/examples/struts/src/main/webapp/prelude.jspf
new file mode 100755
index 0000000..6d589b7
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/prelude.jspf
@@ -0,0 +1,20 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
diff --git a/content/examples/struts/src/main/webapp/style/layout.css b/content/examples/struts/src/main/webapp/style/layout.css
new file mode 100755
index 0000000..66fb1c6
--- /dev/null
+++ b/content/examples/struts/src/main/webapp/style/layout.css
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+body {
+ margin: 0;
+ padding: 0;
+ background: white;
+ text-align: center;
+}
+
+div#page {
+ width: 800px;
+ margin: 0 auto;
+ padding: 0;
+ background: white;
+ text-align: center;
+}
+
+div#header {
+ margin: 0 0 5em 0;
+ padding: 40px 20px;
+ color: white;
+ background: black;
+ text-align: center;
+}
+
+div#content {
+ margin: 0;
+ padding: 0;
+}
+
+div#footer {
+ color: white;
+ background-color: black;
+}
+
+a, a:link, a:visited, a:active {
+ color: white;
+ background-color: black;
+}
+
+a:hover {
+ text-decoration: underline;
+ font-size: larger;
+}
\ No newline at end of file
diff --git a/content/examples/telephone-stateful.html b/content/examples/telephone-stateful.html
new file mode 100644
index 0000000..55030b1
--- /dev/null
+++ b/content/examples/telephone-stateful.html
@@ -0,0 +1,458 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/telephone-stateful.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Telephone Stateful</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example telephone-stateful can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/telephone-stateful" class="bare">https://github.com/apache/tomee/tree/master/examples/telephone-stateful</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+<div class="paragraph">
+<p>This example shows how to use OpenEJB’s remoting capabilities in an embedded scenario.</p>
+</div>
+<div class="paragraph">
+<p>The basic recipe is the same for a standard embedded scenario but with these added
+ingreditents:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><code>openejb.embedded.remotable</code> property</p>
+</li>
+<li>
+<p><code>openejb-ejbd</code> jar</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>While creating the InitialContext, pass in the openejb.embedded.remotable property with
+the value of "true". When this is seen by the LocalInitialContextFactory, it will boot up
+the Server ServiceManager in the VM which will in turn look for ServerServices in the
+classpath.</p>
+</div>
+<div class="paragraph">
+<p>Provided you have the openejb-ejbd jar in your classpath along with it’s dependencies
+(openejb-server, openejb-client, openejb-core), then those services will be brought online
+and remote clients will be able to connect into your vm and invoke beans.</p>
+</div>
+<div class="paragraph">
+<p>If you want to add more ServerServices such as the http version of the ejbd protocol you’d
+simply add the openejb-httpejbd jar to your classpath. A number of ServerServices are
+available currently:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>openejb-ejbd</p>
+</li>
+<li>
+<p>openejb-http</p>
+</li>
+<li>
+<p>openejb-telnet</p>
+</li>
+<li>
+<p>openejb-derbynet</p>
+</li>
+<li>
+<p>openejb-hsql</p>
+</li>
+<li>
+<p>openejb-activemq</p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_telephone">Telephone</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.telephone;
+
+public interface Telephone {
+
+ void speak(String words);
+
+ String listen();
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_telephonebean">TelephoneBean</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.telephone;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import java.util.ArrayList;
+import java.util.List;
+
+@Remote
+@Stateful
+public class TelephoneBean implements Telephone {
+
+ private static final String[] answers = {
+ "How nice.",
+ "Oh, of course.",
+ "Interesting.",
+ "Really?",
+ "No.",
+ "Definitely.",
+ "I wondered about that.",
+ "Good idea.",
+ "You don't say!",
+ };
+
+ private List<String> conversation = new ArrayList<String>();
+
+ public void speak(String words) {
+ conversation.add(words);
+ }
+
+ public String listen() {
+ if (conversation.size() == 0) {
+ return "Nothing has been said";
+ }
+
+ String lastThingSaid = conversation.get(conversation.size() - 1);
+ return answers[Math.abs(lastThingSaid.hashCode()) % answers.length];
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_telephonetest">TelephoneTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.telephone;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+public class TelephoneTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+ // Uncomment these properties to change the defaults
+ //properties.setProperty("ejbd.port", "4202");
+ //properties.setProperty("ejbd.bind", "localhost");
+ //properties.setProperty("ejbd.threads", "200");
+ //properties.setProperty("ejbd.disabled", "false");
+ //properties.setProperty("ejbd.only_from", "127.0.0.1,192.168.1.1");
+
+ new InitialContext(properties);
+ }
+
+ /**
+ * Lookup the Telephone bean via its remote interface but using the LocalInitialContextFactory
+ *
+ * @throws Exception
+ */
+ public void testTalkOverLocalNetwork() throws Exception {
+
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ InitialContext localContext = new InitialContext(properties);
+
+ Telephone telephone = (Telephone) localContext.lookup("TelephoneBeanRemote");
+
+ telephone.speak("Did you know I am talking directly through the embedded container?");
+
+ assertEquals("Interesting.", telephone.listen());
+
+
+ telephone.speak("Yep, I'm using the bean's remote interface but since the ejb container is embedded " +
+ "in the same vm I'm just using the LocalInitialContextFactory.");
+
+ assertEquals("Really?", telephone.listen());
+
+
+ telephone.speak("Right, you really only have to use the RemoteInitialContextFactory if you're in a different vm.");
+
+ assertEquals("Oh, of course.", telephone.listen());
+ }
+
+ /**
+ * Lookup the Telephone bean via its remote interface using the RemoteInitialContextFactory
+ *
+ * @throws Exception
+ */
+ public void testTalkOverRemoteNetwork() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ properties.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201");
+ InitialContext remoteContext = new InitialContext(properties);
+
+ Telephone telephone = (Telephone) remoteContext.lookup("TelephoneBeanRemote");
+
+ telephone.speak("Is this a local call?");
+
+ assertEquals("No.", telephone.listen());
+
+
+ telephone.speak("This would be a lot cooler if I was connecting from another VM then, huh?");
+
+ assertEquals("I wondered about that.", telephone.listen());
+
+
+ telephone.speak("I suppose I should hangup and call back over the LocalInitialContextFactory.");
+
+ assertEquals("Good idea.", telephone.listen());
+
+
+ telephone.speak("I'll remember this though in case I ever have to call you accross a network.");
+
+ assertEquals("Definitely.", telephone.listen());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.telephone.TelephoneTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/telephone-stateful
+INFO - openejb.base = /Users/dblevins/examples/telephone-stateful
+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/telephone-stateful/target/classes
+INFO - Beginning load: /Users/dblevins/examples/telephone-stateful/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/telephone-stateful/classpath.ear
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean TelephoneBean: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Enterprise application "/Users/dblevins/examples/telephone-stateful/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/telephone-stateful/classpath.ear
+INFO - Jndi(name=TelephoneBeanRemote) --> Ejb(deployment-id=TelephoneBean)
+INFO - Jndi(name=global/classpath.ear/telephone-stateful/TelephoneBean!org.superbiz.telephone.Telephone) --> Ejb(deployment-id=TelephoneBean)
+INFO - Jndi(name=global/classpath.ear/telephone-stateful/TelephoneBean) --> Ejb(deployment-id=TelephoneBean)
+INFO - Created Ejb(deployment-id=TelephoneBean, ejb-name=TelephoneBean, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=TelephoneBean, ejb-name=TelephoneBean, container=Default Stateful Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/telephone-stateful/classpath.ear)
+INFO - Initializing network services
+INFO - Creating ServerService(id=admin)
+INFO - Creating ServerService(id=ejbd)
+INFO - Creating ServerService(id=ejbds)
+INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+-------
+Ready!
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.448 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/telephone-stateful.pdf b/content/examples/telephone-stateful.pdf
new file mode 100644
index 0000000..cae2899
--- /dev/null
+++ b/content/examples/telephone-stateful.pdf
Binary files differ
diff --git a/content/examples/telephone-stateful/README.md b/content/examples/telephone-stateful/README.md
new file mode 100755
index 0000000..95cdbec
--- /dev/null
+++ b/content/examples/telephone-stateful/README.md
@@ -0,0 +1,221 @@
+Title: Telephone Stateful
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+This example shows how to use OpenEJB's remoting capabilities in an embedded scenario.
+
+The basic recipe is the same for a standard embedded scenario but with these added
+ingreditents:
+
+ * `openejb.embedded.remotable` property
+ * `openejb-ejbd` jar
+
+While creating the InitialContext, pass in the openejb.embedded.remotable property with
+the value of "true". When this is seen by the LocalInitialContextFactory, it will boot up
+the Server ServiceManager in the VM which will in turn look for ServerServices in the
+classpath.
+
+Provided you have the openejb-ejbd jar in your classpath along with it's dependencies
+(openejb-server, openejb-client, openejb-core), then those services will be brought online
+and remote clients will be able to connect into your vm and invoke beans.
+
+If you want to add more ServerServices such as the http version of the ejbd protocol you'd
+simply add the openejb-httpejbd jar to your classpath. A number of ServerServices are
+available currently:
+
+ * openejb-ejbd
+ * openejb-http
+ * openejb-telnet
+ * openejb-derbynet
+ * openejb-hsql
+ * openejb-activemq
+
+
+## Telephone
+
+ package org.superbiz.telephone;
+
+ public interface Telephone {
+
+ void speak(String words);
+
+ String listen();
+ }
+
+## TelephoneBean
+
+ package org.superbiz.telephone;
+
+ import javax.ejb.Remote;
+ import javax.ejb.Stateful;
+ import java.util.ArrayList;
+ import java.util.List;
+
+ @Remote
+ @Stateful
+ public class TelephoneBean implements Telephone {
+
+ private static final String[] answers = {
+ "How nice.",
+ "Oh, of course.",
+ "Interesting.",
+ "Really?",
+ "No.",
+ "Definitely.",
+ "I wondered about that.",
+ "Good idea.",
+ "You don't say!",
+ };
+
+ private List<String> conversation = new ArrayList<String>();
+
+ public void speak(String words) {
+ conversation.add(words);
+ }
+
+ public String listen() {
+ if (conversation.size() == 0) {
+ return "Nothing has been said";
+ }
+
+ String lastThingSaid = conversation.get(conversation.size() - 1);
+ return answers[Math.abs(lastThingSaid.hashCode()) % answers.length];
+ }
+ }
+
+## TelephoneTest
+
+ package org.superbiz.telephone;
+
+ import junit.framework.TestCase;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.Properties;
+
+ /**
+ * @version $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $
+ */
+ public class TelephoneTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+ // Uncomment these properties to change the defaults
+ //properties.setProperty("ejbd.port", "4202");
+ //properties.setProperty("ejbd.bind", "localhost");
+ //properties.setProperty("ejbd.threads", "200");
+ //properties.setProperty("ejbd.disabled", "false");
+ //properties.setProperty("ejbd.only_from", "127.0.0.1,192.168.1.1");
+
+ new InitialContext(properties);
+ }
+
+ /**
+ * Lookup the Telephone bean via its remote interface but using the LocalInitialContextFactory
+ *
+ * @throws Exception
+ */
+ public void testTalkOverLocalNetwork() throws Exception {
+
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ InitialContext localContext = new InitialContext(properties);
+
+ Telephone telephone = (Telephone) localContext.lookup("TelephoneBeanRemote");
+
+ telephone.speak("Did you know I am talking directly through the embedded container?");
+
+ assertEquals("Interesting.", telephone.listen());
+
+
+ telephone.speak("Yep, I'm using the bean's remote interface but since the ejb container is embedded " +
+ "in the same vm I'm just using the LocalInitialContextFactory.");
+
+ assertEquals("Really?", telephone.listen());
+
+
+ telephone.speak("Right, you really only have to use the RemoteInitialContextFactory if you're in a different vm.");
+
+ assertEquals("Oh, of course.", telephone.listen());
+ }
+
+ /**
+ * Lookup the Telephone bean via its remote interface using the RemoteInitialContextFactory
+ *
+ * @throws Exception
+ */
+ public void testTalkOverRemoteNetwork() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ properties.setProperty(Context.PROVIDER_URL, "ejbd://localhost:4201");
+ InitialContext remoteContext = new InitialContext(properties);
+
+ Telephone telephone = (Telephone) remoteContext.lookup("TelephoneBeanRemote");
+
+ telephone.speak("Is this a local call?");
+
+ assertEquals("No.", telephone.listen());
+
+
+ telephone.speak("This would be a lot cooler if I was connecting from another VM then, huh?");
+
+ assertEquals("I wondered about that.", telephone.listen());
+
+
+ telephone.speak("I suppose I should hangup and call back over the LocalInitialContextFactory.");
+
+ assertEquals("Good idea.", telephone.listen());
+
+
+ telephone.speak("I'll remember this though in case I ever have to call you accross a network.");
+
+ assertEquals("Definitely.", telephone.listen());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.telephone.TelephoneTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/telephone-stateful
+ INFO - openejb.base = /Users/dblevins/examples/telephone-stateful
+ 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/telephone-stateful/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/telephone-stateful/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/telephone-stateful/classpath.ear
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean TelephoneBean: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Enterprise application "/Users/dblevins/examples/telephone-stateful/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/telephone-stateful/classpath.ear
+ INFO - Jndi(name=TelephoneBeanRemote) --> Ejb(deployment-id=TelephoneBean)
+ INFO - Jndi(name=global/classpath.ear/telephone-stateful/TelephoneBean!org.superbiz.telephone.Telephone) --> Ejb(deployment-id=TelephoneBean)
+ INFO - Jndi(name=global/classpath.ear/telephone-stateful/TelephoneBean) --> Ejb(deployment-id=TelephoneBean)
+ INFO - Created Ejb(deployment-id=TelephoneBean, ejb-name=TelephoneBean, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=TelephoneBean, ejb-name=TelephoneBean, container=Default Stateful Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/telephone-stateful/classpath.ear)
+ INFO - Initializing network services
+ INFO - Creating ServerService(id=admin)
+ INFO - Creating ServerService(id=ejbd)
+ INFO - Creating ServerService(id=ejbds)
+ INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+ -------
+ Ready!
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.448 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/telephone-stateful/README.txt b/content/examples/telephone-stateful/README.txt
new file mode 100755
index 0000000..aa1bafe
--- /dev/null
+++ b/content/examples/telephone-stateful/README.txt
@@ -0,0 +1,32 @@
+This example shows how to use OpenEJB3's remoting capabilities in an embedded scenario.
+
+The basic recipe is the same for a standard embedded scenario but with these added
+ingreditents:
+
+ * *openejb.embedded.remotable* property
+ * *openejb-ejbd* jar
+
+While creating the InitialContext, pass in the openejb.embedded.remotable property with
+the value of "true". When this is seen by the LocalInitialContextFactory, it will boot up
+the Server ServiceManager in the VM which will in turn look for ServerServices in the
+classpath.
+
+Provided you have the openejb-ejbd jar in your classpath along with it's dependencies
+(openejb-server, openejb-client, openejb-core), then those services will be brought online
+and remote clients will be able to connect into your vm and invoke beans.
+
+If you want to add more ServerServices such as the http version of the ejbd protocol you'd
+simply add the openejb-httpejbd jar to your classpath. A number of ServerServices are
+available currently:
+
+ * openejb-ejbd
+ * openejb-http
+ * openejb-telnet
+ * openejb-derbynet
+ * openejb-hsql
+ * openejb-activemq
+
+To run the example simply type:
+
+ $ mvn clean install
+
diff --git a/content/examples/telephone-stateful/build.xml b/content/examples/telephone-stateful/build.xml
new file mode 100755
index 0000000..7a022ca
--- /dev/null
+++ b/content/examples/telephone-stateful/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-ejbd" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/telephone-stateful/pom.xml b/content/examples/telephone-stateful/pom.xml
new file mode 100755
index 0000000..34fc440
--- /dev/null
+++ b/content/examples/telephone-stateful/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>telephone-stateful</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Telephone Stateful Pojo</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ START SNIPPET: desc
+ Nice thing about maven2 is it has test-only dependencies.
+ This guarantees that none of your runtime code is dependent
+ on any OpenEJB classes.
+
+ You need this dep or no clients will be able to connect
+ over the ejbd protocol to the embedded ejb container.
+
+ Notice the other examples use 'openejb-core' and this one
+ uses 'openejb-ejbd'. If you wanted to make more protocols
+ available, you simply have to add deps to them and they'll
+ get picked up in the classpath automatically.
+ END SNIPPET: desc
+ -->
+ <!-- START SNIPPET: openejbdep -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-ejbd</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- END SNIPPET: openejbdep -->
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
+
diff --git a/content/examples/telephone-stateful/src/main/java/org/superbiz/telephone/Telephone.java b/content/examples/telephone-stateful/src/main/java/org/superbiz/telephone/Telephone.java
new file mode 100755
index 0000000..cff3f9b
--- /dev/null
+++ b/content/examples/telephone-stateful/src/main/java/org/superbiz/telephone/Telephone.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.telephone;
+
+public interface Telephone {
+
+ void speak(String words);
+
+ String listen();
+}
+//END SNIPPET: code
diff --git a/content/examples/telephone-stateful/src/main/java/org/superbiz/telephone/TelephoneBean.java b/content/examples/telephone-stateful/src/main/java/org/superbiz/telephone/TelephoneBean.java
new file mode 100755
index 0000000..ae466ac
--- /dev/null
+++ b/content/examples/telephone-stateful/src/main/java/org/superbiz/telephone/TelephoneBean.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//START SNIPPET: code
+package org.superbiz.telephone;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import java.util.ArrayList;
+import java.util.List;
+
+@Remote
+@Stateful
+public class TelephoneBean implements Telephone {
+
+ private static final String[] answers = {
+ "How nice.",
+ "Oh, of course.",
+ "Interesting.",
+ "Really?",
+ "No.",
+ "Definitely.",
+ "I wondered about that.",
+ "Good idea.",
+ "You don't say!",
+ };
+
+ private final List<String> conversation = new ArrayList<String>();
+
+ @Override
+ public void speak(final String words) {
+ conversation.add(words);
+ }
+
+ @Override
+ public String listen() {
+ if (conversation.size() == 0) {
+ return "Nothing has been said";
+ }
+
+ final String lastThingSaid = conversation.get(conversation.size() - 1);
+ return answers[Math.abs(lastThingSaid.hashCode()) % answers.length];
+ }
+}
+//END SNIPPET: code
\ No newline at end of file
diff --git a/content/examples/telephone-stateful/src/main/resources/META-INF/ejb-jar.xml b/content/examples/telephone-stateful/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..433757b
--- /dev/null
+++ b/content/examples/telephone-stateful/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
\ No newline at end of file
diff --git a/content/examples/telephone-stateful/src/test/java/org/superbiz/telephone/TelephoneTest.java b/content/examples/telephone-stateful/src/test/java/org/superbiz/telephone/TelephoneTest.java
new file mode 100755
index 0000000..b0b12b1
--- /dev/null
+++ b/content/examples/telephone-stateful/src/test/java/org/superbiz/telephone/TelephoneTest.java
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.telephone;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+/**
+ * @version $Rev: 1591902 $ $Date: 2014-05-02 15:37:53 +0200 (Fri, 02 May 2014) $
+ */
+public class TelephoneTest extends TestCase {
+
+ //START SNIPPET: setup
+
+ //Random port to avoid test conflicts
+ private static final int port = Integer.parseInt(System.getProperty("ejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+ @Override
+ protected void setUp() throws Exception {
+ final Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ //Just for this test we change the default port from 4204 to avoid conflicts
+ properties.setProperty("ejbd.port", "" + port);
+
+ // Uncomment these properties to change the defaults
+ //properties.setProperty("ejbd.bind", "localhost");
+ //properties.setProperty("ejbd.threads", "200");
+ //properties.setProperty("ejbd.disabled", "false");
+ //properties.setProperty("ejbd.only_from", "127.0.0.1,192.168.1.1");
+
+ new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Lookup the Telephone bean via its remote interface but using the LocalInitialContextFactory
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: localcontext
+ public void testTalkOverLocalNetwork() throws Exception {
+
+ final Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ final InitialContext localContext = new InitialContext(properties);
+
+ final Telephone telephone = (Telephone) localContext.lookup("TelephoneBeanRemote");
+
+ telephone.speak("Did you know I am talking directly through the embedded container?");
+
+ assertEquals("Interesting.", telephone.listen());
+
+ telephone.speak("Yep, I'm using the bean's remote interface but since the ejb container is embedded " +
+ "in the same vm I'm just using the LocalInitialContextFactory.");
+
+ assertEquals("Really?", telephone.listen());
+
+ telephone.speak("Right, you really only have to use the RemoteInitialContextFactory if you're in a different vm.");
+
+ assertEquals("Oh, of course.", telephone.listen());
+ }
+ //END SNIPPET: localcontext
+
+ /**
+ * Lookup the Telephone bean via its remote interface using the RemoteInitialContextFactory
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: remotecontext
+ public void testTalkOverRemoteNetwork() throws Exception {
+ final Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ properties.setProperty(Context.PROVIDER_URL, "ejbd://localhost:" + port);
+ final InitialContext remoteContext = new InitialContext(properties);
+
+ final Telephone telephone = (Telephone) remoteContext.lookup("TelephoneBeanRemote");
+
+ telephone.speak("Is this a local call?");
+
+ assertEquals("No.", telephone.listen());
+
+ telephone.speak("This would be a lot cooler if I was connecting from another VM then, huh?");
+
+ assertEquals("I wondered about that.", telephone.listen());
+
+ telephone.speak("I suppose I should hangup and call back over the LocalInitialContextFactory.");
+
+ assertEquals("Good idea.", telephone.listen());
+
+ telephone.speak("I'll remember this though in case I ever have to call you accross a network.");
+
+ assertEquals("Definitely.", telephone.listen());
+ }
+ //END SNIPPET: remotecontext
+
+}
diff --git a/content/examples/testcase-injection.html b/content/examples/testcase-injection.html
new file mode 100644
index 0000000..df0f52a
--- /dev/null
+++ b/content/examples/testcase-injection.html
@@ -0,0 +1,425 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/testcase-injection.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Testcase Injection</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example testcase-injection can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/testcase-injection" class="bare">https://github.com/apache/tomee/tree/master/examples/testcase-injection</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.testinjection;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.testinjection;
+
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+import static javax.ejb.TransactionAttributeType.MANDATORY;
+
+//START SNIPPET: code
+@Stateful
+@TransactionAttribute(MANDATORY)
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.testinjection.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.testinjection;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.UserTransaction;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ userTransaction.commit();
+ }
+
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.testinjection.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/testcase-injection
+INFO - openejb.base = /Users/dblevins/examples/testcase-injection
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/testcase-injection/target/classes
+INFO - Beginning load: /Users/dblevins/examples/testcase-injection/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/testcase-injection
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.testinjection.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/testcase-injection" loaded.
+INFO - Assembling app: /Users/dblevins/examples/testcase-injection
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 408ms
+INFO - Jndi(name="java:global/testcase-injection/Movies!org.superbiz.testinjection.Movies")
+INFO - Jndi(name="java:global/testcase-injection/Movies")
+INFO - Jndi(name="java:global/EjbModule1583515396/org.superbiz.testinjection.MoviesTest!org.superbiz.testinjection.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1583515396/org.superbiz.testinjection.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.testinjection.MoviesTest, ejb-name=org.superbiz.testinjection.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.testinjection.MoviesTest, ejb-name=org.superbiz.testinjection.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/testcase-injection)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.24 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/testcase-injection.pdf b/content/examples/testcase-injection.pdf
new file mode 100644
index 0000000..0d6907c
--- /dev/null
+++ b/content/examples/testcase-injection.pdf
Binary files differ
diff --git a/content/examples/testcase-injection/README.md b/content/examples/testcase-injection/README.md
new file mode 100755
index 0000000..5dd5074
--- /dev/null
+++ b/content/examples/testcase-injection/README.md
@@ -0,0 +1,208 @@
+Title: Testcase Injection
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Movie
+
+ package org.superbiz.testinjection;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.testinjection;
+
+ import javax.ejb.Stateful;
+ import javax.ejb.TransactionAttribute;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ import static javax.ejb.TransactionAttributeType.MANDATORY;
+
+ //START SNIPPET: code
+ @Stateful
+ @TransactionAttribute(MANDATORY)
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.testinjection.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MoviesTest
+
+ package org.superbiz.testinjection;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.Resource;
+ import javax.ejb.EJB;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.transaction.UserTransaction;
+ import java.util.List;
+ import java.util.Properties;
+
+ //START SNIPPET: code
+ public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ userTransaction.commit();
+ }
+
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.testinjection.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/testcase-injection
+ INFO - openejb.base = /Users/dblevins/examples/testcase-injection
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/testcase-injection/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/testcase-injection/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/testcase-injection
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.testinjection.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/testcase-injection" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/testcase-injection
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 408ms
+ INFO - Jndi(name="java:global/testcase-injection/Movies!org.superbiz.testinjection.Movies")
+ INFO - Jndi(name="java:global/testcase-injection/Movies")
+ INFO - Jndi(name="java:global/EjbModule1583515396/org.superbiz.testinjection.MoviesTest!org.superbiz.testinjection.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1583515396/org.superbiz.testinjection.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.testinjection.MoviesTest, ejb-name=org.superbiz.testinjection.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.testinjection.MoviesTest, ejb-name=org.superbiz.testinjection.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/testcase-injection)
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.24 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/testcase-injection/build.xml b/content/examples/testcase-injection/build.xml
new file mode 100755
index 0000000..821f630
--- /dev/null
+++ b/content/examples/testcase-injection/build.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ <dependency groupId="org.apache.openejb" artifactId="openejb-api" version="4.0.0-beta-1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/testcase-injection/pom.xml b/content/examples/testcase-injection/pom.xml
new file mode 100755
index 0000000..0d36d2a
--- /dev/null
+++ b/content/examples/testcase-injection/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>testcase-injection</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: TestCase Injection</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/testcase-injection/src/main/java/org/superbiz/testinjection/Movie.java b/content/examples/testcase-injection/src/main/java/org/superbiz/testinjection/Movie.java
new file mode 100755
index 0000000..d51142a
--- /dev/null
+++ b/content/examples/testcase-injection/src/main/java/org/superbiz/testinjection/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.testinjection;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/testcase-injection/src/main/java/org/superbiz/testinjection/Movies.java b/content/examples/testcase-injection/src/main/java/org/superbiz/testinjection/Movies.java
new file mode 100755
index 0000000..58fd742
--- /dev/null
+++ b/content/examples/testcase-injection/src/main/java/org/superbiz/testinjection/Movies.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.testinjection;
+
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+import static javax.ejb.TransactionAttributeType.MANDATORY;
+
+//START SNIPPET: code
+@Stateful
+@TransactionAttribute(MANDATORY)
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testcase-injection/src/main/resources/META-INF/persistence.xml b/content/examples/testcase-injection/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..2987984
--- /dev/null
+++ b/content/examples/testcase-injection/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.testinjection.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/testcase-injection/src/test/java/org/superbiz/testinjection/MoviesTest.java b/content/examples/testcase-injection/src/test/java/org/superbiz/testinjection/MoviesTest.java
new file mode 100755
index 0000000..728229b
--- /dev/null
+++ b/content/examples/testcase-injection/src/test/java/org/superbiz/testinjection/MoviesTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.testinjection;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.UserTransaction;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+
+ } finally {
+ userTransaction.commit();
+ }
+
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security-2.html b/content/examples/testing-security-2.html
new file mode 100644
index 0000000..47847c0
--- /dev/null
+++ b/content/examples/testing-security-2.html
@@ -0,0 +1,491 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/testing-security-2.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Testing Security 2</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example testing-security-2 can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/testing-security-2" class="bare">https://github.com/apache/tomee/tree/master/examples/testing-security-2</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+//START SNIPPET: code
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movietest">MovieTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+import junit.framework.TestCase;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MovieTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ protected void setUp() throws Exception {
+
+ // Uncomment this line to set the login/logout functionality on Debug
+ //System.setProperty("log4j.category.OpenEJB.security", "debug");
+
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void testAsManager() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put(Context.SECURITY_PRINCIPAL, "jane");
+ p.put(Context.SECURITY_CREDENTIALS, "waterfall");
+
+ InitialContext context = new InitialContext(p);
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void testAsEmployee() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put(Context.SECURITY_PRINCIPAL, "joe");
+ p.put(Context.SECURITY_CREDENTIALS, "cool");
+
+ InitialContext context = new InitialContext(p);
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ List<Movie> list = movies.getMovies();
+ } catch (EJBAccessException e) {
+ fail("Read access should be allowed");
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.secure.MovieTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/testing-security-2
+INFO - openejb.base = /Users/dblevins/examples/testing-security-2
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security-2/target/classes
+INFO - Beginning load: /Users/dblevins/examples/testing-security-2/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/testing-security-2
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.secure.MovieTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/testing-security-2" loaded.
+INFO - Assembling app: /Users/dblevins/examples/testing-security-2
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 413ms
+INFO - Jndi(name="java:global/testing-security-2/Movies!org.superbiz.injection.secure.Movies")
+INFO - Jndi(name="java:global/testing-security-2/Movies")
+INFO - Jndi(name="java:global/EjbModule1634151355/org.superbiz.injection.secure.MovieTest!org.superbiz.injection.secure.MovieTest")
+INFO - Jndi(name="java:global/EjbModule1634151355/org.superbiz.injection.secure.MovieTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/testing-security-2)
+INFO - Logging in
+INFO - Logging out
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+INFO - Logging in
+INFO - Logging out
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.546 sec
+
+Results :
+
+Tests run: 3, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/testing-security-2.pdf b/content/examples/testing-security-2.pdf
new file mode 100644
index 0000000..32d9b68
--- /dev/null
+++ b/content/examples/testing-security-2.pdf
Binary files differ
diff --git a/content/examples/testing-security-2/README.md b/content/examples/testing-security-2/README.md
new file mode 100755
index 0000000..17e612e
--- /dev/null
+++ b/content/examples/testing-security-2/README.md
@@ -0,0 +1,274 @@
+Title: Testing Security 2
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Movie
+
+ package org.superbiz.injection.secure;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection.secure;
+
+ //START SNIPPET: code
+
+ import javax.annotation.security.PermitAll;
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.Stateful;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ @Stateful
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MovieTest
+
+ package org.superbiz.injection.secure;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.EJB;
+ import javax.ejb.EJBAccessException;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import java.util.List;
+ import java.util.Properties;
+
+ //START SNIPPET: code
+ public class MovieTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ protected void setUp() throws Exception {
+
+ // Uncomment this line to set the login/logout functionality on Debug
+ //System.setProperty("log4j.category.OpenEJB.security", "debug");
+
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void testAsManager() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put(Context.SECURITY_PRINCIPAL, "jane");
+ p.put(Context.SECURITY_CREDENTIALS, "waterfall");
+
+ InitialContext context = new InitialContext(p);
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void testAsEmployee() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put(Context.SECURITY_PRINCIPAL, "joe");
+ p.put(Context.SECURITY_CREDENTIALS, "cool");
+
+ InitialContext context = new InitialContext(p);
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ List<Movie> list = movies.getMovies();
+ } catch (EJBAccessException e) {
+ fail("Read access should be allowed");
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.secure.MovieTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/testing-security-2
+ INFO - openejb.base = /Users/dblevins/examples/testing-security-2
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security-2/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/testing-security-2/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/testing-security-2
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.secure.MovieTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/testing-security-2" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/testing-security-2
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 413ms
+ INFO - Jndi(name="java:global/testing-security-2/Movies!org.superbiz.injection.secure.Movies")
+ INFO - Jndi(name="java:global/testing-security-2/Movies")
+ INFO - Jndi(name="java:global/EjbModule1634151355/org.superbiz.injection.secure.MovieTest!org.superbiz.injection.secure.MovieTest")
+ INFO - Jndi(name="java:global/EjbModule1634151355/org.superbiz.injection.secure.MovieTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/testing-security-2)
+ INFO - Logging in
+ INFO - Logging out
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ INFO - Logging in
+ INFO - Logging out
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.546 sec
+
+ Results :
+
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/testing-security-2/build.xml b/content/examples/testing-security-2/build.xml
new file mode 100755
index 0000000..4f29800
--- /dev/null
+++ b/content/examples/testing-security-2/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/testing-security-2/pom.xml b/content/examples/testing-security-2/pom.xml
new file mode 100755
index 0000000..6b4cde0
--- /dev/null
+++ b/content/examples/testing-security-2/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>testing-security-2</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Testing Security</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/testing-security-2/src/main/java/org/superbiz/injection/secure/Movie.java b/content/examples/testing-security-2/src/main/java/org/superbiz/injection/secure/Movie.java
new file mode 100755
index 0000000..b5df45c
--- /dev/null
+++ b/content/examples/testing-security-2/src/main/java/org/superbiz/injection/secure/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/testing-security-2/src/main/java/org/superbiz/injection/secure/Movies.java b/content/examples/testing-security-2/src/main/java/org/superbiz/injection/secure/Movies.java
new file mode 100755
index 0000000..b3ba8e8
--- /dev/null
+++ b/content/examples/testing-security-2/src/main/java/org/superbiz/injection/secure/Movies.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+//START SNIPPET: code
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security-2/src/main/resources/META-INF/persistence.xml b/content/examples/testing-security-2/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..ae3723d
--- /dev/null
+++ b/content/examples/testing-security-2/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/MovieTest.java b/content/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/MovieTest.java
new file mode 100755
index 0000000..3dba45b
--- /dev/null
+++ b/content/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/MovieTest.java
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.SessionContext;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MovieTest {
+
+ @EJB
+ private UserInfo userInfo;
+
+ @EJB
+ private Movies movies;
+
+ private EJBContainer container;
+
+ @Before
+ public void setUp() throws Exception {
+ // Uncomment this line to set the login/logout functionality on Debug
+ //System.setProperty("log4j.category.OpenEJB.security", "debug");
+
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ this.container = EJBContainer.createEJBContainer(p);
+ this.container.getContext().bind("inject", this);
+ }
+
+ @After
+ public void tearDown() {
+ this.container.close();
+ }
+
+ @Test
+ public void testAsManager() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put(Context.SECURITY_PRINCIPAL, "jane");
+ p.put(Context.SECURITY_CREDENTIALS, "waterfall");
+
+ InitialContext context = new InitialContext(p);
+ Assert.assertEquals("Wrong user", "jane", userInfo.getUserName());
+ Assert.assertTrue("jane is supposed to be a Manager", userInfo.isCallerInRole("Manager"));
+ Assert.assertTrue("jane is supposed to be an Employee", userInfo.isCallerInRole("Employee"));
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testAsEmployee() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put(Context.SECURITY_PRINCIPAL, "joe");
+ p.put(Context.SECURITY_CREDENTIALS, "cool");
+
+ InitialContext context = new InitialContext(p);
+ Assert.assertEquals("Wrong user", "joe", userInfo.getUserName());
+ Assert.assertTrue("joe is supposed to be an Employee", userInfo.isCallerInRole("Employee"));
+
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ Assert.fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ Assert.fail("Unauthenticated users should not be able to add movies. User: " + userInfo.getUserName());
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ Assert.fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+ movies.getMovies();
+ } catch (EJBAccessException e) {
+ Assert.fail("Read access should be allowed");
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/UserInfo.java b/content/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/UserInfo.java
new file mode 100755
index 0000000..100af66
--- /dev/null
+++ b/content/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/UserInfo.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.superbiz.injection.secure;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+
+@Stateless
+public class UserInfo {
+ @Resource
+ private SessionContext sessionContext;
+
+ public String getUserName() {
+ return sessionContext.getCallerPrincipal().getName();
+ }
+
+ public boolean isCallerInRole(String role) {
+ return sessionContext.isCallerInRole(role);
+ }
+}
diff --git a/content/examples/testing-security-2/src/test/resources/groups.properties b/content/examples/testing-security-2/src/test/resources/groups.properties
new file mode 100755
index 0000000..3df6bae
--- /dev/null
+++ b/content/examples/testing-security-2/src/test/resources/groups.properties
@@ -0,0 +1,2 @@
+Manager=jane
+Employee=jane,joe
diff --git a/content/examples/testing-security-2/src/test/resources/users.properties b/content/examples/testing-security-2/src/test/resources/users.properties
new file mode 100755
index 0000000..acb4a5d
--- /dev/null
+++ b/content/examples/testing-security-2/src/test/resources/users.properties
@@ -0,0 +1,2 @@
+joe=cool
+jane=waterfall
\ No newline at end of file
diff --git a/content/examples/testing-security-3.html b/content/examples/testing-security-3.html
new file mode 100644
index 0000000..beeac49
--- /dev/null
+++ b/content/examples/testing-security-3.html
@@ -0,0 +1,573 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/testing-security-3.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Testing Security 3</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example testing-security-3 can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/testing-security-3" class="bare">https://github.com/apache/tomee/tree/master/examples/testing-security-3</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+//START SNIPPET: code
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_myloginprovider">MyLoginProvider</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+import org.apache.openejb.core.security.jaas.LoginProvider;
+
+import javax.security.auth.login.FailedLoginException;
+import java.util.Arrays;
+import java.util.List;
+
+public class MyLoginProvider implements LoginProvider {
+
+
+ @Override
+ public List<String> authenticate(String user, String password) throws FailedLoginException {
+ if ("paul".equals(user) && "michelle".equals(password)) {
+ return Arrays.asList("Manager", "rockstar", "beatle");
+ }
+
+ if ("eddie".equals(user) && "jump".equals(password)) {
+ return Arrays.asList("Employee", "rockstar", "vanhalen");
+ }
+
+ throw new FailedLoginException("Bad user or password!");
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_org_apache_openejb_core_security_jaas_loginprovider">org.apache.openejb.core.security.jaas.LoginProvider</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>org.superbiz.injection.secure.MyLoginProvider</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movietest">MovieTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+import junit.framework.TestCase;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.List;
+import java.util.Properties;
+
+public class MovieTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ private Context getContext(String user, String pass) throws NamingException {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.setProperty("openejb.authentication.realmName", "ServiceProviderLogin");
+ p.put(Context.SECURITY_PRINCIPAL, user);
+ p.put(Context.SECURITY_CREDENTIALS, pass);
+
+ return new InitialContext(p);
+ }
+
+ protected void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void testAsManager() throws Exception {
+ final Context context = getContext("paul", "michelle");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void testAsEmployee() throws Exception {
+ final Context context = getContext("eddie", "jump");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ List<Movie> list = movies.getMovies();
+
+ } catch (EJBAccessException e) {
+ fail("Read access should be allowed");
+ }
+
+ }
+
+ public void testLoginFailure() throws NamingException {
+ try {
+ getContext("eddie", "panama");
+ fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+
+ try {
+ getContext("jimmy", "foxylady");
+ fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.secure.MovieTest
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Fri Jul 20 08:42:53 EDT 2012
+INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 4.1.0
+INFO - Build date: 20120720
+INFO - Build time: 08:33
+INFO - ********************************************************************************
+INFO - openejb.home = /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3
+INFO - openejb.base = /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@38ee6681
+INFO - Succeeded in installing singleton service
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Creating TransactionManager(id=Default Transaction Manager)
+INFO - Creating SecurityService(id=Default Security Service)
+INFO - Creating Resource(id=movieDatabase)
+INFO - Beginning load: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3/target/classes
+INFO - Configuring enterprise application: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3
+INFO - Auto-deploying ejb Movies: EjbDeployment(deployment-id=Movies)
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Creating Container(id=Default Stateful Container)
+INFO - Using directory /tmp for stateful session passivation
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.secure.MovieTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Using directory /tmp for stateful session passivation
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Creating Resource(id=movieDatabaseNonJta)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3" loaded.
+INFO - Assembling app: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3
+SEVERE - JAVA AGENT NOT INSTALLED. The JPA Persistence Provider requested installation of a ClassFileTransformer which requires a JavaAgent. See http://tomee.apache.org/3.0/javaagent.html
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 268ms
+INFO - Jndi(name="java:global/testing-security-3/Movies!org.superbiz.injection.secure.Movies")
+INFO - Jndi(name="java:global/testing-security-3/Movies")
+INFO - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@38ee6681
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 170 ms.
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Deployed Application(path=/home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3)
+20-Jul-2012 8:42:55 AM null openjpa.Runtime
+INFO: Starting OpenJPA 2.2.0
+20-Jul-2012 8:42:56 AM null openjpa.jdbc.JDBC
+INFO: Using dictionary class "org.apache.openjpa.jdbc.sql.HSQLDictionary" (HSQL Database Engine 2.2.8 ,HSQL Database Engine Driver 2.2.8).
+20-Jul-2012 8:42:57 AM null openjpa.Enhance
+INFO: Creating subclass and redefining methods for "[class org.superbiz.injection.secure.Movie]". This means that your application will be less efficient than it would if you ran the OpenJPA enhancer.
+INFO - Logging in
+INFO - Logging out
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+INFO - Logging in
+INFO - Logging out
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.069 sec
+
+Results :
+
+Tests run: 3, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/testing-security-3.pdf b/content/examples/testing-security-3.pdf
new file mode 100644
index 0000000..e639c6d
--- /dev/null
+++ b/content/examples/testing-security-3.pdf
Binary files differ
diff --git a/content/examples/testing-security-3/README.md b/content/examples/testing-security-3/README.md
new file mode 100755
index 0000000..ba9c755
--- /dev/null
+++ b/content/examples/testing-security-3/README.md
@@ -0,0 +1,344 @@
+Title: Testing Security 3
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Movie
+
+ package org.superbiz.injection.secure;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection.secure;
+
+ //START SNIPPET: code
+
+ import javax.annotation.security.PermitAll;
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.Stateful;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ @Stateful
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## MyLoginProvider
+
+ package org.superbiz.injection.secure;
+
+ import org.apache.openejb.core.security.jaas.LoginProvider;
+
+ import javax.security.auth.login.FailedLoginException;
+ import java.util.Arrays;
+ import java.util.List;
+
+ public class MyLoginProvider implements LoginProvider {
+
+
+ @Override
+ public List<String> authenticate(String user, String password) throws FailedLoginException {
+ if ("paul".equals(user) && "michelle".equals(password)) {
+ return Arrays.asList("Manager", "rockstar", "beatle");
+ }
+
+ if ("eddie".equals(user) && "jump".equals(password)) {
+ return Arrays.asList("Employee", "rockstar", "vanhalen");
+ }
+
+ throw new FailedLoginException("Bad user or password!");
+ }
+ }
+
+## org.apache.openejb.core.security.jaas.LoginProvider
+
+ org.superbiz.injection.secure.MyLoginProvider
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MovieTest
+
+ package org.superbiz.injection.secure;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.EJB;
+ import javax.ejb.EJBAccessException;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.naming.NamingException;
+ import java.util.List;
+ import java.util.Properties;
+
+ public class MovieTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ private Context getContext(String user, String pass) throws NamingException {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.setProperty("openejb.authentication.realmName", "ServiceProviderLogin");
+ p.put(Context.SECURITY_PRINCIPAL, user);
+ p.put(Context.SECURITY_CREDENTIALS, pass);
+
+ return new InitialContext(p);
+ }
+
+ protected void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void testAsManager() throws Exception {
+ final Context context = getContext("paul", "michelle");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void testAsEmployee() throws Exception {
+ final Context context = getContext("eddie", "jump");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ List<Movie> list = movies.getMovies();
+
+ } catch (EJBAccessException e) {
+ fail("Read access should be allowed");
+ }
+
+ }
+
+ public void testLoginFailure() throws NamingException {
+ try {
+ getContext("eddie", "panama");
+ fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+
+ try {
+ getContext("jimmy", "foxylady");
+ fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.secure.MovieTest
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://openejb.apache.org/
+ INFO - Startup: Fri Jul 20 08:42:53 EDT 2012
+ INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 4.1.0
+ INFO - Build date: 20120720
+ INFO - Build time: 08:33
+ INFO - ********************************************************************************
+ INFO - openejb.home = /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3
+ INFO - openejb.base = /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@38ee6681
+ INFO - Succeeded in installing singleton service
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Creating TransactionManager(id=Default Transaction Manager)
+ INFO - Creating SecurityService(id=Default Security Service)
+ INFO - Creating Resource(id=movieDatabase)
+ INFO - Beginning load: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3/target/classes
+ INFO - Configuring enterprise application: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3
+ INFO - Auto-deploying ejb Movies: EjbDeployment(deployment-id=Movies)
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Creating Container(id=Default Stateful Container)
+ INFO - Using directory /tmp for stateful session passivation
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.secure.MovieTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Creating Container(id=Default Managed Container)
+ INFO - Using directory /tmp for stateful session passivation
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Creating Resource(id=movieDatabaseNonJta)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3" loaded.
+ INFO - Assembling app: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3
+ SEVERE - JAVA AGENT NOT INSTALLED. The JPA Persistence Provider requested installation of a ClassFileTransformer which requires a JavaAgent. See http://openejb.apache.org/3.0/javaagent.html
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 268ms
+ INFO - Jndi(name="java:global/testing-security-3/Movies!org.superbiz.injection.secure.Movies")
+ INFO - Jndi(name="java:global/testing-security-3/Movies")
+ INFO - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@38ee6681
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 170 ms.
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Deployed Application(path=/home/boto/dev/ws/openejb_trunk/openejb/examples/testing-security-3)
+ 20-Jul-2012 8:42:55 AM null openjpa.Runtime
+ INFO: Starting OpenJPA 2.2.0
+ 20-Jul-2012 8:42:56 AM null openjpa.jdbc.JDBC
+ INFO: Using dictionary class "org.apache.openjpa.jdbc.sql.HSQLDictionary" (HSQL Database Engine 2.2.8 ,HSQL Database Engine Driver 2.2.8).
+ 20-Jul-2012 8:42:57 AM null openjpa.Enhance
+ INFO: Creating subclass and redefining methods for "[class org.superbiz.injection.secure.Movie]". This means that your application will be less efficient than it would if you ran the OpenJPA enhancer.
+ INFO - Logging in
+ INFO - Logging out
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ INFO - Logging in
+ INFO - Logging out
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.069 sec
+
+ Results :
+
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/testing-security-3/build.xml b/content/examples/testing-security-3/build.xml
new file mode 100755
index 0000000..4f29800
--- /dev/null
+++ b/content/examples/testing-security-3/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/testing-security-3/pom.xml b/content/examples/testing-security-3/pom.xml
new file mode 100755
index 0000000..9e23622
--- /dev/null
+++ b/content/examples/testing-security-3/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>testing-security-3</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Testing Security Service Provider</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movie.java b/content/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movie.java
new file mode 100755
index 0000000..b5df45c
--- /dev/null
+++ b/content/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movies.java b/content/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movies.java
new file mode 100755
index 0000000..b3ba8e8
--- /dev/null
+++ b/content/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movies.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+//START SNIPPET: code
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/MyLoginProvider.java b/content/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/MyLoginProvider.java
new file mode 100755
index 0000000..a21c43e
--- /dev/null
+++ b/content/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/MyLoginProvider.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import org.apache.openejb.core.security.jaas.LoginProvider;
+
+import javax.security.auth.login.FailedLoginException;
+import java.util.Arrays;
+import java.util.List;
+
+public class MyLoginProvider implements LoginProvider {
+
+ @Override
+ public List<String> authenticate(String user, String password) throws FailedLoginException {
+ if ("paul".equals(user) && "michelle".equals(password)) {
+ return Arrays.asList("Manager", "rockstar", "beatle");
+ }
+
+ if ("eddie".equals(user) && "jump".equals(password)) {
+ return Arrays.asList("Employee", "rockstar", "vanhalen");
+ }
+
+ throw new FailedLoginException("Bad user or password!");
+ }
+}
diff --git a/content/examples/testing-security-3/src/main/resources/META-INF/persistence.xml b/content/examples/testing-security-3/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..ae3723d
--- /dev/null
+++ b/content/examples/testing-security-3/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/testing-security-3/src/main/resources/META-INF/services/org.apache.openejb.core.security.jaas.LoginProvider b/content/examples/testing-security-3/src/main/resources/META-INF/services/org.apache.openejb.core.security.jaas.LoginProvider
new file mode 100755
index 0000000..b3656e7
--- /dev/null
+++ b/content/examples/testing-security-3/src/main/resources/META-INF/services/org.apache.openejb.core.security.jaas.LoginProvider
@@ -0,0 +1 @@
+org.superbiz.injection.secure.MyLoginProvider
\ No newline at end of file
diff --git a/content/examples/testing-security-3/src/test/java/org/superbiz/injection/secure/MovieTest.java b/content/examples/testing-security-3/src/test/java/org/superbiz/injection/secure/MovieTest.java
new file mode 100755
index 0000000..18f505a
--- /dev/null
+++ b/content/examples/testing-security-3/src/test/java/org/superbiz/injection/secure/MovieTest.java
@@ -0,0 +1,157 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MovieTest {
+
+ @EJB
+ private Movies movies;
+
+ private EJBContainer container;
+
+ private Context getContext(String user, String pass) throws NamingException {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.setProperty("openejb.authentication.realmName", "ServiceProviderLogin");
+ p.put(Context.SECURITY_PRINCIPAL, user);
+ p.put(Context.SECURITY_CREDENTIALS, pass);
+ return new InitialContext(p);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ this.container = EJBContainer.createEJBContainer(p);
+ this.container.getContext().bind("inject", this);
+ }
+
+ @After
+ public void tearDown() {
+ this.container.close();
+ }
+
+ @Test
+ public void testAsManager() throws Exception {
+ final Context context = getContext("paul", "michelle");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testAsEmployee() throws Exception {
+ final Context context = getContext("eddie", "jump");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ Assert.fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ Assert.fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ Assert.fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+ movies.getMovies();
+ } catch (EJBAccessException e) {
+ Assert.fail("Read access should be allowed");
+ }
+ }
+
+ @Test
+ public void testLoginFailure() throws NamingException {
+ try {
+ getContext("eddie", "panama");
+ Assert.fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+
+ try {
+ getContext("jimmy", "foxylady");
+ Assert.fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security-4.html b/content/examples/testing-security-4.html
new file mode 100644
index 0000000..07e7434
--- /dev/null
+++ b/content/examples/testing-security-4.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/testing-security-4.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>testing-security-4</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example testing-security-4 can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/testing-security-4" class="bare">https://github.com/apache/tomee/tree/master/examples/testing-security-4</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/testing-security-4.pdf b/content/examples/testing-security-4.pdf
new file mode 100644
index 0000000..4d266c1
--- /dev/null
+++ b/content/examples/testing-security-4.pdf
Binary files differ
diff --git a/content/examples/testing-security-4/pom.xml b/content/examples/testing-security-4/pom.xml
new file mode 100755
index 0000000..4c1a2e7
--- /dev/null
+++ b/content/examples/testing-security-4/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>testing-security-4</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Testing Security Script Service Provider</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/LoginBean.java b/content/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/LoginBean.java
new file mode 100755
index 0000000..7c88fff
--- /dev/null
+++ b/content/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/LoginBean.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import javax.ejb.Stateless;
+import javax.security.auth.login.FailedLoginException;
+import java.util.Arrays;
+import java.util.List;
+
+@Stateless
+public class LoginBean {
+
+ public List<String> authenticate(String user, String password) throws FailedLoginException {
+ if ("paul".equals(user) && "michelle".equals(password)) {
+ return Arrays.asList("Manager", "rockstar", "beatle");
+ }
+
+ if ("eddie".equals(user) && "jump".equals(password)) {
+ return Arrays.asList("Employee", "rockstar", "vanhalen");
+ }
+
+ throw new FailedLoginException("Bad user or password!");
+ }
+}
+
diff --git a/content/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movie.java b/content/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movie.java
new file mode 100755
index 0000000..b5df45c
--- /dev/null
+++ b/content/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movies.java b/content/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movies.java
new file mode 100755
index 0000000..b3ba8e8
--- /dev/null
+++ b/content/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movies.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+//START SNIPPET: code
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security-4/src/main/resources/META-INF/persistence.xml b/content/examples/testing-security-4/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..ae3723d
--- /dev/null
+++ b/content/examples/testing-security-4/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/testing-security-4/src/test/java/org/superbiz/injection/secure/MovieTest.java b/content/examples/testing-security-4/src/test/java/org/superbiz/injection/secure/MovieTest.java
new file mode 100755
index 0000000..0e3654b
--- /dev/null
+++ b/content/examples/testing-security-4/src/test/java/org/superbiz/injection/secure/MovieTest.java
@@ -0,0 +1,161 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MovieTest {
+
+ @EJB
+ private Movies movies;
+
+ private EJBContainer container;
+
+ private Context getContext(String user, String pass) throws NamingException {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.setProperty("openejb.authentication.realmName", "ScriptLogin");
+ p.put(Context.SECURITY_PRINCIPAL, user);
+ p.put(Context.SECURITY_CREDENTIALS, pass);
+
+ return new InitialContext(p);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ final ClassLoader ctxCl = Thread.currentThread().getContextClassLoader();
+ System.setProperty("openejb.ScriptLoginModule.scriptURI", ctxCl.getResource("loginscript.js").toExternalForm());
+
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ this.container = EJBContainer.createEJBContainer(p);
+ this.container.getContext().bind("inject", this);
+ }
+
+ @After
+ public void tearDown() {
+ this.container.close();
+ }
+
+ @Test
+ public void testAsManager() throws Exception {
+ final Context context = getContext("paul", "michelle");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testAsEmployee() throws Exception {
+ final Context context = getContext("eddie", "jump");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ Assert.fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ Assert.fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ Assert.fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+ movies.getMovies();
+ } catch (EJBAccessException e) {
+ Assert.fail("Read access should be allowed");
+ }
+ }
+
+ @Test
+ public void testLoginFailure() throws NamingException {
+ try {
+ getContext("eddie", "panama");
+ Assert.fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+
+ try {
+ getContext("jimmy", "foxylady");
+ Assert.fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security-4/src/test/resources/loginscript.js b/content/examples/testing-security-4/src/test/resources/loginscript.js
new file mode 100755
index 0000000..1afbbf8
--- /dev/null
+++ b/content/examples/testing-security-4/src/test/resources/loginscript.js
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var myImports = new JavaImporter(
+ java.util.Properties,
+ javax.naming.InitialContext
+);
+
+var result = null;
+
+with (myImports) {
+ var p = new Properties();
+ p.put("java.naming.factory.initial", "org.apache.openejb.client.LocalInitialContextFactory");
+
+ var ctx = new InitialContext(p);
+ var myBean = ctx.lookup("java:global/testing-security-4/LoginBean");
+ result = myBean.authenticate(user, password);
+}
+
+result;
\ No newline at end of file
diff --git a/content/examples/testing-security-meta.html b/content/examples/testing-security-meta.html
new file mode 100644
index 0000000..37f2ae9
--- /dev/null
+++ b/content/examples/testing-security-meta.html
@@ -0,0 +1,709 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/testing-security-meta.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Testing Security Meta</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example testing-security-meta can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/testing-security-meta" class="bare">https://github.com/apache/tomee/tree/master/examples/testing-security-meta</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_addpermission">AddPermission</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.RolesAllowed;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AddPermission {
+ public static interface $ {
+
+ @AddPermission
+ @RolesAllowed({"Employee", "Manager"})
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_deletepermission">DeletePermission</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.RolesAllowed;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface DeletePermission {
+ public static interface $ {
+
+ @DeletePermission
+ @RolesAllowed("Manager")
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_metatype">Metatype</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Metatype {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movieunit">MovieUnit</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure.api;
+
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Metatype
+@Target({ElementType.METHOD, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+
+@PersistenceContext(name = "movie-unit", unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+public @interface MovieUnit {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_readpermission">ReadPermission</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.PermitAll;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface ReadPermission {
+ public static interface $ {
+
+ @ReadPermission
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void method();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_runasemployee">RunAsEmployee</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.RunAs;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Metatype
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+
+@RunAs("Employee")
+public @interface RunAsEmployee {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_runasmanager">RunAsManager</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.RunAs;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+@Metatype
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+
+@RunAs("Manager")
+public @interface RunAsManager {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+//START SNIPPET: code
+
+import org.superbiz.injection.secure.api.AddPermission;
+import org.superbiz.injection.secure.api.DeletePermission;
+import org.superbiz.injection.secure.api.MovieUnit;
+import org.superbiz.injection.secure.api.ReadPermission;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @MovieUnit
+ private EntityManager entityManager;
+
+ @AddPermission
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @DeletePermission
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @ReadPermission
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movietest">MovieTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+import junit.framework.TestCase;
+import org.superbiz.injection.secure.api.RunAsEmployee;
+import org.superbiz.injection.secure.api.RunAsManager;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.Stateless;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+//START SNIPPET: code
+
+public class MovieTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "ManagerBean")
+ private Caller manager;
+
+ @EJB(beanName = "EmployeeBean")
+ private Caller employee;
+
+ protected void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void testAsManager() throws Exception {
+ manager.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testAsEmployee() throws Exception {
+ employee.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ List<Movie> list = movies.getMovies();
+ } catch (EJBAccessException e) {
+ fail("Read access should be allowed");
+ }
+ }
+
+ public interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the desired security scope.
+ */
+
+ @Stateless
+ @RunAsManager
+ public static class ManagerBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAsEmployee
+ public static class EmployeeBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.secure.MovieTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/testing-security-meta
+INFO - openejb.base = /Users/dblevins/examples/testing-security-meta
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security-meta/target/classes
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security-meta/target/test-classes
+INFO - Beginning load: /Users/dblevins/examples/testing-security-meta/target/classes
+INFO - Beginning load: /Users/dblevins/examples/testing-security-meta/target/test-classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/testing-security-meta
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean ManagerBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.secure.MovieTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/testing-security-meta" loaded.
+INFO - Assembling app: /Users/dblevins/examples/testing-security-meta
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 419ms
+INFO - Jndi(name="java:global/testing-security-meta/Movies!org.superbiz.injection.secure.Movies")
+INFO - Jndi(name="java:global/testing-security-meta/Movies")
+INFO - Jndi(name="java:global/testing-security-meta/ManagerBean!org.superbiz.injection.secure.MovieTest$Caller")
+INFO - Jndi(name="java:global/testing-security-meta/ManagerBean")
+INFO - Jndi(name="java:global/testing-security-meta/EmployeeBean!org.superbiz.injection.secure.MovieTest$Caller")
+INFO - Jndi(name="java:global/testing-security-meta/EmployeeBean")
+INFO - Jndi(name="java:global/EjbModule53489605/org.superbiz.injection.secure.MovieTest!org.superbiz.injection.secure.MovieTest")
+INFO - Jndi(name="java:global/EjbModule53489605/org.superbiz.injection.secure.MovieTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=EmployeeBean, ejb-name=EmployeeBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=EmployeeBean, ejb-name=EmployeeBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/testing-security-meta)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.754 sec
+
+Results :
+
+Tests run: 3, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/testing-security-meta.pdf b/content/examples/testing-security-meta.pdf
new file mode 100644
index 0000000..8daf1aa
--- /dev/null
+++ b/content/examples/testing-security-meta.pdf
Binary files differ
diff --git a/content/examples/testing-security-meta/README.md b/content/examples/testing-security-meta/README.md
new file mode 100755
index 0000000..af2c31b
--- /dev/null
+++ b/content/examples/testing-security-meta/README.md
@@ -0,0 +1,450 @@
+Title: Testing Security Meta
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## AddPermission
+
+ package org.superbiz.injection.secure.api;
+
+ import javax.annotation.security.RolesAllowed;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface AddPermission {
+ public static interface $ {
+
+ @AddPermission
+ @RolesAllowed({"Employee", "Manager"})
+ public void method();
+ }
+ }
+
+## DeletePermission
+
+ package org.superbiz.injection.secure.api;
+
+ import javax.annotation.security.RolesAllowed;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface DeletePermission {
+ public static interface $ {
+
+ @DeletePermission
+ @RolesAllowed("Manager")
+ public void method();
+ }
+ }
+
+## Metatype
+
+ package org.superbiz.injection.secure.api;
+
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+ @Metatype
+ @Target(ElementType.ANNOTATION_TYPE)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Metatype {
+ }
+
+## MovieUnit
+
+ package org.superbiz.injection.secure.api;
+
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+
+ @Metatype
+ @Target({ElementType.METHOD, ElementType.FIELD})
+ @Retention(RetentionPolicy.RUNTIME)
+
+ @PersistenceContext(name = "movie-unit", unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ public @interface MovieUnit {
+ }
+
+## ReadPermission
+
+ package org.superbiz.injection.secure.api;
+
+ import javax.annotation.security.PermitAll;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+
+ @Metatype
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+
+ public @interface ReadPermission {
+ public static interface $ {
+
+ @ReadPermission
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void method();
+ }
+ }
+
+## RunAsEmployee
+
+ package org.superbiz.injection.secure.api;
+
+ import javax.annotation.security.RunAs;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+
+ @Metatype
+ @Target({ElementType.TYPE, ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+
+ @RunAs("Employee")
+ public @interface RunAsEmployee {
+ }
+
+## RunAsManager
+
+ package org.superbiz.injection.secure.api;
+
+ import javax.annotation.security.RunAs;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ import java.lang.annotation.Target;
+
+
+ @Metatype
+ @Target({ElementType.TYPE, ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+
+ @RunAs("Manager")
+ public @interface RunAsManager {
+ }
+
+## Movie
+
+ package org.superbiz.injection.secure;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection.secure;
+
+ //START SNIPPET: code
+
+ import org.superbiz.injection.secure.api.AddPermission;
+ import org.superbiz.injection.secure.api.DeletePermission;
+ import org.superbiz.injection.secure.api.MovieUnit;
+ import org.superbiz.injection.secure.api.ReadPermission;
+
+ import javax.ejb.Stateful;
+ import javax.persistence.EntityManager;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ @Stateful
+ public class Movies {
+
+ @MovieUnit
+ private EntityManager entityManager;
+
+ @AddPermission
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @DeletePermission
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @ReadPermission
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MovieTest
+
+ package org.superbiz.injection.secure;
+
+ import junit.framework.TestCase;
+ import org.superbiz.injection.secure.api.RunAsEmployee;
+ import org.superbiz.injection.secure.api.RunAsManager;
+
+ import javax.ejb.EJB;
+ import javax.ejb.EJBAccessException;
+ import javax.ejb.Stateless;
+ import javax.ejb.embeddable.EJBContainer;
+ import java.util.List;
+ import java.util.Properties;
+ import java.util.concurrent.Callable;
+
+ //START SNIPPET: code
+
+ public class MovieTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "ManagerBean")
+ private Caller manager;
+
+ @EJB(beanName = "EmployeeBean")
+ private Caller employee;
+
+ protected void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void testAsManager() throws Exception {
+ manager.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testAsEmployee() throws Exception {
+ employee.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ List<Movie> list = movies.getMovies();
+ } catch (EJBAccessException e) {
+ fail("Read access should be allowed");
+ }
+ }
+
+ public interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the desired security scope.
+ */
+
+ @Stateless
+ @RunAsManager
+ public static class ManagerBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAsEmployee
+ public static class EmployeeBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.secure.MovieTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/testing-security-meta
+ INFO - openejb.base = /Users/dblevins/examples/testing-security-meta
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security-meta/target/classes
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security-meta/target/test-classes
+ INFO - Beginning load: /Users/dblevins/examples/testing-security-meta/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/testing-security-meta/target/test-classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/testing-security-meta
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean ManagerBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.secure.MovieTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/testing-security-meta" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/testing-security-meta
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 419ms
+ INFO - Jndi(name="java:global/testing-security-meta/Movies!org.superbiz.injection.secure.Movies")
+ INFO - Jndi(name="java:global/testing-security-meta/Movies")
+ INFO - Jndi(name="java:global/testing-security-meta/ManagerBean!org.superbiz.injection.secure.MovieTest$Caller")
+ INFO - Jndi(name="java:global/testing-security-meta/ManagerBean")
+ INFO - Jndi(name="java:global/testing-security-meta/EmployeeBean!org.superbiz.injection.secure.MovieTest$Caller")
+ INFO - Jndi(name="java:global/testing-security-meta/EmployeeBean")
+ INFO - Jndi(name="java:global/EjbModule53489605/org.superbiz.injection.secure.MovieTest!org.superbiz.injection.secure.MovieTest")
+ INFO - Jndi(name="java:global/EjbModule53489605/org.superbiz.injection.secure.MovieTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=EmployeeBean, ejb-name=EmployeeBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=EmployeeBean, ejb-name=EmployeeBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/testing-security-meta)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.754 sec
+
+ Results :
+
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/testing-security-meta/build.xml b/content/examples/testing-security-meta/build.xml
new file mode 100755
index 0000000..4f29800
--- /dev/null
+++ b/content/examples/testing-security-meta/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/testing-security-meta/pom.xml b/content/examples/testing-security-meta/pom.xml
new file mode 100755
index 0000000..da5c861
--- /dev/null
+++ b/content/examples/testing-security-meta/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>testing-security-meta</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Testing Security (Meta)</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movie.java b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movie.java
new file mode 100755
index 0000000..b5df45c
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movies.java b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movies.java
new file mode 100755
index 0000000..deee414
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movies.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+//START SNIPPET: code
+
+import org.superbiz.injection.secure.api.AddPermission;
+import org.superbiz.injection.secure.api.DeletePermission;
+import org.superbiz.injection.secure.api.MovieUnit;
+import org.superbiz.injection.secure.api.ReadPermission;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @MovieUnit
+ private EntityManager entityManager;
+
+ @AddPermission
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @DeletePermission
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @ReadPermission
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/AddPermission.java b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/AddPermission.java
new file mode 100755
index 0000000..2f22414
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/AddPermission.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.RolesAllowed;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AddPermission {
+
+ public static interface $ {
+
+ @AddPermission
+ @RolesAllowed({"Employee", "Manager"})
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/DeletePermission.java b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/DeletePermission.java
new file mode 100755
index 0000000..dd69028
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/DeletePermission.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.RolesAllowed;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface DeletePermission {
+
+ public static interface $ {
+
+ @DeletePermission
+ @RolesAllowed("Manager")
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/Metatype.java b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/Metatype.java
new file mode 100755
index 0000000..eb08d38
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/Metatype.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Metatype {
+
+}
diff --git a/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/MovieUnit.java b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/MovieUnit.java
new file mode 100755
index 0000000..795a4cf
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/MovieUnit.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure.api;
+
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target({ElementType.METHOD, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+
+@PersistenceContext(name = "movie-unit", unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+public @interface MovieUnit {
+
+}
diff --git a/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/ReadPermission.java b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/ReadPermission.java
new file mode 100755
index 0000000..9614e09
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/ReadPermission.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.PermitAll;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface ReadPermission {
+
+ public static interface $ {
+
+ @ReadPermission
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void method();
+ }
+}
\ No newline at end of file
diff --git a/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/RunAsEmployee.java b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/RunAsEmployee.java
new file mode 100755
index 0000000..1600c69
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/RunAsEmployee.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.RunAs;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+
+@RunAs("Employee")
+public @interface RunAsEmployee {
+
+}
\ No newline at end of file
diff --git a/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/RunAsManager.java b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/RunAsManager.java
new file mode 100755
index 0000000..64e07db
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/RunAsManager.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure.api;
+
+import javax.annotation.security.RunAs;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+
+@RunAs("Manager")
+public @interface RunAsManager {
+
+}
\ No newline at end of file
diff --git a/content/examples/testing-security-meta/src/main/resources/META-INF/persistence.xml b/content/examples/testing-security-meta/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..ae3723d
--- /dev/null
+++ b/content/examples/testing-security-meta/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/testing-security-meta/src/test/java/org/superbiz/injection/secure/MovieTest.java b/content/examples/testing-security-meta/src/test/java/org/superbiz/injection/secure/MovieTest.java
new file mode 100755
index 0000000..47f6efd
--- /dev/null
+++ b/content/examples/testing-security-meta/src/test/java/org/superbiz/injection/secure/MovieTest.java
@@ -0,0 +1,158 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import junit.framework.TestCase;
+import org.superbiz.injection.secure.api.RunAsEmployee;
+import org.superbiz.injection.secure.api.RunAsManager;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.Stateless;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+//START SNIPPET: code
+
+public class MovieTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(beanName = "ManagerBean")
+ private Caller manager;
+
+ @EJB(beanName = "EmployeeBean")
+ private Caller employee;
+
+ protected void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void testAsManager() throws Exception {
+ manager.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testAsEmployee() throws Exception {
+ employee.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ List<Movie> list = movies.getMovies();
+
+ } catch (EJBAccessException e) {
+ fail("Read access should be allowed");
+ }
+
+ }
+
+ public interface Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the desired security scope.
+ */
+
+ @Stateless
+ @RunAsManager
+ public static class ManagerBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+
+ }
+
+ @Stateless
+ @RunAsEmployee
+ public static class EmployeeBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security.html b/content/examples/testing-security.html
new file mode 100644
index 0000000..aedf67f
--- /dev/null
+++ b/content/examples/testing-security.html
@@ -0,0 +1,521 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/testing-security.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Testing Security</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example testing-security can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/testing-security" class="bare">https://github.com/apache/tomee/tree/master/examples/testing-security</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+//START SNIPPET: code
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movietest">MovieTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.secure;
+
+import junit.framework.TestCase;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.Stateless;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+//START SNIPPET: code
+
+public class MovieTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(name = "ManagerBean")
+ private Caller manager;
+
+ @EJB(name = "EmployeeBean")
+ private Caller employee;
+
+ protected void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void testAsManager() throws Exception {
+ manager.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testAsEmployee() throws Exception {
+ employee.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ List<Movie> list = movies.getMovies();
+ } catch (EJBAccessException e) {
+ fail("Read access should be allowed");
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the desired security scope.
+ */
+
+ @Stateless
+ @RunAs("Manager")
+ public static class ManagerBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAs("Employee")
+ public static class EmployeeBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.secure.MovieTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/testing-security
+INFO - openejb.base = /Users/dblevins/examples/testing-security
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security/target/classes
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security/target/test-classes
+INFO - Beginning load: /Users/dblevins/examples/testing-security/target/classes
+INFO - Beginning load: /Users/dblevins/examples/testing-security/target/test-classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/testing-security
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean ManagerBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.secure.MovieTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/testing-security" loaded.
+INFO - Assembling app: /Users/dblevins/examples/testing-security
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 405ms
+INFO - Jndi(name="java:global/testing-security/Movies!org.superbiz.injection.secure.Movies")
+INFO - Jndi(name="java:global/testing-security/Movies")
+INFO - Jndi(name="java:global/testing-security/ManagerBean!org.superbiz.injection.secure.MovieTest$Caller")
+INFO - Jndi(name="java:global/testing-security/ManagerBean")
+INFO - Jndi(name="java:global/testing-security/EmployeeBean!org.superbiz.injection.secure.MovieTest$Caller")
+INFO - Jndi(name="java:global/testing-security/EmployeeBean")
+INFO - Jndi(name="java:global/EjbModule26174809/org.superbiz.injection.secure.MovieTest!org.superbiz.injection.secure.MovieTest")
+INFO - Jndi(name="java:global/EjbModule26174809/org.superbiz.injection.secure.MovieTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=EmployeeBean, ejb-name=EmployeeBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=EmployeeBean, ejb-name=EmployeeBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/testing-security)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.574 sec
+
+Results :
+
+Tests run: 3, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/testing-security.pdf b/content/examples/testing-security.pdf
new file mode 100644
index 0000000..7ccff70
--- /dev/null
+++ b/content/examples/testing-security.pdf
Binary files differ
diff --git a/content/examples/testing-security/README.md b/content/examples/testing-security/README.md
new file mode 100755
index 0000000..c761d1d
--- /dev/null
+++ b/content/examples/testing-security/README.md
@@ -0,0 +1,304 @@
+Title: Testing Security
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Movie
+
+ package org.superbiz.injection.secure;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection.secure;
+
+ //START SNIPPET: code
+
+ import javax.annotation.security.PermitAll;
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.Stateful;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.TransactionAttributeType;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ @Stateful
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MovieTest
+
+ package org.superbiz.injection.secure;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.security.RunAs;
+ import javax.ejb.EJB;
+ import javax.ejb.EJBAccessException;
+ import javax.ejb.Stateless;
+ import javax.ejb.embeddable.EJBContainer;
+ import java.util.List;
+ import java.util.Properties;
+ import java.util.concurrent.Callable;
+
+ //START SNIPPET: code
+
+ public class MovieTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(name = "ManagerBean")
+ private Caller manager;
+
+ @EJB(name = "EmployeeBean")
+ private Caller employee;
+
+ protected void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void testAsManager() throws Exception {
+ manager.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testAsEmployee() throws Exception {
+ employee.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ List<Movie> list = movies.getMovies();
+ } catch (EJBAccessException e) {
+ fail("Read access should be allowed");
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the desired security scope.
+ */
+
+ @Stateless
+ @RunAs("Manager")
+ public static class ManagerBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAs("Employee")
+ public static class EmployeeBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.secure.MovieTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/testing-security
+ INFO - openejb.base = /Users/dblevins/examples/testing-security
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security/target/classes
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-security/target/test-classes
+ INFO - Beginning load: /Users/dblevins/examples/testing-security/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/testing-security/target/test-classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/testing-security
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean ManagerBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.secure.MovieTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/testing-security" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/testing-security
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 405ms
+ INFO - Jndi(name="java:global/testing-security/Movies!org.superbiz.injection.secure.Movies")
+ INFO - Jndi(name="java:global/testing-security/Movies")
+ INFO - Jndi(name="java:global/testing-security/ManagerBean!org.superbiz.injection.secure.MovieTest$Caller")
+ INFO - Jndi(name="java:global/testing-security/ManagerBean")
+ INFO - Jndi(name="java:global/testing-security/EmployeeBean!org.superbiz.injection.secure.MovieTest$Caller")
+ INFO - Jndi(name="java:global/testing-security/EmployeeBean")
+ INFO - Jndi(name="java:global/EjbModule26174809/org.superbiz.injection.secure.MovieTest!org.superbiz.injection.secure.MovieTest")
+ INFO - Jndi(name="java:global/EjbModule26174809/org.superbiz.injection.secure.MovieTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=EmployeeBean, ejb-name=EmployeeBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=EmployeeBean, ejb-name=EmployeeBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.secure.MovieTest, ejb-name=org.superbiz.injection.secure.MovieTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/testing-security)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.574 sec
+
+ Results :
+
+ Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/testing-security/build.xml b/content/examples/testing-security/build.xml
new file mode 100755
index 0000000..4f29800
--- /dev/null
+++ b/content/examples/testing-security/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/testing-security/pom.xml b/content/examples/testing-security/pom.xml
new file mode 100755
index 0000000..04b9e4f
--- /dev/null
+++ b/content/examples/testing-security/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>testing-security</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Testing Security</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/testing-security/src/main/java/org/superbiz/injection/secure/Movie.java b/content/examples/testing-security/src/main/java/org/superbiz/injection/secure/Movie.java
new file mode 100755
index 0000000..b5df45c
--- /dev/null
+++ b/content/examples/testing-security/src/main/java/org/superbiz/injection/secure/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/testing-security/src/main/java/org/superbiz/injection/secure/Movies.java b/content/examples/testing-security/src/main/java/org/superbiz/injection/secure/Movies.java
new file mode 100755
index 0000000..b3ba8e8
--- /dev/null
+++ b/content/examples/testing-security/src/main/java/org/superbiz/injection/secure/Movies.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+//START SNIPPET: code
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-security/src/main/resources/META-INF/persistence.xml b/content/examples/testing-security/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..ae3723d
--- /dev/null
+++ b/content/examples/testing-security/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.secure.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/testing-security/src/test/java/org/superbiz/injection/secure/MovieTest.java b/content/examples/testing-security/src/test/java/org/superbiz/injection/secure/MovieTest.java
new file mode 100755
index 0000000..303d513
--- /dev/null
+++ b/content/examples/testing-security/src/test/java/org/superbiz/injection/secure/MovieTest.java
@@ -0,0 +1,167 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.secure;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.annotation.security.RunAs;
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.Stateless;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+//START SNIPPET: code
+
+public class MovieTest {
+
+ @EJB
+ private Movies movies;
+
+ @EJB(name = "ManagerBean")
+ private Caller manager;
+
+ @EJB(name = "EmployeeBean")
+ private Caller employee;
+
+ private EJBContainer container;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ this.container = EJBContainer.createEJBContainer(p);
+ this.container.getContext().bind("inject", this);
+ }
+
+ @After
+ public void tearDown() {
+ this.container.close();
+ }
+
+ @Test
+ public void testAsManager() throws Exception {
+ manager.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ @Test
+ public void testAsEmployee() throws Exception {
+ employee.call(new Callable() {
+ public Object call() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ Assert.fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ return null;
+ }
+ });
+ }
+
+ @Test
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ Assert.fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ Assert.fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+
+ movies.getMovies();
+
+ } catch (EJBAccessException e) {
+ Assert.fail("Read access should be allowed");
+ }
+
+ }
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the desired security scope.
+ */
+
+ @Stateless
+ @RunAs("Manager")
+ public static class ManagerBean implements Caller {
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+ @Stateless
+ @RunAs("Employee")
+ public static class EmployeeBean implements Caller {
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-transactions-bmt.html b/content/examples/testing-transactions-bmt.html
new file mode 100644
index 0000000..c422bf0
--- /dev/null
+++ b/content/examples/testing-transactions-bmt.html
@@ -0,0 +1,465 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/testing-transactions-bmt.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Testing Transactions BMT</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example testing-transactions-bmt can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/testing-transactions-bmt" class="bare">https://github.com/apache/tomee/tree/master/examples/testing-transactions-bmt</a></p>
+</div>
+<div class="paragraph">
+<p>Shows how to begin, commit and rollback transactions using a UserTransaction via a Stateful Bean.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public Movie() {
+
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+@Stateful(name = "Movies")
+@TransactionManagement(TransactionManagementType.BEAN)
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ public void addMovie(Movie movie) throws Exception {
+ try {
+ userTransaction.begin();
+ entityManager.persist(movie);
+
+ //For some dummy reason, this db can have only 5 titles. :O)
+ if (countMovies() > 5) {
+ userTransaction.rollback();
+ } else {
+ userTransaction.commit();
+ }
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ userTransaction.rollback();
+ }
+ }
+
+ public Long countMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT COUNT(m) FROM Movie m");
+ return Long.class.cast(query.getSingleResult());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.Properties;
+
+public class MoviesTest {
+
+ @EJB
+ private Movies movies;
+
+ @Test
+ public void testMe() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+
+ movies.addMovie(new Movie("Asif Kapadia", "Senna", 2010));
+ movies.addMovie(new Movie("José Padilha", "Tropa de Elite", 2007));
+ movies.addMovie(new Movie("Andy Wachowski/Lana Wachowski", "The Matrix", 1999));
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ Assert.assertEquals(5L, movies.countMovies().longValue());
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.tx.MoviesTest
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Sat Jul 21 16:39:28 EDT 2012
+INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 4.1.0
+INFO - Build date: 20120721
+INFO - Build time: 12:06
+INFO - ********************************************************************************
+INFO - openejb.home = /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt
+INFO - openejb.base = /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@3f3f210f
+INFO - Succeeded in installing singleton service
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Creating TransactionManager(id=Default Transaction Manager)
+INFO - Creating SecurityService(id=Default Security Service)
+INFO - Creating Resource(id=movieDatabase)
+INFO - Beginning load: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt/target/classes
+INFO - Configuring enterprise application: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt
+WARNING - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Auto-deploying ejb Movies: EjbDeployment(deployment-id=Movies)
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Creating Container(id=Default Stateful Container)
+INFO - Using directory /tmp for stateful session passivation
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Using directory /tmp for stateful session passivation
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Creating Resource(id=movieDatabaseNonJta)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt" loaded.
+INFO - Assembling app: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt
+SEVERE - JAVA AGENT NOT INSTALLED. The JPA Persistence Provider requested installation of a ClassFileTransformer which requires a JavaAgent. See http://tomee.apache.org/3.0/javaagent.html
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 399ms
+INFO - Jndi(name="java:global/testing-transactions-bmt/Movies!org.superbiz.injection.tx.Movies")
+INFO - Jndi(name="java:global/testing-transactions-bmt/Movies")
+INFO - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@3f3f210f
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 157 ms.
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Deployed Application(path=/home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt)
+INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@709a1411
+21-Jul-2012 4:39:32 PM null openjpa.Runtime
+INFO: Starting OpenJPA 2.2.0
+21-Jul-2012 4:39:32 PM null openjpa.jdbc.JDBC
+INFO: Using dictionary class "org.apache.openjpa.jdbc.sql.HSQLDictionary" (HSQL Database Engine 2.2.8 ,HSQL Database Engine Driver 2.2.8).
+21-Jul-2012 4:39:33 PM null openjpa.Enhance
+INFO: Creating subclass and redefining methods for "[class org.superbiz.injection.tx.Movie]". This means that your application will be less efficient than it would if you ran the OpenJPA enhancer.
+INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@709a1411
+INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@2bb64b70
+INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@2bb64b70
+INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@627b5c
+INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@627b5c
+INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@2f031310
+INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@2f031310
+INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@4df2a9da
+INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@4df2a9da
+INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@3fa9b4a4
+INFO - Rolling back user transaction org.apache.geronimo.transaction.manager.TransactionImpl@3fa9b4a4
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.471 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/testing-transactions-bmt.pdf b/content/examples/testing-transactions-bmt.pdf
new file mode 100644
index 0000000..dc82bdc
--- /dev/null
+++ b/content/examples/testing-transactions-bmt.pdf
Binary files differ
diff --git a/content/examples/testing-transactions-bmt/README.md b/content/examples/testing-transactions-bmt/README.md
new file mode 100755
index 0000000..b220017
--- /dev/null
+++ b/content/examples/testing-transactions-bmt/README.md
@@ -0,0 +1,248 @@
+Title: Testing Transactions BMT
+
+Shows how to begin, commit and rollback transactions using a UserTransaction via a Stateful Bean.
+
+## Movie
+
+ package org.superbiz.injection.tx;
+
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.Id;
+
+ @Entity
+ public class Movie {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public Movie() {
+
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+ }
+
+## Movies
+
+ package org.superbiz.injection.tx;
+
+ import javax.annotation.Resource;
+ import javax.ejb.Stateful;
+ import javax.ejb.TransactionManagement;
+ import javax.ejb.TransactionManagementType;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import javax.transaction.UserTransaction;
+
+ @Stateful(name = "Movies")
+ @TransactionManagement(TransactionManagementType.BEAN)
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ public void addMovie(Movie movie) throws Exception {
+ try {
+ userTransaction.begin();
+ entityManager.persist(movie);
+
+ //For some dummy reason, this db can have only 5 titles. :O)
+ if (countMovies() > 5) {
+ userTransaction.rollback();
+ } else {
+ userTransaction.commit();
+ }
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ userTransaction.rollback();
+ }
+ }
+
+ public Long countMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT COUNT(m) FROM Movie m");
+ return Long.class.cast(query.getSingleResult());
+ }
+ }
+
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MoviesTest
+
+ package org.superbiz.injection.tx;
+
+ import org.junit.Assert;
+ import org.junit.Test;
+
+ import javax.ejb.EJB;
+ import javax.ejb.embeddable.EJBContainer;
+ import java.util.Properties;
+
+ public class MoviesTest {
+
+ @EJB
+ private Movies movies;
+
+ @Test
+ public void testMe() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+
+ movies.addMovie(new Movie("Asif Kapadia", "Senna", 2010));
+ movies.addMovie(new Movie("José Padilha", "Tropa de Elite", 2007));
+ movies.addMovie(new Movie("Andy Wachowski/Lana Wachowski", "The Matrix", 1999));
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ Assert.assertEquals(5L, movies.countMovies().longValue());
+ }
+
+ }
+
+
+# Running
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.tx.MoviesTest
+ INFO - ********************************************************************************
+ INFO - OpenEJB http://openejb.apache.org/
+ INFO - Startup: Sat Jul 21 16:39:28 EDT 2012
+ INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+ INFO - Version: 4.1.0
+ INFO - Build date: 20120721
+ INFO - Build time: 12:06
+ INFO - ********************************************************************************
+ INFO - openejb.home = /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt
+ INFO - openejb.base = /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt
+ INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@3f3f210f
+ INFO - Succeeded in installing singleton service
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Creating TransactionManager(id=Default Transaction Manager)
+ INFO - Creating SecurityService(id=Default Security Service)
+ INFO - Creating Resource(id=movieDatabase)
+ INFO - Beginning load: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt/target/classes
+ INFO - Configuring enterprise application: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt
+ WARNING - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Auto-deploying ejb Movies: EjbDeployment(deployment-id=Movies)
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Creating Container(id=Default Stateful Container)
+ INFO - Using directory /tmp for stateful session passivation
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Creating Container(id=Default Managed Container)
+ INFO - Using directory /tmp for stateful session passivation
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Creating Resource(id=movieDatabaseNonJta)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt" loaded.
+ INFO - Assembling app: /home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt
+ SEVERE - JAVA AGENT NOT INSTALLED. The JPA Persistence Provider requested installation of a ClassFileTransformer which requires a JavaAgent. See http://openejb.apache.org/3.0/javaagent.html
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 399ms
+ INFO - Jndi(name="java:global/testing-transactions-bmt/Movies!org.superbiz.injection.tx.Movies")
+ INFO - Jndi(name="java:global/testing-transactions-bmt/Movies")
+ INFO - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@3f3f210f
+ INFO - OpenWebBeans Container is starting...
+ INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+ INFO - All injection points are validated successfully.
+ INFO - OpenWebBeans Container has started, it took 157 ms.
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Deployed Application(path=/home/boto/dev/ws/openejb_trunk/openejb/examples/testing-transactions-bmt)
+ INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@709a1411
+ 21-Jul-2012 4:39:32 PM null openjpa.Runtime
+ INFO: Starting OpenJPA 2.2.0
+ 21-Jul-2012 4:39:32 PM null openjpa.jdbc.JDBC
+ INFO: Using dictionary class "org.apache.openjpa.jdbc.sql.HSQLDictionary" (HSQL Database Engine 2.2.8 ,HSQL Database Engine Driver 2.2.8).
+ 21-Jul-2012 4:39:33 PM null openjpa.Enhance
+ INFO: Creating subclass and redefining methods for "[class org.superbiz.injection.tx.Movie]". This means that your application will be less efficient than it would if you ran the OpenJPA enhancer.
+ INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@709a1411
+ INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@2bb64b70
+ INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@2bb64b70
+ INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@627b5c
+ INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@627b5c
+ INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@2f031310
+ INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@2f031310
+ INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@4df2a9da
+ INFO - Committing user transaction org.apache.geronimo.transaction.manager.TransactionImpl@4df2a9da
+ INFO - Started user transaction org.apache.geronimo.transaction.manager.TransactionImpl@3fa9b4a4
+ INFO - Rolling back user transaction org.apache.geronimo.transaction.manager.TransactionImpl@3fa9b4a4
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.471 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
diff --git a/content/examples/testing-transactions-bmt/build.xml b/content/examples/testing-transactions-bmt/build.xml
new file mode 100755
index 0000000..4f29800
--- /dev/null
+++ b/content/examples/testing-transactions-bmt/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/testing-transactions-bmt/pom.xml b/content/examples/testing-transactions-bmt/pom.xml
new file mode 100755
index 0000000..9d0e933
--- /dev/null
+++ b/content/examples/testing-transactions-bmt/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>testing-transactions-bmt</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Testing Transactions BMT</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/testing-transactions-bmt/src/main/java/org/superbiz/injection/tx/Movie.java b/content/examples/testing-transactions-bmt/src/main/java/org/superbiz/injection/tx/Movie.java
new file mode 100755
index 0000000..5ee6c57
--- /dev/null
+++ b/content/examples/testing-transactions-bmt/src/main/java/org/superbiz/injection/tx/Movie.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public Movie() {
+
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+}
diff --git a/content/examples/testing-transactions-bmt/src/main/java/org/superbiz/injection/tx/Movies.java b/content/examples/testing-transactions-bmt/src/main/java/org/superbiz/injection/tx/Movies.java
new file mode 100755
index 0000000..964eafc
--- /dev/null
+++ b/content/examples/testing-transactions-bmt/src/main/java/org/superbiz/injection/tx/Movies.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import javax.transaction.UserTransaction;
+
+@Stateful(name = "Movies")
+@TransactionManagement(TransactionManagementType.BEAN)
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ public void addMovie(Movie movie) throws Exception {
+ try {
+ userTransaction.begin();
+ entityManager.persist(movie);
+
+ //For some dummy reason, this db can have only 5 titles. :O)
+ if (countMovies() > 5) {
+ userTransaction.rollback();
+ } else {
+ userTransaction.commit();
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ userTransaction.rollback();
+ }
+ }
+
+ public Long countMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT COUNT(m) FROM Movie m");
+ return Long.class.cast(query.getSingleResult());
+ }
+}
+
diff --git a/content/examples/testing-transactions-bmt/src/main/resources/META-INF/persistence.xml b/content/examples/testing-transactions-bmt/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..029144e
--- /dev/null
+++ b/content/examples/testing-transactions-bmt/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/testing-transactions-bmt/src/test/java/org/superbiz/injection/tx/MoviesTest.java b/content/examples/testing-transactions-bmt/src/test/java/org/superbiz/injection/tx/MoviesTest.java
new file mode 100755
index 0000000..3315153
--- /dev/null
+++ b/content/examples/testing-transactions-bmt/src/test/java/org/superbiz/injection/tx/MoviesTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.Properties;
+
+public class MoviesTest {
+
+ @EJB
+ private Movies movies;
+
+ @Test
+ public void testMe() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+
+ movies.addMovie(new Movie("Asif Kapadia", "Senna", 2010));
+ movies.addMovie(new Movie("José Padilha", "Tropa de Elite", 2007));
+ movies.addMovie(new Movie("Andy Wachowski/Lana Wachowski", "The Matrix", 1999));
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ Assert.assertEquals(5L, movies.countMovies().longValue());
+ }
+
+}
diff --git a/content/examples/testing-transactions.html b/content/examples/testing-transactions.html
new file mode 100644
index 0000000..192bdf3
--- /dev/null
+++ b/content/examples/testing-transactions.html
@@ -0,0 +1,464 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/testing-transactions.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Testing Transactions</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example testing-transactions can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/testing-transactions" class="bare">https://github.com/apache/tomee/tree/master/examples/testing-transactions</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+import static javax.ejb.TransactionAttributeType.MANDATORY;
+
+//START SNIPPET: code
+@Stateful(name = "Movies")
+@TransactionAttribute(MANDATORY)
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.injection.tx;
+
+import junit.framework.TestCase;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+/**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB
+ private Caller transactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ doWork();
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBTransactionRequiredException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.injection.tx.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/testing-transactions
+INFO - openejb.base = /Users/dblevins/examples/testing-transactions
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-transactions/target/classes
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-transactions/target/test-classes
+INFO - Beginning load: /Users/dblevins/examples/testing-transactions/target/classes
+INFO - Beginning load: /Users/dblevins/examples/testing-transactions/target/test-classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/testing-transactions
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/testing-transactions" loaded.
+INFO - Assembling app: /Users/dblevins/examples/testing-transactions
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 406ms
+INFO - Jndi(name="java:global/testing-transactions/Movies!org.superbiz.injection.tx.Movies")
+INFO - Jndi(name="java:global/testing-transactions/Movies")
+INFO - Jndi(name="java:global/testing-transactions/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+INFO - Jndi(name="java:global/testing-transactions/TransactionBean")
+INFO - Jndi(name="java:global/EjbModule2036741132/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule2036741132/org.superbiz.injection.tx.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/testing-transactions)
+INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.403 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/testing-transactions.pdf b/content/examples/testing-transactions.pdf
new file mode 100644
index 0000000..cd963bb
--- /dev/null
+++ b/content/examples/testing-transactions.pdf
Binary files differ
diff --git a/content/examples/testing-transactions/README.md b/content/examples/testing-transactions/README.md
new file mode 100755
index 0000000..5443036
--- /dev/null
+++ b/content/examples/testing-transactions/README.md
@@ -0,0 +1,247 @@
+Title: Testing Transactions
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Movie
+
+ package org.superbiz.injection.tx;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.injection.tx;
+
+ import javax.ejb.Stateful;
+ import javax.ejb.TransactionAttribute;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ import static javax.ejb.TransactionAttributeType.MANDATORY;
+
+ //START SNIPPET: code
+ @Stateful(name = "Movies")
+ @TransactionAttribute(MANDATORY)
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MoviesTest
+
+ package org.superbiz.injection.tx;
+
+ import junit.framework.TestCase;
+
+ import javax.ejb.EJB;
+ import javax.ejb.Stateless;
+ import javax.ejb.TransactionAttribute;
+ import javax.ejb.embeddable.EJBContainer;
+ import java.util.List;
+ import java.util.Properties;
+ import java.util.concurrent.Callable;
+
+ import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+ /**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+ //START SNIPPET: code
+ public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB
+ private Caller transactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ doWork();
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBTransactionRequiredException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+
+ public static interface Caller {
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.injection.tx.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/testing-transactions
+ INFO - openejb.base = /Users/dblevins/examples/testing-transactions
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-transactions/target/classes
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/testing-transactions/target/test-classes
+ INFO - Beginning load: /Users/dblevins/examples/testing-transactions/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/testing-transactions/target/test-classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/testing-transactions
+ INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container)
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/testing-transactions" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/testing-transactions
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 406ms
+ INFO - Jndi(name="java:global/testing-transactions/Movies!org.superbiz.injection.tx.Movies")
+ INFO - Jndi(name="java:global/testing-transactions/Movies")
+ INFO - Jndi(name="java:global/testing-transactions/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller")
+ INFO - Jndi(name="java:global/testing-transactions/TransactionBean")
+ INFO - Jndi(name="java:global/EjbModule2036741132/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule2036741132/org.superbiz.injection.tx.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container)
+ INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/testing-transactions)
+ INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.403 sec
+
+ Results :
+
+ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/testing-transactions/build.xml b/content/examples/testing-transactions/build.xml
new file mode 100755
index 0000000..4f29800
--- /dev/null
+++ b/content/examples/testing-transactions/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/testing-transactions/pom.xml b/content/examples/testing-transactions/pom.xml
new file mode 100755
index 0000000..1874ad9
--- /dev/null
+++ b/content/examples/testing-transactions/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>testing-transactions</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Testing Transactions</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/testing-transactions/src/main/java/org/superbiz/injection/tx/Movie.java b/content/examples/testing-transactions/src/main/java/org/superbiz/injection/tx/Movie.java
new file mode 100755
index 0000000..1d0c359
--- /dev/null
+++ b/content/examples/testing-transactions/src/main/java/org/superbiz/injection/tx/Movie.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/testing-transactions/src/main/java/org/superbiz/injection/tx/Movies.java b/content/examples/testing-transactions/src/main/java/org/superbiz/injection/tx/Movies.java
new file mode 100755
index 0000000..6c5ace4
--- /dev/null
+++ b/content/examples/testing-transactions/src/main/java/org/superbiz/injection/tx/Movies.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+import static javax.ejb.TransactionAttributeType.MANDATORY;
+
+//START SNIPPET: code
+@Stateful(name = "Movies")
+@TransactionAttribute(MANDATORY)
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/testing-transactions/src/main/resources/META-INF/persistence.xml b/content/examples/testing-transactions/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..029144e
--- /dev/null
+++ b/content/examples/testing-transactions/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.injection.tx.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/testing-transactions/src/test/java/org/superbiz/injection/tx/MoviesTest.java b/content/examples/testing-transactions/src/test/java/org/superbiz/injection/tx/MoviesTest.java
new file mode 100755
index 0000000..15928bc
--- /dev/null
+++ b/content/examples/testing-transactions/src/test/java/org/superbiz/injection/tx/MoviesTest.java
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.injection.tx;
+
+import junit.framework.TestCase;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.embeddable.EJBContainer;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+
+/**
+ * See the transaction-rollback example as it does the same thing
+ * via UserTransaction and shows more techniques for rollback
+ */
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @EJB
+ private Caller transactionalCaller;
+
+ protected void setUp() throws Exception {
+ final Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ private void doWork() throws Exception {
+
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ }
+
+ public void testWithTransaction() throws Exception {
+ transactionalCaller.call(new Callable() {
+ public Object call() throws Exception {
+ doWork();
+ return null;
+ }
+ });
+ }
+
+ public void testWithoutTransaction() throws Exception {
+ try {
+ doWork();
+ fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
+ } catch (javax.ejb.EJBTransactionRequiredException e) {
+ // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
+ }
+ }
+
+ public static interface Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception;
+ }
+
+ /**
+ * This little bit of magic allows our test code to execute in
+ * the scope of a container controlled transaction.
+ */
+ @Stateless
+ @TransactionAttribute(REQUIRES_NEW)
+ public static class TransactionBean implements Caller {
+
+ public <V> V call(Callable<V> callable) throws Exception {
+ return callable.call();
+ }
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/tomee-jersey-eclipselink.html b/content/examples/tomee-jersey-eclipselink.html
new file mode 100644
index 0000000..27c1107
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/tomee-jersey-eclipselink.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>tomee-jersey-eclipselink</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example tomee-jersey-eclipselink can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/tomee-jersey-eclipselink" class="bare">https://github.com/apache/tomee/tree/master/examples/tomee-jersey-eclipselink</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/tomee-jersey-eclipselink.pdf b/content/examples/tomee-jersey-eclipselink.pdf
new file mode 100644
index 0000000..39dd003
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink.pdf
Binary files differ
diff --git a/content/examples/tomee-jersey-eclipselink/pom.xml b/content/examples/tomee-jersey-eclipselink/pom.xml
new file mode 100755
index 0000000..472e5b7
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink/pom.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>tomee-jersey-eclipselink</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>OpenEJB :: Examples :: TomEE, Jersey, Eclipselink</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <version.eclipselink>2.5.1</version.eclipselink>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.core</artifactId>
+ <version>${version.eclipselink}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.antlr</artifactId>
+ <version>${version.eclipselink}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.asm</artifactId>
+ <version>${version.eclipselink}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.jpa</artifactId>
+ <version>${version.eclipselink}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-bundle</artifactId>
+ <version>1.12</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ <configuration>
+ <systemVariables>
+ <com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager>true</com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager>
+ </systemVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ <repository>
+ <id>eclipselink-repo</id>
+ <name>EclipseLink Repository</name>
+ <url>http://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/rt/eclipselink/maven.repo</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot-plugin</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+
+</project>
diff --git a/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/dao/PersonDAO.java b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/dao/PersonDAO.java
new file mode 100755
index 0000000..c5cbc80
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/dao/PersonDAO.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dao;
+
+import org.superbiz.domain.Person;
+
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import java.util.List;
+
+@Singleton
+@Lock(LockType.READ)
+public class PersonDAO {
+
+ @PersistenceContext
+ private EntityManager em;
+
+ public Person save(final String name) {
+ final Person person = new Person();
+ person.setName(name);
+ em.persist(person);
+ return person;
+ }
+
+ public List<Person> findAll() {
+ return em.createNamedQuery("Person.findAll", Person.class).getResultList();
+ }
+}
diff --git a/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/domain/Person.java b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/domain/Person.java
new file mode 100755
index 0000000..a74732c
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/domain/Person.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.domain;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@XmlRootElement
+@NamedQuery(name = "Person.findAll", query = "select p from Person p")
+public class Person {
+
+ @Id
+ @GeneratedValue
+ private long id;
+ private String name;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/init/Initializer.java b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/init/Initializer.java
new file mode 100755
index 0000000..5077838
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/init/Initializer.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.init;
+
+import org.eclipse.persistence.transaction.JTATransactionController;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.transaction.TransactionManager;
+
+@Startup
+@Singleton // tomee does it itself if eclipselink is in common.lib otherwise it is to be done by the app
+public class Initializer {
+
+ @Resource
+ private TransactionManager tm;
+
+ @PostConstruct
+ private void init() {
+ JTATransactionController.setDefaultTransactionManager(tm);
+ }
+}
diff --git a/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/JerseyApplication.java b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/JerseyApplication.java
new file mode 100755
index 0000000..bb355e6
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/JerseyApplication.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.service;
+
+import javax.ws.rs.core.Application;
+import java.util.HashSet;
+import java.util.Set;
+
+public class JerseyApplication extends Application {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ final Set<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(PersonService.class);
+ return classes;
+ }
+}
diff --git a/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/PersonService.java b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/PersonService.java
new file mode 100755
index 0000000..053d732
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/PersonService.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.service;
+
+import org.superbiz.dao.PersonDAO;
+import org.superbiz.domain.Person;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import java.util.List;
+
+@Path("/person")
+@RequestScoped
+public class PersonService {
+
+ @Inject
+ private PersonDAO dao;
+
+ public PersonService() {
+ System.out.println();
+ }
+
+ @GET
+ @Path("/create/{name}")
+ public Person create(@PathParam("name") final String name) {
+ return dao.save(name);
+ }
+
+ @GET
+ @Path("/all")
+ public List<Person> list() {
+ return dao.findAll();
+ }
+}
diff --git a/content/examples/tomee-jersey-eclipselink/src/main/resources/META-INF/persistence.xml b/content/examples/tomee-jersey-eclipselink/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..dcf2356
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence version="1.0"
+ xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="movie-unit">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <jta-data-source>My Default DataSource</jta-data-source>
+ <class>org.superbiz.domain.Person</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ <properties>
+ <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.HSQLPlatform"/>
+ <property name="eclipselink.target-server" value="org.eclipse.persistence.transaction.JTATransactionController"/>
+ <property name="eclipselink.ddl-generation" value="create-tables"/>
+ <property name="eclipselink.ddl-generation.output-mode" value="database"/>
+ </properties>
+ </persistence-unit>
+</persistence>
diff --git a/content/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/beans.xml b/content/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/beans.xml
new file mode 100755
index 0000000..c913a0e
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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"/>
diff --git a/content/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/web.xml b/content/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000..4e19c96
--- /dev/null
+++ b/content/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<web-app 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/web-app_3_0.xsd"
+ version="3.0">
+ <servlet>
+ <servlet-name>Jersey Web Application</servlet-name>
+ <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.superbiz.service.JerseyApplication</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Jersey Web Application</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
diff --git a/content/examples/transaction-rollback.html b/content/examples/transaction-rollback.html
new file mode 100644
index 0000000..0f64ae7
--- /dev/null
+++ b/content/examples/transaction-rollback.html
@@ -0,0 +1,770 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/transaction-rollback.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Transaction Rollback</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example transaction-rollback can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/transaction-rollback" class="bare">https://github.com/apache/tomee/tree/master/examples/transaction-rollback</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_customruntimeexception">CustomRuntimeException</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.txrollback;
+
+import javax.ejb.ApplicationException;
+
+@ApplicationException
+public class CustomRuntimeException extends RuntimeException {
+
+ public CustomRuntimeException() {
+ }
+
+ public CustomRuntimeException(String s) {
+ super(s);
+ }
+
+ public CustomRuntimeException(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public CustomRuntimeException(Throwable throwable) {
+ super(throwable);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.txrollback;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity(name = "Movie")
+public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.txrollback;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+//START SNIPPET: code
+@Stateless
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @Resource
+ private SessionContext sessionContext;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+ public void callSetRollbackOnly() {
+ sessionContext.setRollbackOnly();
+ }
+
+ public void throwUncheckedException() {
+ throw new RuntimeException("Throwing unchecked exceptions will rollback a transaction");
+ }
+
+ public void throwApplicationException() {
+ throw new CustomRuntimeException("This is marked @ApplicationException, so no TX rollback");
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.testinjection.MoviesTest.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.txrollback;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.RollbackException;
+import javax.transaction.UserTransaction;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ private EJBContainer ejbContainer;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb" + System.currentTimeMillis());
+
+ ejbContainer = EJBContainer.createEJBContainer(p);
+ ejbContainer.getContext().bind("inject", this);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ ejbContainer.close();
+ }
+
+ /**
+ * Standard successful transaction scenario. The data created inside
+ * the transaction is visible after the transaction completes.
+ * <p/>
+ * Note that UserTransaction is only usable by Bean-Managed Transaction
+ * beans, which can be specified with @TransactionManagement(BEAN)
+ */
+ public void testCommit() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ } finally {
+ userTransaction.commit();
+ }
+
+ // Transaction was committed
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ }
+
+ /**
+ * Standard transaction rollback scenario. The data created inside
+ * the transaction is not visible after the transaction completes.
+ */
+ public void testUserTransactionRollback() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ } finally {
+ userTransaction.rollback();
+ }
+
+ // Transaction was rolled back
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 0, list.size());
+ }
+
+ /**
+ * Transaction is marked for rollback inside the bean via
+ * calling the javax.ejb.SessionContext.setRollbackOnly() method
+ * <p/>
+ * This is the cleanest way to make a transaction rollback.
+ */
+ public void testMarkedRollback() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ movies.callSetRollbackOnly();
+ } finally {
+ try {
+ userTransaction.commit();
+ fail("A RollbackException should have been thrown");
+ } catch (RollbackException e) {
+ // Pass
+ }
+ }
+
+ // Transaction was rolled back
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 0, list.size());
+ }
+
+ /**
+ * Throwing an unchecked exception from a bean will cause
+ * the container to call setRollbackOnly() and discard the
+ * bean instance from further use without calling any @PreDestroy
+ * methods on the bean instance.
+ */
+ public void testExceptionBasedRollback() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ try {
+ movies.throwUncheckedException();
+ } catch (RuntimeException e) {
+ // Good, this will cause the tx to rollback
+ }
+ } finally {
+ try {
+ userTransaction.commit();
+ fail("A RollbackException should have been thrown");
+ } catch (RollbackException e) {
+ // Pass
+ }
+ }
+
+ // Transaction was rolled back
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 0, list.size());
+ }
+
+ /**
+ * It is still possible to throw unchecked (runtime) exceptions
+ * without dooming the transaction by marking the exception
+ * with the @ApplicationException annotation or in the ejb-jar.xml
+ * deployment descriptor via the <application-exception> tag
+ */
+ public void testCommit2() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ try {
+ movies.throwApplicationException();
+ } catch (RuntimeException e) {
+ // This will *not* cause the tx to rollback
+ // because it is marked as an @ApplicationException
+ }
+ } finally {
+ userTransaction.commit();
+ }
+
+ // Transaction was committed
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.txrollback.MoviesTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 412ms
+INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+INFO - Jndi(name="java:global/transaction-rollback/Movies")
+INFO - Jndi(name="java:global/EjbModule1718375554/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1718375554/org.superbiz.txrollback.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+INFO - Closing DataSource: movieDatabase
+INFO - Closing DataSource: movieDatabaseNonJta
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 5ms
+INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+INFO - Jndi(name="java:global/transaction-rollback/Movies")
+INFO - Jndi(name="java:global/EjbModule935567559/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule935567559/org.superbiz.txrollback.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+INFO - Closing DataSource: movieDatabase
+INFO - Closing DataSource: movieDatabaseNonJta
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 5ms
+INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+INFO - Jndi(name="java:global/transaction-rollback/Movies")
+INFO - Jndi(name="java:global/EjbModule1961109485/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule1961109485/org.superbiz.txrollback.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+INFO - Closing DataSource: movieDatabase
+INFO - Closing DataSource: movieDatabaseNonJta
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 5ms
+INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+INFO - Jndi(name="java:global/transaction-rollback/Movies")
+INFO - Jndi(name="java:global/EjbModule419651577/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule419651577/org.superbiz.txrollback.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+INFO - Closing DataSource: movieDatabase
+INFO - Closing DataSource: movieDatabaseNonJta
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Configuring PersistenceUnit(name=movie-unit)
+INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 4ms
+INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+INFO - Jndi(name="java:global/transaction-rollback/Movies")
+INFO - Jndi(name="java:global/EjbModule15169271/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+INFO - Jndi(name="java:global/EjbModule15169271/org.superbiz.txrollback.MoviesTest")
+INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+INFO - Closing DataSource: movieDatabase
+INFO - Closing DataSource: movieDatabaseNonJta
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.586 sec
+
+Results :
+
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/transaction-rollback.pdf b/content/examples/transaction-rollback.pdf
new file mode 100644
index 0000000..efd4232
--- /dev/null
+++ b/content/examples/transaction-rollback.pdf
Binary files differ
diff --git a/content/examples/transaction-rollback/README.md b/content/examples/transaction-rollback/README.md
new file mode 100755
index 0000000..9208efe
--- /dev/null
+++ b/content/examples/transaction-rollback/README.md
@@ -0,0 +1,547 @@
+Title: Transaction Rollback
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## CustomRuntimeException
+
+ package org.superbiz.txrollback;
+
+ import javax.ejb.ApplicationException;
+
+ @ApplicationException
+ public class CustomRuntimeException extends RuntimeException {
+
+ public CustomRuntimeException() {
+ }
+
+ public CustomRuntimeException(String s) {
+ super(s);
+ }
+
+ public CustomRuntimeException(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public CustomRuntimeException(Throwable throwable) {
+ super(throwable);
+ }
+ }
+
+## Movie
+
+ package org.superbiz.txrollback;
+
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.GenerationType;
+ import javax.persistence.Id;
+
+ @Entity(name = "Movie")
+ public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.txrollback;
+
+ import javax.annotation.Resource;
+ import javax.ejb.SessionContext;
+ import javax.ejb.Stateless;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ //START SNIPPET: code
+ @Stateless
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @Resource
+ private SessionContext sessionContext;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+ public void callSetRollbackOnly() {
+ sessionContext.setRollbackOnly();
+ }
+
+ public void throwUncheckedException() {
+ throw new RuntimeException("Throwing unchecked exceptions will rollback a transaction");
+ }
+
+ public void throwApplicationException() {
+ throw new CustomRuntimeException("This is marked @ApplicationException, so no TX rollback");
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.testinjection.MoviesTest.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MoviesTest
+
+ package org.superbiz.txrollback;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.Resource;
+ import javax.ejb.EJB;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.transaction.RollbackException;
+ import javax.transaction.UserTransaction;
+ import java.util.List;
+ import java.util.Properties;
+
+ //START SNIPPET: code
+ public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ private EJBContainer ejbContainer;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb" + System.currentTimeMillis());
+
+ ejbContainer = EJBContainer.createEJBContainer(p);
+ ejbContainer.getContext().bind("inject", this);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ ejbContainer.close();
+ }
+
+ /**
+ * Standard successful transaction scenario. The data created inside
+ * the transaction is visible after the transaction completes.
+ * <p/>
+ * Note that UserTransaction is only usable by Bean-Managed Transaction
+ * beans, which can be specified with @TransactionManagement(BEAN)
+ */
+ public void testCommit() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ } finally {
+ userTransaction.commit();
+ }
+
+ // Transaction was committed
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ }
+
+ /**
+ * Standard transaction rollback scenario. The data created inside
+ * the transaction is not visible after the transaction completes.
+ */
+ public void testUserTransactionRollback() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ } finally {
+ userTransaction.rollback();
+ }
+
+ // Transaction was rolled back
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 0, list.size());
+ }
+
+ /**
+ * Transaction is marked for rollback inside the bean via
+ * calling the javax.ejb.SessionContext.setRollbackOnly() method
+ * <p/>
+ * This is the cleanest way to make a transaction rollback.
+ */
+ public void testMarkedRollback() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ movies.callSetRollbackOnly();
+ } finally {
+ try {
+ userTransaction.commit();
+ fail("A RollbackException should have been thrown");
+ } catch (RollbackException e) {
+ // Pass
+ }
+ }
+
+ // Transaction was rolled back
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 0, list.size());
+ }
+
+ /**
+ * Throwing an unchecked exception from a bean will cause
+ * the container to call setRollbackOnly() and discard the
+ * bean instance from further use without calling any @PreDestroy
+ * methods on the bean instance.
+ */
+ public void testExceptionBasedRollback() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ try {
+ movies.throwUncheckedException();
+ } catch (RuntimeException e) {
+ // Good, this will cause the tx to rollback
+ }
+ } finally {
+ try {
+ userTransaction.commit();
+ fail("A RollbackException should have been thrown");
+ } catch (RollbackException e) {
+ // Pass
+ }
+ }
+
+ // Transaction was rolled back
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 0, list.size());
+ }
+
+ /**
+ * It is still possible to throw unchecked (runtime) exceptions
+ * without dooming the transaction by marking the exception
+ * with the @ApplicationException annotation or in the ejb-jar.xml
+ * deployment descriptor via the <application-exception> tag
+ */
+ public void testCommit2() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ try {
+ movies.throwApplicationException();
+ } catch (RuntimeException e) {
+ // This will *not* cause the tx to rollback
+ // because it is marked as an @ApplicationException
+ }
+ } finally {
+ userTransaction.commit();
+ }
+
+ // Transaction was committed
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.txrollback.MoviesTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+ INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+ WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 412ms
+ INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+ INFO - Jndi(name="java:global/transaction-rollback/Movies")
+ INFO - Jndi(name="java:global/EjbModule1718375554/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1718375554/org.superbiz.txrollback.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+ INFO - Closing DataSource: movieDatabase
+ INFO - Closing DataSource: movieDatabaseNonJta
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+ INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 5ms
+ INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+ INFO - Jndi(name="java:global/transaction-rollback/Movies")
+ INFO - Jndi(name="java:global/EjbModule935567559/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule935567559/org.superbiz.txrollback.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+ INFO - Closing DataSource: movieDatabase
+ INFO - Closing DataSource: movieDatabaseNonJta
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+ INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 5ms
+ INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+ INFO - Jndi(name="java:global/transaction-rollback/Movies")
+ INFO - Jndi(name="java:global/EjbModule1961109485/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule1961109485/org.superbiz.txrollback.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+ INFO - Closing DataSource: movieDatabase
+ INFO - Closing DataSource: movieDatabaseNonJta
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+ INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 5ms
+ INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+ INFO - Jndi(name="java:global/transaction-rollback/Movies")
+ INFO - Jndi(name="java:global/EjbModule419651577/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule419651577/org.superbiz.txrollback.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+ INFO - Closing DataSource: movieDatabase
+ INFO - Closing DataSource: movieDatabaseNonJta
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/transaction-rollback
+ INFO - openejb.base = /Users/dblevins/examples/transaction-rollback
+ 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 - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/transaction-rollback/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/transaction-rollback
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.txrollback.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Configuring PersistenceUnit(name=movie-unit)
+ INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ INFO - Enterprise application "/Users/dblevins/examples/transaction-rollback" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/transaction-rollback
+ INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 4ms
+ INFO - Jndi(name="java:global/transaction-rollback/Movies!org.superbiz.txrollback.Movies")
+ INFO - Jndi(name="java:global/transaction-rollback/Movies")
+ INFO - Jndi(name="java:global/EjbModule15169271/org.superbiz.txrollback.MoviesTest!org.superbiz.txrollback.MoviesTest")
+ INFO - Jndi(name="java:global/EjbModule15169271/org.superbiz.txrollback.MoviesTest")
+ INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=org.superbiz.txrollback.MoviesTest, ejb-name=org.superbiz.txrollback.MoviesTest, container=Default Managed Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/transaction-rollback)
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@39172e08; ignoring.
+ INFO - Undeploying app: /Users/dblevins/examples/transaction-rollback
+ INFO - Closing DataSource: movieDatabase
+ INFO - Closing DataSource: movieDatabaseNonJta
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.586 sec
+
+ Results :
+
+ Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/transaction-rollback/build.xml b/content/examples/transaction-rollback/build.xml
new file mode 100755
index 0000000..821f630
--- /dev/null
+++ b/content/examples/transaction-rollback/build.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ <dependency groupId="org.apache.openejb" artifactId="openejb-api" version="4.0.0-beta-1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/transaction-rollback/pom.xml b/content/examples/transaction-rollback/pom.xml
new file mode 100755
index 0000000..aaf8740
--- /dev/null
+++ b/content/examples/transaction-rollback/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>transaction-rollback</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Transaction Rollback</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- openejb container for running tests -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/transaction-rollback/src/main/java/org/superbiz/txrollback/CustomRuntimeException.java b/content/examples/transaction-rollback/src/main/java/org/superbiz/txrollback/CustomRuntimeException.java
new file mode 100755
index 0000000..32e5537
--- /dev/null
+++ b/content/examples/transaction-rollback/src/main/java/org/superbiz/txrollback/CustomRuntimeException.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.txrollback;
+
+import javax.ejb.ApplicationException;
+
+@ApplicationException
+public class CustomRuntimeException extends RuntimeException {
+
+ public CustomRuntimeException() {
+ }
+
+ public CustomRuntimeException(String s) {
+ super(s);
+ }
+
+ public CustomRuntimeException(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public CustomRuntimeException(Throwable throwable) {
+ super(throwable);
+ }
+}
diff --git a/content/examples/transaction-rollback/src/main/java/org/superbiz/txrollback/Movie.java b/content/examples/transaction-rollback/src/main/java/org/superbiz/txrollback/Movie.java
new file mode 100755
index 0000000..0b98e8a
--- /dev/null
+++ b/content/examples/transaction-rollback/src/main/java/org/superbiz/txrollback/Movie.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.txrollback;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity(name = "Movie")
+public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/transaction-rollback/src/main/java/org/superbiz/txrollback/Movies.java b/content/examples/transaction-rollback/src/main/java/org/superbiz/txrollback/Movies.java
new file mode 100755
index 0000000..162e7b8
--- /dev/null
+++ b/content/examples/transaction-rollback/src/main/java/org/superbiz/txrollback/Movies.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.txrollback;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+//START SNIPPET: code
+@Stateless
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ @Resource
+ private SessionContext sessionContext;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+ public void callSetRollbackOnly() {
+ sessionContext.setRollbackOnly();
+ }
+
+ public void throwUncheckedException() {
+ throw new RuntimeException("Throwing unchecked exceptions will rollback a transaction");
+ }
+
+ public void throwApplicationException() {
+ throw new CustomRuntimeException("This is marked @ApplicationException, so no TX rollback");
+ }
+}
diff --git a/content/examples/transaction-rollback/src/main/resources/META-INF/persistence.xml b/content/examples/transaction-rollback/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..9254875
--- /dev/null
+++ b/content/examples/transaction-rollback/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.testinjection.MoviesTest.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/transaction-rollback/src/test/java/org/superbiz/txrollback/MoviesTest.java b/content/examples/transaction-rollback/src/test/java/org/superbiz/txrollback/MoviesTest.java
new file mode 100755
index 0000000..7afbf86
--- /dev/null
+++ b/content/examples/transaction-rollback/src/test/java/org/superbiz/txrollback/MoviesTest.java
@@ -0,0 +1,221 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.txrollback;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.RollbackException;
+import javax.transaction.UserTransaction;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ private EJBContainer ejbContainer;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb" + System.currentTimeMillis());
+
+ ejbContainer = EJBContainer.createEJBContainer(p);
+ ejbContainer.getContext().bind("inject", this);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ ejbContainer.close();
+ }
+
+ /**
+ * Standard successful transaction scenario. The data created inside
+ * the transaction is visible after the transaction completes.
+ * <p/>
+ * Note that UserTransaction is only usable by Bean-Managed Transaction
+ * beans, which can be specified with @TransactionManagement(BEAN)
+ */
+ public void testCommit() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ } finally {
+ userTransaction.commit();
+ }
+
+ // Transaction was committed
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ }
+
+ /**
+ * Standard transaction rollback scenario. The data created inside
+ * the transaction is not visible after the transaction completes.
+ */
+ public void testUserTransactionRollback() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ } finally {
+ userTransaction.rollback();
+ }
+
+ // Transaction was rolled back
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 0, list.size());
+
+ }
+
+ /**
+ * Transaction is marked for rollback inside the bean via
+ * calling the javax.ejb.SessionContext.setRollbackOnly() method
+ * <p/>
+ * This is the cleanest way to make a transaction rollback.
+ */
+ public void testMarkedRollback() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ movies.callSetRollbackOnly();
+ } finally {
+ try {
+ userTransaction.commit();
+ fail("A RollbackException should have been thrown");
+ } catch (RollbackException e) {
+ // Pass
+ }
+ }
+
+ // Transaction was rolled back
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 0, list.size());
+
+ }
+
+ /**
+ * Throwing an unchecked exception from a bean will cause
+ * the container to call setRollbackOnly() and discard the
+ * bean instance from further use without calling any @PreDestroy
+ * methods on the bean instance.
+ */
+ public void testExceptionBasedRollback() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ try {
+ movies.throwUncheckedException();
+ } catch (RuntimeException e) {
+ // Good, this will cause the tx to rollback
+ }
+ } finally {
+ try {
+ userTransaction.commit();
+ fail("A RollbackException should have been thrown");
+ } catch (RollbackException e) {
+ // Pass
+ }
+ }
+
+ // Transaction was rolled back
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 0, list.size());
+
+ }
+
+ /**
+ * It is still possible to throw unchecked (runtime) exceptions
+ * without dooming the transaction by marking the exception
+ * with the @ApplicationException annotation or in the ejb-jar.xml
+ * deployment descriptor via the <application-exception> tag
+ */
+ public void testCommit2() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ try {
+ movies.throwApplicationException();
+ } catch (RuntimeException e) {
+ // This will *not* cause the tx to rollback
+ // because it is marked as an @ApplicationException
+ }
+ } finally {
+ userTransaction.commit();
+ }
+
+ // Transaction was committed
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ }
+}
+//END SNIPPET: code
diff --git a/content/examples/troubleshooting.html b/content/examples/troubleshooting.html
new file mode 100644
index 0000000..31f375a
--- /dev/null
+++ b/content/examples/troubleshooting.html
@@ -0,0 +1,665 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/troubleshooting.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Troubleshooting</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example troubleshooting can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/troubleshooting" class="bare">https://github.com/apache/tomee/tree/master/examples/troubleshooting</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movie">Movie</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.troubleshooting;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity(name = "Movie")
+public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_movies">Movies</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.troubleshooting;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+//START SNIPPET: code
+@Stateless
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.testinjection.MoviesTest.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_moviestest">MoviesTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.troubleshooting;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.UserTransaction;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+
+ // These two debug levels will get you the basic log information
+ // on the deployment of applications. Good first step in troubleshooting.
+ p.put("log4j.category.OpenEJB.startup", "debug");
+ p.put("log4j.category.OpenEJB.startup.config", "debug");
+
+ // This log category is a good way to see what "openejb.foo" options
+ // and flags are available and what their default values are
+ p.put("log4j.category.OpenEJB.options", "debug");
+
+ // This will output the full configuration of all containers
+ // resources and other openejb.xml configurable items. A good
+ // way to see what the final configuration looks like after all
+ // overriding has been applied.
+ p.put("log4j.category.OpenEJB.startup.service", "debug");
+
+ // Will output a generated ejb-jar.xml file that represents
+ // 100% of the annotations used in the code. This is a great
+ // way to figure out how to do something in xml for overriding
+ // or just to "see" all your application meta-data in one place.
+ // Look for log lines like this "Dumping Generated ejb-jar.xml to"
+ p.put("openejb.descriptors.output", "true");
+
+ // Setting the validation output level to verbose results in
+ // validation messages that attempt to provide explanations
+ // and information on what steps can be taken to remedy failures.
+ // A great tool for those learning EJB.
+ p.put("openejb.validation.output.level", "verbose");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ } finally {
+ userTransaction.commit();
+ }
+
+ // Transaction was committed
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.troubleshooting.MoviesTest
+2011-10-29 11:50:19,482 - DEBUG - Using default 'openejb.nobanner=true'
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+2011-10-29 11:50:19,482 - INFO - openejb.home = /Users/dblevins/examples/troubleshooting
+2011-10-29 11:50:19,482 - INFO - openejb.base = /Users/dblevins/examples/troubleshooting
+2011-10-29 11:50:19,483 - DEBUG - Using default 'openejb.assembler=org.apache.openejb.assembler.classic.Assembler'
+2011-10-29 11:50:19,483 - DEBUG - Instantiating assembler class org.apache.openejb.assembler.classic.Assembler
+2011-10-29 11:50:19,517 - DEBUG - Using default 'openejb.jndiname.failoncollision=true'
+2011-10-29 11:50:19,517 - INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+2011-10-29 11:50:19,520 - DEBUG - Using default 'openejb.configurator=org.apache.openejb.config.ConfigurationFactory'
+2011-10-29 11:50:19,588 - DEBUG - Using default 'openejb.validation.skip=false'
+2011-10-29 11:50:19,589 - DEBUG - Using default 'openejb.deploymentId.format={ejbName}'
+2011-10-29 11:50:19,589 - DEBUG - Using default 'openejb.debuggable-vm-hackery=false'
+2011-10-29 11:50:19,589 - DEBUG - Using default 'openejb.webservices.enabled=true'
+2011-10-29 11:50:19,594 - DEBUG - Using default 'openejb.vendor.config=ALL' Possible values are: geronimo, glassfish, jboss, weblogic or NONE or ALL
+2011-10-29 11:50:19,612 - DEBUG - Using default 'openejb.provider.default=org.apache.openejb.embedded'
+2011-10-29 11:50:19,658 - INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+2011-10-29 11:50:19,662 - INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+2011-10-29 11:50:19,665 - INFO - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+2011-10-29 11:50:19,665 - DEBUG - Override [JdbcDriver=org.hsqldb.jdbcDriver]
+2011-10-29 11:50:19,666 - DEBUG - Using default 'openejb.deployments.classpath=false'
+2011-10-29 11:50:19,666 - INFO - Creating TransactionManager(id=Default Transaction Manager)
+2011-10-29 11:50:19,676 - DEBUG - defaultTransactionTimeoutSeconds=600
+2011-10-29 11:50:19,676 - DEBUG - TxRecovery=false
+2011-10-29 11:50:19,676 - DEBUG - bufferSizeKb=32
+2011-10-29 11:50:19,676 - DEBUG - checksumEnabled=true
+2011-10-29 11:50:19,676 - DEBUG - adler32Checksum=true
+2011-10-29 11:50:19,676 - DEBUG - flushSleepTimeMilliseconds=50
+2011-10-29 11:50:19,676 - DEBUG - logFileDir=txlog
+2011-10-29 11:50:19,676 - DEBUG - logFileExt=log
+2011-10-29 11:50:19,676 - DEBUG - logFileName=howl
+2011-10-29 11:50:19,676 - DEBUG - maxBlocksPerFile=-1
+2011-10-29 11:50:19,677 - DEBUG - maxBuffers=0
+2011-10-29 11:50:19,677 - DEBUG - maxLogFiles=2
+2011-10-29 11:50:19,677 - DEBUG - minBuffers=4
+2011-10-29 11:50:19,677 - DEBUG - threadsWaitingForceThreshold=-1
+2011-10-29 11:50:19,724 - DEBUG - createService.success
+2011-10-29 11:50:19,724 - INFO - Creating SecurityService(id=Default Security Service)
+2011-10-29 11:50:19,724 - DEBUG - DefaultUser=guest
+2011-10-29 11:50:19,750 - DEBUG - createService.success
+2011-10-29 11:50:19,750 - INFO - Creating Resource(id=movieDatabase)
+2011-10-29 11:50:19,750 - DEBUG - Definition=
+2011-10-29 11:50:19,750 - DEBUG - JtaManaged=true
+2011-10-29 11:50:19,750 - DEBUG - JdbcDriver=org.hsqldb.jdbcDriver
+2011-10-29 11:50:19,750 - DEBUG - JdbcUrl=jdbc:hsqldb:mem:hsqldb
+2011-10-29 11:50:19,750 - DEBUG - UserName=sa
+2011-10-29 11:50:19,750 - DEBUG - Password=
+2011-10-29 11:50:19,750 - DEBUG - PasswordCipher=PlainText
+2011-10-29 11:50:19,750 - DEBUG - ConnectionProperties=
+2011-10-29 11:50:19,750 - DEBUG - DefaultAutoCommit=true
+2011-10-29 11:50:19,750 - DEBUG - InitialSize=0
+2011-10-29 11:50:19,750 - DEBUG - MaxActive=20
+2011-10-29 11:50:19,750 - DEBUG - MaxIdle=20
+2011-10-29 11:50:19,751 - DEBUG - MinIdle=0
+2011-10-29 11:50:19,751 - DEBUG - MaxWait=-1
+2011-10-29 11:50:19,751 - DEBUG - TestOnBorrow=true
+2011-10-29 11:50:19,751 - DEBUG - TestOnReturn=false
+2011-10-29 11:50:19,751 - DEBUG - TestWhileIdle=false
+2011-10-29 11:50:19,751 - DEBUG - TimeBetweenEvictionRunsMillis=-1
+2011-10-29 11:50:19,751 - DEBUG - NumTestsPerEvictionRun=3
+2011-10-29 11:50:19,751 - DEBUG - MinEvictableIdleTimeMillis=1800000
+2011-10-29 11:50:19,751 - DEBUG - PoolPreparedStatements=false
+2011-10-29 11:50:19,751 - DEBUG - MaxOpenPreparedStatements=0
+2011-10-29 11:50:19,751 - DEBUG - AccessToUnderlyingConnectionAllowed=false
+2011-10-29 11:50:19,781 - DEBUG - createService.success
+2011-10-29 11:50:19,783 - DEBUG - Containers : 0
+2011-10-29 11:50:19,785 - DEBUG - Deployments : 0
+2011-10-29 11:50:19,785 - DEBUG - SecurityService : org.apache.openejb.core.security.SecurityServiceImpl
+2011-10-29 11:50:19,786 - DEBUG - TransactionManager: org.apache.geronimo.transaction.manager.GeronimoTransactionManager
+2011-10-29 11:50:19,786 - DEBUG - OpenEJB Container System ready.
+2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.validation.skip=false'
+2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.deploymentId.format={ejbName}'
+2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.debuggable-vm-hackery=false'
+2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.webservices.enabled=true'
+2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.vendor.config=ALL' Possible values are: geronimo, glassfish, jboss, weblogic or NONE or ALL
+2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.include=.*'
+2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.exclude='
+2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.require.descriptor=client' Possible values are: ejb, client or NONE or ALL
+2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.filter.descriptors=false'
+2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.filter.systemapps=true'
+2011-10-29 11:50:19,828 - DEBUG - Inspecting classpath for applications: 5 urls.
+2011-10-29 11:50:19,846 - INFO - Found EjbModule in classpath: /Users/dblevins/examples/troubleshooting/target/classes
+2011-10-29 11:50:20,011 - DEBUG - URLs after filtering: 55
+2011-10-29 11:50:20,011 - DEBUG - Annotations path: file:/Users/dblevins/examples/troubleshooting/target/classes/
+2011-10-29 11:50:20,011 - DEBUG - Annotations path: jar:file:/Users/dblevins/.m2/repository/org/apache/maven/surefire/surefire-api/2.7.2/surefire-api-2.7.2.jar!/
+2011-10-29 11:50:20,011 - DEBUG - Annotations path: jar:file:/Users/dblevins/.m2/repository/org/apache/openejb/mbean-annotation-api/4.0.0-beta-1/mbean-annotation-api-4.0.0-beta-1.jar!/
+2011-10-29 11:50:20,011 - DEBUG - Annotations path: jar:file:/Users/dblevins/.m2/repository/org/apache/maven/surefire/surefire-booter/2.7.2/surefire-booter-2.7.2.jar!/
+2011-10-29 11:50:20,011 - DEBUG - Annotations path: file:/Users/dblevins/examples/troubleshooting/target/test-classes/
+2011-10-29 11:50:20,011 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar!/
+2011-10-29 11:50:20,011 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/bval/bval-core/0.3-incubating/bval-core-0.3-incubating.jar!/
+2011-10-29 11:50:20,011 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/specs/geronimo-j2ee-management_1.1_spec/1.0.1/geronimo-j2ee-management_1.1_spec-1.0.1.jar!/
+2011-10-29 11:50:20,011 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/activemq-core/5.4.2/activemq-core-5.4.2.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-bundleutils/3.8/xbean-bundleutils-3.8.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/net/sf/scannotation/scannotation/1.0.2/scannotation-1.0.2.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openejb/javaee-api/6.0-2/javaee-api-6.0-2.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.3/commons-beanutils-core-1.8.3.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-web/1.1.1/openwebbeans-web-1.1.1.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/wsdl4j/wsdl4j/1.6.2/wsdl4j-1.6.2.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/logkit/logkit/1.0.1/logkit-1.0.1.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/com/ibm/icu/icu4j/4.0.1/icu4j-4.0.1.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-asm-shaded/3.8/xbean-asm-shaded-3.8.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-ee-common/1.1.1/openwebbeans-ee-common-1.1.1.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-pool/commons-pool/1.5.6/commons-pool-1.5.6.jar!/
+2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-impl/1.1.1/openwebbeans-impl-1.1.1.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-finder-shaded/3.8/xbean-finder-shaded-3.8.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/specs/geronimo-j2ee-connector_1.6_spec/1.0/geronimo-j2ee-connector_1.6_spec-1.0.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/kahadb/5.4.2/kahadb-5.4.2.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/hsqldb/hsqldb/1.8.0.10/hsqldb-1.8.0.10.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/components/geronimo-connector/3.1.1/geronimo-connector-3.1.1.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/activemq-ra/5.4.2/activemq-ra-5.4.2.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar!/
+2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/activeio-core/3.1.2/activeio-core-3.1.2.jar!/
+2011-10-29 11:50:20,014 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/quartz-scheduler/quartz/1.8.5/quartz-1.8.5.jar!/
+2011-10-29 11:50:20,014 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-ee/1.1.1/openwebbeans-ee-1.1.1.jar!/
+2011-10-29 11:50:20,014 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar!/
+2011-10-29 11:50:20,014 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-spi/1.1.1/openwebbeans-spi-1.1.1.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/codehaus/swizzle/swizzle-stream/1.0.2/swizzle-stream-1.0.2.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openjpa/openjpa/2.1.1/openjpa-2.1.1.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-naming/3.8/xbean-naming-3.8.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/components/geronimo-transaction/3.1.1/geronimo-transaction-3.1.1.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/javassist/javassist/3.12.0.GA/javassist-3.12.0.GA.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/objectweb/howl/howl/1.0.1-1/howl-1.0.1-1.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-reflect/3.8/xbean-reflect-3.8.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-ejb/1.1.1/openwebbeans-ejb-1.1.1.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-logging/commons-logging/1.1/commons-logging-1.1.jar!/
+2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-net/commons-net/2.0/commons-net-2.0.jar!/
+2011-10-29 11:50:20,017 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/protobuf/activemq-protobuf/1.1/activemq-protobuf-1.1.jar!/
+2011-10-29 11:50:20,017 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar!/
+2011-10-29 11:50:20,017 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/1.8.2/geronimo-javamail_1.4_mail-1.8.2.jar!/
+2011-10-29 11:50:20,017 - DEBUG - Searched 5 classpath urls in 80 milliseconds. Average 16 milliseconds per url.
+2011-10-29 11:50:20,023 - INFO - Beginning load: /Users/dblevins/examples/troubleshooting/target/classes
+2011-10-29 11:50:20,028 - DEBUG - Using default 'openejb.tempclassloader.skip=none' Possible values are: none, annotations, enums or NONE or ALL
+2011-10-29 11:50:20,030 - DEBUG - Using default 'openejb.tempclassloader.skip=none' Possible values are: none, annotations, enums or NONE or ALL
+2011-10-29 11:50:20,099 - INFO - Configuring enterprise application: /Users/dblevins/examples/troubleshooting
+2011-10-29 11:50:20,099 - DEBUG - No ejb-jar.xml found assuming annotated beans present: /Users/dblevins/examples/troubleshooting, module: troubleshooting
+2011-10-29 11:50:20,213 - DEBUG - Searching for annotated application exceptions (see OPENEJB-980)
+2011-10-29 11:50:20,214 - DEBUG - Searching for annotated application exceptions (see OPENEJB-980)
+2011-10-29 11:50:20,248 - WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+2011-10-29 11:50:20,249 - DEBUG - looking for annotated MBeans in
+2011-10-29 11:50:20,249 - DEBUG - registered 0 annotated MBeans in
+2011-10-29 11:50:20,278 - INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+2011-10-29 11:50:20,278 - INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+2011-10-29 11:50:20,278 - INFO - Creating Container(id=Default Stateless Container)
+2011-10-29 11:50:20,279 - DEBUG - AccessTimeout=30 seconds
+2011-10-29 11:50:20,279 - DEBUG - MaxSize=10
+2011-10-29 11:50:20,279 - DEBUG - MinSize=0
+2011-10-29 11:50:20,279 - DEBUG - StrictPooling=true
+2011-10-29 11:50:20,279 - DEBUG - MaxAge=0 hours
+2011-10-29 11:50:20,279 - DEBUG - ReplaceAged=true
+2011-10-29 11:50:20,279 - DEBUG - ReplaceFlushed=false
+2011-10-29 11:50:20,279 - DEBUG - MaxAgeOffset=-1
+2011-10-29 11:50:20,279 - DEBUG - IdleTimeout=0 minutes
+2011-10-29 11:50:20,279 - DEBUG - GarbageCollection=false
+2011-10-29 11:50:20,279 - DEBUG - SweepInterval=5 minutes
+2011-10-29 11:50:20,279 - DEBUG - CallbackThreads=5
+2011-10-29 11:50:20,279 - DEBUG - CloseTimeout=5 minutes
+2011-10-29 11:50:20,295 - DEBUG - createService.success
+2011-10-29 11:50:20,296 - INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+2011-10-29 11:50:20,296 - INFO - Auto-creating a container for bean org.superbiz.troubleshooting.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+2011-10-29 11:50:20,296 - INFO - Creating Container(id=Default Managed Container)
+2011-10-29 11:50:20,310 - DEBUG - createService.success
+2011-10-29 11:50:20,310 - INFO - Configuring PersistenceUnit(name=movie-unit)
+2011-10-29 11:50:20,310 - DEBUG - raw <jta-data-source>movieDatabase</jta-datasource>
+2011-10-29 11:50:20,310 - DEBUG - raw <non-jta-data-source>movieDatabaseUnmanaged</non-jta-datasource>
+2011-10-29 11:50:20,310 - DEBUG - normalized <jta-data-source>movieDatabase</jta-datasource>
+2011-10-29 11:50:20,310 - DEBUG - normalized <non-jta-data-source>movieDatabaseUnmanaged</non-jta-datasource>
+2011-10-29 11:50:20,310 - DEBUG - Available DataSources
+2011-10-29 11:50:20,310 - DEBUG - DataSource(name=movieDatabase, JtaManaged=true)
+2011-10-29 11:50:20,311 - INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+2011-10-29 11:50:20,311 - INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+2011-10-29 11:50:20,311 - INFO - Creating Resource(id=movieDatabaseNonJta)
+2011-10-29 11:50:20,311 - DEBUG - Definition=
+2011-10-29 11:50:20,312 - DEBUG - JtaManaged=false
+2011-10-29 11:50:20,312 - DEBUG - JdbcDriver=org.hsqldb.jdbcDriver
+2011-10-29 11:50:20,312 - DEBUG - JdbcUrl=jdbc:hsqldb:mem:hsqldb
+2011-10-29 11:50:20,312 - DEBUG - UserName=sa
+2011-10-29 11:50:20,312 - DEBUG - Password=
+2011-10-29 11:50:20,312 - DEBUG - PasswordCipher=PlainText
+2011-10-29 11:50:20,312 - DEBUG - ConnectionProperties=
+2011-10-29 11:50:20,312 - DEBUG - DefaultAutoCommit=true
+2011-10-29 11:50:20,312 - DEBUG - InitialSize=0
+2011-10-29 11:50:20,312 - DEBUG - MaxActive=20
+2011-10-29 11:50:20,312 - DEBUG - MaxIdle=20
+2011-10-29 11:50:20,312 - DEBUG - MinIdle=0
+2011-10-29 11:50:20,312 - DEBUG - MaxWait=-1
+2011-10-29 11:50:20,312 - DEBUG - TestOnBorrow=true
+2011-10-29 11:50:20,312 - DEBUG - TestOnReturn=false
+2011-10-29 11:50:20,312 - DEBUG - TestWhileIdle=false
+2011-10-29 11:50:20,312 - DEBUG - TimeBetweenEvictionRunsMillis=-1
+2011-10-29 11:50:20,312 - DEBUG - NumTestsPerEvictionRun=3
+2011-10-29 11:50:20,312 - DEBUG - MinEvictableIdleTimeMillis=1800000
+2011-10-29 11:50:20,312 - DEBUG - PoolPreparedStatements=false
+2011-10-29 11:50:20,312 - DEBUG - MaxOpenPreparedStatements=0
+2011-10-29 11:50:20,312 - DEBUG - AccessToUnderlyingConnectionAllowed=false
+2011-10-29 11:50:20,316 - DEBUG - createService.success
+2011-10-29 11:50:20,316 - INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+2011-10-29 11:50:20,317 - INFO - Using 'openejb.descriptors.output=true'
+2011-10-29 11:50:20,317 - INFO - Using 'openejb.descriptors.output=true'
+2011-10-29 11:50:20,642 - INFO - Dumping Generated ejb-jar.xml to: /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T/ejb-jar-4107959830671443055troubleshooting.xml
+2011-10-29 11:50:20,657 - INFO - Dumping Generated openejb-jar.xml to: /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T/openejb-jar-5369342778223971127troubleshooting.xml
+2011-10-29 11:50:20,657 - INFO - Using 'openejb.descriptors.output=true'
+2011-10-29 11:50:20,658 - INFO - Dumping Generated ejb-jar.xml to: /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T/ejb-jar-5569422837673302173EjbModule837053032.xml
+2011-10-29 11:50:20,659 - INFO - Dumping Generated openejb-jar.xml to: /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T/openejb-jar-560959152015048895EjbModule837053032.xml
+2011-10-29 11:50:20,665 - DEBUG - Adding persistence-unit movie-unit property openjpa.Log=log4j
+2011-10-29 11:50:20,665 - DEBUG - Adjusting PersistenceUnit(name=movie-unit) property to openjpa.RuntimeUnenhancedClasses=supported
+2011-10-29 11:50:20,674 - INFO - Using 'openejb.validation.output.level=VERBOSE'
+2011-10-29 11:50:20,674 - INFO - Enterprise application "/Users/dblevins/examples/troubleshooting" loaded.
+2011-10-29 11:50:20,674 - INFO - Assembling app: /Users/dblevins/examples/troubleshooting
+2011-10-29 11:50:20,678 - DEBUG - Using default 'openejb.tempclassloader.skip=none' Possible values are: none, annotations, enums or NONE or ALL
+2011-10-29 11:50:20,757 - DEBUG - Using default 'openejb.tempclassloader.skip=none' Possible values are: none, annotations, enums or NONE or ALL
+2011-10-29 11:50:21,137 - INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 407ms
+2011-10-29 11:50:21,138 - DEBUG - openjpa.jdbc.SynchronizeMappings=buildSchema(ForeignKeys=true)
+2011-10-29 11:50:21,138 - DEBUG - openjpa.Log=log4j
+2011-10-29 11:50:21,138 - DEBUG - openjpa.RuntimeUnenhancedClasses=supported
+2011-10-29 11:50:21,262 - DEBUG - Using default 'openejb.jndiname.strategy.class=org.apache.openejb.assembler.classic.JndiBuilder$TemplatedStrategy'
+2011-10-29 11:50:21,262 - DEBUG - Using default 'openejb.jndiname.format={deploymentId}{interfaceType.annotationName}'
+2011-10-29 11:50:21,267 - DEBUG - Using default 'openejb.localcopy=true'
+2011-10-29 11:50:21,270 - DEBUG - bound ejb at name: openejb/Deployment/Movies/org.superbiz.troubleshooting.Movies!LocalBean, ref: org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference@2569a1c5
+2011-10-29 11:50:21,270 - DEBUG - bound ejb at name: openejb/Deployment/Movies/org.superbiz.troubleshooting.Movies!LocalBeanHome, ref: org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference@2569a1c5
+2011-10-29 11:50:21,272 - INFO - Jndi(name="java:global/troubleshooting/Movies!org.superbiz.troubleshooting.Movies")
+2011-10-29 11:50:21,272 - INFO - Jndi(name="java:global/troubleshooting/Movies")
+2011-10-29 11:50:21,277 - DEBUG - Using default 'openejb.jndiname.strategy.class=org.apache.openejb.assembler.classic.JndiBuilder$TemplatedStrategy'
+2011-10-29 11:50:21,277 - DEBUG - Using default 'openejb.jndiname.format={deploymentId}{interfaceType.annotationName}'
+2011-10-29 11:50:21,277 - DEBUG - bound ejb at name: openejb/Deployment/org.superbiz.troubleshooting.MoviesTest/org.superbiz.troubleshooting.MoviesTest!LocalBean, ref: org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference@3f78e13f
+2011-10-29 11:50:21,277 - DEBUG - bound ejb at name: openejb/Deployment/org.superbiz.troubleshooting.MoviesTest/org.superbiz.troubleshooting.MoviesTest!LocalBeanHome, ref: org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference@3f78e13f
+2011-10-29 11:50:21,277 - INFO - Jndi(name="java:global/EjbModule837053032/org.superbiz.troubleshooting.MoviesTest!org.superbiz.troubleshooting.MoviesTest")
+2011-10-29 11:50:21,277 - INFO - Jndi(name="java:global/EjbModule837053032/org.superbiz.troubleshooting.MoviesTest")
+2011-10-29 11:50:21,291 - DEBUG - CDI Service not installed: org.apache.webbeans.spi.ConversationService
+2011-10-29 11:50:21,399 - INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+2011-10-29 11:50:21,428 - INFO - Created Ejb(deployment-id=org.superbiz.troubleshooting.MoviesTest, ejb-name=org.superbiz.troubleshooting.MoviesTest, container=Default Managed Container)
+2011-10-29 11:50:21,463 - INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+2011-10-29 11:50:21,463 - INFO - Started Ejb(deployment-id=org.superbiz.troubleshooting.MoviesTest, ejb-name=org.superbiz.troubleshooting.MoviesTest, container=Default Managed Container)
+2011-10-29 11:50:21,463 - INFO - Deployed Application(path=/Users/dblevins/examples/troubleshooting)
+2011-10-29 11:50:21,728 - WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@27a8c4e7; ignoring.
+2011-10-29 11:50:21,834 - WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@27a8c4e7; ignoring.
+2011-10-29 11:50:21,846 - WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@27a8c4e7; ignoring.
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.642 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/troubleshooting.pdf b/content/examples/troubleshooting.pdf
new file mode 100644
index 0000000..a898e0e
--- /dev/null
+++ b/content/examples/troubleshooting.pdf
Binary files differ
diff --git a/content/examples/troubleshooting/README.md b/content/examples/troubleshooting/README.md
new file mode 100755
index 0000000..33f6b9d
--- /dev/null
+++ b/content/examples/troubleshooting/README.md
@@ -0,0 +1,448 @@
+Title: Troubleshooting
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Movie
+
+ package org.superbiz.troubleshooting;
+
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.GenerationType;
+ import javax.persistence.Id;
+
+ @Entity(name = "Movie")
+ public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ }
+
+## Movies
+
+ package org.superbiz.troubleshooting;
+
+ import javax.ejb.Stateless;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ //START SNIPPET: code
+ @Stateless
+ public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+ }
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.testinjection.MoviesTest.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+
+## MoviesTest
+
+ package org.superbiz.troubleshooting;
+
+ import junit.framework.TestCase;
+
+ import javax.annotation.Resource;
+ import javax.ejb.EJB;
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.transaction.UserTransaction;
+ import java.util.List;
+ import java.util.Properties;
+
+ //START SNIPPET: code
+ public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+
+ // These two debug levels will get you the basic log information
+ // on the deployment of applications. Good first step in troubleshooting.
+ p.put("log4j.category.OpenEJB.startup", "debug");
+ p.put("log4j.category.OpenEJB.startup.config", "debug");
+
+ // This log category is a good way to see what "openejb.foo" options
+ // and flags are available and what their default values are
+ p.put("log4j.category.OpenEJB.options", "debug");
+
+ // This will output the full configuration of all containers
+ // resources and other openejb.xml configurable items. A good
+ // way to see what the final configuration looks like after all
+ // overriding has been applied.
+ p.put("log4j.category.OpenEJB.startup.service", "debug");
+
+ // Will output a generated ejb-jar.xml file that represents
+ // 100% of the annotations used in the code. This is a great
+ // way to figure out how to do something in xml for overriding
+ // or just to "see" all your application meta-data in one place.
+ // Look for log lines like this "Dumping Generated ejb-jar.xml to"
+ p.put("openejb.descriptors.output", "true");
+
+ // Setting the validation output level to verbose results in
+ // validation messages that attempt to provide explanations
+ // and information on what steps can be taken to remedy failures.
+ // A great tool for those learning EJB.
+ p.put("openejb.validation.output.level", "verbose");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ } finally {
+ userTransaction.commit();
+ }
+
+ // Transaction was committed
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.troubleshooting.MoviesTest
+ 2011-10-29 11:50:19,482 - DEBUG - Using default 'openejb.nobanner=true'
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ 2011-10-29 11:50:19,482 - INFO - openejb.home = /Users/dblevins/examples/troubleshooting
+ 2011-10-29 11:50:19,482 - INFO - openejb.base = /Users/dblevins/examples/troubleshooting
+ 2011-10-29 11:50:19,483 - DEBUG - Using default 'openejb.assembler=org.apache.openejb.assembler.classic.Assembler'
+ 2011-10-29 11:50:19,483 - DEBUG - Instantiating assembler class org.apache.openejb.assembler.classic.Assembler
+ 2011-10-29 11:50:19,517 - DEBUG - Using default 'openejb.jndiname.failoncollision=true'
+ 2011-10-29 11:50:19,517 - INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+ 2011-10-29 11:50:19,520 - DEBUG - Using default 'openejb.configurator=org.apache.openejb.config.ConfigurationFactory'
+ 2011-10-29 11:50:19,588 - DEBUG - Using default 'openejb.validation.skip=false'
+ 2011-10-29 11:50:19,589 - DEBUG - Using default 'openejb.deploymentId.format={ejbName}'
+ 2011-10-29 11:50:19,589 - DEBUG - Using default 'openejb.debuggable-vm-hackery=false'
+ 2011-10-29 11:50:19,589 - DEBUG - Using default 'openejb.webservices.enabled=true'
+ 2011-10-29 11:50:19,594 - DEBUG - Using default 'openejb.vendor.config=ALL' Possible values are: geronimo, glassfish, jboss, weblogic or NONE or ALL
+ 2011-10-29 11:50:19,612 - DEBUG - Using default 'openejb.provider.default=org.apache.openejb.embedded'
+ 2011-10-29 11:50:19,658 - INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+ 2011-10-29 11:50:19,662 - INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+ 2011-10-29 11:50:19,665 - INFO - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database)
+ 2011-10-29 11:50:19,665 - DEBUG - Override [JdbcDriver=org.hsqldb.jdbcDriver]
+ 2011-10-29 11:50:19,666 - DEBUG - Using default 'openejb.deployments.classpath=false'
+ 2011-10-29 11:50:19,666 - INFO - Creating TransactionManager(id=Default Transaction Manager)
+ 2011-10-29 11:50:19,676 - DEBUG - defaultTransactionTimeoutSeconds=600
+ 2011-10-29 11:50:19,676 - DEBUG - TxRecovery=false
+ 2011-10-29 11:50:19,676 - DEBUG - bufferSizeKb=32
+ 2011-10-29 11:50:19,676 - DEBUG - checksumEnabled=true
+ 2011-10-29 11:50:19,676 - DEBUG - adler32Checksum=true
+ 2011-10-29 11:50:19,676 - DEBUG - flushSleepTimeMilliseconds=50
+ 2011-10-29 11:50:19,676 - DEBUG - logFileDir=txlog
+ 2011-10-29 11:50:19,676 - DEBUG - logFileExt=log
+ 2011-10-29 11:50:19,676 - DEBUG - logFileName=howl
+ 2011-10-29 11:50:19,676 - DEBUG - maxBlocksPerFile=-1
+ 2011-10-29 11:50:19,677 - DEBUG - maxBuffers=0
+ 2011-10-29 11:50:19,677 - DEBUG - maxLogFiles=2
+ 2011-10-29 11:50:19,677 - DEBUG - minBuffers=4
+ 2011-10-29 11:50:19,677 - DEBUG - threadsWaitingForceThreshold=-1
+ 2011-10-29 11:50:19,724 - DEBUG - createService.success
+ 2011-10-29 11:50:19,724 - INFO - Creating SecurityService(id=Default Security Service)
+ 2011-10-29 11:50:19,724 - DEBUG - DefaultUser=guest
+ 2011-10-29 11:50:19,750 - DEBUG - createService.success
+ 2011-10-29 11:50:19,750 - INFO - Creating Resource(id=movieDatabase)
+ 2011-10-29 11:50:19,750 - DEBUG - Definition=
+ 2011-10-29 11:50:19,750 - DEBUG - JtaManaged=true
+ 2011-10-29 11:50:19,750 - DEBUG - JdbcDriver=org.hsqldb.jdbcDriver
+ 2011-10-29 11:50:19,750 - DEBUG - JdbcUrl=jdbc:hsqldb:mem:hsqldb
+ 2011-10-29 11:50:19,750 - DEBUG - UserName=sa
+ 2011-10-29 11:50:19,750 - DEBUG - Password=
+ 2011-10-29 11:50:19,750 - DEBUG - PasswordCipher=PlainText
+ 2011-10-29 11:50:19,750 - DEBUG - ConnectionProperties=
+ 2011-10-29 11:50:19,750 - DEBUG - DefaultAutoCommit=true
+ 2011-10-29 11:50:19,750 - DEBUG - InitialSize=0
+ 2011-10-29 11:50:19,750 - DEBUG - MaxActive=20
+ 2011-10-29 11:50:19,750 - DEBUG - MaxIdle=20
+ 2011-10-29 11:50:19,751 - DEBUG - MinIdle=0
+ 2011-10-29 11:50:19,751 - DEBUG - MaxWait=-1
+ 2011-10-29 11:50:19,751 - DEBUG - TestOnBorrow=true
+ 2011-10-29 11:50:19,751 - DEBUG - TestOnReturn=false
+ 2011-10-29 11:50:19,751 - DEBUG - TestWhileIdle=false
+ 2011-10-29 11:50:19,751 - DEBUG - TimeBetweenEvictionRunsMillis=-1
+ 2011-10-29 11:50:19,751 - DEBUG - NumTestsPerEvictionRun=3
+ 2011-10-29 11:50:19,751 - DEBUG - MinEvictableIdleTimeMillis=1800000
+ 2011-10-29 11:50:19,751 - DEBUG - PoolPreparedStatements=false
+ 2011-10-29 11:50:19,751 - DEBUG - MaxOpenPreparedStatements=0
+ 2011-10-29 11:50:19,751 - DEBUG - AccessToUnderlyingConnectionAllowed=false
+ 2011-10-29 11:50:19,781 - DEBUG - createService.success
+ 2011-10-29 11:50:19,783 - DEBUG - Containers : 0
+ 2011-10-29 11:50:19,785 - DEBUG - Deployments : 0
+ 2011-10-29 11:50:19,785 - DEBUG - SecurityService : org.apache.openejb.core.security.SecurityServiceImpl
+ 2011-10-29 11:50:19,786 - DEBUG - TransactionManager: org.apache.geronimo.transaction.manager.GeronimoTransactionManager
+ 2011-10-29 11:50:19,786 - DEBUG - OpenEJB Container System ready.
+ 2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.validation.skip=false'
+ 2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.deploymentId.format={ejbName}'
+ 2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.debuggable-vm-hackery=false'
+ 2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.webservices.enabled=true'
+ 2011-10-29 11:50:19,786 - DEBUG - Using default 'openejb.vendor.config=ALL' Possible values are: geronimo, glassfish, jboss, weblogic or NONE or ALL
+ 2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.include=.*'
+ 2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.exclude='
+ 2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.require.descriptor=client' Possible values are: ejb, client or NONE or ALL
+ 2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.filter.descriptors=false'
+ 2011-10-29 11:50:19,789 - DEBUG - Using default 'openejb.deployments.classpath.filter.systemapps=true'
+ 2011-10-29 11:50:19,828 - DEBUG - Inspecting classpath for applications: 5 urls.
+ 2011-10-29 11:50:19,846 - INFO - Found EjbModule in classpath: /Users/dblevins/examples/troubleshooting/target/classes
+ 2011-10-29 11:50:20,011 - DEBUG - URLs after filtering: 55
+ 2011-10-29 11:50:20,011 - DEBUG - Annotations path: file:/Users/dblevins/examples/troubleshooting/target/classes/
+ 2011-10-29 11:50:20,011 - DEBUG - Annotations path: jar:file:/Users/dblevins/.m2/repository/org/apache/maven/surefire/surefire-api/2.7.2/surefire-api-2.7.2.jar!/
+ 2011-10-29 11:50:20,011 - DEBUG - Annotations path: jar:file:/Users/dblevins/.m2/repository/org/apache/openejb/mbean-annotation-api/4.0.0-beta-1/mbean-annotation-api-4.0.0-beta-1.jar!/
+ 2011-10-29 11:50:20,011 - DEBUG - Annotations path: jar:file:/Users/dblevins/.m2/repository/org/apache/maven/surefire/surefire-booter/2.7.2/surefire-booter-2.7.2.jar!/
+ 2011-10-29 11:50:20,011 - DEBUG - Annotations path: file:/Users/dblevins/examples/troubleshooting/target/test-classes/
+ 2011-10-29 11:50:20,011 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar!/
+ 2011-10-29 11:50:20,011 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/bval/bval-core/0.3-incubating/bval-core-0.3-incubating.jar!/
+ 2011-10-29 11:50:20,011 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/specs/geronimo-j2ee-management_1.1_spec/1.0.1/geronimo-j2ee-management_1.1_spec-1.0.1.jar!/
+ 2011-10-29 11:50:20,011 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/activemq-core/5.4.2/activemq-core-5.4.2.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-bundleutils/3.8/xbean-bundleutils-3.8.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/net/sf/scannotation/scannotation/1.0.2/scannotation-1.0.2.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openejb/javaee-api/6.0-2/javaee-api-6.0-2.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.3/commons-beanutils-core-1.8.3.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/avalon-framework/avalon-framework/4.1.3/avalon-framework-4.1.3.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-web/1.1.1/openwebbeans-web-1.1.1.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/wsdl4j/wsdl4j/1.6.2/wsdl4j-1.6.2.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/logkit/logkit/1.0.1/logkit-1.0.1.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/com/ibm/icu/icu4j/4.0.1/icu4j-4.0.1.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-asm-shaded/3.8/xbean-asm-shaded-3.8.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-ee-common/1.1.1/openwebbeans-ee-common-1.1.1.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-pool/commons-pool/1.5.6/commons-pool-1.5.6.jar!/
+ 2011-10-29 11:50:20,012 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-impl/1.1.1/openwebbeans-impl-1.1.1.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-finder-shaded/3.8/xbean-finder-shaded-3.8.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/specs/geronimo-j2ee-connector_1.6_spec/1.0/geronimo-j2ee-connector_1.6_spec-1.0.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/kahadb/5.4.2/kahadb-5.4.2.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/hsqldb/hsqldb/1.8.0.10/hsqldb-1.8.0.10.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/components/geronimo-connector/3.1.1/geronimo-connector-3.1.1.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/activemq-ra/5.4.2/activemq-ra-5.4.2.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar!/
+ 2011-10-29 11:50:20,013 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/activeio-core/3.1.2/activeio-core-3.1.2.jar!/
+ 2011-10-29 11:50:20,014 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/quartz-scheduler/quartz/1.8.5/quartz-1.8.5.jar!/
+ 2011-10-29 11:50:20,014 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-ee/1.1.1/openwebbeans-ee-1.1.1.jar!/
+ 2011-10-29 11:50:20,014 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar!/
+ 2011-10-29 11:50:20,014 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-spi/1.1.1/openwebbeans-spi-1.1.1.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/codehaus/swizzle/swizzle-stream/1.0.2/swizzle-stream-1.0.2.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openjpa/openjpa/2.1.1/openjpa-2.1.1.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-naming/3.8/xbean-naming-3.8.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/components/geronimo-transaction/3.1.1/geronimo-transaction-3.1.1.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/javassist/javassist/3.12.0.GA/javassist-3.12.0.GA.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/objectweb/howl/howl/1.0.1-1/howl-1.0.1-1.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/xbean/xbean-reflect/3.8/xbean-reflect-3.8.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/openwebbeans/openwebbeans-ejb/1.1.1/openwebbeans-ejb-1.1.1.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-logging/commons-logging/1.1/commons-logging-1.1.jar!/
+ 2011-10-29 11:50:20,016 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-net/commons-net/2.0/commons-net-2.0.jar!/
+ 2011-10-29 11:50:20,017 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/activemq/protobuf/activemq-protobuf/1.1/activemq-protobuf-1.1.jar!/
+ 2011-10-29 11:50:20,017 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/commons-dbcp/commons-dbcp/1.4/commons-dbcp-1.4.jar!/
+ 2011-10-29 11:50:20,017 - DEBUG - Descriptors path: jar:file:/Users/dblevins/.m2/repository/org/apache/geronimo/javamail/geronimo-javamail_1.4_mail/1.8.2/geronimo-javamail_1.4_mail-1.8.2.jar!/
+ 2011-10-29 11:50:20,017 - DEBUG - Searched 5 classpath urls in 80 milliseconds. Average 16 milliseconds per url.
+ 2011-10-29 11:50:20,023 - INFO - Beginning load: /Users/dblevins/examples/troubleshooting/target/classes
+ 2011-10-29 11:50:20,028 - DEBUG - Using default 'openejb.tempclassloader.skip=none' Possible values are: none, annotations, enums or NONE or ALL
+ 2011-10-29 11:50:20,030 - DEBUG - Using default 'openejb.tempclassloader.skip=none' Possible values are: none, annotations, enums or NONE or ALL
+ 2011-10-29 11:50:20,099 - INFO - Configuring enterprise application: /Users/dblevins/examples/troubleshooting
+ 2011-10-29 11:50:20,099 - DEBUG - No ejb-jar.xml found assuming annotated beans present: /Users/dblevins/examples/troubleshooting, module: troubleshooting
+ 2011-10-29 11:50:20,213 - DEBUG - Searching for annotated application exceptions (see OPENEJB-980)
+ 2011-10-29 11:50:20,214 - DEBUG - Searching for annotated application exceptions (see OPENEJB-980)
+ 2011-10-29 11:50:20,248 - WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+ 2011-10-29 11:50:20,249 - DEBUG - looking for annotated MBeans in
+ 2011-10-29 11:50:20,249 - DEBUG - registered 0 annotated MBeans in
+ 2011-10-29 11:50:20,278 - INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ 2011-10-29 11:50:20,278 - INFO - Auto-creating a container for bean Movies: Container(type=STATELESS, id=Default Stateless Container)
+ 2011-10-29 11:50:20,278 - INFO - Creating Container(id=Default Stateless Container)
+ 2011-10-29 11:50:20,279 - DEBUG - AccessTimeout=30 seconds
+ 2011-10-29 11:50:20,279 - DEBUG - MaxSize=10
+ 2011-10-29 11:50:20,279 - DEBUG - MinSize=0
+ 2011-10-29 11:50:20,279 - DEBUG - StrictPooling=true
+ 2011-10-29 11:50:20,279 - DEBUG - MaxAge=0 hours
+ 2011-10-29 11:50:20,279 - DEBUG - ReplaceAged=true
+ 2011-10-29 11:50:20,279 - DEBUG - ReplaceFlushed=false
+ 2011-10-29 11:50:20,279 - DEBUG - MaxAgeOffset=-1
+ 2011-10-29 11:50:20,279 - DEBUG - IdleTimeout=0 minutes
+ 2011-10-29 11:50:20,279 - DEBUG - GarbageCollection=false
+ 2011-10-29 11:50:20,279 - DEBUG - SweepInterval=5 minutes
+ 2011-10-29 11:50:20,279 - DEBUG - CallbackThreads=5
+ 2011-10-29 11:50:20,279 - DEBUG - CloseTimeout=5 minutes
+ 2011-10-29 11:50:20,295 - DEBUG - createService.success
+ 2011-10-29 11:50:20,296 - INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ 2011-10-29 11:50:20,296 - INFO - Auto-creating a container for bean org.superbiz.troubleshooting.MoviesTest: Container(type=MANAGED, id=Default Managed Container)
+ 2011-10-29 11:50:20,296 - INFO - Creating Container(id=Default Managed Container)
+ 2011-10-29 11:50:20,310 - DEBUG - createService.success
+ 2011-10-29 11:50:20,310 - INFO - Configuring PersistenceUnit(name=movie-unit)
+ 2011-10-29 11:50:20,310 - DEBUG - raw <jta-data-source>movieDatabase</jta-datasource>
+ 2011-10-29 11:50:20,310 - DEBUG - raw <non-jta-data-source>movieDatabaseUnmanaged</non-jta-datasource>
+ 2011-10-29 11:50:20,310 - DEBUG - normalized <jta-data-source>movieDatabase</jta-datasource>
+ 2011-10-29 11:50:20,310 - DEBUG - normalized <non-jta-data-source>movieDatabaseUnmanaged</non-jta-datasource>
+ 2011-10-29 11:50:20,310 - DEBUG - Available DataSources
+ 2011-10-29 11:50:20,310 - DEBUG - DataSource(name=movieDatabase, JtaManaged=true)
+ 2011-10-29 11:50:20,311 - INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'.
+ 2011-10-29 11:50:20,311 - INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase)
+ 2011-10-29 11:50:20,311 - INFO - Creating Resource(id=movieDatabaseNonJta)
+ 2011-10-29 11:50:20,311 - DEBUG - Definition=
+ 2011-10-29 11:50:20,312 - DEBUG - JtaManaged=false
+ 2011-10-29 11:50:20,312 - DEBUG - JdbcDriver=org.hsqldb.jdbcDriver
+ 2011-10-29 11:50:20,312 - DEBUG - JdbcUrl=jdbc:hsqldb:mem:hsqldb
+ 2011-10-29 11:50:20,312 - DEBUG - UserName=sa
+ 2011-10-29 11:50:20,312 - DEBUG - Password=
+ 2011-10-29 11:50:20,312 - DEBUG - PasswordCipher=PlainText
+ 2011-10-29 11:50:20,312 - DEBUG - ConnectionProperties=
+ 2011-10-29 11:50:20,312 - DEBUG - DefaultAutoCommit=true
+ 2011-10-29 11:50:20,312 - DEBUG - InitialSize=0
+ 2011-10-29 11:50:20,312 - DEBUG - MaxActive=20
+ 2011-10-29 11:50:20,312 - DEBUG - MaxIdle=20
+ 2011-10-29 11:50:20,312 - DEBUG - MinIdle=0
+ 2011-10-29 11:50:20,312 - DEBUG - MaxWait=-1
+ 2011-10-29 11:50:20,312 - DEBUG - TestOnBorrow=true
+ 2011-10-29 11:50:20,312 - DEBUG - TestOnReturn=false
+ 2011-10-29 11:50:20,312 - DEBUG - TestWhileIdle=false
+ 2011-10-29 11:50:20,312 - DEBUG - TimeBetweenEvictionRunsMillis=-1
+ 2011-10-29 11:50:20,312 - DEBUG - NumTestsPerEvictionRun=3
+ 2011-10-29 11:50:20,312 - DEBUG - MinEvictableIdleTimeMillis=1800000
+ 2011-10-29 11:50:20,312 - DEBUG - PoolPreparedStatements=false
+ 2011-10-29 11:50:20,312 - DEBUG - MaxOpenPreparedStatements=0
+ 2011-10-29 11:50:20,312 - DEBUG - AccessToUnderlyingConnectionAllowed=false
+ 2011-10-29 11:50:20,316 - DEBUG - createService.success
+ 2011-10-29 11:50:20,316 - INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged'
+ 2011-10-29 11:50:20,317 - INFO - Using 'openejb.descriptors.output=true'
+ 2011-10-29 11:50:20,317 - INFO - Using 'openejb.descriptors.output=true'
+ 2011-10-29 11:50:20,642 - INFO - Dumping Generated ejb-jar.xml to: /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T/ejb-jar-4107959830671443055troubleshooting.xml
+ 2011-10-29 11:50:20,657 - INFO - Dumping Generated openejb-jar.xml to: /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T/openejb-jar-5369342778223971127troubleshooting.xml
+ 2011-10-29 11:50:20,657 - INFO - Using 'openejb.descriptors.output=true'
+ 2011-10-29 11:50:20,658 - INFO - Dumping Generated ejb-jar.xml to: /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T/ejb-jar-5569422837673302173EjbModule837053032.xml
+ 2011-10-29 11:50:20,659 - INFO - Dumping Generated openejb-jar.xml to: /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T/openejb-jar-560959152015048895EjbModule837053032.xml
+ 2011-10-29 11:50:20,665 - DEBUG - Adding persistence-unit movie-unit property openjpa.Log=log4j
+ 2011-10-29 11:50:20,665 - DEBUG - Adjusting PersistenceUnit(name=movie-unit) property to openjpa.RuntimeUnenhancedClasses=supported
+ 2011-10-29 11:50:20,674 - INFO - Using 'openejb.validation.output.level=VERBOSE'
+ 2011-10-29 11:50:20,674 - INFO - Enterprise application "/Users/dblevins/examples/troubleshooting" loaded.
+ 2011-10-29 11:50:20,674 - INFO - Assembling app: /Users/dblevins/examples/troubleshooting
+ 2011-10-29 11:50:20,678 - DEBUG - Using default 'openejb.tempclassloader.skip=none' Possible values are: none, annotations, enums or NONE or ALL
+ 2011-10-29 11:50:20,757 - DEBUG - Using default 'openejb.tempclassloader.skip=none' Possible values are: none, annotations, enums or NONE or ALL
+ 2011-10-29 11:50:21,137 - INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 407ms
+ 2011-10-29 11:50:21,138 - DEBUG - openjpa.jdbc.SynchronizeMappings=buildSchema(ForeignKeys=true)
+ 2011-10-29 11:50:21,138 - DEBUG - openjpa.Log=log4j
+ 2011-10-29 11:50:21,138 - DEBUG - openjpa.RuntimeUnenhancedClasses=supported
+ 2011-10-29 11:50:21,262 - DEBUG - Using default 'openejb.jndiname.strategy.class=org.apache.openejb.assembler.classic.JndiBuilder$TemplatedStrategy'
+ 2011-10-29 11:50:21,262 - DEBUG - Using default 'openejb.jndiname.format={deploymentId}{interfaceType.annotationName}'
+ 2011-10-29 11:50:21,267 - DEBUG - Using default 'openejb.localcopy=true'
+ 2011-10-29 11:50:21,270 - DEBUG - bound ejb at name: openejb/Deployment/Movies/org.superbiz.troubleshooting.Movies!LocalBean, ref: org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference@2569a1c5
+ 2011-10-29 11:50:21,270 - DEBUG - bound ejb at name: openejb/Deployment/Movies/org.superbiz.troubleshooting.Movies!LocalBeanHome, ref: org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference@2569a1c5
+ 2011-10-29 11:50:21,272 - INFO - Jndi(name="java:global/troubleshooting/Movies!org.superbiz.troubleshooting.Movies")
+ 2011-10-29 11:50:21,272 - INFO - Jndi(name="java:global/troubleshooting/Movies")
+ 2011-10-29 11:50:21,277 - DEBUG - Using default 'openejb.jndiname.strategy.class=org.apache.openejb.assembler.classic.JndiBuilder$TemplatedStrategy'
+ 2011-10-29 11:50:21,277 - DEBUG - Using default 'openejb.jndiname.format={deploymentId}{interfaceType.annotationName}'
+ 2011-10-29 11:50:21,277 - DEBUG - bound ejb at name: openejb/Deployment/org.superbiz.troubleshooting.MoviesTest/org.superbiz.troubleshooting.MoviesTest!LocalBean, ref: org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference@3f78e13f
+ 2011-10-29 11:50:21,277 - DEBUG - bound ejb at name: openejb/Deployment/org.superbiz.troubleshooting.MoviesTest/org.superbiz.troubleshooting.MoviesTest!LocalBeanHome, ref: org.apache.openejb.core.ivm.naming.BusinessLocalBeanReference@3f78e13f
+ 2011-10-29 11:50:21,277 - INFO - Jndi(name="java:global/EjbModule837053032/org.superbiz.troubleshooting.MoviesTest!org.superbiz.troubleshooting.MoviesTest")
+ 2011-10-29 11:50:21,277 - INFO - Jndi(name="java:global/EjbModule837053032/org.superbiz.troubleshooting.MoviesTest")
+ 2011-10-29 11:50:21,291 - DEBUG - CDI Service not installed: org.apache.webbeans.spi.ConversationService
+ 2011-10-29 11:50:21,399 - INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ 2011-10-29 11:50:21,428 - INFO - Created Ejb(deployment-id=org.superbiz.troubleshooting.MoviesTest, ejb-name=org.superbiz.troubleshooting.MoviesTest, container=Default Managed Container)
+ 2011-10-29 11:50:21,463 - INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateless Container)
+ 2011-10-29 11:50:21,463 - INFO - Started Ejb(deployment-id=org.superbiz.troubleshooting.MoviesTest, ejb-name=org.superbiz.troubleshooting.MoviesTest, container=Default Managed Container)
+ 2011-10-29 11:50:21,463 - INFO - Deployed Application(path=/Users/dblevins/examples/troubleshooting)
+ 2011-10-29 11:50:21,728 - WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@27a8c4e7; ignoring.
+ 2011-10-29 11:50:21,834 - WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@27a8c4e7; ignoring.
+ 2011-10-29 11:50:21,846 - WARN - The class "org.superbiz.testinjection.MoviesTest.Movie" listed in the openjpa.MetaDataFactory configuration property could not be loaded by sun.misc.Launcher$AppClassLoader@27a8c4e7; ignoring.
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.642 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/troubleshooting/build.xml b/content/examples/troubleshooting/build.xml
new file mode 100755
index 0000000..821f630
--- /dev/null
+++ b/content/examples/troubleshooting/build.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27 Dec 2007) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ <dependency groupId="org.apache.openejb" artifactId="openejb-api" version="4.0.0-beta-1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/troubleshooting/pom.xml b/content/examples/troubleshooting/pom.xml
new file mode 100755
index 0000000..848464e
--- /dev/null
+++ b/content/examples/troubleshooting/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 636494 $ $Date: 2008-03-12 21:24:02 +0100 (Wed, 12 Mar 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>troubleshooting</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Troubleshooting</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- openejb container for running tests -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/troubleshooting/src/main/java/org/superbiz/troubleshooting/Movie.java b/content/examples/troubleshooting/src/main/java/org/superbiz/troubleshooting/Movie.java
new file mode 100755
index 0000000..5d350f1
--- /dev/null
+++ b/content/examples/troubleshooting/src/main/java/org/superbiz/troubleshooting/Movie.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.troubleshooting;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity(name = "Movie")
+public class Movie {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long id;
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
diff --git a/content/examples/troubleshooting/src/main/java/org/superbiz/troubleshooting/Movies.java b/content/examples/troubleshooting/src/main/java/org/superbiz/troubleshooting/Movies.java
new file mode 100755
index 0000000..8b5c6c5
--- /dev/null
+++ b/content/examples/troubleshooting/src/main/java/org/superbiz/troubleshooting/Movies.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.troubleshooting;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+//START SNIPPET: code
+@Stateless
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+
+}
diff --git a/content/examples/troubleshooting/src/main/resources/META-INF/persistence.xml b/content/examples/troubleshooting/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..9254875
--- /dev/null
+++ b/content/examples/troubleshooting/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="movie-unit">
+ <jta-data-source>movieDatabase</jta-data-source>
+ <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
+ <class>org.superbiz.testinjection.MoviesTest.Movie</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/troubleshooting/src/test/java/org/superbiz/troubleshooting/MoviesTest.java b/content/examples/troubleshooting/src/test/java/org/superbiz/troubleshooting/MoviesTest.java
new file mode 100755
index 0000000..2aa8997
--- /dev/null
+++ b/content/examples/troubleshooting/src/test/java/org/superbiz/troubleshooting/MoviesTest.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.troubleshooting;
+
+import junit.framework.TestCase;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.UserTransaction;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+ @EJB
+ private Movies movies;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+
+ // These two debug levels will get you the basic log information
+ // on the deployment of applications. Good first step in troubleshooting.
+ p.put("log4j.category.OpenEJB.startup", "debug");
+ p.put("log4j.category.OpenEJB.startup.config", "debug");
+
+ // This log category is a good way to see what "openejb.foo" options
+ // and flags are available and what their default values are
+ p.put("log4j.category.OpenEJB.options", "debug");
+
+ // This will output the full configuration of all containers
+ // resources and other openejb.xml configurable items. A good
+ // way to see what the final configuration looks like after all
+ // overriding has been applied.
+ p.put("log4j.category.OpenEJB.startup.service", "debug");
+
+ // Will output a generated ejb-jar.xml file that represents
+ // 100% of the annotations used in the code. This is a great
+ // way to figure out how to do something in xml for overriding
+ // or just to "see" all your application meta-data in one place.
+ // Look for log lines like this "Dumping Generated ejb-jar.xml to"
+ p.put("openejb.descriptors.output", "true");
+
+ // Setting the validation output level to verbose results in
+ // validation messages that attempt to provide explanations
+ // and information on what steps can be taken to remedy failures.
+ // A great tool for those learning EJB.
+ p.put("openejb.validation.output.level", "verbose");
+
+ EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
+ }
+
+ public void test() throws Exception {
+
+ userTransaction.begin();
+
+ try {
+ entityManager.persist(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ entityManager.persist(new Movie("Joel Coen", "Fargo", 1996));
+ entityManager.persist(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ } finally {
+ userTransaction.commit();
+ }
+
+ // Transaction was committed
+ List<Movie> list = movies.getMovies();
+ assertEquals("List.size()", 3, list.size());
+
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/webservice-attachments.html b/content/examples/webservice-attachments.html
new file mode 100644
index 0000000..26381a5
--- /dev/null
+++ b/content/examples/webservice-attachments.html
@@ -0,0 +1,419 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/webservice-attachments.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Webservice Attachments</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example webservice-attachments can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/webservice-attachments" class="bare">https://github.com/apache/tomee/tree/master/examples/webservice-attachments</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_attachmentimpl">AttachmentImpl</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.attachment;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.soap.SOAPBinding;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: {@link AttachmentWs} a webservice interface.
+ */
+@Stateless
+@WebService(
+ portName = "AttachmentPort",
+ serviceName = "AttachmentWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.attachment.AttachmentWs")
+@BindingType(value = SOAPBinding.SOAP12HTTP_MTOM_BINDING)
+public class AttachmentImpl implements AttachmentWs {
+
+ public String stringFromBytes(byte[] data) {
+ return new String(data);
+ }
+
+ public String stringFromDataSource(DataSource source) {
+
+ try {
+ InputStream inStr = source.getInputStream();
+ int size = inStr.available();
+ byte[] data = new byte[size];
+ inStr.read(data);
+ inStr.close();
+ return new String(data);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+ public String stringFromDataHandler(DataHandler handler) {
+
+ try {
+ return (String) handler.getContent();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_attachmentws">AttachmentWs</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.attachment;
+
+import javax.activation.DataHandler;
+import javax.jws.WebService;
+
+/**
+ * This is an EJB 3 webservice interface to send attachments throughout SAOP.
+ */
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface AttachmentWs {
+
+ public String stringFromBytes(byte[] data);
+
+ // Not working at the moment with SUN saaj provider and CXF
+ //public String stringFromDataSource(DataSource source);
+
+ public String stringFromDataHandler(DataHandler handler);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar/></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_attachmenttest">AttachmentTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.attachment;
+
+import junit.framework.TestCase;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.mail.util.ByteArrayDataSource;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+import java.net.URL;
+import java.util.Properties;
+
+public class AttachmentTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ initialContext = new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Create a webservice client using wsdl url
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: webservice
+ public void testAttachmentViaWsInterface() throws Exception {
+ Service service = Service.create(
+ new URL("http://127.0.0.1:4204/AttachmentImpl?wsdl"),
+ new QName("http://superbiz.org/wsdl", "AttachmentWsService"));
+ assertNotNull(service);
+
+ AttachmentWs ws = service.getPort(AttachmentWs.class);
+
+ // retrieve the SOAPBinding
+ SOAPBinding binding = (SOAPBinding) ((BindingProvider) ws).getBinding();
+ binding.setMTOMEnabled(true);
+
+ String request = "tsztelak@gmail.com";
+
+ // Byte array
+ String response = ws.stringFromBytes(request.getBytes());
+ assertEquals(request, response);
+
+ // Data Source
+ DataSource source = new ByteArrayDataSource(request.getBytes(), "text/plain; charset=UTF-8");
+
+ // not yet supported !
+// response = ws.stringFromDataSource(source);
+// assertEquals(request, response);
+
+ // Data Handler
+ response = ws.stringFromDataHandler(new DataHandler(source));
+ assertEquals(request, response);
+ }
+ //END SNIPPET: webservice
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.attachment.AttachmentTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/webservice-attachments
+INFO - openejb.base = /Users/dblevins/examples/webservice-attachments
+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/webservice-attachments/target/classes
+INFO - Beginning load: /Users/dblevins/examples/webservice-attachments/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-attachments/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean AttachmentImpl: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "/Users/dblevins/examples/webservice-attachments/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/webservice-attachments/classpath.ear
+INFO - Created Ejb(deployment-id=AttachmentImpl, ejb-name=AttachmentImpl, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=AttachmentImpl, ejb-name=AttachmentImpl, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/webservice-attachments/classpath.ear)
+INFO - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Creating ServerService(id=cxf)
+INFO - Creating ServerService(id=admin)
+INFO - Creating ServerService(id=ejbd)
+INFO - Creating ServerService(id=ejbds)
+INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+-------
+Ready!
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.034 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/webservice-attachments.pdf b/content/examples/webservice-attachments.pdf
new file mode 100644
index 0000000..490d0a7
--- /dev/null
+++ b/content/examples/webservice-attachments.pdf
Binary files differ
diff --git a/content/examples/webservice-attachments/README.md b/content/examples/webservice-attachments/README.md
new file mode 100755
index 0000000..751efe4
--- /dev/null
+++ b/content/examples/webservice-attachments/README.md
@@ -0,0 +1,202 @@
+Title: Webservice Attachments
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## AttachmentImpl
+
+ package org.superbiz.attachment;
+
+ import javax.activation.DataHandler;
+ import javax.activation.DataSource;
+ import javax.ejb.Stateless;
+ import javax.jws.WebService;
+ import javax.xml.ws.BindingType;
+ import javax.xml.ws.soap.SOAPBinding;
+ import java.io.IOException;
+ import java.io.InputStream;
+
+ /**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: {@link AttachmentWs} a webservice interface.
+ */
+ @Stateless
+ @WebService(
+ portName = "AttachmentPort",
+ serviceName = "AttachmentWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.attachment.AttachmentWs")
+ @BindingType(value = SOAPBinding.SOAP12HTTP_MTOM_BINDING)
+ public class AttachmentImpl implements AttachmentWs {
+
+ public String stringFromBytes(byte[] data) {
+ return new String(data);
+ }
+
+ public String stringFromDataSource(DataSource source) {
+
+ try {
+ InputStream inStr = source.getInputStream();
+ int size = inStr.available();
+ byte[] data = new byte[size];
+ inStr.read(data);
+ inStr.close();
+ return new String(data);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+ public String stringFromDataHandler(DataHandler handler) {
+
+ try {
+ return (String) handler.getContent();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+ }
+
+## AttachmentWs
+
+ package org.superbiz.attachment;
+
+ import javax.activation.DataHandler;
+ import javax.jws.WebService;
+
+ /**
+ * This is an EJB 3 webservice interface to send attachments throughout SAOP.
+ */
+ @WebService(targetNamespace = "http://superbiz.org/wsdl")
+ public interface AttachmentWs {
+
+ public String stringFromBytes(byte[] data);
+
+ // Not working at the moment with SUN saaj provider and CXF
+ //public String stringFromDataSource(DataSource source);
+
+ public String stringFromDataHandler(DataHandler handler);
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar/>
+
+## AttachmentTest
+
+ package org.superbiz.attachment;
+
+ import junit.framework.TestCase;
+
+ import javax.activation.DataHandler;
+ import javax.activation.DataSource;
+ import javax.mail.util.ByteArrayDataSource;
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.xml.namespace.QName;
+ import javax.xml.ws.BindingProvider;
+ import javax.xml.ws.Service;
+ import javax.xml.ws.soap.SOAPBinding;
+ import java.net.URL;
+ import java.util.Properties;
+
+ public class AttachmentTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ initialContext = new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Create a webservice client using wsdl url
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: webservice
+ public void testAttachmentViaWsInterface() throws Exception {
+ Service service = Service.create(
+ new URL("http://127.0.0.1:4204/AttachmentImpl?wsdl"),
+ new QName("http://superbiz.org/wsdl", "AttachmentWsService"));
+ assertNotNull(service);
+
+ AttachmentWs ws = service.getPort(AttachmentWs.class);
+
+ // retrieve the SOAPBinding
+ SOAPBinding binding = (SOAPBinding) ((BindingProvider) ws).getBinding();
+ binding.setMTOMEnabled(true);
+
+ String request = "tsztelak@gmail.com";
+
+ // Byte array
+ String response = ws.stringFromBytes(request.getBytes());
+ assertEquals(request, response);
+
+ // Data Source
+ DataSource source = new ByteArrayDataSource(request.getBytes(), "text/plain; charset=UTF-8");
+
+ // not yet supported !
+ // response = ws.stringFromDataSource(source);
+ // assertEquals(request, response);
+
+ // Data Handler
+ response = ws.stringFromDataHandler(new DataHandler(source));
+ assertEquals(request, response);
+ }
+ //END SNIPPET: webservice
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.attachment.AttachmentTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/webservice-attachments
+ INFO - openejb.base = /Users/dblevins/examples/webservice-attachments
+ 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/webservice-attachments/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/webservice-attachments/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-attachments/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean AttachmentImpl: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "/Users/dblevins/examples/webservice-attachments/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/webservice-attachments/classpath.ear
+ INFO - Created Ejb(deployment-id=AttachmentImpl, ejb-name=AttachmentImpl, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=AttachmentImpl, ejb-name=AttachmentImpl, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/webservice-attachments/classpath.ear)
+ INFO - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Creating ServerService(id=cxf)
+ INFO - Creating ServerService(id=admin)
+ INFO - Creating ServerService(id=ejbd)
+ INFO - Creating ServerService(id=ejbds)
+ INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+ -------
+ Ready!
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.034 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/webservice-attachments/build.xml b/content/examples/webservice-attachments/build.xml
new file mode 100755
index 0000000..f8f04fc
--- /dev/null
+++ b/content/examples/webservice-attachments/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-30 01:48:17 +0100 (Mon, 30 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-cxf" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/webservice-attachments/pom.xml b/content/examples/webservice-attachments/pom.xml
new file mode 100755
index 0000000..56dca43
--- /dev/null
+++ b/content/examples/webservice-attachments/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1624046 $ $Date: 2014-09-10 18:01:13 +0200 (Wed, 10 Sep 2014) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>webservice-attachments</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Webservice Attachments</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- This is required on IBM JDKs (and potentially others) because saaj-impl depends
+ on Sun's internal copy of Xerces. See OPENEJB-1126. -->
+ <dependency>
+ <groupId>com.sun.xml.parsers</groupId>
+ <artifactId>jaxp-ri</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/webservice-attachments/src/main/java/org/superbiz/attachment/AttachmentImpl.java b/content/examples/webservice-attachments/src/main/java/org/superbiz/attachment/AttachmentImpl.java
new file mode 100755
index 0000000..18f304d
--- /dev/null
+++ b/content/examples/webservice-attachments/src/main/java/org/superbiz/attachment/AttachmentImpl.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.attachment;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.soap.SOAPBinding;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: {@link AttachmentWs} a webservice interface.
+ */
+@Stateless
+@WebService(
+ portName = "AttachmentPort",
+ serviceName = "AttachmentWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.attachment.AttachmentWs")
+@BindingType(value = SOAPBinding.SOAP12HTTP_MTOM_BINDING)
+public class AttachmentImpl implements AttachmentWs {
+
+ public String stringFromBytes(byte[] data) {
+ return new String(data);
+
+ }
+
+ public String stringFromDataSource(DataSource source) {
+
+ try {
+ InputStream inStr = source.getInputStream();
+ int size = inStr.available();
+ byte[] data = new byte[size];
+ inStr.read(data);
+ inStr.close();
+ return new String(data);
+
+ } catch (IOException e) {
+ e.printStackTrace();
+
+ }
+ return "";
+
+ }
+
+ public String stringFromDataHandler(DataHandler handler) {
+
+ try {
+ return (String) handler.getContent();
+
+ } catch (IOException e) {
+ e.printStackTrace();
+
+ }
+ return "";
+
+ }
+
+}
diff --git a/content/examples/webservice-attachments/src/main/java/org/superbiz/attachment/AttachmentWs.java b/content/examples/webservice-attachments/src/main/java/org/superbiz/attachment/AttachmentWs.java
new file mode 100755
index 0000000..164f374
--- /dev/null
+++ b/content/examples/webservice-attachments/src/main/java/org/superbiz/attachment/AttachmentWs.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.attachment;
+
+import javax.activation.DataHandler;
+import javax.jws.WebService;
+
+/**
+ * This is an EJB 3 webservice interface to send attachments throughout SAOP.
+ */
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface AttachmentWs {
+
+ public String stringFromBytes(byte[] data);
+
+ // Not working at the moment with SUN saaj provider and CXF
+ //public String stringFromDataSource(DataSource source);
+
+ public String stringFromDataHandler(DataHandler handler);
+
+}
diff --git a/content/examples/webservice-attachments/src/main/resources/META-INF/ejb-jar.xml b/content/examples/webservice-attachments/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..433757b
--- /dev/null
+++ b/content/examples/webservice-attachments/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
\ No newline at end of file
diff --git a/content/examples/webservice-attachments/src/test/java/org/superbiz/attachment/AttachmentTest.java b/content/examples/webservice-attachments/src/test/java/org/superbiz/attachment/AttachmentTest.java
new file mode 100755
index 0000000..f840d61
--- /dev/null
+++ b/content/examples/webservice-attachments/src/test/java/org/superbiz/attachment/AttachmentTest.java
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.attachment;
+
+import junit.framework.TestCase;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.mail.util.ByteArrayDataSource;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+import java.net.URL;
+import java.util.Properties;
+
+public class AttachmentTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ //Random port to avoid test conflicts
+ private static final int port = Integer.parseInt(System.getProperty("httpejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+ protected void setUp() throws Exception {
+
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ //Just for this test we change the default port from 4204 to avoid conflicts
+ properties.setProperty("httpejbd.port", "" + port);
+
+ initialContext = new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Create a webservice client using wsdl url
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: webservice
+ public void testAttachmentViaWsInterface() throws Exception {
+ Service service = Service.create(
+ new URL("http://localhost:" + port + "/webservice-attachments/AttachmentImpl?wsdl"),
+ new QName("http://superbiz.org/wsdl", "AttachmentWsService"));
+ assertNotNull(service);
+
+ AttachmentWs ws = service.getPort(AttachmentWs.class);
+
+ // retrieve the SOAPBinding
+ SOAPBinding binding = (SOAPBinding) ((BindingProvider) ws).getBinding();
+ binding.setMTOMEnabled(true);
+
+ String request = "tsztelak@gmail.com";
+
+ // Byte array
+ String response = ws.stringFromBytes(request.getBytes());
+ assertEquals(request, response);
+
+ // Data Source
+ DataSource source = new ByteArrayDataSource(request.getBytes(), "text/plain; charset=UTF-8");
+
+ // not yet supported !
+ // response = ws.stringFromDataSource(source);
+ // assertEquals(request, response);
+
+ // Data Handler
+ response = ws.stringFromDataHandler(new DataHandler(source));
+ assertEquals(request, response);
+
+ }
+ //END SNIPPET: webservice
+
+}
diff --git a/content/examples/webservice-handlerchain.html b/content/examples/webservice-handlerchain.html
new file mode 100644
index 0000000..fa2379a
--- /dev/null
+++ b/content/examples/webservice-handlerchain.html
@@ -0,0 +1,633 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/webservice-handlerchain.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>@WebService handlers with @HandlerChain</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example webservice-handlerchain can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/webservice-handlerchain" class="bare">https://github.com/apache/tomee/tree/master/examples/webservice-handlerchain</a></p>
+</div>
+<div class="paragraph">
+<p>In this example we see a basic JAX-WS <code>@WebService</code> component use a handler chain to alter incoming and outgoing SOAP messages. SOAP Handlers are similar to Servlet Filters or EJB/CDI Interceptors.</p>
+</div>
+<div class="paragraph">
+<p>At high level, the steps involved are:</p>
+</div>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Create handler(s) implementing <code>javax.xml.ws.handler.soap.SOAPHandler</code></p>
+</li>
+<li>
+<p>Declare and order them in an xml file via <code><handler-chain></code></p>
+</li>
+<li>
+<p>Associate the xml file with an <code>@WebService</code> component via <code>@HandlerChain</code></p>
+</li>
+</ol>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_handlerchain">The @HandlerChain</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>First we’ll start with our plain <code>@WebService</code> bean, called <code>Calculator</code>, which is annotated with <code>@HandlerChain</code></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Singleton
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.wsh.CalculatorWs")
+@HandlerChain(file = "handlers.xml")
+public class Calculator implements CalculatorWs {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Here we see <code>@HandlerChain</code> pointing to a file called <code>handlers.xml</code>. This file could be called anything, but it must be in the same jar and java package as our <code>Calculator</code> component.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_handler_chains_file">The <handler-chains> file</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Our <code>Calculator</code> service is in the package <code>org.superbiz.calculator.wsh</code>, which means our handler chain xml file must be at <code>org/superbiz/calculator/wsh/handlers.xml</code> in our application’s classpath or the file will not be found and no handlers will be used.</p>
+</div>
+<div class="paragraph">
+<p>In maven we achieve this by putting our handlers.xml in <code>src/main/resources</code> like so:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><code>src/main/resources/org/superbiz/calculator/wsh/handlers.xml</code></p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>With this file we declare and <strong>order</strong> our handler chain.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
+ <handler-chain>
+ <handler>
+ <handler-name>org.superbiz.calculator.wsh.Inflate</handler-name>
+ <handler-class>org.superbiz.calculator.wsh.Inflate</handler-class>
+ </handler>
+ <handler>
+ <handler-name>org.superbiz.calculator.wsh.Increment</handler-name>
+ <handler-class>org.superbiz.calculator.wsh.Increment</handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The order as you might suspect is:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><code>Inflate</code></p>
+</li>
+<li>
+<p><code>Increment</code></p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_soaphandler_implementation">The SOAPHandler implementation</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Our <code>Inflate</code> handler has the job of monitoring <strong>responses</strong> to the <code>sum</code> and <code>multiply</code> operations and making them 1000 times better. Manipulation of the message is done by walking the <code>SOAPBody</code> and editing the nodes. The <code>handleMessage</code> method is invoked for both requests and responses, so it is important to check the <code>SOAPBody</code> before attempting to naviage the nodes.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import org.w3c.dom.Node;
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+import java.util.Collections;
+import java.util.Set;
+
+public class Inflate implements SOAPHandler<SOAPMessageContext> {
+
+ public boolean handleMessage(SOAPMessageContext mc) {
+ try {
+ final SOAPMessage message = mc.getMessage();
+ final SOAPBody body = message.getSOAPBody();
+ final String localName = body.getFirstChild().getLocalName();
+
+ if ("sumResponse".equals(localName) || "multiplyResponse".equals(localName)) {
+ final Node responseNode = body.getFirstChild();
+ final Node returnNode = responseNode.getFirstChild();
+ final Node intNode = returnNode.getFirstChild();
+
+ final int value = new Integer(intNode.getNodeValue());
+ intNode.setNodeValue(Integer.toString(value * 1000));
+ }
+
+ return true;
+ } catch (SOAPException e) {
+ return false;
+ }
+ }
+
+ public Set<QName> getHeaders() {
+ return Collections.emptySet();
+ }
+
+ public void close(MessageContext mc) {
+ }
+
+ public boolean handleFault(SOAPMessageContext mc) {
+ return true;
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The <code>Increment</code> handler is identical in code and therefore not shown. Instead of multiplying by 1000, it simply adds 1.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_testcase">The TestCase</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>We use the JAX-WS API to create a Java client for our <code>Calculator</code> web service and use it to invoke both the <code>sum</code> and <code>multiply</code> operations. Note the clever use of math to assert both the existence and order of our handlers. If <code>Inflate</code> and <code>Increment</code> were reversed, the responses would be 11000 and 13000 respectively.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class CalculatorTest {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void testCalculatorViaWsInterface() throws Exception {
+ final Service calculatorService = Service.create(
+ new URL("http://127.0.0.1:4204/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ final CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+
+ // we expect our answers to come back 1000 times better, plus one!
+ assertEquals(10001, calculator.sum(4, 6));
+ assertEquals(12001, calculator.multiply(3, 4));
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_running_the_example">Running the example</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Simply run <code>mvn clean install</code> and you should see output similar to the following:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.calculator.wsh.CalculatorTest
+INFO - openejb.home = /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers
+INFO - openejb.base = /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers
+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 - Beginning load: /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers/target/test-classes
+INFO - Beginning load: /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers
+INFO - Auto-deploying ejb Calculator: EjbDeployment(deployment-id=Calculator)
+INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+INFO - Auto-creating a container for bean Calculator: Container(type=SINGLETON, id=Default Singleton Container)
+INFO - Creating Container(id=Default Singleton Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.calculator.wsh.CalculatorTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers" loaded.
+INFO - Assembling app: /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers
+INFO - Created Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Singleton Container)
+INFO - Started Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Singleton Container)
+INFO - Deployed Application(path=/Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers)
+INFO - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Creating ServerService(id=cxf)
+INFO - Creating ServerService(id=admin)
+INFO - Creating ServerService(id=ejbd)
+INFO - Creating ServerService(id=ejbds)
+INFO - Initializing network services
+INFO - ** Starting Services **
+INFO - NAME IP PORT
+INFO - httpejbd 127.0.0.1 4204
+INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from class org.superbiz.calculator.wsh.CalculatorWs
+INFO - Setting the server's publish address to be http://nopath:80
+INFO - Webservice(wsdl=http://127.0.0.1:4204/Calculator, qname={http://superbiz.org/wsdl}CalculatorService) --> Ejb(id=Calculator)
+INFO - admin thread 127.0.0.1 4200
+INFO - ejbd 127.0.0.1 4201
+INFO - ejbd 127.0.0.1 4203
+INFO - -------
+INFO - Ready!
+INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+INFO - Default SAAJ universe not set
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.783 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_inspecting_the_messages">Inspecting the messages</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The above would generate the following messages.</p>
+</div>
+<div class="sect2">
+<h3 id="_calculator_wsdl">Calculator wsdl</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ name="CalculatorService" targetNamespace="http://superbiz.org/wsdl"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://superbiz.org/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
+ targetNamespace="http://superbiz.org/wsdl" xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="multiply" type="tns:multiply"/>
+ <xsd:complexType name="multiply">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="multiplyResponse" type="tns:multiplyResponse"/>
+ <xsd:complexType name="multiplyResponse">
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sum" type="tns:sum"/>
+ <xsd:complexType name="sum">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sumResponse" type="tns:sumResponse"/>
+ <xsd:complexType name="sumResponse">
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="multiplyResponse">
+ <wsdl:part element="tns:multiplyResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="sumResponse">
+ <wsdl:part element="tns:sumResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="sum">
+ <wsdl:part element="tns:sum" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="multiply">
+ <wsdl:part element="tns:multiply" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="CalculatorWs">
+ <wsdl:operation name="multiply">
+ <wsdl:input message="tns:multiply" name="multiply">
+ </wsdl:input>
+ <wsdl:output message="tns:multiplyResponse" name="multiplyResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sum">
+ <wsdl:input message="tns:sum" name="sum">
+ </wsdl:input>
+ <wsdl:output message="tns:sumResponse" name="sumResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CalculatorServiceSoapBinding" type="tns:CalculatorWs">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="multiply">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="multiply">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="multiplyResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sum">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sum">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sumResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port binding="tns:CalculatorServiceSoapBinding" name="CalculatorPort">
+ <soap:address location="http://127.0.0.1:4204/Calculator?wsdl"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_soap_sum_and_sumresponse">SOAP sum and sumResponse</h3>
+<div class="paragraph">
+<p>Request:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sum xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>4</arg0>
+ <arg1>6</arg1>
+ </ns1:sum>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Response:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <return>10001</return>
+ </ns1:sumResponse>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_soap_multiply_and_multiplyresponse">SOAP multiply and multiplyResponse</h3>
+<div class="paragraph">
+<p>Request:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:multiply xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>3</arg0>
+ <arg1>4</arg1>
+ </ns1:multiply>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Response:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:multiplyResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <return>12001</return>
+ </ns1:multiplyResponse>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/webservice-handlerchain.pdf b/content/examples/webservice-handlerchain.pdf
new file mode 100644
index 0000000..3e46acc
--- /dev/null
+++ b/content/examples/webservice-handlerchain.pdf
Binary files differ
diff --git a/content/examples/webservice-handlerchain/README.md b/content/examples/webservice-handlerchain/README.md
new file mode 100755
index 0000000..8b8d79e
--- /dev/null
+++ b/content/examples/webservice-handlerchain/README.md
@@ -0,0 +1,352 @@
+Title: @WebService handlers with @HandlerChain
+
+In this example we see a basic JAX-WS `@WebService` component use a handler chain to alter incoming and outgoing SOAP messages. SOAP Handlers are similar to Servlet Filters or EJB/CDI Interceptors.
+
+At high level, the steps involved are:
+
+ 1. Create handler(s) implementing `javax.xml.ws.handler.soap.SOAPHandler`
+ 1. Declare and order them in an xml file via `<handler-chain>`
+ 1. Associate the xml file with an `@WebService` component via `@HandlerChain`
+
+## The @HandlerChain
+
+First we'll start with our plain `@WebService` bean, called `Calculator`, which is annotated with `@HandlerChain`
+
+ @Singleton
+ @WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.wsh.CalculatorWs")
+ @HandlerChain(file = "handlers.xml")
+ public class Calculator implements CalculatorWs {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+ }
+
+Here we see `@HandlerChain` pointing to a file called `handlers.xml`. This file could be called anything, but it must be in the same jar and java package as our `Calculator` component.
+
+## The <handler-chains> file
+
+Our `Calculator` service is in the package `org.superbiz.calculator.wsh`, which means our handler chain xml file must be at `org/superbiz/calculator/wsh/handlers.xml` in our application's classpath or the file will not be found and no handlers will be used.
+
+In maven we achieve this by putting our handlers.xml in `src/main/resources` like so:
+
+ - `src/main/resources/org/superbiz/calculator/wsh/handlers.xml`
+
+With this file we declare and **order** our handler chain.
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
+ <handler-chain>
+ <handler>
+ <handler-name>org.superbiz.calculator.wsh.Inflate</handler-name>
+ <handler-class>org.superbiz.calculator.wsh.Inflate</handler-class>
+ </handler>
+ <handler>
+ <handler-name>org.superbiz.calculator.wsh.Increment</handler-name>
+ <handler-class>org.superbiz.calculator.wsh.Increment</handler-class>
+ </handler>
+ </handler-chain>
+ </handler-chains>
+
+The order as you might suspect is:
+
+ - `Inflate`
+ - `Increment`
+
+## The SOAPHandler implementation
+
+Our `Inflate` handler has the job of monitoring *responses* to the `sum` and `multiply` operations and making them 1000 times better. Manipulation of the message is done by walking the `SOAPBody` and editing the nodes. The `handleMessage` method is invoked for both requests and responses, so it is important to check the `SOAPBody` before attempting to naviage the nodes.
+
+ import org.w3c.dom.Node;
+ import javax.xml.namespace.QName;
+ import javax.xml.soap.SOAPBody;
+ import javax.xml.soap.SOAPException;
+ import javax.xml.soap.SOAPMessage;
+ import javax.xml.ws.handler.MessageContext;
+ import javax.xml.ws.handler.soap.SOAPHandler;
+ import javax.xml.ws.handler.soap.SOAPMessageContext;
+ import java.util.Collections;
+ import java.util.Set;
+
+ public class Inflate implements SOAPHandler<SOAPMessageContext> {
+
+ public boolean handleMessage(SOAPMessageContext mc) {
+ try {
+ final SOAPMessage message = mc.getMessage();
+ final SOAPBody body = message.getSOAPBody();
+ final String localName = body.getFirstChild().getLocalName();
+
+ if ("sumResponse".equals(localName) || "multiplyResponse".equals(localName)) {
+ final Node responseNode = body.getFirstChild();
+ final Node returnNode = responseNode.getFirstChild();
+ final Node intNode = returnNode.getFirstChild();
+
+ final int value = new Integer(intNode.getNodeValue());
+ intNode.setNodeValue(Integer.toString(value * 1000));
+ }
+
+ return true;
+ } catch (SOAPException e) {
+ return false;
+ }
+ }
+
+ public Set<QName> getHeaders() {
+ return Collections.emptySet();
+ }
+
+ public void close(MessageContext mc) {
+ }
+
+ public boolean handleFault(SOAPMessageContext mc) {
+ return true;
+ }
+ }
+
+The `Increment` handler is identical in code and therefore not shown. Instead of multiplying by 1000, it simply adds 1.
+
+## The TestCase
+
+We use the JAX-WS API to create a Java client for our `Calculator` web service and use it to invoke both the `sum` and `multiply` operations. Note the clever use of math to assert both the existence and order of our handlers. If `Inflate` and `Increment` were reversed, the responses would be 11000 and 13000 respectively.
+
+ public class CalculatorTest {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void testCalculatorViaWsInterface() throws Exception {
+ final Service calculatorService = Service.create(
+ new URL("http://127.0.0.1:4204/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ final CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+
+ // we expect our answers to come back 1000 times better, plus one!
+ assertEquals(10001, calculator.sum(4, 6));
+ assertEquals(12001, calculator.multiply(3, 4));
+ }
+ }
+
+## Running the example
+
+Simply run `mvn clean install` and you should see output similar to the following:
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.calculator.wsh.CalculatorTest
+ INFO - openejb.home = /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers
+ INFO - openejb.base = /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers
+ 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 - Beginning load: /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers/target/test-classes
+ INFO - Beginning load: /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers
+ INFO - Auto-deploying ejb Calculator: EjbDeployment(deployment-id=Calculator)
+ INFO - Configuring Service(id=Default Singleton Container, type=Container, provider-id=Default Singleton Container)
+ INFO - Auto-creating a container for bean Calculator: Container(type=SINGLETON, id=Default Singleton Container)
+ INFO - Creating Container(id=Default Singleton Container)
+ INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+ INFO - Auto-creating a container for bean org.superbiz.calculator.wsh.CalculatorTest: Container(type=MANAGED, id=Default Managed Container)
+ INFO - Creating Container(id=Default Managed Container)
+ INFO - Enterprise application "/Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers" loaded.
+ INFO - Assembling app: /Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers
+ INFO - Created Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Singleton Container)
+ INFO - Started Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Singleton Container)
+ INFO - Deployed Application(path=/Users/dblevins/work/all/trunk/openejb/examples/webservice-handlers)
+ INFO - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Creating ServerService(id=cxf)
+ INFO - Creating ServerService(id=admin)
+ INFO - Creating ServerService(id=ejbd)
+ INFO - Creating ServerService(id=ejbds)
+ INFO - Initializing network services
+ INFO - ** Starting Services **
+ INFO - NAME IP PORT
+ INFO - httpejbd 127.0.0.1 4204
+ INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from class org.superbiz.calculator.wsh.CalculatorWs
+ INFO - Setting the server's publish address to be http://nopath:80
+ INFO - Webservice(wsdl=http://127.0.0.1:4204/Calculator, qname={http://superbiz.org/wsdl}CalculatorService) --> Ejb(id=Calculator)
+ INFO - admin thread 127.0.0.1 4200
+ INFO - ejbd 127.0.0.1 4201
+ INFO - ejbd 127.0.0.1 4203
+ INFO - -------
+ INFO - Ready!
+ INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+ INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+ INFO - Default SAAJ universe not set
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.783 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+## Inspecting the messages
+
+The above would generate the following messages.
+
+### Calculator wsdl
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ name="CalculatorService" targetNamespace="http://superbiz.org/wsdl"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://superbiz.org/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
+ targetNamespace="http://superbiz.org/wsdl" xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="multiply" type="tns:multiply"/>
+ <xsd:complexType name="multiply">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="multiplyResponse" type="tns:multiplyResponse"/>
+ <xsd:complexType name="multiplyResponse">
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sum" type="tns:sum"/>
+ <xsd:complexType name="sum">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sumResponse" type="tns:sumResponse"/>
+ <xsd:complexType name="sumResponse">
+ <xsd:sequence>
+ <xsd:element name="return" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="multiplyResponse">
+ <wsdl:part element="tns:multiplyResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="sumResponse">
+ <wsdl:part element="tns:sumResponse" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="sum">
+ <wsdl:part element="tns:sum" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="multiply">
+ <wsdl:part element="tns:multiply" name="parameters">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="CalculatorWs">
+ <wsdl:operation name="multiply">
+ <wsdl:input message="tns:multiply" name="multiply">
+ </wsdl:input>
+ <wsdl:output message="tns:multiplyResponse" name="multiplyResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sum">
+ <wsdl:input message="tns:sum" name="sum">
+ </wsdl:input>
+ <wsdl:output message="tns:sumResponse" name="sumResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CalculatorServiceSoapBinding" type="tns:CalculatorWs">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="multiply">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="multiply">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="multiplyResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sum">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sum">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sumResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port binding="tns:CalculatorServiceSoapBinding" name="CalculatorPort">
+ <soap:address location="http://127.0.0.1:4204/Calculator?wsdl"/>
+ </wsdl:port>
+ </wsdl:service>
+ </wsdl:definitions>
+
+### SOAP sum and sumResponse
+
+Request:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sum xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>4</arg0>
+ <arg1>6</arg1>
+ </ns1:sum>
+ </soap:Body>
+ </soap:Envelope>
+
+Response:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <return>10001</return>
+ </ns1:sumResponse>
+ </soap:Body>
+ </soap:Envelope>
+
+### SOAP multiply and multiplyResponse
+
+Request:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:multiply xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>3</arg0>
+ <arg1>4</arg1>
+ </ns1:multiply>
+ </soap:Body>
+ </soap:Envelope>
+
+Response:
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:multiplyResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <return>12001</return>
+ </ns1:multiplyResponse>
+ </soap:Body>
+ </soap:Envelope>
diff --git a/content/examples/webservice-handlerchain/build.xml b/content/examples/webservice-handlerchain/build.xml
new file mode 100755
index 0000000..8a003ee
--- /dev/null
+++ b/content/examples/webservice-handlerchain/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 16:48:17 -0800 (Sun, 29 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-cxf" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/webservice-handlerchain/pom.xml b/content/examples/webservice-handlerchain/pom.xml
new file mode 100755
index 0000000..67ef88e
--- /dev/null
+++ b/content/examples/webservice-handlerchain/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 16:48:17 -0800 (Sun, 29 Jan 2012) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>webservice-handlerchain</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Web Service Handlers</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- This is required on IBM JDKs (and potentially others) because saaj-impl depends
+ on Sun's internal copy of Xerces. See OPENEJB-1126. -->
+ <dependency>
+ <groupId>com.sun.xml.parsers</groupId>
+ <artifactId>jaxp-ri</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/Calculator.java b/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/Calculator.java
new file mode 100755
index 0000000..2460eba
--- /dev/null
+++ b/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/Calculator.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator.wsh;
+
+import javax.ejb.Singleton;
+import javax.jws.HandlerChain;
+import javax.jws.WebService;
+
+@Singleton
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.wsh.CalculatorWs")
+@HandlerChain(file = "handlers.xml")
+public class Calculator implements CalculatorWs {
+
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}
diff --git a/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/CalculatorWs.java b/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/CalculatorWs.java
new file mode 100755
index 0000000..e1a4dd6
--- /dev/null
+++ b/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/CalculatorWs.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator.wsh;
+
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}
diff --git a/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/Increment.java b/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/Increment.java
new file mode 100755
index 0000000..5077506
--- /dev/null
+++ b/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/Increment.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator.wsh;
+
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+import java.util.Collections;
+import java.util.Set;
+
+public class Increment implements SOAPHandler<SOAPMessageContext> {
+
+ public boolean handleMessage(SOAPMessageContext mc) {
+ try {
+ final SOAPMessage message = mc.getMessage();
+ final SOAPBody body = message.getSOAPBody();
+ final String localName = body.getFirstChild().getLocalName();
+
+ if ("sumResponse".equals(localName) || "multiplyResponse".equals(localName)) {
+ final Node responseNode = body.getFirstChild();
+ final Node returnNode = responseNode.getFirstChild();
+ final Node intNode = returnNode.getFirstChild();
+
+ final int value = new Integer(intNode.getNodeValue());
+ intNode.setNodeValue(Integer.toString(value + 1));
+ }
+
+ return true;
+ } catch (SOAPException e) {
+ return false;
+ }
+ }
+
+ public Set<QName> getHeaders() {
+ return Collections.emptySet();
+ }
+
+ public void close(MessageContext mc) {
+ }
+
+ public boolean handleFault(SOAPMessageContext mc) {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/Inflate.java b/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/Inflate.java
new file mode 100755
index 0000000..007e1e3
--- /dev/null
+++ b/content/examples/webservice-handlerchain/src/main/java/org/superbiz/calculator/wsh/Inflate.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator.wsh;
+
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+import java.util.Collections;
+import java.util.Set;
+
+public class Inflate implements SOAPHandler<SOAPMessageContext> {
+
+ public boolean handleMessage(SOAPMessageContext mc) {
+ try {
+ final SOAPMessage message = mc.getMessage();
+ final SOAPBody body = message.getSOAPBody();
+ final String localName = body.getFirstChild().getLocalName();
+
+ if ("sumResponse".equals(localName) || "multiplyResponse".equals(localName)) {
+ final Node responseNode = body.getFirstChild();
+ final Node returnNode = responseNode.getFirstChild();
+ final Node intNode = returnNode.getFirstChild();
+
+ final int value = new Integer(intNode.getNodeValue());
+ intNode.setNodeValue(Integer.toString(value * 1000));
+ }
+
+ return true;
+ } catch (SOAPException e) {
+ return false;
+ }
+ }
+
+ public Set<QName> getHeaders() {
+ return Collections.emptySet();
+ }
+
+ public void close(MessageContext mc) {
+ }
+
+ public boolean handleFault(SOAPMessageContext mc) {
+ return true;
+ }
+}
diff --git a/content/examples/webservice-handlerchain/src/main/resources/org/superbiz/calculator/wsh/handlers.xml b/content/examples/webservice-handlerchain/src/main/resources/org/superbiz/calculator/wsh/handlers.xml
new file mode 100755
index 0000000..844bb1f
--- /dev/null
+++ b/content/examples/webservice-handlerchain/src/main/resources/org/superbiz/calculator/wsh/handlers.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 773519 $ $Date: 2009-05-11 12:08:51 +0200 (Mon, 11 May 2009) $ -->
+
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
+ <handler-chain>
+ <handler>
+ <handler-name>org.superbiz.calculator.wsh.Inflate</handler-name>
+ <handler-class>org.superbiz.calculator.wsh.Inflate</handler-class>
+ </handler>
+ <handler>
+ <handler-name>org.superbiz.calculator.wsh.Increment</handler-name>
+ <handler-class>org.superbiz.calculator.wsh.Increment</handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains>
diff --git a/content/examples/webservice-handlerchain/src/test/java/org/superbiz/calculator/wsh/CalculatorTest.java b/content/examples/webservice-handlerchain/src/test/java/org/superbiz/calculator/wsh/CalculatorTest.java
new file mode 100755
index 0000000..87cb5bc
--- /dev/null
+++ b/content/examples/webservice-handlerchain/src/test/java/org/superbiz/calculator/wsh/CalculatorTest.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator.wsh;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CalculatorTest {
+
+ //Random port to avoid test conflicts
+ private static final int port = Integer.parseInt(System.getProperty("httpejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ //Just for this test we change the default port from 4204 to avoid conflicts
+ properties.setProperty("httpejbd.port", "" + port);
+
+ //properties.setProperty("httpejbd.print", "true");
+ //properties.setProperty("httpejbd.indent.xml", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void testCalculatorViaWsInterface() throws Exception {
+ final Service calculatorService = Service.create(
+ new URL("http://localhost:" + port + "/webservice-handlerchain/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ final CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+
+ // we expect our answers to come back 1000 times better, plus one!
+ assertEquals(10001, calculator.sum(4, 6));
+ assertEquals(12001, calculator.multiply(3, 4));
+ }
+}
diff --git a/content/examples/webservice-holder.html b/content/examples/webservice-holder.html
new file mode 100644
index 0000000..cf98e8e
--- /dev/null
+++ b/content/examples/webservice-holder.html
@@ -0,0 +1,397 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/webservice-holder.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>@WebService OUT params via javax.xml.ws.Holder</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example webservice-holder can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/webservice-holder" class="bare">https://github.com/apache/tomee/tree/master/examples/webservice-holder</a></p>
+</div>
+<div class="paragraph">
+<p>With SOAP it is possible to return multiple values in a single request. This is impossible in Java as a method can only return one object.</p>
+</div>
+<div class="paragraph">
+<p>JAX-WS solves this problem with the concept of Holders. A <code>javax.xml.ws.Holder</code> is a simple wrapper object that can be passed into the <code>@WebService</code> method as a parameter. The application sets the value of the holder during the request and the server will send the value back as an OUT parameter.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_using_webparam_and_javax_xml_ws_holder">Using @WebParam and javax.xml.ws.Holder</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The <code>@WebParam</code> annotation allows us to declare the <code>sum</code> and <code>multiply</code> Holders as <code>WebParam.Mode.OUT</code> parameters. As mentioned, these holders are simply empty buckets the application can fill in with data to have sent to the client. The server will pass them in uninitialized.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.ws.out.CalculatorWs")
+public class Calculator implements CalculatorWs {
+
+ public void sumAndMultiply(int a, int b,
+ @WebParam(name = "sum", mode = WebParam.Mode.OUT) Holder<Integer> sum,
+ @WebParam(name = "multiply", mode = WebParam.Mode.OUT) Holder<Integer> multiply) {
+ sum.value = a + b;
+ multiply.value = a * b;
+ }
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>If the Holders were specified as <code>WebParam.Mode.INOUT</code> params, then the client could use them to send data and the application as well. The <code>Holder</code> instances would then be initialized with the data from the client request. The application could check the data before eventually overriting it with the response values.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_wsdl">The WSDL</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The above JAX-WS <code>@WebService</code> component results in the folliwing WSDL that will be created automatically. Note the <code>sumAndMultiplyResponse</code> complext type returns two elements. These match the <code>@WebParam</code> declarations and our two <code>Holder<Integer></code> params.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ name="CalculatorService"
+ targetNamespace="http://superbiz.org/wsdl"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
+ targetNamespace="http://superbiz.org/wsdl"
+ xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="sumAndMultiply" type="tns:sumAndMultiply"/>
+ <xsd:complexType name="sumAndMultiply">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sumAndMultiplyResponse" type="tns:sumAndMultiplyResponse"/>
+ <xsd:complexType name="sumAndMultiplyResponse">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" name="sum" type="xsd:int"/>
+ <xsd:element minOccurs="0" name="multiply" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="sumAndMultiplyResponse">
+ <wsdl:part element="tns:sumAndMultiplyResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="sumAndMultiply">
+ <wsdl:part element="tns:sumAndMultiply" name="parameters"/>
+ </wsdl:message>
+ <wsdl:portType name="CalculatorWs">
+ <wsdl:operation name="sumAndMultiply">
+ <wsdl:input message="tns:sumAndMultiply" name="sumAndMultiply"/>
+ <wsdl:output message="tns:sumAndMultiplyResponse" name="sumAndMultiplyResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CalculatorServiceSoapBinding" type="tns:CalculatorWs">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="sumAndMultiply">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sumAndMultiply">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sumAndMultiplyResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port binding="tns:CalculatorServiceSoapBinding" name="CalculatorPort">
+ <soap:address location="http://127.0.0.1:4204/Calculator?wsdl"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_testing_the_out_params">Testing the OUT params</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Here we see a JAX-WS client executing the <code>sumAndMultiply</code> operation. Two empty <code>Holder</code> instances are created and passed in as parameters. The data from the <code>sumAndMultiplyResponse</code> is placed in the <code>Holder</code> instances and is then available to the client after the operation completes.</p>
+</div>
+<div class="paragraph">
+<p>The holders themselves are not actually sent in the request unless they are configured as INOUT params via WebParam.Mode.INOUT on <code>@WebParam</code></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CalculatorTest {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+ //properties.setProperty("httpejbd.print", "true");
+ //properties.setProperty("httpejbd.indent.xml", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void outParams() throws Exception {
+ final Service calculatorService = Service.create(
+ new URL("http://127.0.0.1:4204/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ final CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+
+ final Holder<Integer> sum = new Holder<Integer>();
+ final Holder<Integer> multiply = new Holder<Integer>();
+
+ calculator.sumAndMultiply(4, 6, sum, multiply);
+
+ assertEquals(10, (int) sum.value);
+ assertEquals(24, (int) multiply.value);
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_inspecting_the_messages">Inspecting the messages</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The above execution results in the following SOAP message.</p>
+</div>
+<div class="sect2">
+<h3 id="_soap_sumandmultiply_small_client_request_small">SOAP sumAndMultiply <small>client request</small></h3>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumAndMultiply xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>4</arg0>
+ <arg1>6</arg1>
+ </ns1:sumAndMultiply>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_soap_sumandmultiplyresponse_small_server_response_small">SOAP sumAndMultiplyResponse <small>server response</small></h3>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumAndMultiplyResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <sum>10</sum>
+ <multiply>24</multiply>
+ </ns1:sumAndMultiplyResponse>
+ </soap:Body>
+</soap:Envelope></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/webservice-holder.pdf b/content/examples/webservice-holder.pdf
new file mode 100644
index 0000000..53eb7ef
--- /dev/null
+++ b/content/examples/webservice-holder.pdf
Binary files differ
diff --git a/content/examples/webservice-holder/README.md b/content/examples/webservice-holder/README.md
new file mode 100755
index 0000000..5c26edc
--- /dev/null
+++ b/content/examples/webservice-holder/README.md
@@ -0,0 +1,169 @@
+Title: @WebService OUT params via javax.xml.ws.Holder
+
+With SOAP it is possible to return multiple values in a single request. This is impossible in Java as a method can only return one object.
+
+JAX-WS solves this problem with the concept of Holders. A `javax.xml.ws.Holder` is a simple wrapper object that can be passed into the `@WebService` method as a parameter. The application sets the value of the holder during the request and the server will send the value back as an OUT parameter.
+
+## Using @WebParam and javax.xml.ws.Holder
+
+The `@WebParam` annotation allows us to declare the `sum` and `multiply` Holders as `WebParam.Mode.OUT` parameters. As mentioned, these holders are simply empty buckets the application can fill in with data to have sent to the client. The server will pass them in uninitialized.
+
+ @Stateless
+ @WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.ws.out.CalculatorWs")
+ public class Calculator implements CalculatorWs {
+
+ public void sumAndMultiply(int a, int b,
+ @WebParam(name = "sum", mode = WebParam.Mode.OUT) Holder<Integer> sum,
+ @WebParam(name = "multiply", mode = WebParam.Mode.OUT) Holder<Integer> multiply) {
+ sum.value = a + b;
+ multiply.value = a * b;
+ }
+ }
+
+If the Holders were specified as `WebParam.Mode.INOUT` params, then the client could use them to send data and the application as well. The `Holder` instances would then be initialized with the data from the client request. The application could check the data before eventually overriting it with the response values.
+
+## The WSDL
+
+The above JAX-WS `@WebService` component results in the folliwing WSDL that will be created automatically. Note the `sumAndMultiplyResponse` complext type returns two elements. These match the `@WebParam` declarations and our two `Holder<Integer>` params.
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ name="CalculatorService"
+ targetNamespace="http://superbiz.org/wsdl"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
+ targetNamespace="http://superbiz.org/wsdl"
+ xmlns:tns="http://superbiz.org/wsdl"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="sumAndMultiply" type="tns:sumAndMultiply"/>
+ <xsd:complexType name="sumAndMultiply">
+ <xsd:sequence>
+ <xsd:element name="arg0" type="xsd:int"/>
+ <xsd:element name="arg1" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="sumAndMultiplyResponse" type="tns:sumAndMultiplyResponse"/>
+ <xsd:complexType name="sumAndMultiplyResponse">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" name="sum" type="xsd:int"/>
+ <xsd:element minOccurs="0" name="multiply" type="xsd:int"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="sumAndMultiplyResponse">
+ <wsdl:part element="tns:sumAndMultiplyResponse" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="sumAndMultiply">
+ <wsdl:part element="tns:sumAndMultiply" name="parameters"/>
+ </wsdl:message>
+ <wsdl:portType name="CalculatorWs">
+ <wsdl:operation name="sumAndMultiply">
+ <wsdl:input message="tns:sumAndMultiply" name="sumAndMultiply"/>
+ <wsdl:output message="tns:sumAndMultiplyResponse" name="sumAndMultiplyResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="CalculatorServiceSoapBinding" type="tns:CalculatorWs">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="sumAndMultiply">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sumAndMultiply">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sumAndMultiplyResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port binding="tns:CalculatorServiceSoapBinding" name="CalculatorPort">
+ <soap:address location="http://127.0.0.1:4204/Calculator?wsdl"/>
+ </wsdl:port>
+ </wsdl:service>
+ </wsdl:definitions>
+
+## Testing the OUT params
+
+Here we see a JAX-WS client executing the `sumAndMultiply` operation. Two empty `Holder` instances are created and passed in as parameters. The data from the `sumAndMultiplyResponse` is placed in the `Holder` instances and is then available to the client after the operation completes.
+
+The holders themselves are not actually sent in the request unless they are configured as INOUT params via WebParam.Mode.INOUT on `@WebParam`
+
+ import org.junit.BeforeClass;
+ import org.junit.Test;
+
+ import javax.ejb.embeddable.EJBContainer;
+ import javax.xml.namespace.QName;
+ import javax.xml.ws.Holder;
+ import javax.xml.ws.Service;
+ import java.net.URL;
+ import java.util.Properties;
+
+ import static org.junit.Assert.assertEquals;
+ import static org.junit.Assert.assertNotNull;
+
+ public class CalculatorTest {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+ //properties.setProperty("httpejbd.print", "true");
+ //properties.setProperty("httpejbd.indent.xml", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void outParams() throws Exception {
+ final Service calculatorService = Service.create(
+ new URL("http://127.0.0.1:4204/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ final CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+
+ final Holder<Integer> sum = new Holder<Integer>();
+ final Holder<Integer> multiply = new Holder<Integer>();
+
+ calculator.sumAndMultiply(4, 6, sum, multiply);
+
+ assertEquals(10, (int) sum.value);
+ assertEquals(24, (int) multiply.value);
+ }
+ }
+
+
+## Inspecting the messages
+
+The above execution results in the following SOAP message.
+
+### SOAP sumAndMultiply <small>client request</small>
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumAndMultiply xmlns:ns1="http://superbiz.org/wsdl">
+ <arg0>4</arg0>
+ <arg1>6</arg1>
+ </ns1:sumAndMultiply>
+ </soap:Body>
+ </soap:Envelope>
+
+### SOAP sumAndMultiplyResponse <small>server response</small>
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <ns1:sumAndMultiplyResponse xmlns:ns1="http://superbiz.org/wsdl">
+ <sum>10</sum>
+ <multiply>24</multiply>
+ </ns1:sumAndMultiplyResponse>
+ </soap:Body>
+ </soap:Envelope>
diff --git a/content/examples/webservice-holder/build.xml b/content/examples/webservice-holder/build.xml
new file mode 100755
index 0000000..8a003ee
--- /dev/null
+++ b/content/examples/webservice-holder/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 16:48:17 -0800 (Sun, 29 Jan 2012) $ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+ <!-- ===============================================================
+
+ HOW TO RUN
+
+ Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+ Then execute ant as follows:
+
+ ant -lib maven-ant-tasks-2.0.9.jar
+
+ NOTE
+
+ You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+ testing with Ant. It is simply used in this example to make the build.xml
+ a bit simpler. As long as OpenEJB and it's required libraries are in the
+ <junit> classpath, the tests will run with OpenEJB embedded.
+
+ ================================================================= -->
+
+ <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+ <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+ <!-- Build Classpath -->
+ <artifact:dependencies pathId="classpath.main">
+ <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+ </artifact:dependencies>
+
+ <!-- Test Build Classpath -->
+ <artifact:dependencies pathId="classpath.test.build">
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Test Run Classpath -->
+ <artifact:dependencies pathId="classpath.test.run">
+ <remoteRepository refid="apache.snapshot.repository"/>
+ <remoteRepository refid="m2.repository"/>
+
+ <dependency groupId="org.apache.openejb" artifactId="openejb-cxf" version="4.0.0-beta-1"/>
+ <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+ </artifact:dependencies>
+
+ <!-- Properties -->
+
+ <property name="src.main.java" location="src/main/java"/>
+ <property name="src.main.resources" location="src/main/resources"/>
+ <property name="src.test.java" location="src/test/java"/>
+ <property name="build.main" location="target/classes"/>
+ <property name="build.test" location="target/test-classes"/>
+ <property name="test.reports" location="target/test-reports"/>
+ <property name="dist" location="target"/>
+
+
+ <target name="init">
+ <mkdir dir="${build.main}"/>
+ <mkdir dir="${build.test}"/>
+ <mkdir dir="${test.reports}"/>
+ </target>
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.main.java}" destdir="${build.main}">
+ <classpath refid="classpath.main"/>
+ </javac>
+ <copy todir="${build.main}">
+ <fileset dir="${src.main.resources}"/>
+ </copy>
+
+ <javac srcdir="${src.test.java}" destdir="${build.test}">
+ <classpath location="${build.main}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ </javac>
+ </target>
+
+ <target name="test" depends="compile">
+ <junit fork="yes" printsummary="yes">
+ <classpath location="${build.main}"/>
+ <classpath location="${build.test}"/>
+ <classpath refid="classpath.main"/>
+ <classpath refid="classpath.test.build"/>
+ <classpath refid="classpath.test.run"/>
+
+ <formatter type="plain"/>
+
+ <batchtest fork="yes" todir="${test.reports}">
+ <fileset dir="${src.test.java}">
+ <include name="**/*Test.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="test">
+ <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+ </target>
+
+</project>
diff --git a/content/examples/webservice-holder/pom.xml b/content/examples/webservice-holder/pom.xml
new file mode 100755
index 0000000..ff0f70a
--- /dev/null
+++ b/content/examples/webservice-holder/pom.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 1237516 $ $Date: 2012-01-29 16:48:17 -0800 (Sun, 29 Jan 2012) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>webservice-holder</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: @WebService Holder</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- This is required on IBM JDKs (and potentially others) because saaj-impl depends
+ on Sun's internal copy of Xerces. See OPENEJB-1126. -->
+ <dependency>
+ <groupId>com.sun.xml.parsers</groupId>
+ <artifactId>jaxp-ri</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/webservice-holder/src/main/java/org/superbiz/ws/out/Calculator.java b/content/examples/webservice-holder/src/main/java/org/superbiz/ws/out/Calculator.java
new file mode 100755
index 0000000..706d04d
--- /dev/null
+++ b/content/examples/webservice-holder/src/main/java/org/superbiz/ws/out/Calculator.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.out;
+
+import javax.ejb.Stateless;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.ws.out.CalculatorWs")
+public class Calculator implements CalculatorWs {
+
+ public void sumAndMultiply(int a, int b,
+ @WebParam(name = "sum", mode = WebParam.Mode.OUT) Holder<Integer> sum,
+ @WebParam(name = "multiply", mode = WebParam.Mode.OUT) Holder<Integer> multiply) {
+ sum.value = a + b;
+ multiply.value = a * b;
+ }
+}
diff --git a/content/examples/webservice-holder/src/main/java/org/superbiz/ws/out/CalculatorWs.java b/content/examples/webservice-holder/src/main/java/org/superbiz/ws/out/CalculatorWs.java
new file mode 100755
index 0000000..9d81913
--- /dev/null
+++ b/content/examples/webservice-holder/src/main/java/org/superbiz/ws/out/CalculatorWs.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.out;
+
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+ public void sumAndMultiply(int a, int b, Holder<Integer> sum, Holder<Integer> multiply);
+}
diff --git a/content/examples/webservice-holder/src/test/java/org/superbiz/ws/out/CalculatorTest.java b/content/examples/webservice-holder/src/test/java/org/superbiz/ws/out/CalculatorTest.java
new file mode 100755
index 0000000..49a182e
--- /dev/null
+++ b/content/examples/webservice-holder/src/test/java/org/superbiz/ws/out/CalculatorTest.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.out;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CalculatorTest {
+
+ //Random port to avoid test conflicts
+ private static final int port = Integer.parseInt(System.getProperty("httpejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ //Just for this test we change the default port from 4204 to avoid conflicts
+ properties.setProperty("httpejbd.port", "" + port);
+
+ // properties.setProperty("httpejbd.print", "true");
+ // properties.setProperty("httpejbd.indent.xml", "true");
+ EJBContainer.createEJBContainer(properties);
+ }
+
+ @Test
+ public void outParams() throws Exception {
+ final Service calculatorService = Service.create(
+ new URL("http://localhost:" + port + "/webservice-holder/Calculator?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+ assertNotNull(calculatorService);
+
+ final CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+
+ final Holder<Integer> sum = new Holder<Integer>();
+ final Holder<Integer> multiply = new Holder<Integer>();
+
+ calculator.sumAndMultiply(4, 6, sum, multiply);
+
+ assertEquals(10, (int) sum.value);
+ assertEquals(24, (int) multiply.value);
+ }
+}
diff --git a/content/examples/webservice-inheritance.html b/content/examples/webservice-inheritance.html
new file mode 100644
index 0000000..43c177d
--- /dev/null
+++ b/content/examples/webservice-inheritance.html
@@ -0,0 +1,666 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/webservice-inheritance.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Webservice Inheritance</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example webservice-inheritance can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/webservice-inheritance" class="bare">https://github.com/apache/tomee/tree/master/examples/webservice-inheritance</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_item">Item</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.inheritance;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import java.io.Serializable;
+
+@Entity
+@Inheritance(strategy = InheritanceType.JOINED)
+public class Item implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+ private String brand;
+ private String itemName;
+ private double price;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public String getItemName() {
+ return itemName;
+ }
+
+ public void setItemName(String itemName) {
+ this.itemName = itemName;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_tower">Tower</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.inheritance;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Tower extends Item {
+ private Fit fit;
+ private String tubing;
+
+ public static enum Fit {
+ Custom, Exact, Universal
+ }
+
+ public Fit getFit() {
+ return fit;
+ }
+
+ public void setFit(Fit fit) {
+ this.fit = fit;
+ }
+
+ public String getTubing() {
+ return tubing;
+ }
+
+ public void setTubing(String tubing) {
+ this.tubing = tubing;
+ }
+
+ ;
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_wakeboard">Wakeboard</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.inheritance;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Wakeboard extends Wearable {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_wakeboardbinding">WakeboardBinding</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.inheritance;
+
+import javax.persistence.Entity;
+
+@Entity
+public class WakeboardBinding extends Wearable {
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_wakeriderimpl">WakeRiderImpl</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.inheritance;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean Every stateless session
+ * bean implementation must be annotated using the annotation @Stateless This
+ * EJB has a single interface: {@link WakeRiderWs} a webservice interface.
+ */
+@Stateless
+@WebService(
+ portName = "InheritancePort",
+ serviceName = "InheritanceWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.inheritance.WakeRiderWs")
+public class WakeRiderImpl implements WakeRiderWs {
+
+ @PersistenceContext(unitName = "wakeboard-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addItem(Item item) throws Exception {
+ entityManager.persist(item);
+ }
+
+ public void deleteMovie(Item item) throws Exception {
+ entityManager.remove(item);
+ }
+
+ public List<Item> getItems() throws Exception {
+ Query query = entityManager.createQuery("SELECT i FROM Item i");
+ List<Item> items = query.getResultList();
+ return items;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_wakeriderws">WakeRiderWs</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.inheritance;
+
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import java.util.List;
+
+/**
+ * This is an EJB 3 webservice interface that uses inheritance.
+ */
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+@XmlSeeAlso({Wakeboard.class, WakeboardBinding.class, Tower.class})
+public interface WakeRiderWs {
+ public void addItem(Item item) throws Exception;
+
+ public void deleteMovie(Item item) throws Exception;
+
+ public List<Item> getItems() throws Exception;
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_wearable">Wearable</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.inheritance;
+
+import javax.persistence.MappedSuperclass;
+
+@MappedSuperclass
+public abstract class Wearable extends Item {
+ protected String size;
+
+ public String getSize() {
+ return size;
+ }
+
+ public void setSize(String size) {
+ this.size = size;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar/></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_persistence_xml">persistence.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="wakeboard-unit">
+
+ <jta-data-source>wakeBoardDatabase</jta-data-source>
+ <non-jta-data-source>wakeBoardDatabaseUnmanaged</non-jta-data-source>
+
+ <class>org.superbiz.inheritance.Item</class>
+ <class>org.superbiz.inheritance.Tower</class>
+ <class>org.superbiz.inheritance.Wakeboard</class>
+ <class>org.superbiz.inheritance.WakeboardBinding</class>
+ <class>org.superbiz.inheritance.Wearable</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+
+ </persistence-unit>
+</persistence></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_inheritancetest">InheritanceTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.inheritance;
+
+import junit.framework.TestCase;
+import org.superbiz.inheritance.Tower.Fit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+public class InheritanceTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put("wakeBoardDatabase", "new://Resource?type=DataSource");
+ p.put("wakeBoardDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("wakeBoardDatabase.JdbcUrl", "jdbc:hsqldb:mem:wakeBoarddb");
+
+ p.put("wakeBoardDatabaseUnmanaged", "new://Resource?type=DataSource");
+ p.put("wakeBoardDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("wakeBoardDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:wakeBoarddb");
+ p.put("wakeBoardDatabaseUnmanaged.JtaManaged", "false");
+
+ p.put("openejb.embedded.remotable", "true");
+
+ initialContext = new InitialContext(p);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Create a webservice client using wsdl url
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: webservice
+ public void testInheritanceViaWsInterface() throws Exception {
+ Service service = Service.create(
+ new URL("http://127.0.0.1:4204/WakeRiderImpl?wsdl"),
+ new QName("http://superbiz.org/wsdl", "InheritanceWsService"));
+ assertNotNull(service);
+
+ WakeRiderWs ws = service.getPort(WakeRiderWs.class);
+
+ Tower tower = createTower();
+ Item item = createItem();
+ Wakeboard wakeBoard = createWakeBoard();
+ WakeboardBinding wakeBoardbinding = createWakeboardBinding();
+
+ ws.addItem(tower);
+ ws.addItem(item);
+ ws.addItem(wakeBoard);
+ ws.addItem(wakeBoardbinding);
+
+
+ List<Item> returnedItems = ws.getItems();
+
+ assertEquals("testInheritanceViaWsInterface, nb Items", 4, returnedItems.size());
+
+ //check tower
+ assertEquals("testInheritanceViaWsInterface, first Item", returnedItems.get(0).getClass(), Tower.class);
+ tower = (Tower) returnedItems.get(0);
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getBrand(), "Tower brand");
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getFit().ordinal(), Fit.Custom.ordinal());
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getItemName(), "Tower item name");
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getPrice(), 1.0d);
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getTubing(), "Tower tubing");
+
+ //check item
+ assertEquals("testInheritanceViaWsInterface, second Item", returnedItems.get(1).getClass(), Item.class);
+ item = (Item) returnedItems.get(1);
+ assertEquals("testInheritanceViaWsInterface, second Item", item.getBrand(), "Item brand");
+ assertEquals("testInheritanceViaWsInterface, second Item", item.getItemName(), "Item name");
+ assertEquals("testInheritanceViaWsInterface, second Item", item.getPrice(), 2.0d);
+
+ //check wakeboard
+ assertEquals("testInheritanceViaWsInterface, third Item", returnedItems.get(2).getClass(), Wakeboard.class);
+ wakeBoard = (Wakeboard) returnedItems.get(2);
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getBrand(), "Wakeboard brand");
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getItemName(), "Wakeboard item name");
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getPrice(), 3.0d);
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getSize(), "WakeBoard size");
+
+ //check wakeboardbinding
+ assertEquals("testInheritanceViaWsInterface, fourth Item", returnedItems.get(3).getClass(), WakeboardBinding.class);
+ wakeBoardbinding = (WakeboardBinding) returnedItems.get(3);
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getBrand(), "Wakeboardbinding brand");
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getItemName(), "Wakeboardbinding item name");
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getPrice(), 4.0d);
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getSize(), "WakeBoardbinding size");
+ }
+ //END SNIPPET: webservice
+
+ private Tower createTower() {
+ Tower tower = new Tower();
+ tower.setBrand("Tower brand");
+ tower.setFit(Fit.Custom);
+ tower.setItemName("Tower item name");
+ tower.setPrice(1.0f);
+ tower.setTubing("Tower tubing");
+ return tower;
+ }
+
+ private Item createItem() {
+ Item item = new Item();
+ item.setBrand("Item brand");
+ item.setItemName("Item name");
+ item.setPrice(2.0f);
+ return item;
+ }
+
+ private Wakeboard createWakeBoard() {
+ Wakeboard wakeBoard = new Wakeboard();
+ wakeBoard.setBrand("Wakeboard brand");
+ wakeBoard.setItemName("Wakeboard item name");
+ wakeBoard.setPrice(3.0f);
+ wakeBoard.setSize("WakeBoard size");
+ return wakeBoard;
+ }
+
+ private WakeboardBinding createWakeboardBinding() {
+ WakeboardBinding wakeBoardBinding = new WakeboardBinding();
+ wakeBoardBinding.setBrand("Wakeboardbinding brand");
+ wakeBoardBinding.setItemName("Wakeboardbinding item name");
+ wakeBoardBinding.setPrice(4.0f);
+ wakeBoardBinding.setSize("WakeBoardbinding size");
+ return wakeBoardBinding;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.inheritance.InheritanceTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/webservice-inheritance
+INFO - openejb.base = /Users/dblevins/examples/webservice-inheritance
+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 - Configuring Service(id=wakeBoardDatabaseUnmanaged, type=Resource, provider-id=Default JDBC Database)
+INFO - Configuring Service(id=wakeBoardDatabase, type=Resource, provider-id=Default JDBC Database)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/webservice-inheritance/target/classes
+INFO - Beginning load: /Users/dblevins/examples/webservice-inheritance/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-inheritance/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean WakeRiderImpl: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Configuring PersistenceUnit(name=wakeboard-unit)
+INFO - Enterprise application "/Users/dblevins/examples/webservice-inheritance/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/webservice-inheritance/classpath.ear
+INFO - PersistenceUnit(name=wakeboard-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 396ms
+INFO - Created Ejb(deployment-id=WakeRiderImpl, ejb-name=WakeRiderImpl, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=WakeRiderImpl, ejb-name=WakeRiderImpl, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/webservice-inheritance/classpath.ear)
+INFO - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Creating ServerService(id=cxf)
+INFO - Creating ServerService(id=admin)
+INFO - Creating ServerService(id=ejbd)
+INFO - Creating ServerService(id=ejbds)
+INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+-------
+Ready!
+WARN - Found no persistent property in "org.superbiz.inheritance.WakeboardBinding"
+WARN - Found no persistent property in "org.superbiz.inheritance.Wakeboard"
+WARN - Found no persistent property in "org.superbiz.inheritance.WakeboardBinding"
+WARN - Found no persistent property in "org.superbiz.inheritance.Wakeboard"
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.442 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/webservice-inheritance.pdf b/content/examples/webservice-inheritance.pdf
new file mode 100644
index 0000000..13a31c7
--- /dev/null
+++ b/content/examples/webservice-inheritance.pdf
Binary files differ
diff --git a/content/examples/webservice-inheritance/README.md b/content/examples/webservice-inheritance/README.md
new file mode 100755
index 0000000..ca95cbc
--- /dev/null
+++ b/content/examples/webservice-inheritance/README.md
@@ -0,0 +1,414 @@
+Title: Webservice Inheritance
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## Item
+
+ package org.superbiz.inheritance;
+
+ import javax.persistence.Entity;
+ import javax.persistence.GeneratedValue;
+ import javax.persistence.GenerationType;
+ import javax.persistence.Id;
+ import javax.persistence.Inheritance;
+ import javax.persistence.InheritanceType;
+ import java.io.Serializable;
+
+ @Entity
+ @Inheritance(strategy = InheritanceType.JOINED)
+ public class Item implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+ private String brand;
+ private String itemName;
+ private double price;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public String getItemName() {
+ return itemName;
+ }
+
+ public void setItemName(String itemName) {
+ this.itemName = itemName;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+ }
+
+## Tower
+
+ package org.superbiz.inheritance;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Tower extends Item {
+ private Fit fit;
+ private String tubing;
+
+ public static enum Fit {
+ Custom, Exact, Universal
+ }
+
+ public Fit getFit() {
+ return fit;
+ }
+
+ public void setFit(Fit fit) {
+ this.fit = fit;
+ }
+
+ public String getTubing() {
+ return tubing;
+ }
+
+ public void setTubing(String tubing) {
+ this.tubing = tubing;
+ }
+
+ ;
+ }
+
+## Wakeboard
+
+ package org.superbiz.inheritance;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class Wakeboard extends Wearable {
+ }
+
+## WakeboardBinding
+
+ package org.superbiz.inheritance;
+
+ import javax.persistence.Entity;
+
+ @Entity
+ public class WakeboardBinding extends Wearable {
+ }
+
+## WakeRiderImpl
+
+ package org.superbiz.inheritance;
+
+ import javax.ejb.Stateless;
+ import javax.jws.WebService;
+ import javax.persistence.EntityManager;
+ import javax.persistence.PersistenceContext;
+ import javax.persistence.PersistenceContextType;
+ import javax.persistence.Query;
+ import java.util.List;
+
+ /**
+ * This is an EJB 3 style pojo stateless session bean Every stateless session
+ * bean implementation must be annotated using the annotation @Stateless This
+ * EJB has a single interface: {@link WakeRiderWs} a webservice interface.
+ */
+ @Stateless
+ @WebService(
+ portName = "InheritancePort",
+ serviceName = "InheritanceWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.inheritance.WakeRiderWs")
+ public class WakeRiderImpl implements WakeRiderWs {
+
+ @PersistenceContext(unitName = "wakeboard-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addItem(Item item) throws Exception {
+ entityManager.persist(item);
+ }
+
+ public void deleteMovie(Item item) throws Exception {
+ entityManager.remove(item);
+ }
+
+ public List<Item> getItems() throws Exception {
+ Query query = entityManager.createQuery("SELECT i FROM Item i");
+ List<Item> items = query.getResultList();
+ return items;
+ }
+ }
+
+## WakeRiderWs
+
+ package org.superbiz.inheritance;
+
+ import javax.jws.WebService;
+ import javax.xml.bind.annotation.XmlSeeAlso;
+ import java.util.List;
+
+ /**
+ * This is an EJB 3 webservice interface that uses inheritance.
+ */
+ @WebService(targetNamespace = "http://superbiz.org/wsdl")
+ @XmlSeeAlso({Wakeboard.class, WakeboardBinding.class, Tower.class})
+ public interface WakeRiderWs {
+ public void addItem(Item item) throws Exception;
+
+ public void deleteMovie(Item item) throws Exception;
+
+ public List<Item> getItems() throws Exception;
+ }
+
+## Wearable
+
+ package org.superbiz.inheritance;
+
+ import javax.persistence.MappedSuperclass;
+
+ @MappedSuperclass
+ public abstract class Wearable extends Item {
+ protected String size;
+
+ public String getSize() {
+ return size;
+ }
+
+ public void setSize(String size) {
+ this.size = size;
+ }
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar/>
+
+
+## persistence.xml
+
+ <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="wakeboard-unit">
+
+ <jta-data-source>wakeBoardDatabase</jta-data-source>
+ <non-jta-data-source>wakeBoardDatabaseUnmanaged</non-jta-data-source>
+
+ <class>org.superbiz.inheritance.Item</class>
+ <class>org.superbiz.inheritance.Tower</class>
+ <class>org.superbiz.inheritance.Wakeboard</class>
+ <class>org.superbiz.inheritance.WakeboardBinding</class>
+ <class>org.superbiz.inheritance.Wearable</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+
+ </persistence-unit>
+ </persistence>
+
+## InheritanceTest
+
+ package org.superbiz.inheritance;
+
+ import junit.framework.TestCase;
+ import org.superbiz.inheritance.Tower.Fit;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.xml.namespace.QName;
+ import javax.xml.ws.Service;
+ import java.net.URL;
+ import java.util.List;
+ import java.util.Properties;
+
+ public class InheritanceTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put("wakeBoardDatabase", "new://Resource?type=DataSource");
+ p.put("wakeBoardDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("wakeBoardDatabase.JdbcUrl", "jdbc:hsqldb:mem:wakeBoarddb");
+
+ p.put("wakeBoardDatabaseUnmanaged", "new://Resource?type=DataSource");
+ p.put("wakeBoardDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("wakeBoardDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:wakeBoarddb");
+ p.put("wakeBoardDatabaseUnmanaged.JtaManaged", "false");
+
+ p.put("openejb.embedded.remotable", "true");
+
+ initialContext = new InitialContext(p);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Create a webservice client using wsdl url
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: webservice
+ public void testInheritanceViaWsInterface() throws Exception {
+ Service service = Service.create(
+ new URL("http://127.0.0.1:4204/WakeRiderImpl?wsdl"),
+ new QName("http://superbiz.org/wsdl", "InheritanceWsService"));
+ assertNotNull(service);
+
+ WakeRiderWs ws = service.getPort(WakeRiderWs.class);
+
+ Tower tower = createTower();
+ Item item = createItem();
+ Wakeboard wakeBoard = createWakeBoard();
+ WakeboardBinding wakeBoardbinding = createWakeboardBinding();
+
+ ws.addItem(tower);
+ ws.addItem(item);
+ ws.addItem(wakeBoard);
+ ws.addItem(wakeBoardbinding);
+
+
+ List<Item> returnedItems = ws.getItems();
+
+ assertEquals("testInheritanceViaWsInterface, nb Items", 4, returnedItems.size());
+
+ //check tower
+ assertEquals("testInheritanceViaWsInterface, first Item", returnedItems.get(0).getClass(), Tower.class);
+ tower = (Tower) returnedItems.get(0);
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getBrand(), "Tower brand");
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getFit().ordinal(), Fit.Custom.ordinal());
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getItemName(), "Tower item name");
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getPrice(), 1.0d);
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getTubing(), "Tower tubing");
+
+ //check item
+ assertEquals("testInheritanceViaWsInterface, second Item", returnedItems.get(1).getClass(), Item.class);
+ item = (Item) returnedItems.get(1);
+ assertEquals("testInheritanceViaWsInterface, second Item", item.getBrand(), "Item brand");
+ assertEquals("testInheritanceViaWsInterface, second Item", item.getItemName(), "Item name");
+ assertEquals("testInheritanceViaWsInterface, second Item", item.getPrice(), 2.0d);
+
+ //check wakeboard
+ assertEquals("testInheritanceViaWsInterface, third Item", returnedItems.get(2).getClass(), Wakeboard.class);
+ wakeBoard = (Wakeboard) returnedItems.get(2);
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getBrand(), "Wakeboard brand");
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getItemName(), "Wakeboard item name");
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getPrice(), 3.0d);
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getSize(), "WakeBoard size");
+
+ //check wakeboardbinding
+ assertEquals("testInheritanceViaWsInterface, fourth Item", returnedItems.get(3).getClass(), WakeboardBinding.class);
+ wakeBoardbinding = (WakeboardBinding) returnedItems.get(3);
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getBrand(), "Wakeboardbinding brand");
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getItemName(), "Wakeboardbinding item name");
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getPrice(), 4.0d);
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getSize(), "WakeBoardbinding size");
+ }
+ //END SNIPPET: webservice
+
+ private Tower createTower() {
+ Tower tower = new Tower();
+ tower.setBrand("Tower brand");
+ tower.setFit(Fit.Custom);
+ tower.setItemName("Tower item name");
+ tower.setPrice(1.0f);
+ tower.setTubing("Tower tubing");
+ return tower;
+ }
+
+ private Item createItem() {
+ Item item = new Item();
+ item.setBrand("Item brand");
+ item.setItemName("Item name");
+ item.setPrice(2.0f);
+ return item;
+ }
+
+ private Wakeboard createWakeBoard() {
+ Wakeboard wakeBoard = new Wakeboard();
+ wakeBoard.setBrand("Wakeboard brand");
+ wakeBoard.setItemName("Wakeboard item name");
+ wakeBoard.setPrice(3.0f);
+ wakeBoard.setSize("WakeBoard size");
+ return wakeBoard;
+ }
+
+ private WakeboardBinding createWakeboardBinding() {
+ WakeboardBinding wakeBoardBinding = new WakeboardBinding();
+ wakeBoardBinding.setBrand("Wakeboardbinding brand");
+ wakeBoardBinding.setItemName("Wakeboardbinding item name");
+ wakeBoardBinding.setPrice(4.0f);
+ wakeBoardBinding.setSize("WakeBoardbinding size");
+ return wakeBoardBinding;
+ }
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.inheritance.InheritanceTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/webservice-inheritance
+ INFO - openejb.base = /Users/dblevins/examples/webservice-inheritance
+ 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 - Configuring Service(id=wakeBoardDatabaseUnmanaged, type=Resource, provider-id=Default JDBC Database)
+ INFO - Configuring Service(id=wakeBoardDatabase, type=Resource, provider-id=Default JDBC Database)
+ INFO - Found EjbModule in classpath: /Users/dblevins/examples/webservice-inheritance/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/webservice-inheritance/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-inheritance/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean WakeRiderImpl: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Configuring PersistenceUnit(name=wakeboard-unit)
+ INFO - Enterprise application "/Users/dblevins/examples/webservice-inheritance/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/webservice-inheritance/classpath.ear
+ INFO - PersistenceUnit(name=wakeboard-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 396ms
+ INFO - Created Ejb(deployment-id=WakeRiderImpl, ejb-name=WakeRiderImpl, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=WakeRiderImpl, ejb-name=WakeRiderImpl, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/webservice-inheritance/classpath.ear)
+ INFO - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Creating ServerService(id=cxf)
+ INFO - Creating ServerService(id=admin)
+ INFO - Creating ServerService(id=ejbd)
+ INFO - Creating ServerService(id=ejbds)
+ INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+ -------
+ Ready!
+ WARN - Found no persistent property in "org.superbiz.inheritance.WakeboardBinding"
+ WARN - Found no persistent property in "org.superbiz.inheritance.Wakeboard"
+ WARN - Found no persistent property in "org.superbiz.inheritance.WakeboardBinding"
+ WARN - Found no persistent property in "org.superbiz.inheritance.Wakeboard"
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.442 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/webservice-inheritance/pom.xml b/content/examples/webservice-inheritance/pom.xml
new file mode 100755
index 0000000..7f8e994
--- /dev/null
+++ b/content/examples/webservice-inheritance/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 751189 $ $Date: 2009-03-07 04:37:34 +0100 (sam., 07 mars 2009) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>webservice-inheritance</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Examples :: Webservice Inheritance</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- This is required on IBM JDKs (and potentially others) because saaj-impl depends
+ on Sun's internal copy of Xerces. See OPENEJB-1126. -->
+ <dependency>
+ <groupId>com.sun.xml.parsers</groupId>
+ <artifactId>jaxp-ri</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Item.java b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Item.java
new file mode 100755
index 0000000..919ea20
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Item.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.inheritance;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import java.io.Serializable;
+
+@Entity
+@Inheritance(strategy = InheritanceType.JOINED)
+public class Item implements Serializable {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+ private String brand;
+ private String itemName;
+ private double price;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public String getItemName() {
+ return itemName;
+ }
+
+ public void setItemName(String itemName) {
+ this.itemName = itemName;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+}
diff --git a/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Tower.java b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Tower.java
new file mode 100755
index 0000000..427f3c7
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Tower.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.inheritance;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Tower extends Item {
+
+ private Fit fit;
+ private String tubing;
+
+ public static enum Fit {
+ Custom,
+ Exact,
+ Universal
+ }
+
+ public Fit getFit() {
+ return fit;
+ }
+
+ public void setFit(Fit fit) {
+ this.fit = fit;
+ }
+
+ public String getTubing() {
+ return tubing;
+ }
+
+ public void setTubing(String tubing) {
+ this.tubing = tubing;
+ }
+
+ ;
+}
\ No newline at end of file
diff --git a/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/WakeRiderImpl.java b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/WakeRiderImpl.java
new file mode 100755
index 0000000..0c76eb1
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/WakeRiderImpl.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.inheritance;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean Every stateless session
+ * bean implementation must be annotated using the annotation @Stateless This
+ * EJB has a single interface: {@link WakeRiderWs} a webservice interface.
+ */
+@Stateless
+@WebService(
+ portName = "InheritancePort",
+ serviceName = "InheritanceWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.inheritance.WakeRiderWs")
+public class WakeRiderImpl implements WakeRiderWs {
+
+ @PersistenceContext(unitName = "wakeboard-unit", type = PersistenceContextType.TRANSACTION)
+ private EntityManager entityManager;
+
+ public void addItem(Item item) throws Exception {
+ entityManager.persist(item);
+ }
+
+ public void deleteMovie(Item item) throws Exception {
+ entityManager.remove(item);
+ }
+
+ public List<Item> getItems() throws Exception {
+ Query query = entityManager.createQuery("SELECT i FROM Item i");
+ List<Item> items = query.getResultList();
+ return items;
+ }
+}
diff --git a/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/WakeRiderWs.java b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/WakeRiderWs.java
new file mode 100755
index 0000000..372caa4
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/WakeRiderWs.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.inheritance;
+
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import java.util.List;
+
+/**
+ * This is an EJB 3 webservice interface that uses inheritance.
+ */
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+@XmlSeeAlso({Wakeboard.class, WakeboardBinding.class, Tower.class})
+public interface WakeRiderWs {
+
+ public void addItem(Item item) throws Exception;
+
+ public void deleteMovie(Item item) throws Exception;
+
+ public List<Item> getItems() throws Exception;
+}
diff --git a/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Wakeboard.java b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Wakeboard.java
new file mode 100755
index 0000000..231115d
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Wakeboard.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.inheritance;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Wakeboard extends Wearable {
+
+}
diff --git a/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/WakeboardBinding.java b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/WakeboardBinding.java
new file mode 100755
index 0000000..def1c0e
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/WakeboardBinding.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.inheritance;
+
+import javax.persistence.Entity;
+
+@Entity
+public class WakeboardBinding extends Wearable {
+
+}
diff --git a/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Wearable.java b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Wearable.java
new file mode 100755
index 0000000..6db5073
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/main/java/org/superbiz/inheritance/Wearable.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.inheritance;
+
+import javax.persistence.MappedSuperclass;
+
+@MappedSuperclass
+public abstract class Wearable extends Item {
+
+ protected String size;
+
+ public String getSize() {
+ return size;
+ }
+
+ public void setSize(String size) {
+ this.size = size;
+ }
+}
diff --git a/content/examples/webservice-inheritance/src/main/resources/META-INF/ejb-jar.xml b/content/examples/webservice-inheritance/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..91be4f8
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
diff --git a/content/examples/webservice-inheritance/src/main/resources/META-INF/persistence.xml b/content/examples/webservice-inheritance/src/main/resources/META-INF/persistence.xml
new file mode 100755
index 0000000..4c5ccbf
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership. The
+ ASF licenses this file to You under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
+ law or agreed to in writing, software distributed under the License is
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="wakeboard-unit">
+
+ <jta-data-source>wakeBoardDatabase</jta-data-source>
+ <non-jta-data-source>wakeBoardDatabaseUnmanaged</non-jta-data-source>
+
+ <class>org.superbiz.inheritance.Item</class>
+ <class>org.superbiz.inheritance.Tower</class>
+ <class>org.superbiz.inheritance.Wakeboard</class>
+ <class>org.superbiz.inheritance.WakeboardBinding</class>
+ <class>org.superbiz.inheritance.Wearable</class>
+
+ <properties>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ </properties>
+
+ </persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/content/examples/webservice-inheritance/src/test/java/org/superbiz/inheritance/InheritanceTest.java b/content/examples/webservice-inheritance/src/test/java/org/superbiz/inheritance/InheritanceTest.java
new file mode 100755
index 0000000..0adb975
--- /dev/null
+++ b/content/examples/webservice-inheritance/src/test/java/org/superbiz/inheritance/InheritanceTest.java
@@ -0,0 +1,157 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.inheritance;
+
+import junit.framework.TestCase;
+import org.superbiz.inheritance.Tower.Fit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+public class InheritanceTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ //Random port to avoid test conflicts
+ private static final int port = Integer.parseInt(System.getProperty("httpejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+ protected void setUp() throws Exception {
+
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put("wakeBoardDatabase", "new://Resource?type=DataSource");
+ p.put("wakeBoardDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("wakeBoardDatabase.JdbcUrl", "jdbc:hsqldb:mem:wakeBoarddb");
+
+ p.put("wakeBoardDatabaseUnmanaged", "new://Resource?type=DataSource");
+ p.put("wakeBoardDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("wakeBoardDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:wakeBoarddb");
+ p.put("wakeBoardDatabaseUnmanaged.JtaManaged", "false");
+
+ p.put("openejb.embedded.remotable", "true");
+
+ //Just for this test we change the default port from 4204 to avoid conflicts
+ p.put("httpejbd.port", "" + port);
+
+ initialContext = new InitialContext(p);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Create a webservice client using wsdl url
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: webservice
+ public void testInheritanceViaWsInterface() throws Exception {
+ Service service = Service.create(
+ new URL("http://localhost:" + port + "/webservice-inheritance/WakeRiderImpl?wsdl"),
+ new QName("http://superbiz.org/wsdl", "InheritanceWsService"));
+ assertNotNull(service);
+
+ WakeRiderWs ws = service.getPort(WakeRiderWs.class);
+
+ Tower tower = createTower();
+ Item item = createItem();
+ Wakeboard wakeBoard = createWakeBoard();
+ WakeboardBinding wakeBoardbinding = createWakeboardBinding();
+
+ ws.addItem(tower);
+ ws.addItem(item);
+ ws.addItem(wakeBoard);
+ ws.addItem(wakeBoardbinding);
+
+ List<Item> returnedItems = ws.getItems();
+
+ assertEquals("testInheritanceViaWsInterface, nb Items", 4, returnedItems.size());
+
+ //check tower
+ assertEquals("testInheritanceViaWsInterface, first Item", returnedItems.get(0).getClass(), Tower.class);
+ tower = (Tower) returnedItems.get(0);
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getBrand(), "Tower brand");
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getFit().ordinal(), Fit.Custom.ordinal());
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getItemName(), "Tower item name");
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getPrice(), 1.0d);
+ assertEquals("testInheritanceViaWsInterface, first Item", tower.getTubing(), "Tower tubing");
+
+ //check item
+ assertEquals("testInheritanceViaWsInterface, second Item", returnedItems.get(1).getClass(), Item.class);
+ item = (Item) returnedItems.get(1);
+ assertEquals("testInheritanceViaWsInterface, second Item", item.getBrand(), "Item brand");
+ assertEquals("testInheritanceViaWsInterface, second Item", item.getItemName(), "Item name");
+ assertEquals("testInheritanceViaWsInterface, second Item", item.getPrice(), 2.0d);
+
+ //check wakeboard
+ assertEquals("testInheritanceViaWsInterface, third Item", returnedItems.get(2).getClass(), Wakeboard.class);
+ wakeBoard = (Wakeboard) returnedItems.get(2);
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getBrand(), "Wakeboard brand");
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getItemName(), "Wakeboard item name");
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getPrice(), 3.0d);
+ assertEquals("testInheritanceViaWsInterface, third Item", wakeBoard.getSize(), "WakeBoard size");
+
+ //check wakeboardbinding
+ assertEquals("testInheritanceViaWsInterface, fourth Item", returnedItems.get(3).getClass(), WakeboardBinding.class);
+ wakeBoardbinding = (WakeboardBinding) returnedItems.get(3);
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getBrand(), "Wakeboardbinding brand");
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getItemName(), "Wakeboardbinding item name");
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getPrice(), 4.0d);
+ assertEquals("testInheritanceViaWsInterface, fourth Item", wakeBoardbinding.getSize(), "WakeBoardbinding size");
+ }
+ //END SNIPPET: webservice
+
+ private Tower createTower() {
+ Tower tower = new Tower();
+ tower.setBrand("Tower brand");
+ tower.setFit(Fit.Custom);
+ tower.setItemName("Tower item name");
+ tower.setPrice(1.0f);
+ tower.setTubing("Tower tubing");
+ return tower;
+ }
+
+ private Item createItem() {
+ Item item = new Item();
+ item.setBrand("Item brand");
+ item.setItemName("Item name");
+ item.setPrice(2.0f);
+ return item;
+ }
+
+ private Wakeboard createWakeBoard() {
+ Wakeboard wakeBoard = new Wakeboard();
+ wakeBoard.setBrand("Wakeboard brand");
+ wakeBoard.setItemName("Wakeboard item name");
+ wakeBoard.setPrice(3.0f);
+ wakeBoard.setSize("WakeBoard size");
+ return wakeBoard;
+ }
+
+ private WakeboardBinding createWakeboardBinding() {
+ WakeboardBinding wakeBoardBinding = new WakeboardBinding();
+ wakeBoardBinding.setBrand("Wakeboardbinding brand");
+ wakeBoardBinding.setItemName("Wakeboardbinding item name");
+ wakeBoardBinding.setPrice(4.0f);
+ wakeBoardBinding.setSize("WakeBoardbinding size");
+ return wakeBoardBinding;
+ }
+}
diff --git a/content/examples/webservice-security.html b/content/examples/webservice-security.html
new file mode 100644
index 0000000..7ad65ed
--- /dev/null
+++ b/content/examples/webservice-security.html
@@ -0,0 +1,420 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/webservice-security.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Webservice Security</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example webservice-security can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/webservice-security" class="bare">https://github.com/apache/tomee/tree/master/examples/webservice-security</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorimpl">CalculatorImpl</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: CalculatorWs a webservice interface.
+ */
+//START SNIPPET: code
+@DeclareRoles(value = {"Administrator"})
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.CalculatorWs")
+public class CalculatorImpl implements CalculatorWs, CalculatorRemote {
+
+ @RolesAllowed(value = {"Administrator"})
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ @RolesAllowed(value = {"Administrator"})
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorremote">CalculatorRemote</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface CalculatorRemote {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorws">CalculatorWs</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import javax.jws.WebService;
+
+//END SNIPPET: code
+
+/**
+ * This is an EJB 3 webservice interface
+ * A webservice interface must be annotated with the @Local
+ * annotation.
+ */
+//START SNIPPET: code
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar/></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_openejb_jar_xml">openejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><openejb-jar xmlns="http://tomee.apache.org/xml/ns/openejb-jar-2.2">
+ <enterprise-beans>
+ <session>
+ <ejb-name>CalculatorImpl</ejb-name>
+ <web-service-security>
+ <security-realm-name/>
+ <transport-guarantee>NONE</transport-guarantee>
+ <auth-method>BASIC</auth-method>
+ </web-service-security>
+ </session>
+ </enterprise-beans>
+</openejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatortest">CalculatorTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ initialContext = new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Create a webservice client using wsdl url
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: webservice
+ public void testCalculatorViaWsInterface() throws Exception {
+ URL url = new URL("http://127.0.0.1:4204/CalculatorImpl?wsdl");
+ QName calcServiceQName = new QName("http://superbiz.org/wsdl", "CalculatorWsService");
+ Service calcService = Service.create(url, calcServiceQName);
+ assertNotNull(calcService);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+ ((BindingProvider) calc).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jane");
+ ((BindingProvider) calc).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "waterfall");
+ assertEquals(10, calc.sum(4, 6));
+ assertEquals(12, calc.multiply(3, 4));
+ }
+ //END SNIPPET: webservice
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.calculator.CalculatorTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/webservice-security
+INFO - openejb.base = /Users/dblevins/examples/webservice-security
+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/webservice-security/target/classes
+INFO - Beginning load: /Users/dblevins/examples/webservice-security/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-security/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean CalculatorImpl: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "/Users/dblevins/examples/webservice-security/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/webservice-security/classpath.ear
+INFO - Jndi(name=CalculatorImplRemote) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/webservice-security/CalculatorImpl!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/webservice-security/CalculatorImpl) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Created Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/webservice-security/classpath.ear)
+INFO - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Creating ServerService(id=cxf)
+INFO - Creating ServerService(id=admin)
+INFO - Creating ServerService(id=ejbd)
+INFO - Creating ServerService(id=ejbds)
+INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+-------
+Ready!
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.481 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/webservice-security.pdf b/content/examples/webservice-security.pdf
new file mode 100644
index 0000000..24119f0
--- /dev/null
+++ b/content/examples/webservice-security.pdf
Binary files differ
diff --git a/content/examples/webservice-security/README.md b/content/examples/webservice-security/README.md
new file mode 100755
index 0000000..700d1ec
--- /dev/null
+++ b/content/examples/webservice-security/README.md
@@ -0,0 +1,191 @@
+Title: Webservice Security
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## CalculatorImpl
+
+ package org.superbiz.calculator;
+
+ import javax.annotation.security.DeclareRoles;
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.Stateless;
+ import javax.jws.WebService;
+
+ /**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: CalculatorWs a webservice interface.
+ */
+ //START SNIPPET: code
+ @DeclareRoles(value = {"Administrator"})
+ @Stateless
+ @WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.CalculatorWs")
+ public class CalculatorImpl implements CalculatorWs, CalculatorRemote {
+
+ @RolesAllowed(value = {"Administrator"})
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ @RolesAllowed(value = {"Administrator"})
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+ }
+
+## CalculatorRemote
+
+ package org.superbiz.calculator;
+
+ import javax.ejb.Remote;
+
+ @Remote
+ public interface CalculatorRemote {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+ }
+
+## CalculatorWs
+
+ package org.superbiz.calculator;
+
+ import javax.jws.WebService;
+
+ //END SNIPPET: code
+
+ /**
+ * This is an EJB 3 webservice interface
+ * A webservice interface must be annotated with the @Local
+ * annotation.
+ */
+ //START SNIPPET: code
+ @WebService(targetNamespace = "http://superbiz.org/wsdl")
+ public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar/>
+
+## openejb-jar.xml
+
+ <openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2">
+ <enterprise-beans>
+ <session>
+ <ejb-name>CalculatorImpl</ejb-name>
+ <web-service-security>
+ <security-realm-name/>
+ <transport-guarantee>NONE</transport-guarantee>
+ <auth-method>BASIC</auth-method>
+ </web-service-security>
+ </session>
+ </enterprise-beans>
+ </openejb-jar>
+
+## CalculatorTest
+
+ package org.superbiz.calculator;
+
+ import junit.framework.TestCase;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.xml.namespace.QName;
+ import javax.xml.ws.BindingProvider;
+ import javax.xml.ws.Service;
+ import java.net.URL;
+ import java.util.Properties;
+
+ public class CalculatorTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ initialContext = new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Create a webservice client using wsdl url
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: webservice
+ public void testCalculatorViaWsInterface() throws Exception {
+ URL url = new URL("http://127.0.0.1:4204/CalculatorImpl?wsdl");
+ QName calcServiceQName = new QName("http://superbiz.org/wsdl", "CalculatorWsService");
+ Service calcService = Service.create(url, calcServiceQName);
+ assertNotNull(calcService);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+ ((BindingProvider) calc).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jane");
+ ((BindingProvider) calc).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "waterfall");
+ assertEquals(10, calc.sum(4, 6));
+ assertEquals(12, calc.multiply(3, 4));
+ }
+ //END SNIPPET: webservice
+ }
+
+# Running
+
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.calculator.CalculatorTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/webservice-security
+ INFO - openejb.base = /Users/dblevins/examples/webservice-security
+ 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/webservice-security/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/webservice-security/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-security/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean CalculatorImpl: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "/Users/dblevins/examples/webservice-security/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/webservice-security/classpath.ear
+ INFO - Jndi(name=CalculatorImplRemote) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Jndi(name=global/classpath.ear/webservice-security/CalculatorImpl!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Jndi(name=global/classpath.ear/webservice-security/CalculatorImpl) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Created Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/webservice-security/classpath.ear)
+ INFO - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Creating ServerService(id=cxf)
+ INFO - Creating ServerService(id=admin)
+ INFO - Creating ServerService(id=ejbd)
+ INFO - Creating ServerService(id=ejbds)
+ INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+ -------
+ Ready!
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.481 sec
+
+ Results :
+
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/webservice-security/pom.xml b/content/examples/webservice-security/pom.xml
new file mode 100755
index 0000000..b02d30b
--- /dev/null
+++ b/content/examples/webservice-security/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 684173 $ $Date: 2008-08-08 20:13:24 -0700 (Fri, 08 Aug 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>webservice-security</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: EJB WebService with Security</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- This is required on IBM JDKs (and potentially others) because saaj-impl depends
+ on Sun's internal copy of Xerces. See OPENEJB-1126. -->
+ <dependency>
+ <groupId>com.sun.xml.parsers</groupId>
+ <artifactId>jaxp-ri</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>
diff --git a/content/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java b/content/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java
new file mode 100755
index 0000000..cab94a1
--- /dev/null
+++ b/content/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: CalculatorWs a webservice interface.
+ */
+//START SNIPPET: code
+@DeclareRoles(value = {"Administrator"})
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.CalculatorWs")
+public class CalculatorImpl implements CalculatorWs, CalculatorRemote {
+
+ @RolesAllowed(value = {"Administrator"})
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ @RolesAllowed(value = {"Administrator"})
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+
+}
+//END SNIPPET: code
\ No newline at end of file
diff --git a/content/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java b/content/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
new file mode 100755
index 0000000..31149f2
--- /dev/null
+++ b/content/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface CalculatorRemote {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+
+}
diff --git a/content/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorWs.java b/content/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorWs.java
new file mode 100755
index 0000000..8feb08f
--- /dev/null
+++ b/content/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorWs.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import javax.jws.WebService;
+
+//END SNIPPET: code
+
+/**
+ * This is an EJB 3 webservice interface
+ * A webservice interface must be annotated with the @Local
+ * annotation.
+ */
+//START SNIPPET: code
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}
+//END SNIPPET: code
\ No newline at end of file
diff --git a/content/examples/webservice-security/src/main/resources/META-INF/ejb-jar.xml b/content/examples/webservice-security/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..433757b
--- /dev/null
+++ b/content/examples/webservice-security/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1 @@
+<ejb-jar/>
\ No newline at end of file
diff --git a/content/examples/webservice-security/src/main/resources/META-INF/openejb-jar.xml b/content/examples/webservice-security/src/main/resources/META-INF/openejb-jar.xml
new file mode 100755
index 0000000..977f3f5
--- /dev/null
+++ b/content/examples/webservice-security/src/main/resources/META-INF/openejb-jar.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2">
+ <enterprise-beans>
+ <session>
+ <ejb-name>CalculatorImpl</ejb-name>
+ <web-service-security>
+ <security-realm-name/>
+ <transport-guarantee>NONE</transport-guarantee>
+ <auth-method>BASIC</auth-method>
+ </web-service-security>
+ </session>
+ </enterprise-beans>
+</openejb-jar>
\ No newline at end of file
diff --git a/content/examples/webservice-security/src/test/java/org/superbiz/calculator/CalculatorTest.java b/content/examples/webservice-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
new file mode 100755
index 0000000..ef226e7
--- /dev/null
+++ b/content/examples/webservice-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+ //START SNIPPET: setup
+ private InitialContext initialContext;
+
+ //Random port to avoid test conflicts
+ private static final int port = Integer.parseInt(System.getProperty("httpejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ //Just for this test we change the default port from 4204 to avoid conflicts
+ properties.setProperty("httpejbd.port", "" + port);
+
+ initialContext = new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ /**
+ * Create a webservice client using wsdl url
+ *
+ * @throws Exception
+ */
+ //START SNIPPET: webservice
+ public void testCalculatorViaWsInterface() throws Exception {
+ URL url = new URL("http://localhost:" + port + "/webservice-security/CalculatorImpl?wsdl");
+ QName calcServiceQName = new QName("http://superbiz.org/wsdl", "CalculatorWsService");
+ Service calcService = Service.create(url, calcServiceQName);
+ assertNotNull(calcService);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+ ((BindingProvider) calc).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jane");
+ ((BindingProvider) calc).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "waterfall");
+ assertEquals(10, calc.sum(4, 6));
+ assertEquals(12, calc.multiply(3, 4));
+ }
+ //END SNIPPET: webservice
+
+}
diff --git a/content/examples/webservice-security/src/test/resources/groups.properties b/content/examples/webservice-security/src/test/resources/groups.properties
new file mode 100755
index 0000000..116ec08
--- /dev/null
+++ b/content/examples/webservice-security/src/test/resources/groups.properties
@@ -0,0 +1 @@
+Administrator=jane,joe
diff --git a/content/examples/webservice-security/src/test/resources/users.properties b/content/examples/webservice-security/src/test/resources/users.properties
new file mode 100755
index 0000000..acb4a5d
--- /dev/null
+++ b/content/examples/webservice-security/src/test/resources/users.properties
@@ -0,0 +1,2 @@
+joe=cool
+jane=waterfall
\ No newline at end of file
diff --git a/content/examples/webservice-ws-security.html b/content/examples/webservice-ws-security.html
new file mode 100644
index 0000000..9438a4b
--- /dev/null
+++ b/content/examples/webservice-ws-security.html
@@ -0,0 +1,964 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/webservice-ws-security.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>Webservice Ws Security</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Example webservice-ws-security can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/webservice-ws-security" class="bare">https://github.com/apache/tomee/tree/master/examples/webservice-ws-security</a></p>
+</div>
+<div class="paragraph">
+<p><strong>Help us document this example! Click the blue pencil icon in the upper right to edit this page.</strong></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorimpl">CalculatorImpl</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: CalculatorWs a webservice interface.
+ */
+//START SNIPPET: code
+@DeclareRoles(value = {"Administrator"})
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.CalculatorWs")
+public class CalculatorImpl implements CalculatorWs, CalculatorRemote {
+
+ @RolesAllowed(value = {"Administrator"})
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorremote">CalculatorRemote</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface CalculatorRemote {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatorws">CalculatorWs</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import javax.jws.WebService;
+
+//END SNIPPET: code
+
+/**
+ * This is an EJB 3 webservice interface
+ * A webservice interface must be annotated with the @Local
+ * annotation.
+ */
+//START SNIPPET: code
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ejb_jar_xml">ejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><ejb-jar 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/ejb-jar_3_0.xsd"
+ version="3.0" id="simple" metadata-complete="false">
+
+ <enterprise-beans>
+
+ <session>
+ <ejb-name>CalculatorImplTimestamp1way</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplTimestamp2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplUsernameTokenPlainPassword</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplUsernameTokenHashedPassword</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplUsernameTokenPlainPasswordEncrypt</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplSign</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplEncrypt2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplSign2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplEncryptAndSign2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ </enterprise-beans>
+
+</ejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_openejb_jar_xml">openejb-jar.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
+
+ <ejb-deployment ejb-name="CalculatorImpl">
+ <properties>
+ # webservice.security.realm
+ # webservice.security.securityRealm
+ # webservice.security.transportGarantee = NONE
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken
+ wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass = org.superbiz.calculator.CustomPasswordHandler
+
+ # automatically added
+ wss4j.in.validator.{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken = org.apache.openejb.server.cxf.OpenEJBLoginValidator
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplTimestamp1way">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = Timestamp
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplTimestamp2ways">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = Timestamp
+ wss4j.out.action = Timestamp
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplUsernameTokenPlainPassword">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken
+ wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplUsernameTokenHashedPassword">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken
+ wss4j.in.passwordType = PasswordDigest
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplUsernameTokenPlainPasswordEncrypt">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken Encrypt
+ wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ wss4j.in.decryptionPropFile = META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-server.properties
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplSign">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = Signature
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ wss4j.in.signaturePropFile = META-INF/CalculatorImplSign-server.properties
+ </properties>
+ </ejb-deployment>
+
+</openejb-jar></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_webservices_xml">webservices.xml</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><webservices xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"
+ xmlns:ger="http://ciaows.org/wsdl" version="1.1">
+
+ <webservice-description>
+ <webservice-description-name>CalculatorWsService</webservice-description-name>
+ <port-component>
+ <port-component-name>CalculatorImplTimestamp1way</port-component-name>
+ <wsdl-port>CalculatorImplTimestamp1way</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplTimestamp1way</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplTimestamp2ways</port-component-name>
+ <wsdl-port>CalculatorImplTimestamp2ways</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplTimestamp2ways</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplUsernameTokenPlainPassword</port-component-name>
+ <wsdl-port>CalculatorImplUsernameTokenPlainPassword</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplUsernameTokenPlainPassword</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplUsernameTokenHashedPassword</port-component-name>
+ <wsdl-port>CalculatorImplUsernameTokenHashedPassword</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplUsernameTokenHashedPassword</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplUsernameTokenPlainPasswordEncrypt</port-component-name>
+ <wsdl-port>CalculatorImplUsernameTokenPlainPasswordEncrypt</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplUsernameTokenPlainPasswordEncrypt</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ </webservice-description>
+
+</webservices></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_calculatortest">CalculatorTest</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import junit.framework.TestCase;
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
+import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSPasswordCallback;
+import org.apache.ws.security.handler.WSHandlerConstants;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+ //START SNIPPET: setup
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ //START SNIPPET: webservice
+ public void testCalculatorViaWsInterface() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImpl?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithTimestamp1way() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplTimestamp1way?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplTimestamp1way");
+
+// CalculatorWs calc = calcService.getPort(
+// new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+// CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(12, calc.multiply(3, 4));
+ }
+
+ public void testCalculatorViaWsInterfaceWithTimestamp2ways() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplTimestamp2ways?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplTimestamp2ways");
+
+// CalculatorWs calc = calcService.getPort(
+// new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+// CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+ endpoint.getInInterceptors().add(new SAAJInInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ Map<String, Object> inProps = new HashMap<String, Object>();
+ inProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+ WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
+ endpoint.getInInterceptors().add(wssIn);
+
+ assertEquals(12, calc.multiply(3, 4));
+ }
+
+ public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPassword() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplUsernameTokenPlainPassword?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPassword");
+
+// CalculatorWs calc = calcService.getPort(
+// new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+// CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithUsernameTokenHashedPassword() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplUsernameTokenHashedPassword?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplUsernameTokenHashedPassword");
+
+// CalculatorWs calc = calcService.getPort(
+// new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+// CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPasswordEncrypt() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplUsernameTokenPlainPasswordEncrypt?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPasswordEncrypt");
+
+// CalculatorWs calc = calcService.getPort(
+// new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+// CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN
+ + " " + WSHandlerConstants.ENCRYPT);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+ outProps.put(WSHandlerConstants.ENC_PROP_FILE, "META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-client.properties");
+ outProps.put(WSHandlerConstants.ENCRYPTION_USER, "serveralias");
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithSign() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplSign?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplSign");
+
+// CalculatorWs calc = calcService.getPort(
+// new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+// CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+ outProps.put(WSHandlerConstants.USER, "clientalias");
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("clientPassword");
+ }
+ });
+ outProps.put(WSHandlerConstants.SIG_PROP_FILE, "META-INF/CalculatorImplSign-client.properties");
+ outProps.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(24, calc.multiply(4, 6));
+ }
+ //END SNIPPET: webservice
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_custompasswordhandler">CustomPasswordHandler</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package org.superbiz.calculator;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.IOException;
+
+public class CustomPasswordHandler implements CallbackHandler {
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+
+ if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) {
+ // TODO get the password from the users.properties if possible
+ pc.setPassword("waterfall");
+ } else if (pc.getUsage() == WSPasswordCallback.DECRYPT) {
+ pc.setPassword("serverPassword");
+ } else if (pc.getUsage() == WSPasswordCallback.SIGNATURE) {
+ pc.setPassword("serverPassword");
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="literalblock">
+<div class="content">
+<pre>generate keys:</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>do.sun.jdk:
+ [echo] *** Running on a Sun JDK ***
+ [echo] generate server keys
+ [java] Certificate stored in file </Users/dblevins/examples/webservice-ws-security/target/classes/META-INF/serverKey.rsa>
+ [echo] generate client keys
+ [java] Certificate stored in file </Users/dblevins/examples/webservice-ws-security/target/test-classes/META-INF/clientKey.rsa>
+ [echo] import client/server public keys in client/server keystores
+ [java] Certificate was added to keystore
+ [java] Certificate was added to keystore</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>do.ibm.jdk:</pre>
+</div>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>run:
+ [echo] Running JDK specific keystore creation target</pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="prettyprint highlight"><code>-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.calculator.CalculatorTest
+Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/webservice-ws-security
+INFO - openejb.base = /Users/dblevins/examples/webservice-ws-security
+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/webservice-ws-security/target/classes
+INFO - Beginning load: /Users/dblevins/examples/webservice-ws-security/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-ws-security/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean CalculatorImplTimestamp1way: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "/Users/dblevins/examples/webservice-ws-security/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/webservice-ws-security/classpath.ear
+INFO - Jndi(name=CalculatorImplTimestamp1wayRemote) --> Ejb(deployment-id=CalculatorImplTimestamp1way)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplTimestamp1way!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplTimestamp1way)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplTimestamp1way) --> Ejb(deployment-id=CalculatorImplTimestamp1way)
+INFO - Jndi(name=CalculatorImplTimestamp2waysRemote) --> Ejb(deployment-id=CalculatorImplTimestamp2ways)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplTimestamp2ways!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplTimestamp2ways)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplTimestamp2ways) --> Ejb(deployment-id=CalculatorImplTimestamp2ways)
+INFO - Jndi(name=CalculatorImplUsernameTokenPlainPasswordRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenPlainPassword!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenPlainPassword) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword)
+INFO - Jndi(name=CalculatorImplUsernameTokenHashedPasswordRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenHashedPassword!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenHashedPassword) --> Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword)
+INFO - Jndi(name=CalculatorImplUsernameTokenPlainPasswordEncryptRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenPlainPasswordEncrypt!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenPlainPasswordEncrypt) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt)
+INFO - Jndi(name=CalculatorImplSignRemote) --> Ejb(deployment-id=CalculatorImplSign)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplSign!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplSign)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplSign) --> Ejb(deployment-id=CalculatorImplSign)
+INFO - Jndi(name=CalculatorImplEncrypt2waysRemote) --> Ejb(deployment-id=CalculatorImplEncrypt2ways)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplEncrypt2ways!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplEncrypt2ways)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplEncrypt2ways) --> Ejb(deployment-id=CalculatorImplEncrypt2ways)
+INFO - Jndi(name=CalculatorImplSign2waysRemote) --> Ejb(deployment-id=CalculatorImplSign2ways)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplSign2ways!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplSign2ways)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplSign2ways) --> Ejb(deployment-id=CalculatorImplSign2ways)
+INFO - Jndi(name=CalculatorImplEncryptAndSign2waysRemote) --> Ejb(deployment-id=CalculatorImplEncryptAndSign2ways)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplEncryptAndSign2ways!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplEncryptAndSign2ways)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplEncryptAndSign2ways) --> Ejb(deployment-id=CalculatorImplEncryptAndSign2ways)
+INFO - Jndi(name=CalculatorImplRemote) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImpl!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/simple/CalculatorImpl) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Created Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword, ejb-name=CalculatorImplUsernameTokenHashedPassword, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=CalculatorImplSign, ejb-name=CalculatorImplSign, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=CalculatorImplEncryptAndSign2ways, ejb-name=CalculatorImplEncryptAndSign2ways, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=CalculatorImplTimestamp1way, ejb-name=CalculatorImplTimestamp1way, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=CalculatorImplSign2ways, ejb-name=CalculatorImplSign2ways, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=CalculatorImplEncrypt2ways, ejb-name=CalculatorImplEncrypt2ways, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword, ejb-name=CalculatorImplUsernameTokenPlainPassword, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=CalculatorImplTimestamp2ways, ejb-name=CalculatorImplTimestamp2ways, container=Default Stateless Container)
+INFO - Created Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt, ejb-name=CalculatorImplUsernameTokenPlainPasswordEncrypt, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword, ejb-name=CalculatorImplUsernameTokenHashedPassword, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImplSign, ejb-name=CalculatorImplSign, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImplEncryptAndSign2ways, ejb-name=CalculatorImplEncryptAndSign2ways, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImplTimestamp1way, ejb-name=CalculatorImplTimestamp1way, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImplSign2ways, ejb-name=CalculatorImplSign2ways, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImplEncrypt2ways, ejb-name=CalculatorImplEncrypt2ways, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword, ejb-name=CalculatorImplUsernameTokenPlainPassword, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImplTimestamp2ways, ejb-name=CalculatorImplTimestamp2ways, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt, ejb-name=CalculatorImplUsernameTokenPlainPasswordEncrypt, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/webservice-ws-security/classpath.ear)
+INFO - Initializing network services
+INFO - Creating ServerService(id=httpejbd)
+INFO - Creating ServerService(id=cxf)
+INFO - Creating ServerService(id=admin)
+INFO - Creating ServerService(id=ejbd)
+INFO - Creating ServerService(id=ejbds)
+INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+-------
+Ready!
+Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.582 sec
+
+Results :
+
+Tests run: 7, Failures: 0, Errors: 0, Skipped: 0</code></pre>
+</div>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/webservice-ws-security.pdf b/content/examples/webservice-ws-security.pdf
new file mode 100644
index 0000000..58e6a22
--- /dev/null
+++ b/content/examples/webservice-ws-security.pdf
Binary files differ
diff --git a/content/examples/webservice-ws-security/README.md b/content/examples/webservice-ws-security/README.md
new file mode 100755
index 0000000..0f5ab21
--- /dev/null
+++ b/content/examples/webservice-ws-security/README.md
@@ -0,0 +1,714 @@
+Title: Webservice Ws Security
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+## CalculatorImpl
+
+ package org.superbiz.calculator;
+
+ import javax.annotation.security.DeclareRoles;
+ import javax.annotation.security.RolesAllowed;
+ import javax.ejb.Stateless;
+ import javax.jws.WebService;
+
+ /**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: CalculatorWs a webservice interface.
+ */
+ //START SNIPPET: code
+ @DeclareRoles(value = {"Administrator"})
+ @Stateless
+ @WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.CalculatorWs")
+ public class CalculatorImpl implements CalculatorWs, CalculatorRemote {
+
+ @RolesAllowed(value = {"Administrator"})
+ public int sum(int add1, int add2) {
+ return add1 + add2;
+ }
+
+ public int multiply(int mul1, int mul2) {
+ return mul1 * mul2;
+ }
+ }
+
+## CalculatorRemote
+
+ package org.superbiz.calculator;
+
+ import javax.ejb.Remote;
+
+ @Remote
+ public interface CalculatorRemote {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+ }
+
+## CalculatorWs
+
+ package org.superbiz.calculator;
+
+ import javax.jws.WebService;
+
+ //END SNIPPET: code
+
+ /**
+ * This is an EJB 3 webservice interface
+ * A webservice interface must be annotated with the @Local
+ * annotation.
+ */
+ //START SNIPPET: code
+ @WebService(targetNamespace = "http://superbiz.org/wsdl")
+ public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+ }
+
+## ejb-jar.xml
+
+ <ejb-jar 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/ejb-jar_3_0.xsd"
+ version="3.0" id="simple" metadata-complete="false">
+
+ <enterprise-beans>
+
+ <session>
+ <ejb-name>CalculatorImplTimestamp1way</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplTimestamp2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplUsernameTokenPlainPassword</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplUsernameTokenHashedPassword</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplUsernameTokenPlainPasswordEncrypt</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplSign</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplEncrypt2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplSign2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplEncryptAndSign2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ </enterprise-beans>
+
+ </ejb-jar>
+
+
+## openejb-jar.xml
+
+ <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
+
+ <ejb-deployment ejb-name="CalculatorImpl">
+ <properties>
+ # webservice.security.realm
+ # webservice.security.securityRealm
+ # webservice.security.transportGarantee = NONE
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken
+ wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass = org.superbiz.calculator.CustomPasswordHandler
+
+ # automatically added
+ wss4j.in.validator.{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken = org.apache.openejb.server.cxf.OpenEJBLoginValidator
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplTimestamp1way">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = Timestamp
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplTimestamp2ways">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = Timestamp
+ wss4j.out.action = Timestamp
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplUsernameTokenPlainPassword">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken
+ wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplUsernameTokenHashedPassword">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken
+ wss4j.in.passwordType = PasswordDigest
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplUsernameTokenPlainPasswordEncrypt">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken Encrypt
+ wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ wss4j.in.decryptionPropFile = META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-server.properties
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplSign">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = Signature
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ wss4j.in.signaturePropFile = META-INF/CalculatorImplSign-server.properties
+ </properties>
+ </ejb-deployment>
+
+ </openejb-jar>
+
+
+## webservices.xml
+
+ <webservices xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"
+ xmlns:ger="http://ciaows.org/wsdl" version="1.1">
+
+ <webservice-description>
+ <webservice-description-name>CalculatorWsService</webservice-description-name>
+ <port-component>
+ <port-component-name>CalculatorImplTimestamp1way</port-component-name>
+ <wsdl-port>CalculatorImplTimestamp1way</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplTimestamp1way</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplTimestamp2ways</port-component-name>
+ <wsdl-port>CalculatorImplTimestamp2ways</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplTimestamp2ways</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplUsernameTokenPlainPassword</port-component-name>
+ <wsdl-port>CalculatorImplUsernameTokenPlainPassword</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplUsernameTokenPlainPassword</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplUsernameTokenHashedPassword</port-component-name>
+ <wsdl-port>CalculatorImplUsernameTokenHashedPassword</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplUsernameTokenHashedPassword</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplUsernameTokenPlainPasswordEncrypt</port-component-name>
+ <wsdl-port>CalculatorImplUsernameTokenPlainPasswordEncrypt</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplUsernameTokenPlainPasswordEncrypt</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ </webservice-description>
+
+ </webservices>
+
+
+## CalculatorTest
+
+ package org.superbiz.calculator;
+
+ import junit.framework.TestCase;
+ import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
+ import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+ import org.apache.cxf.endpoint.Client;
+ import org.apache.cxf.endpoint.Endpoint;
+ import org.apache.cxf.frontend.ClientProxy;
+ import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
+ import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+ import org.apache.ws.security.WSConstants;
+ import org.apache.ws.security.WSPasswordCallback;
+ import org.apache.ws.security.handler.WSHandlerConstants;
+
+ import javax.naming.Context;
+ import javax.naming.InitialContext;
+ import javax.security.auth.callback.Callback;
+ import javax.security.auth.callback.CallbackHandler;
+ import javax.security.auth.callback.UnsupportedCallbackException;
+ import javax.xml.namespace.QName;
+ import javax.xml.ws.Service;
+ import javax.xml.ws.soap.SOAPBinding;
+ import java.io.IOException;
+ import java.net.URL;
+ import java.util.HashMap;
+ import java.util.Map;
+ import java.util.Properties;
+
+ public class CalculatorTest extends TestCase {
+
+ //START SNIPPET: setup
+ protected void setUp() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ //START SNIPPET: webservice
+ public void testCalculatorViaWsInterface() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImpl?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithTimestamp1way() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplTimestamp1way?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplTimestamp1way");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(12, calc.multiply(3, 4));
+ }
+
+ public void testCalculatorViaWsInterfaceWithTimestamp2ways() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplTimestamp2ways?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplTimestamp2ways");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+ endpoint.getInInterceptors().add(new SAAJInInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ Map<String, Object> inProps = new HashMap<String, Object>();
+ inProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+ WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
+ endpoint.getInInterceptors().add(wssIn);
+
+ assertEquals(12, calc.multiply(3, 4));
+ }
+
+ public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPassword() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplUsernameTokenPlainPassword?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPassword");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithUsernameTokenHashedPassword() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplUsernameTokenHashedPassword?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplUsernameTokenHashedPassword");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPasswordEncrypt() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplUsernameTokenPlainPasswordEncrypt?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPasswordEncrypt");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN
+ + " " + WSHandlerConstants.ENCRYPT);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+ outProps.put(WSHandlerConstants.ENC_PROP_FILE, "META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-client.properties");
+ outProps.put(WSHandlerConstants.ENCRYPTION_USER, "serveralias");
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithSign() throws Exception {
+ Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImplSign?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplSign");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ Client client = ClientProxy.getClient(calc);
+ Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+ outProps.put(WSHandlerConstants.USER, "clientalias");
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("clientPassword");
+ }
+ });
+ outProps.put(WSHandlerConstants.SIG_PROP_FILE, "META-INF/CalculatorImplSign-client.properties");
+ outProps.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
+
+ WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(24, calc.multiply(4, 6));
+ }
+ //END SNIPPET: webservice
+ }
+
+## CustomPasswordHandler
+
+ package org.superbiz.calculator;
+
+ import org.apache.ws.security.WSPasswordCallback;
+
+ import javax.security.auth.callback.Callback;
+ import javax.security.auth.callback.CallbackHandler;
+ import javax.security.auth.callback.UnsupportedCallbackException;
+ import java.io.IOException;
+
+ public class CustomPasswordHandler implements CallbackHandler {
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+
+ if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) {
+ // TODO get the password from the users.properties if possible
+ pc.setPassword("waterfall");
+ } else if (pc.getUsage() == WSPasswordCallback.DECRYPT) {
+ pc.setPassword("serverPassword");
+ } else if (pc.getUsage() == WSPasswordCallback.SIGNATURE) {
+ pc.setPassword("serverPassword");
+ }
+ }
+ }
+
+# Running
+
+
+ generate keys:
+
+ do.sun.jdk:
+ [echo] *** Running on a Sun JDK ***
+ [echo] generate server keys
+ [java] Certificate stored in file </Users/dblevins/examples/webservice-ws-security/target/classes/META-INF/serverKey.rsa>
+ [echo] generate client keys
+ [java] Certificate stored in file </Users/dblevins/examples/webservice-ws-security/target/test-classes/META-INF/clientKey.rsa>
+ [echo] import client/server public keys in client/server keystores
+ [java] Certificate was added to keystore
+ [java] Certificate was added to keystore
+
+ do.ibm.jdk:
+
+ run:
+ [echo] Running JDK specific keystore creation target
+
+ -------------------------------------------------------
+ T E S T S
+ -------------------------------------------------------
+ Running org.superbiz.calculator.CalculatorTest
+ Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06
+ http://openejb.apache.org/
+ INFO - openejb.home = /Users/dblevins/examples/webservice-ws-security
+ INFO - openejb.base = /Users/dblevins/examples/webservice-ws-security
+ 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/webservice-ws-security/target/classes
+ INFO - Beginning load: /Users/dblevins/examples/webservice-ws-security/target/classes
+ INFO - Configuring enterprise application: /Users/dblevins/examples/webservice-ws-security/classpath.ear
+ INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+ INFO - Auto-creating a container for bean CalculatorImplTimestamp1way: Container(type=STATELESS, id=Default Stateless Container)
+ INFO - Enterprise application "/Users/dblevins/examples/webservice-ws-security/classpath.ear" loaded.
+ INFO - Assembling app: /Users/dblevins/examples/webservice-ws-security/classpath.ear
+ INFO - Jndi(name=CalculatorImplTimestamp1wayRemote) --> Ejb(deployment-id=CalculatorImplTimestamp1way)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplTimestamp1way!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplTimestamp1way)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplTimestamp1way) --> Ejb(deployment-id=CalculatorImplTimestamp1way)
+ INFO - Jndi(name=CalculatorImplTimestamp2waysRemote) --> Ejb(deployment-id=CalculatorImplTimestamp2ways)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplTimestamp2ways!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplTimestamp2ways)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplTimestamp2ways) --> Ejb(deployment-id=CalculatorImplTimestamp2ways)
+ INFO - Jndi(name=CalculatorImplUsernameTokenPlainPasswordRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenPlainPassword!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenPlainPassword) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword)
+ INFO - Jndi(name=CalculatorImplUsernameTokenHashedPasswordRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenHashedPassword!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenHashedPassword) --> Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword)
+ INFO - Jndi(name=CalculatorImplUsernameTokenPlainPasswordEncryptRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenPlainPasswordEncrypt!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplUsernameTokenPlainPasswordEncrypt) --> Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt)
+ INFO - Jndi(name=CalculatorImplSignRemote) --> Ejb(deployment-id=CalculatorImplSign)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplSign!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplSign)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplSign) --> Ejb(deployment-id=CalculatorImplSign)
+ INFO - Jndi(name=CalculatorImplEncrypt2waysRemote) --> Ejb(deployment-id=CalculatorImplEncrypt2ways)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplEncrypt2ways!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplEncrypt2ways)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplEncrypt2ways) --> Ejb(deployment-id=CalculatorImplEncrypt2ways)
+ INFO - Jndi(name=CalculatorImplSign2waysRemote) --> Ejb(deployment-id=CalculatorImplSign2ways)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplSign2ways!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplSign2ways)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplSign2ways) --> Ejb(deployment-id=CalculatorImplSign2ways)
+ INFO - Jndi(name=CalculatorImplEncryptAndSign2waysRemote) --> Ejb(deployment-id=CalculatorImplEncryptAndSign2ways)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplEncryptAndSign2ways!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImplEncryptAndSign2ways)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImplEncryptAndSign2ways) --> Ejb(deployment-id=CalculatorImplEncryptAndSign2ways)
+ INFO - Jndi(name=CalculatorImplRemote) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImpl!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Jndi(name=global/classpath.ear/simple/CalculatorImpl) --> Ejb(deployment-id=CalculatorImpl)
+ INFO - Created Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword, ejb-name=CalculatorImplUsernameTokenHashedPassword, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=CalculatorImplSign, ejb-name=CalculatorImplSign, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=CalculatorImplEncryptAndSign2ways, ejb-name=CalculatorImplEncryptAndSign2ways, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=CalculatorImplTimestamp1way, ejb-name=CalculatorImplTimestamp1way, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=CalculatorImplSign2ways, ejb-name=CalculatorImplSign2ways, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=CalculatorImplEncrypt2ways, ejb-name=CalculatorImplEncrypt2ways, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword, ejb-name=CalculatorImplUsernameTokenPlainPassword, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=CalculatorImplTimestamp2ways, ejb-name=CalculatorImplTimestamp2ways, container=Default Stateless Container)
+ INFO - Created Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt, ejb-name=CalculatorImplUsernameTokenPlainPasswordEncrypt, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImplUsernameTokenHashedPassword, ejb-name=CalculatorImplUsernameTokenHashedPassword, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImplSign, ejb-name=CalculatorImplSign, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImplEncryptAndSign2ways, ejb-name=CalculatorImplEncryptAndSign2ways, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImplTimestamp1way, ejb-name=CalculatorImplTimestamp1way, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImplSign2ways, ejb-name=CalculatorImplSign2ways, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImplEncrypt2ways, ejb-name=CalculatorImplEncrypt2ways, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImplUsernameTokenPlainPassword, ejb-name=CalculatorImplUsernameTokenPlainPassword, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImplTimestamp2ways, ejb-name=CalculatorImplTimestamp2ways, container=Default Stateless Container)
+ INFO - Started Ejb(deployment-id=CalculatorImplUsernameTokenPlainPasswordEncrypt, ejb-name=CalculatorImplUsernameTokenPlainPasswordEncrypt, container=Default Stateless Container)
+ INFO - Deployed Application(path=/Users/dblevins/examples/webservice-ws-security/classpath.ear)
+ INFO - Initializing network services
+ INFO - Creating ServerService(id=httpejbd)
+ INFO - Creating ServerService(id=cxf)
+ INFO - Creating ServerService(id=admin)
+ INFO - Creating ServerService(id=ejbd)
+ INFO - Creating ServerService(id=ejbds)
+ INFO - Initializing network services
+ ** Starting Services **
+ NAME IP PORT
+ httpejbd 127.0.0.1 4204
+ admin thread 127.0.0.1 4200
+ ejbd 127.0.0.1 4201
+ ejbd 127.0.0.1 4203
+ -------
+ Ready!
+ Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.582 sec
+
+ Results :
+
+ Tests run: 7, Failures: 0, Errors: 0, Skipped: 0
+
diff --git a/content/examples/webservice-ws-security/create-keystores.xml b/content/examples/webservice-ws-security/create-keystores.xml
new file mode 100755
index 0000000..cfd0cbf
--- /dev/null
+++ b/content/examples/webservice-ws-security/create-keystores.xml
@@ -0,0 +1,198 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<project default="run" name="create keystores et al">
+
+ <!-- first create our properties -->
+ <condition property="is.ibm.jdk">
+ <available classname="com.ibm.crypto.tools.KeyTool"/>
+ </condition>
+ <condition property="is.sun.jdk">
+ <available classname="sun.security.tools.KeyTool"/>
+ </condition>
+ <property name="server.alias" value="serveralias"/>
+ <property name="server.keypass" value="serverPassword"/>
+ <property name="server.keystore" value="${basedir}/target/classes/META-INF/serverStore.jks"/>
+ <property name="server.storepass" value="keystorePass"/>
+ <property name="server.dname" value="'cn=serveralias'"/>
+ <property name="server.file" value="${basedir}/target/classes/META-INF/serverKey.rsa"/>
+
+ <property name="client.alias" value="clientalias"/>
+ <property name="client.keypass" value="clientPassword"/>
+ <property name="client.keystore" value="${basedir}/target/test-classes/META-INF/clientStore.jks"/>
+ <property name="client.storepass" value="keystorePass"/>
+ <property name="client.dname" value="'cn=clientalias'"/>
+ <property name="client.file" value="${basedir}/target/test-classes/META-INF/clientKey.rsa"/>
+
+ <property name="keyalg" value="RSA"/>
+
+ <!-- now create our JDK specific targets -->
+ <target name="do.ibm.jdk" if="is.ibm.jdk">
+ <echo message="*** Running on an IBM JDK ***"/>
+ <echo message="generate server keys"/>
+ <java classname="com.ibm.crypto.tools.KeyTool" fork="true">
+ <arg line="-genkey"/>
+ <arg line="-alias ${server.alias}"/>
+ <arg line="-keypass ${server.keypass}"/>
+ <arg line="-keystore ${server.keystore}"/>
+ <arg line="-storepass ${server.storepass}"/>
+ <arg line="-dname ${server.dname}"/>
+ <arg line="-keyalg ${keyalg}"/>
+ </java>
+ <java classname="com.ibm.crypto.tools.KeyTool" fork="true">
+ <arg line="-selfcert"/>
+ <arg line="-alias ${server.alias}"/>
+ <arg line="-keystore ${server.keystore}"/>
+ <arg line="-storepass ${server.storepass}"/>
+ <arg line="-keypass ${server.keypass}"/>
+ </java>
+ <java classname="com.ibm.crypto.tools.KeyTool" fork="true">
+ <arg line="-export"/>
+ <arg line="-alias ${server.alias}"/>
+ <arg line="-file ${server.file}"/>
+ <arg line="-keystore ${server.keystore}"/>
+ <arg line="-storepass ${server.storepass}"/>
+ </java>
+
+ <echo message="generate client keys"/>
+
+ <java classname="com.ibm.crypto.tools.KeyTool" fork="true">
+ <arg line="-genkey"/>
+ <arg line="-alias ${client.alias}"/>
+ <arg line="-keypass ${client.keypass}"/>
+ <arg line="-keystore ${client.keystore}"/>
+ <arg line="-storepass ${client.storepass}"/>
+ <arg line="-dname ${client.dname}"/>
+ <arg line="-keyalg ${keyalg}"/>
+ </java>
+ <java classname="com.ibm.crypto.tools.KeyTool" fork="true">
+ <arg line="-selfcert"/>
+ <arg line="-alias ${client.alias}"/>
+ <arg line="-keystore ${client.keystore}"/>
+ <arg line="-storepass ${client.storepass}"/>
+ <arg line="-keypass ${client.keypass}"/>
+ </java>
+ <java classname="com.ibm.crypto.tools.KeyTool" fork="true">
+ <arg line="-export"/>
+ <arg line="-alias ${client.alias}"/>
+ <arg line="-file ${client.file}"/>
+ <arg line="-keystore ${client.keystore}"/>
+ <arg line="-storepass ${client.storepass}"/>
+ </java>
+
+ <echo message="import client/server public keys in client/server keystores"/>
+ <java classname="com.ibm.crypto.tools.KeyTool" fork="true">
+ <arg line="-import"/>
+ <arg line="-alias ${server.alias}"/>
+ <arg line="-file ${server.file}"/>
+ <arg line="-keystore ${client.keystore}"/>
+ <arg line="-storepass ${client.storepass}"/>
+ <arg line="-noprompt"/>
+ </java>
+ <java classname="com.ibm.crypto.tools.KeyTool" fork="true">
+ <arg line="-import"/>
+ <arg line="-alias ${client.alias}"/>
+ <arg line="-file ${client.file}"/>
+ <arg line="-keystore ${server.keystore}"/>
+ <arg line="-storepass ${server.storepass}"/>
+ <arg line="-noprompt"/>
+ </java>
+ </target>
+
+ <target name="do.sun.jdk" if="is.sun.jdk">
+ <echo message="*** Running on a Sun JDK ***"/>
+ <echo message="generate server keys"/>
+ <java classname="sun.security.tools.KeyTool" fork="true">
+ <arg line="-genkey"/>
+ <arg line="-alias ${server.alias}"/>
+ <arg line="-keypass ${server.keypass}"/>
+ <arg line="-keystore ${server.keystore}"/>
+ <arg line="-storepass ${server.storepass}"/>
+ <arg line="-dname ${server.dname}"/>
+ <arg line="-keyalg ${keyalg}"/>
+ </java>
+ <java classname="sun.security.tools.KeyTool" fork="true">
+ <arg line="-selfcert"/>
+ <arg line="-alias ${server.alias}"/>
+ <arg line="-keystore ${server.keystore}"/>
+ <arg line="-storepass ${server.storepass}"/>
+ <arg line="-keypass ${server.keypass}"/>
+ </java>
+ <java classname="sun.security.tools.KeyTool" fork="true">
+ <arg line="-export"/>
+ <arg line="-alias ${server.alias}"/>
+ <arg line="-file ${server.file}"/>
+ <arg line="-keystore ${server.keystore}"/>
+ <arg line="-storepass ${server.storepass}"/>
+ </java>
+
+ <echo message="generate client keys"/>
+
+ <java classname="sun.security.tools.KeyTool" fork="true">
+ <arg line="-genkey"/>
+ <arg line="-alias ${client.alias}"/>
+ <arg line="-keypass ${client.keypass}"/>
+ <arg line="-keystore ${client.keystore}"/>
+ <arg line="-storepass ${client.storepass}"/>
+ <arg line="-dname ${client.dname}"/>
+ <arg line="-keyalg ${keyalg}"/>
+ </java>
+ <java classname="sun.security.tools.KeyTool" fork="true">
+ <arg line="-selfcert"/>
+ <arg line="-alias ${client.alias}"/>
+ <arg line="-keystore ${client.keystore}"/>
+ <arg line="-storepass ${client.storepass}"/>
+ <arg line="-keypass ${client.keypass}"/>
+ </java>
+ <java classname="sun.security.tools.KeyTool" fork="true">
+ <arg line="-export"/>
+ <arg line="-alias ${client.alias}"/>
+ <arg line="-file ${client.file}"/>
+ <arg line="-keystore ${client.keystore}"/>
+ <arg line="-storepass ${client.storepass}"/>
+ </java>
+
+ <echo message="import client/server public keys in client/server keystores"/>
+ <java classname="sun.security.tools.KeyTool" fork="true">
+ <arg line="-import"/>
+ <arg line="-alias ${server.alias}"/>
+ <arg line="-file ${server.file}"/>
+ <arg line="-keystore ${client.keystore}"/>
+ <arg line="-storepass ${client.storepass}"/>
+ <arg line="-noprompt"/>
+ </java>
+ <java classname="sun.security.tools.KeyTool" fork="true">
+ <arg line="-import"/>
+ <arg line="-alias ${client.alias}"/>
+ <arg line="-file ${client.file}"/>
+ <arg line="-keystore ${server.keystore}"/>
+ <arg line="-storepass ${server.storepass}"/>
+ <arg line="-noprompt"/>
+ </java>
+ </target>
+
+ <!-- run everything from our main target -->
+ <!-- the other targets will only be run when their properties are true -->
+ <target name="run" depends="do.sun.jdk, do.ibm.jdk">
+ <echo message="Running JDK specific keystore creation target"/>
+ </target>
+
+</project>
+
diff --git a/content/examples/webservice-ws-security/keys/generateKeyPair.bat b/content/examples/webservice-ws-security/keys/generateKeyPair.bat
new file mode 100755
index 0000000..ac58c92
--- /dev/null
+++ b/content/examples/webservice-ws-security/keys/generateKeyPair.bat
@@ -0,0 +1,31 @@
+@echo off
+REM================================================
+REM Licensed to the Apache Software Foundation (ASF) under one or more
+REM contributor license agreements. See the NOTICE file distributed with
+REM this work for additional information regarding copyright ownership.
+REM The ASF licenses this file to You under the Apache License, Version 2.0
+REM (the "License"); you may not use this file except in compliance with
+REM the License. You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+REM _______________________________________________
+REM $Rev: 636963 $ $Date: 2008-03-13 19:40:08 -0700 (Thu, 13 Mar 2008) $
+REM================================================
+
+rem @echo off
+echo alias %1
+echo keypass %2
+echo keystoreName %3
+echo KeyStorePass %4
+echo keyName %5
+
+echo keyName %5
+keytool -genkey -alias %1 -keypass %2 -keystore "%3" -storepass %4 -dname "cn=%1" -keyalg RSA
+keytool -selfcert -alias %1 -keystore "%3" -storepass %4 -keypass %2
+keytool -export -alias %1 -file %5 -keystore "%3" -storepass %4
diff --git a/content/examples/webservice-ws-security/keys/generateServerKey.bat b/content/examples/webservice-ws-security/keys/generateServerKey.bat
new file mode 100755
index 0000000..8ce997b
--- /dev/null
+++ b/content/examples/webservice-ws-security/keys/generateServerKey.bat
@@ -0,0 +1,24 @@
+@echo off
+REM================================================
+REM Licensed to the Apache Software Foundation (ASF) under one or more
+REM contributor license agreements. See the NOTICE file distributed with
+REM this work for additional information regarding copyright ownership.
+REM The ASF licenses this file to You under the Apache License, Version 2.0
+REM (the "License"); you may not use this file except in compliance with
+REM the License. You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+REM _______________________________________________
+REM $Rev: 636963 $ $Date: 2008-03-13 19:40:08 -0700 (Thu, 13 Mar 2008) $
+REM================================================
+
+call generateKeyPair.bat serveralias serverPassword serverStore.jks keystorePass serverKey.rsa
+call generateKeyPair.bat clientalias clientPassword clientStore.jks keystorePass clientKey.rsa
+keytool -import -alias serveralias -file serverKey.rsa -keystore clientStore.jks -storepass keystorePass -noprompt
+keytool -import -alias clientalias -file clientKey.rsa -keystore serverStore.jks -storepass keystorePass -noprompt
diff --git a/content/examples/webservice-ws-security/pom.xml b/content/examples/webservice-ws-security/pom.xml
new file mode 100755
index 0000000..d7a1708
--- /dev/null
+++ b/content/examples/webservice-ws-security/pom.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev: 684173 $ $Date: 2008-08-08 20:13:24 -0700 (Fri, 08 Aug 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>webservice-ws-security</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: EJB WebService with WS-Security</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-6</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--
+ The <scope>test</scope> guarantees that non of your runtime
+ code is dependent on any OpenEJB classes.
+ -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- This is required on IBM JDKs (and potentially others) because saaj-impl depends
+ on Sun's internal copy of Xerces. See OPENEJB-1126. -->
+ <dependency>
+ <groupId>com.sun.xml.parsers</groupId>
+ <artifactId>jaxp-ri</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.17</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clover-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <jdk>1.6</jdk>
+ <excludes>
+ <exclude>**/package-info.java</exclude>
+ </excludes>
+ <cloverOutputDirectory>${basedir}/target/cloverOut</cloverOutputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <id>site</id>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>instrument</goal>
+ <goal>aggregate</goal>
+ <goal>save-history</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <id>generate-keys</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target name="generate keys">
+ <ant antfile="create-keystores.xml" target="run"/>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java b/content/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java
new file mode 100755
index 0000000..fa5e800
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: CalculatorWs a webservice interface.
+ */
+//START SNIPPET: code
+@DeclareRoles(value = {"Administrator"})
+@Stateless
+@WebService(
+ portName = "CalculatorPort",
+ serviceName = "CalculatorWsService",
+ targetNamespace = "http://superbiz.org/wsdl",
+ endpointInterface = "org.superbiz.calculator.CalculatorWs")
+public class CalculatorImpl implements CalculatorWs, CalculatorRemote {
+
+ @Override
+ @RolesAllowed(value = {"Administrator"})
+ public int sum(final int add1, final int add2) {
+ return add1 + add2;
+ }
+
+ @Override
+ public int multiply(final int mul1, final int mul2) {
+ return mul1 * mul2;
+ }
+
+}
+//END SNIPPET: code
diff --git a/content/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java b/content/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
new file mode 100755
index 0000000..68fed28
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface CalculatorRemote {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+
+}
diff --git a/content/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorWs.java b/content/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorWs.java
new file mode 100755
index 0000000..8feb08f
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorWs.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import javax.jws.WebService;
+
+//END SNIPPET: code
+
+/**
+ * This is an EJB 3 webservice interface
+ * A webservice interface must be annotated with the @Local
+ * annotation.
+ */
+//START SNIPPET: code
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+ public int sum(int add1, int add2);
+
+ public int multiply(int mul1, int mul2);
+}
+//END SNIPPET: code
\ No newline at end of file
diff --git a/content/examples/webservice-ws-security/src/main/resources/META-INF/CalculatorImplSign-server.properties b/content/examples/webservice-ws-security/src/main/resources/META-INF/CalculatorImplSign-server.properties
new file mode 100755
index 0000000..5b36649
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/main/resources/META-INF/CalculatorImplSign-server.properties
@@ -0,0 +1,7 @@
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=keystorePass
+org.apache.ws.security.crypto.merlin.keystore.alias=serveralias
+org.apache.ws.security.crypto.merlin.file=META-INF/serverStore.jks
+# OPENEJB-1061 OpenJDK doesn't come with cacerts
+org.apache.ws.security.crypto.merlin.load.cacerts=false
diff --git a/content/examples/webservice-ws-security/src/main/resources/META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-server.properties b/content/examples/webservice-ws-security/src/main/resources/META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-server.properties
new file mode 100755
index 0000000..5b36649
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/main/resources/META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-server.properties
@@ -0,0 +1,7 @@
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=keystorePass
+org.apache.ws.security.crypto.merlin.keystore.alias=serveralias
+org.apache.ws.security.crypto.merlin.file=META-INF/serverStore.jks
+# OPENEJB-1061 OpenJDK doesn't come with cacerts
+org.apache.ws.security.crypto.merlin.load.cacerts=false
diff --git a/content/examples/webservice-ws-security/src/main/resources/META-INF/ejb-jar.xml b/content/examples/webservice-ws-security/src/main/resources/META-INF/ejb-jar.xml
new file mode 100755
index 0000000..19cd263
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/main/resources/META-INF/ejb-jar.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<ejb-jar 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/ejb-jar_3_0.xsd"
+ version="3.0" id="webservice-ws-security" metadata-complete="false">
+
+ <enterprise-beans>
+
+ <session>
+ <ejb-name>CalculatorImplTimestamp1way</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplTimestamp2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplUsernameTokenPlainPassword</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplUsernameTokenHashedPassword</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplUsernameTokenPlainPasswordEncrypt</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplSign</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplEncrypt2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplSign2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ <session>
+ <ejb-name>CalculatorImplEncryptAndSign2ways</ejb-name>
+ <service-endpoint>org.superbiz.calculator.CalculatorWs</service-endpoint>
+ <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Container</transaction-type>
+ </session>
+
+ </enterprise-beans>
+
+</ejb-jar>
diff --git a/content/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml b/content/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml
new file mode 100755
index 0000000..14a5b2b
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership. The
+ ASF licenses this file to You under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
+ law or agreed to in writing, software distributed under the License is
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+-->
+
+<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
+
+ <ejb-deployment ejb-name="CalculatorImpl">
+ <properties>
+ # webservice.security.realm
+ # webservice.security.securityRealm
+ # webservice.security.transportGarantee = NONE
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken
+ wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass = org.superbiz.calculator.CustomPasswordHandler
+
+ # automatically added
+ wss4j.in.validator.{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken = org.apache.openejb.server.cxf.OpenEJBLoginValidator
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplTimestamp1way">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = Timestamp
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplTimestamp2ways">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = Timestamp
+ wss4j.out.action = Timestamp
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplUsernameTokenPlainPassword">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken
+ wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplUsernameTokenHashedPassword">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken
+ wss4j.in.passwordType = PasswordDigest
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplUsernameTokenPlainPasswordEncrypt">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = UsernameToken Encrypt
+ wss4j.in.passwordType = PasswordText
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ wss4j.in.decryptionPropFile = META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-server.properties
+ </properties>
+ </ejb-deployment>
+ <ejb-deployment ejb-name="CalculatorImplSign">
+ <properties>
+ webservice.security.authMethod = WS-SECURITY
+ wss4j.in.action = Signature
+ wss4j.in.passwordCallbackClass=org.superbiz.calculator.CustomPasswordHandler
+ wss4j.in.signaturePropFile = META-INF/CalculatorImplSign-server.properties
+ </properties>
+ </ejb-deployment>
+
+</openejb-jar>
diff --git a/content/examples/webservice-ws-security/src/main/resources/META-INF/webservices.xml b/content/examples/webservice-ws-security/src/main/resources/META-INF/webservices.xml
new file mode 100755
index 0000000..db709b6
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/main/resources/META-INF/webservices.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership. The
+ ASF licenses this file to You under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
+ law or agreed to in writing, software distributed under the License is
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+-->
+<webservices xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"
+ version="1.1">
+
+ <webservice-description>
+ <webservice-description-name>CalculatorWsService</webservice-description-name>
+ <port-component>
+ <port-component-name>CalculatorImplTimestamp1way</port-component-name>
+ <wsdl-port>CalculatorImplTimestamp1way</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplTimestamp1way</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplTimestamp2ways</port-component-name>
+ <wsdl-port>CalculatorImplTimestamp2ways</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplTimestamp2ways</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplUsernameTokenPlainPassword</port-component-name>
+ <wsdl-port>CalculatorImplUsernameTokenPlainPassword</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplUsernameTokenPlainPassword</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplUsernameTokenHashedPassword</port-component-name>
+ <wsdl-port>CalculatorImplUsernameTokenHashedPassword</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplUsernameTokenHashedPassword</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ <port-component>
+ <port-component-name>CalculatorImplUsernameTokenPlainPasswordEncrypt</port-component-name>
+ <wsdl-port>CalculatorImplUsernameTokenPlainPasswordEncrypt</wsdl-port>
+ <service-endpoint-interface>org.superbiz.calculator.CalculatorWs</service-endpoint-interface>
+ <service-impl-bean>
+ <ejb-link>CalculatorImplUsernameTokenPlainPasswordEncrypt</ejb-link>
+ </service-impl-bean>
+ </port-component>
+ </webservice-description>
+
+</webservices>
diff --git a/content/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java b/content/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
new file mode 100755
index 0000000..9b9ecfa
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
@@ -0,0 +1,318 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import junit.framework.TestCase;
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
+import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSPasswordCallback;
+import org.apache.ws.security.handler.WSHandlerConstants;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+ //START SNIPPET: setup
+
+ //Random port to avoid test conflicts
+ private static final int port = Integer.parseInt(System.getProperty("httpejbd.port", "" + org.apache.openejb.util.NetworkUtil.getNextAvailablePort()));
+
+ @Override
+ protected void setUp() throws Exception {
+ final Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ properties.setProperty("openejb.embedded.remotable", "true");
+
+ //Just for this test we change the default port from 4204 to avoid conflicts
+ properties.setProperty("httpejbd.port", "" + port);
+
+ new InitialContext(properties);
+ }
+ //END SNIPPET: setup
+
+ //START SNIPPET: webservice
+ public void testCalculatorViaWsInterface() throws Exception {
+ final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImpl?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ final Client client = ClientProxy.getClient(calc);
+ final Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ final Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+
+ final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithTimestamp1way() throws Exception {
+ final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplTimestamp1way?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplTimestamp1way");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ final Client client = ClientProxy.getClient(calc);
+ final Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ final Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+ final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(12, calc.multiply(3, 4));
+ }
+
+ public void testCalculatorViaWsInterfaceWithTimestamp2ways() throws Exception {
+ final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplTimestamp2ways?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplTimestamp2ways");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ final Client client = ClientProxy.getClient(calc);
+ final Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+ endpoint.getInInterceptors().add(new SAAJInInterceptor());
+
+ final Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+ final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ final Map<String, Object> inProps = new HashMap<String, Object>();
+ inProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+ final WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
+ endpoint.getInInterceptors().add(wssIn);
+
+ assertEquals(12, calc.multiply(3, 4));
+ }
+
+ public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPassword() throws Exception {
+ final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenPlainPassword?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPassword");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ final Client client = ClientProxy.getClient(calc);
+ final Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ final Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+
+ final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithUsernameTokenHashedPassword() throws Exception {
+ final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenHashedPassword?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplUsernameTokenHashedPassword");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ final Client client = ClientProxy.getClient(calc);
+ final Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ final Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+
+ final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithUsernameTokenPlainPasswordEncrypt() throws Exception {
+ final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplUsernameTokenPlainPasswordEncrypt?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplUsernameTokenPlainPasswordEncrypt");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ final Client client = ClientProxy.getClient(calc);
+ final Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ final Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN
+ + " " + WSHandlerConstants.ENCRYPT);
+ outProps.put(WSHandlerConstants.USER, "jane");
+ outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("waterfall");
+ }
+ });
+ outProps.put(WSHandlerConstants.ENC_PROP_FILE, "META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-client.properties");
+ outProps.put(WSHandlerConstants.ENCRYPTION_USER, "serveralias");
+
+ final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(10, calc.sum(4, 6));
+ }
+
+ public void testCalculatorViaWsInterfaceWithSign() throws Exception {
+ final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplSign?wsdl"),
+ new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
+ assertNotNull(calcService);
+
+ // for debugging (ie. TCPMon)
+ calcService.addPort(new QName("http://superbiz.org/wsdl",
+ "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
+ "http://127.0.0.1:8204/CalculatorImplSign");
+
+ // CalculatorWs calc = calcService.getPort(
+ // new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
+ // CalculatorWs.class);
+
+ final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+ final Client client = ClientProxy.getClient(calc);
+ final Endpoint endpoint = client.getEndpoint();
+ endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+ final Map<String, Object> outProps = new HashMap<String, Object>();
+ outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+ outProps.put(WSHandlerConstants.USER, "clientalias");
+ outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+ @Override
+ public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("clientPassword");
+ }
+ });
+ outProps.put(WSHandlerConstants.SIG_PROP_FILE, "META-INF/CalculatorImplSign-client.properties");
+ outProps.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");
+
+ final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+ endpoint.getOutInterceptors().add(wssOut);
+
+ assertEquals(24, calc.multiply(4, 6));
+ }
+ //END SNIPPET: webservice
+}
diff --git a/content/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java b/content/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
new file mode 100755
index 0000000..fa6e4b2
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CustomPasswordHandler.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.calculator;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.IOException;
+
+public class CustomPasswordHandler implements CallbackHandler {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+
+ if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) {
+ // TODO get the password from the users.properties if possible
+ pc.setPassword("waterfall");
+
+ } else if (pc.getUsage() == WSPasswordCallback.DECRYPT) {
+ pc.setPassword("serverPassword");
+
+ } else if (pc.getUsage() == WSPasswordCallback.SIGNATURE) {
+ pc.setPassword("serverPassword");
+
+ }
+ }
+}
diff --git a/content/examples/webservice-ws-security/src/test/resources/META-INF/CalculatorImplSign-client.properties b/content/examples/webservice-ws-security/src/test/resources/META-INF/CalculatorImplSign-client.properties
new file mode 100755
index 0000000..350eaf9
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/test/resources/META-INF/CalculatorImplSign-client.properties
@@ -0,0 +1,7 @@
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=keystorePass
+org.apache.ws.security.crypto.merlin.keystore.alias=clientalias
+org.apache.ws.security.crypto.merlin.file=META-INF/clientStore.jks
+# OPENEJB-1061 OpenJDK doesn't come with cacerts
+org.apache.ws.security.crypto.merlin.load.cacerts=false
diff --git a/content/examples/webservice-ws-security/src/test/resources/META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-client.properties b/content/examples/webservice-ws-security/src/test/resources/META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-client.properties
new file mode 100755
index 0000000..350eaf9
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/test/resources/META-INF/CalculatorImplUsernameTokenPlainPasswordEncrypt-client.properties
@@ -0,0 +1,7 @@
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=keystorePass
+org.apache.ws.security.crypto.merlin.keystore.alias=clientalias
+org.apache.ws.security.crypto.merlin.file=META-INF/clientStore.jks
+# OPENEJB-1061 OpenJDK doesn't come with cacerts
+org.apache.ws.security.crypto.merlin.load.cacerts=false
diff --git a/content/examples/webservice-ws-security/src/test/resources/groups.properties b/content/examples/webservice-ws-security/src/test/resources/groups.properties
new file mode 100755
index 0000000..116ec08
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/test/resources/groups.properties
@@ -0,0 +1 @@
+Administrator=jane,joe
diff --git a/content/examples/webservice-ws-security/src/test/resources/users.properties b/content/examples/webservice-ws-security/src/test/resources/users.properties
new file mode 100755
index 0000000..acb4a5d
--- /dev/null
+++ b/content/examples/webservice-ws-security/src/test/resources/users.properties
@@ -0,0 +1,2 @@
+joe=cool
+jane=waterfall
\ No newline at end of file
diff --git a/content/examples/webservice-ws-with-resources-config.html b/content/examples/webservice-ws-with-resources-config.html
new file mode 100644
index 0000000..bf470f3
--- /dev/null
+++ b/content/examples/webservice-ws-with-resources-config.html
@@ -0,0 +1,192 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Apache TomEE</title>
+ <meta name="description" content="Apache TomEE is a light JavaEE server with a lot tooling" />
+ <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" />
+ <meta name="author" content="Luka Cvetinovic for Codrops" />
+ <link rel="icon" href="../favicon.ico">
+ <link rel="icon" type="image/png" href="../favicon.png">
+ <meta name="msapplication-TileColor" content="#80287a">
+ <meta name="theme-color" content="#80287a">
+ <link rel="stylesheet" type="text/css" href="../css/normalize.css">
+ <link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="../css/owl.css">
+ <link rel="stylesheet" type="text/css" href="../css/animate.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/font-awesome-4.1.0/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="../fonts/eleganticons/et-icons.css">
+ <link rel="stylesheet" type="text/css" href="../css/jqtree.css">
+ <link rel="stylesheet" type="text/css" href="../css/idea.css">
+ <link rel="stylesheet" type="text/css" href="../css/cardio.css">
+
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-2717626-1']);
+ _gaq.push(['_setDomainName', 'apache.org']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+ </script>
+</head>
+
+<body>
+ <div class="preloader">
+ <img src="../img/loader.gif" alt="Preloader image">
+ </div>
+ <nav class="navbar">
+ <div class="container">
+ <!-- Brand and toggle get grouped for better mobile display -->
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="..//#">
+ <span>
+
+
+ <img src="../img/logo-active.png">
+
+
+ </span>
+ Apache TomEE
+ </a>
+ </div>
+ <!-- Collect the nav links, forms, and other content for toggling -->
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+ <ul class="nav navbar-nav navbar-right main-nav">
+ <li><a href="../developer/index.html">Developer</a></li>
+ <li><a href="../admin/index.html">Admin</a></li>
+ <li><a href="../advanced/index.html">Advanced</a></li>
+ <li><a href="../security/index.html">Security</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
+ <li><a href="../blog/index.html">Blog</a></li>
+ <li><a href="../community/index.html">Community</a></li>
+ <li><a href="../download-ng.html">Downloads</a></li>
+ </ul>
+ </div>
+ <!-- /.navbar-collapse -->
+ </div>
+ <!-- /.container-fluid -->
+ </nav>
+
+
+ <div id="main-block" class="container section-padded">
+ <div class="row title">
+ <div class='page-header'>
+
+ <div class='btn-toolbar pull-right' style="z-index: 2000;">
+ <div class='btn-group'>
+ <a class="btn" href="../examples/webservice-ws-with-resources-config.pdf"><i class="fa fa-file-pdf-o"></i> Download as PDF</a>
+ </div>
+ </div>
+
+ <h2>webservice-ws-with-resources-config</h2>
+ </div>
+ </div>
+ <div class="row">
+
+ <div class="col-md-12">
+ <div class="paragraph">
+<p>Example webservice-ws-with-resources-config can be browsed at <a href="https://github.com/apache/tomee/tree/master/examples/webservice-ws-with-resources-config" class="bare">https://github.com/apache/tomee/tree/master/examples/webservice-ws-with-resources-config</a></p>
+</div>
+<div class="paragraph">
+<p>No README.md yet, be the first to contribute one!</p>
+</div>
+ </div>
+
+ </div>
+ </div>
+<footer>
+ <div class="container">
+ <div class="row">
+ <div class="col-sm-6 text-center-mobile">
+ <h3 class="white">Apache TomEE the little great server.</h3>
+ <h5 class="light regular light-white">"A good application in a good server"</h5>
+ <ul class="social-footer">
+ <li><a href="https://fr-fr.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li>
+ <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li>
+ <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li>
+ </ul>
+ </div>
+ <div class="col-sm-6 text-center-mobile">
+ <div class="row opening-hours">
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../admin/index.html" class="white">Administration</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../admin/cluster/index.html" class="regular light-white">Cluster</a></li>
+ <li><a href="../admin/configuration/index.html" class="regular light-white">Configuration</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../developer/index.html" class="white">Developer</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../developer/classloading/index.html" class="regular light-white">Classloading</a></li>
+ <li><a href="../developer/ide/index.html" class="regular light-white">IDE</a></li>
+ <li><a href="../developer/testing/index.html" class="regular light-white">Testing</a></li>
+ <li><a href="../developer/tools/index.html" class="regular light-white">Tools</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../advanced/index.html" class="white">Advanced</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../advanced/applicationcomposer/index.html" class="regular light-white">Application Composer</a></li>
+ <li><a href="../advanced/setup/index.html" class="regular light-white">Setup</a></li>
+ <li><a href="../advanced/shading/index.html" class="regular light-white">Shading</a></li>
+ <li><a href="../advanced/tomee-embedded/index.html" class="regular light-white">TomEE Embedded</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 text-center-mobile">
+ <h5><a href="../community/index.html" class="white">Community</a></h5>
+ <ul class="list-unstyled">
+ <li><a href="../community/contributors.html" class="regular light-white">Contributors</a></li>
+ <li><a href="../community/social.html" class="regular light-white">Social</a></li>
+ <li><a href="../community/sources.html" class="regular light-white">Sources</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row bottom-footer text-center-mobile">
+ <div class="col-sm-12 light-white">
+ <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+ <!-- Holder for mobile navigation -->
+ <div class="mobile-nav">
+ <ul>
+ <li><a hef="../admin/index.html">Administrators</a>
+ <li><a hef="../developer/index.html">Developers</a>
+ <li><a hef="../advanced/index.html">Advanced</a>
+ <li><a hef="../community/index.html">Community</a>
+ </ul>
+ <a href="#" class="close-link"><i class="arrow_up"></i></a>
+ </div>
+ <!-- Scripts -->
+ <script src="../js/jquery-1.11.1.min.js"></script>
+ <script src="../js/owl.carousel.min.js"></script>
+ <script src="../js/bootstrap.min.js"></script>
+ <script src="../js/wow.min.js"></script>
+ <script src="../js/typewriter.js"></script>
+ <script src="../js/jquery.onepagenav.js"></script>
+ <script src="../js/tree.jquery.js"></script>
+ <script src="../js/highlight.pack.js"></script>
+ <script src="../js/main.js"></script>
+ </body>
+
+</html>
+
diff --git a/content/examples/webservice-ws-with-resources-config.pdf b/content/examples/webservice-ws-with-resources-config.pdf
new file mode 100644
index 0000000..21414ed
--- /dev/null
+++ b/content/examples/webservice-ws-with-resources-config.pdf
Binary files differ
diff --git a/content/examples/webservice-ws-with-resources-config/pom.xml b/content/examples/webservice-ws-with-resources-config/pom.xml
new file mode 100755
index 0000000..fe2a46b
--- /dev/null
+++ b/content/examples/webservice-ws-with-resources-config/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.superbiz</groupId>
+ <artifactId>webservice-ws-with-resources-config</artifactId>
+ <packaging>jar</packaging>
+ <version>1.1.1-SNAPSHOT</version>
+ <name>OpenEJB :: Web Examples :: EJB WebService WS Security with resources.xml</name>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-cxf</artifactId>
+ <version>4.7.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+</project>
diff --git a/content/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java b/content/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
new file mode 100755
index 0000000..f57e9cd
--- /dev/null
+++ b/content/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/Calculator.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.security;
+
+import javax.jws.WebService;
+
+@WebService
+public interface Calculator {
+
+ int add(int op1, int op2);
+}
diff --git a/content/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java b/content/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
new file mode 100755
index 0000000..2a406fc
--- /dev/null
+++ b/content/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/CalculatorBean.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.security;
+
+import javax.ejb.Singleton;
+import javax.jws.WebService;
+
+@Singleton
+@WebService
+public class CalculatorBean implements Calculator {
+
+ @Override
+ public int add(int op1, int op2) {
+ return op1 + op2;
+ }
+}
diff --git a/content/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java b/content/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
new file mode 100755
index 0000000..5701cc7
--- /dev/null
+++ b/content/examples/webservice-ws-with-resources-config/src/main/java/org/superbiz/ws/security/PasswordCallbackHandler.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.security;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.IOException;
+
+public class PasswordCallbackHandler implements CallbackHandler {
+
+ private static boolean called = false;
+
+ @Override
+ public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ called = true;
+
+ final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ if (pc.getIdentifier().equals("openejb")) {
+ System.out.println("logged openejb user");
+ pc.setPassword("tomee");
+ }
+ }
+
+ public static boolean wasCalled() {
+ return called;
+ }
+}
diff --git a/content/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/openejb-jar.xml b/content/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/openejb-jar.xml
new file mode 100755
index 0000000..cb05bae
--- /dev/null
+++ b/content/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/openejb-jar.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
+ <ejb-deployment ejb-name="CalculatorBean"> <!-- configure the bean, values are in resources.xml -->
+ <properties>
+ cxf.jaxws.in-interceptors = wss4j
+ </properties>
+ </ejb-deployment>
+</openejb-jar>
diff --git a/content/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/resources.xml b/content/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/resources.xml
new file mode 100755
index 0000000..fb13ed3
--- /dev/null
+++ b/content/examples/webservice-ws-with-resources-config/src/main/resources/META-INF/resources.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <!-- the interceptors -->
+ <Service id="wss4j" class-name="org.apache.openejb.server.cxf.config.WSS4JInInterceptorFactory" factory-name="create">
+ action = UsernameToken
+ passwordType = PasswordText
+ passwordCallbackClass = org.superbiz.ws.security.PasswordCallbackHandler
+ </Service>
+</resources>
\ No newline at end of file
diff --git a/content/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/security/CalculatorTest.java b/content/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/security/CalculatorTest.java
new file mode 100755
index 0000000..3e14a74
--- /dev/null
+++ b/content/examples/webservice-ws-with-resources-config/src/test/java/org/superbiz/ws/security/CalculatorTest.java
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.ws.security;
+
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+import org.apache.openejb.OpenEjbContainer;
+import org.apache.ws.security.WSPasswordCallback;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPFaultException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+public class CalculatorTest {
+
+ @Test
+ public void call() throws MalformedURLException {
+ final EJBContainer container = EJBContainer.createEJBContainer(new Properties() {{
+ setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
+ }});
+
+ // normal call
+
+ final Service service = Service.create(
+ new URL("http://127.0.0.1:4204/webservice-ws-with-resources-config/CalculatorBean?wsdl"),
+ new QName("http://security.ws.superbiz.org/", "CalculatorBeanService"));
+
+ final Calculator calculator = service.getPort(Calculator.class);
+ ClientProxy.getClient(calculator).getOutInterceptors().add(
+ new WSS4JOutInterceptor(new HashMap<String, Object>() {{
+ put("action", "UsernameToken");
+ put("user", "openejb");
+ put("passwordType", "PasswordText");
+ put("passwordCallbackRef", new CallbackHandler() {
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("tomee");
+ }
+ });
+ }}));
+
+ assertEquals(5, calculator.add(2, 3));
+
+ // bad auth
+
+ final Calculator calculator2 = service.getPort(Calculator.class);
+ ClientProxy.getClient(calculator2).getOutInterceptors().add(
+ new WSS4JOutInterceptor(new HashMap<String, Object>() {{
+ put("action", "UsernameToken");
+ put("user", "openejb");
+ put("passwordType", "PasswordText");
+ put("passwordCallbackRef", new CallbackHandler() {
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+ pc.setPassword("wrong");
+ }
+ });
+ }}));
+
+ try {
+ assertEquals(5, calculator2.add(2, 3));
+ } catch (SOAPFaultException sfe) {
+ assertThat(sfe.getMessage(), containsString("The security token could not be authenticated or authorized"));
+ }
+
+ container.close();
+
+ // valid it passed because all was fine and not because the server config was not here
+ assertTrue(PasswordCallbackHandler.wasCalled());
+ }
+}
diff --git a/content/index.html b/content/index.html
index cf6dfc8..aaeea90 100644
--- a/content/index.html
+++ b/content/index.html
@@ -71,7 +71,7 @@
<li><a href="admin/index.html">Admin</a></li>
<li><a href="advanced/index.html">Advanced</a></li>
<li><a href="security/index.html">Security</a></li>
- <li><a href="examples/index.html">Examples</a></li>
+ <li><a href="examples/index-ng.html">Examples</a></li>
<li><a href="blog/index.html">Blog</a></li>
<li><a href="community/index.html">Community</a></li>
<li><a href="download-ng.html">Downloads</a></li>
diff --git a/content/security/index.html b/content/security/index.html
index a3f3e37..d25df1a 100644
--- a/content/security/index.html
+++ b/content/security/index.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/security/index.pdf b/content/security/index.pdf
index 34d0b22..eedd443 100644
--- a/content/security/index.pdf
+++ b/content/security/index.pdf
Binary files differ
diff --git a/content/security/support.html b/content/security/support.html
index 5af0d9d..f450c84 100644
--- a/content/security/support.html
+++ b/content/security/support.html
@@ -71,7 +71,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>
diff --git a/content/security/support.pdf b/content/security/support.pdf
index 95d5fcb..eba49a1 100644
--- a/content/security/support.pdf
+++ b/content/security/support.pdf
Binary files differ
diff --git a/content/sitemap.xml b/content/sitemap.xml
index 0b06202..efd5c0c 100644
--- a/content/sitemap.xml
+++ b/content/sitemap.xml
@@ -857,6 +857,11 @@
</url>
<url>
+ <loc>http://tomee.apache.org/examples/index-ng.html</loc>
+ <lastmod>2016-08-30</lastmod>
+ </url>
+
+ <url>
<loc>http://tomee.apache.org/examples/index.html</loc>
<lastmod>2016-08-30</lastmod>
</url>
diff --git a/content/tags/website.html b/content/tags/website.html
index 156915e..d829206 100644
--- a/content/tags/website.html
+++ b/content/tags/website.html
@@ -72,7 +72,7 @@
<li><a href="../admin/index.html">Admin</a></li>
<li><a href="../advanced/index.html">Advanced</a></li>
<li><a href="../security/index.html">Security</a></li>
- <li><a href="../examples/index.html">Examples</a></li>
+ <li><a href="../examples/index-ng.html">Examples</a></li>
<li><a href="../blog/index.html">Blog</a></li>
<li><a href="../community/index.html">Community</a></li>
<li><a href="../download-ng.html">Downloads</a></li>