You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2018/12/30 19:02:52 UTC
svn commit: r1849998 [4/8] - in /tomee/site/trunk/content: ./ community/
latest/docs/developer/ide/ latest/examples/ master/docs/developer/ide/
master/examples/ tomee-8.0/docs/developer/ide/ tomee-8.0/examples/
Modified: tomee/site/trunk/content/master/examples/cdi-interceptors.html
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/cdi-interceptors.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/master/examples/cdi-interceptors.html (original)
+++ tomee/site/trunk/content/master/examples/cdi-interceptors.html Sun Dec 30 19:02:51 2018
@@ -95,102 +95,186 @@
<div class="row">
<div class="col-md-12">
- <p>Let's write a simple application that would allow us to book tickets for a movie show. As with all applications, logging is one cross-cutting concern that we have. Apart from that, there are some methods in our application, that can be accessed only in the working hours. If accessed at non-working-hours we'll throw out an AccessDeniedException.</p>
-<p>How do we mark which methods are to be intercepted? Wouldn't it be handy to annotate a method like</p>
-<pre><code>@Log
-public void aMethod(){...}
-</code></pre>
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>Let’s write a simple application that would allow us to book tickets for a movie show. As with all applications, logging is one cross-cutting concern that we have. Apart from that, there are some methods in our application, that can be accessed only in the working hours. If accessed at non-working-hours we’ll throw out an AccessDeniedException.</p>
+</div>
+<div class="paragraph">
+<p>How do we mark which methods are to be intercepted? Wouldn’t it be handy to annotate a method like</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Log
+public void aMethod(){...}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>or</p>
-<pre><code>@TimeRestricted
-public void bMethod(){...}
-</code></pre>
-<p>Let's create these annotations that would "mark" a method for interception.</p>
-<pre><code>@InterceptorBinding
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@TimeRestricted
+public void bMethod(){...}</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Let’s create these annotations that would "mark" a method for interception.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@InterceptorBinding
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
public @interface Log {
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>And</p>
-<pre><code>@InterceptorBinding
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@InterceptorBinding
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
public @interface TimeRestricted {
-}
-</code></pre>
-<p>Sure, you haven't missed the <code>@InterceptorBinding</code> annotation above! Now that our custom annotations are created, lets attach them (or to use a better term for it, "bind them") to interceptors.</p>
-<p>So here's our logging interceptor. An <code>@AroundInvoke</code> method and we are almost done.</p>
-<pre><code>@Interceptor
+}</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Sure, you haven’t missed the <code>@InterceptorBinding</code> annotation above! Now that our custom annotations are created, lets attach them (or to use a better term for it, "bind them") to interceptors.</p>
+</div>
+<div class="paragraph">
+<p>So here’s our logging interceptor. An <code>@AroundInvoke</code> method and we are almost done.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Interceptor
@Log //binding the interceptor here. now any method annotated with @Log would be intercepted by logMethodEntry
public class BookForAShowLoggingInterceptor implements Serializable {
private static final long serialVersionUID = 8139854519874743530L;
- private Logger logger = Logger.getLogger("BookForAShowApplicationLogger");
+ private Logger logger = Logger.getLogger("BookForAShowApplicationLogger");
@AroundInvoke
public Object logMethodEntry(InvocationContext ctx) throws Exception {
- logger.info("Before entering method:" + ctx.getMethod().getName());
+ logger.info("Before entering method:" + ctx.getMethod().getName());
InterceptionOrderTracker.getMethodsInterceptedList().add(ctx.getMethod().getName());
InterceptionOrderTracker.getInterceptedByList().add(this.getClass().getSimpleName());
return ctx.proceed();
}
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>Now the <code>@Log</code> annotation we created is bound to this interceptor. (Likewise we bind <code>@TimeRestrict</code> for <code>TimeBasedRestrictingInterceptor</code>. See links below for source)</p>
-<p>That done, let's annotate at class-level or method-level and have fun intercepting!</p>
-<pre><code>@Log
+</div>
+<div class="paragraph">
+<p>That done, let’s annotate at class-level or method-level and have fun intercepting!</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Log
@Stateful
public class BookForAShowOneInterceptorApplied implements Serializable {
private static final long serialVersionUID = 6350400892234496909L;
public List<String> getMoviesList() {
List<String> moviesAvailable = new ArrayList<String>();
- moviesAvailable.add("12 Angry Men");
- moviesAvailable.add("Kings speech");
+ moviesAvailable.add("12 Angry Men");
+ moviesAvailable.add("Kings speech");
return moviesAvailable;
}
public Integer getDiscountedPrice(int ticketPrice) {
return ticketPrice - 50;
}
// assume more methods are present
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>The <code>@Log</code> annotation applied at class level denotes that all the methods should be intercepted with <code>BookForAShowLoggingInterceptor</code>.</p>
-<p>Before we say "all done" there's one last thing we are left with! To enable the interceptors!</p>
+</div>
+<div class="paragraph">
+<p>Before we say "all done" there’s one last thing we are left with! To enable the interceptors!</p>
+</div>
+<div class="paragraph">
<p>Lets quickly put up a <code>beans.xml</code> file like the following in <code>src/main/resources/META-INF/beans.xml</code>:</p>
-<pre><code><beans>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre><beans>
<interceptors>
<class>org.superbiz.cdi.bookshow.interceptors.BookForAShowLoggingInterceptor
</class>
<class>org.superbiz.cdi.bookshow.interceptors.TimeBasedRestrictingInterceptor
</class>
</interceptors>
-</beans>
-</code></pre>
-<p>By default, a bean archive has no enabled interceptors; an interceptor must be explicitly enabled by listing its class in the <code>beans.xml</code>.</p>
-<p>The order of the interceptor annotations has no real significance. Eg:</p>
-<pre><code>@TimeRestrict
+</beans></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>By default, a bean archive has no enabled interceptors; an interceptor must be explicitly enabled by listing its class
+in the <code>beans.xml</code>.</p>
+</div>
+<div class="paragraph">
+<p>The order of the interceptor annotations has no real significance.
+Eg:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@TimeRestrict
@Log
-void cMethod(){}
-</code></pre>
+void cMethod(){}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>It is the <code>interceptor</code> elements in <code>beans.xml</code> that not only "enable" the interceptors, but also define the "order of execution" of the interceptors. In this case the <code>BookForAShowLoggingInterceptor</code> would be applied first and then <code>TimeBasedRestrictingInterceptor</code></p>
+</div>
+<div class="paragraph">
<p>So now you know that the order is only determined by the order within the <code>interceptors</code> element within the <code>beans.xml</code>. The rule is simple, interceptors which occur earlier in the list are called first.</p>
+</div>
+<div class="paragraph">
<p>Also note that a method can be marked for interception using multiple interceptors by applying multiple annotations as above.</p>
-<p>This brings us to another question. In the above case there were two interceptors applied together. What if I would require about 4 such interceptors that would go along.... Having to annotate so much makes the code a little clumsy?</p>
+</div>
+<div class="paragraph">
+<p>This brings us to another question. In the above case there were two interceptors applied together. What if I would require about 4 such interceptors that would go along…​. Having to annotate so much makes the code a little clumsy?</p>
+</div>
+<div class="paragraph">
<p>No worries! Just create a custom annotation which inherits from others</p>
-<pre><code>@Inherited
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>@Inherited
@InterceptorBinding
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
@Log
@TimeRestricted
public @interface TimeRestrictAndLog {
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+<div class="paragraph">
<p>This is interceptor binding inheritance.</p>
+</div>
+<div class="paragraph">
<p>The code below demonstrates the many cases that we have discussed.</p>
+</div>
+<div class="paragraph">
<p>Not to forget, the old style binding with <code>@Interceptors(WhicheverInterceptor.class)</code> is also supported. Have a look at <code>BookForAShowOldStyleInterceptorBinding</code> where the comments explain how the newer way discussed above is better.</p>
-<h1>The Code</h1>
-<h2>BookForAShowOneInterceptorApplied</h2>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_code">The Code</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_bookforashowoneinterceptorapplied">BookForAShowOneInterceptorApplied</h3>
+<div class="paragraph">
<p><code>BookForAShowOneInterceptorApplied</code> shows a simple <code>@Log</code> interceptor applied.</p>
-<pre><code>package org.superbiz.cdi.bookshow.beans;
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.bookshow.beans;
import org.superbiz.cdi.bookshow.interceptorbinding.Log;
@@ -206,19 +290,26 @@ public class BookForAShowOneInterceptorA
public List<String> getMoviesList() {
List<String> moviesAvailable = new ArrayList<String>();
- moviesAvailable.add("12 Angry Men");
- moviesAvailable.add("Kings speech");
+ moviesAvailable.add("12 Angry Men");
+ moviesAvailable.add("Kings speech");
return moviesAvailable;
}
public Integer getDiscountedPrice(int ticketPrice) {
return ticketPrice - 50;
}
-}
-</code></pre>
-<h2>BookForAShowTwoInterceptorsApplied</h2>
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_bookforashowtwointerceptorsapplied">BookForAShowTwoInterceptorsApplied</h3>
+<div class="paragraph">
<p><code>BookForAShowTwoInterceptorsApplied</code> shows both <code>@Log</code> and <code>@TimeRestricted</code> being applied.</p>
-<pre><code>package org.superbiz.cdi.bookshow.beans;
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.bookshow.beans;
import org.superbiz.cdi.bookshow.interceptorbinding.Log;
import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestricted;
@@ -235,8 +326,8 @@ public class BookForAShowTwoInterceptors
public List<String> getMoviesList() {
List<String> moviesAvailable = new ArrayList<String>();
- moviesAvailable.add("12 Angry Men");
- moviesAvailable.add("Kings speech");
+ moviesAvailable.add("12 Angry Men");
+ moviesAvailable.add("Kings speech");
return moviesAvailable;
}
@@ -244,11 +335,18 @@ public class BookForAShowTwoInterceptors
public Integer getDiscountedPrice(int ticketPrice) {
return ticketPrice - 50;
}
-}
-</code></pre>
-<h2>BookShowInterceptorBindingInheritanceExplored</h2>
-<p><code>BookShowInterceptorBindingInheritanceExplored</code> shows how <code>@TimeRestrictAndLog</code> (interceptor-binding-inheritance) can be used as an alternative for annotating a method with multiple annotations explicitly.</p>
-<pre><code>package org.superbiz.cdi.bookshow.beans;
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_bookshowinterceptorbindinginheritanceexplored">BookShowInterceptorBindingInheritanceExplored</h3>
+<div class="paragraph">
+<p><code>BookShowInterceptorBindingInheritanceExplored</code> shows how <code>@TimeRestrictAndLog</code> (interceptor-binding-inheritance) can be used as an alternative for annotating a method with multiple annotations explicitly.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.bookshow.beans;
import org.superbiz.cdi.bookshow.interceptorbinding.TimeRestrictAndLog;
@@ -263,8 +361,8 @@ public class BookShowInterceptorBindingI
public List<String> getMoviesList() {
List<String> moviesAvailable = new ArrayList<String>();
- moviesAvailable.add("12 Angry Men");
- moviesAvailable.add("Kings speech");
+ moviesAvailable.add("12 Angry Men");
+ moviesAvailable.add("Kings speech");
return moviesAvailable;
}
@@ -272,8 +370,12 @@ public class BookShowInterceptorBindingI
public Integer getDiscountedPrice(int ticketPrice) {
return ticketPrice - 50;
}
-}
-</code></pre>
+}</pre>
+</div>
+</div>
+</div>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/master/examples/cdi-produces-disposes.html
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/cdi-produces-disposes.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/master/examples/cdi-produces-disposes.html (original)
+++ tomee/site/trunk/content/master/examples/cdi-produces-disposes.html Sun Dec 30 19:02:51 2018
@@ -95,16 +95,42 @@
<div class="row">
<div class="col-md-12">
- <p>This example shows how the @Produces and @Disposes annotations work. A LogFactory creates an instance of the LogHandler depending on a "type" attribute. For the purposes of this example, the type is hard-coded to a specific value. A Logger implementation shall contain a list of LogHandlers. We shall have three implementations of the LogHandler interface.</p>
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>This example shows how the @Produces and @Disposes annotations work. A LogFactory creates an instance of the LogHandler
+depending on a "type" attribute. For the purposes of this example, the type is hard-coded to a specific value.
+A Logger implementation shall contain a list of LogHandlers. We shall have three implementations of the LogHandler interface.</p>
+</div>
+<div class="ulist">
<ul>
- <li>A DatabaseHandler</li>
- <li>A FileHandler</li>
- <li>A ConsoleHandler</li>
+<li>
+<p>A DatabaseHandler</p>
+</li>
+<li>
+<p>A FileHandler</p>
+</li>
+<li>
+<p>A ConsoleHandler</p>
+</li>
</ul>
-<p>The DatabaseHandler would seemingly write the logs to a database. The FileHandler would write the same logs to a file. The ConsoleHandler would just print the logs to a console (Standard out). This example is just an illustration of how the concepts within CDI work and is not intended to provide a logging framework design/implementation.</p>
+</div>
+<div class="paragraph">
+<p>The DatabaseHandler would seemingly write the logs to a database. The FileHandler would write the same logs to a file.
+The ConsoleHandler would just print the logs to a console (Standard out). This example is just an illustration of how
+the concepts within CDI work and is not intended to provide a logging framework design/implementation.</p>
+</div>
+<div class="paragraph">
<p><em>Help us finish documenting this example! Click the blue pencil icon in the upper right to edit this page.</em></p>
-<h2>ConsoleHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_consolehandler">ConsoleHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public class ConsoleHandler implements LogHandler {
@@ -121,12 +147,19 @@ public class ConsoleHandler implements L
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
}
-}
-</code></pre>
-<h2>DatabaseHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_databasehandler">DatabaseHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public class DatabaseHandler implements LogHandler {
@@ -143,13 +176,20 @@ public class DatabaseHandler implements
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
// Use connection to write log to database
}
-}
-</code></pre>
-<h2>FileHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_filehandler">FileHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public class FileHandler implements LogHandler {
@@ -166,13 +206,20 @@ public class FileHandler implements LogH
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
// Write to log file
}
-}
-</code></pre>
-<h2>LogFactory</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logfactory">LogFactory</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
@@ -185,47 +232,61 @@ public class LogFactory {
public LogHandler getLogHandler() {
switch (type) {
case 1:
- return new FileHandler("@Produces created FileHandler!");
+ return new FileHandler("@Produces created FileHandler!");
case 2:
- return new DatabaseHandler("@Produces created DatabaseHandler!");
+ return new DatabaseHandler("@Produces created DatabaseHandler!");
case 3:
default:
- return new ConsoleHandler("@Produces created ConsoleHandler!");
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
}
}
public void closeLogHandler(@Disposes LogHandler handler) {
switch (type) {
case 1:
- System.out.println("Closing File handler!");
+ System.out.println("Closing File handler!");
break;
case 2:
- System.out.println("Closing DB handler!");
+ System.out.println("Closing DB handler!");
break;
case 3:
default:
- System.out.println("Closing Console handler!");
+ System.out.println("Closing Console handler!");
}
}
-}
-</code></pre>
-<h2>Logger</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logger">Logger</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public interface Logger {
public void log(String s);
public LogHandler getHandler();
-}
-</code></pre>
-<h2>LoggerImpl</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggerimpl">LoggerImpl</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
import javax.inject.Inject;
import javax.inject.Named;
-@Named("logger")
+@Named("logger")
public class LoggerImpl implements Logger {
@Inject
@@ -239,27 +300,48 @@ public class LoggerImpl implements Logge
public LogHandler getHandler() {
return handler;
}
-}
-</code></pre>
-<h2>LogHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loghandler">LogHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
public interface LogHandler {
public String getName();
public void writeLog(String s);
-}
-</code></pre>
-<h2>beans.xml</h2>
-<pre><code><beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
-
-</beans>
-</code></pre>
-<h2>LoggerTest</h2>
-<pre><code>package org.superbiz.cdi.produces.disposes;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_beans_xml">beans.xml</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre><beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+</beans></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggertest">LoggerTest</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.disposes;
import org.junit.After;
import org.junit.Before;
@@ -284,7 +366,7 @@ public class LoggerTest {
public void setUp() {
try {
ctxt = EJBContainer.createEJBContainer().getContext();
- ctxt.bind("inject", this);
+ ctxt.bind("inject", this);
} catch (Exception e) {
e.printStackTrace();
}
@@ -293,7 +375,7 @@ public class LoggerTest {
@After
public void cleanUp() {
try {
- ctxt.unbind("inject");
+ ctxt.unbind("inject");
ctxt.close();
} catch (Exception e) {
e.printStackTrace();
@@ -303,17 +385,22 @@ public class LoggerTest {
@Test
public void testLogHandler() {
assertNotNull(logger);
- assertFalse("Handler should not be a ConsoleHandler", logger.getHandler() instanceof ConsoleHandler);
- assertFalse("Handler should not be a FileHandler", logger.getHandler() instanceof FileHandler);
- assertTrue("Handler should be a DatabaseHandler", logger.getHandler() instanceof DatabaseHandler);
- logger.log("##### Testing write\n");
+ assertFalse("Handler should not be a ConsoleHandler", logger.getHandler() instanceof ConsoleHandler);
+ assertFalse("Handler should not be a FileHandler", logger.getHandler() instanceof FileHandler);
+ assertTrue("Handler should be a DatabaseHandler", logger.getHandler() instanceof DatabaseHandler);
+ logger.log("##### Testing write\n");
logger = null;
}
-}
-</code></pre>
-<h1>Running</h1>
-<pre><code>-------------------------------------------------------
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="literalblock">
+<div class="content">
+<pre>-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.superbiz.cdi.produces.disposes.LoggerTest
@@ -321,7 +408,7 @@ Apache OpenEJB 4.0.0-beta-1 build: 20
http://tomee.apache.org/
INFO - openejb.home = /Users/dblevins/examples/cdi-produces-disposes
INFO - openejb.base = /Users/dblevins/examples/cdi-produces-disposes
-INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Found EjbModule in classpath: /Users/dblevins/examples/cdi-produces-disposes/target/classes
@@ -329,12 +416,12 @@ INFO - Beginning load: /Users/dblevins/e
INFO - Configuring enterprise application: /Users/dblevins/examples/cdi-produces-disposes
INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
INFO - Auto-creating a container for bean cdi-produces-disposes.Comp: Container(type=MANAGED, id=Default Managed Container)
-INFO - Enterprise application "/Users/dblevins/examples/cdi-produces-disposes" loaded.
+INFO - Enterprise application "/Users/dblevins/examples/cdi-produces-disposes" loaded.
INFO - Assembling app: /Users/dblevins/examples/cdi-produces-disposes
-INFO - Jndi(name="java:global/cdi-produces-disposes/cdi-produces-disposes.Comp!org.apache.openejb.BeanContext$Comp")
-INFO - Jndi(name="java:global/cdi-produces-disposes/cdi-produces-disposes.Comp")
-INFO - Jndi(name="java:global/EjbModule10202458/org.superbiz.cdi.produces.disposes.LoggerTest!org.superbiz.cdi.produces.disposes.LoggerTest")
-INFO - Jndi(name="java:global/EjbModule10202458/org.superbiz.cdi.produces.disposes.LoggerTest")
+INFO - Jndi(name="java:global/cdi-produces-disposes/cdi-produces-disposes.Comp!org.apache.openejb.BeanContext$Comp")
+INFO - Jndi(name="java:global/cdi-produces-disposes/cdi-produces-disposes.Comp")
+INFO - Jndi(name="java:global/EjbModule10202458/org.superbiz.cdi.produces.disposes.LoggerTest!org.superbiz.cdi.produces.disposes.LoggerTest")
+INFO - Jndi(name="java:global/EjbModule10202458/org.superbiz.cdi.produces.disposes.LoggerTest")
INFO - Created Ejb(deployment-id=cdi-produces-disposes.Comp, ejb-name=cdi-produces-disposes.Comp, container=Default Managed Container)
INFO - Created Ejb(deployment-id=org.superbiz.cdi.produces.disposes.LoggerTest, ejb-name=org.superbiz.cdi.produces.disposes.LoggerTest, container=Default Managed Container)
INFO - Started Ejb(deployment-id=cdi-produces-disposes.Comp, ejb-name=cdi-produces-disposes.Comp, container=Default Managed Container)
@@ -345,8 +432,9 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
Results :
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-</code></pre>
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</pre>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/master/examples/cdi-produces-field.html
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/cdi-produces-field.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/master/examples/cdi-produces-field.html (original)
+++ tomee/site/trunk/content/master/examples/cdi-produces-field.html Sun Dec 30 19:02:51 2018
@@ -88,23 +88,52 @@
<div class="col-md-12">
<div class='page-header'>
- <h1>CDI field producer</h1>
+ <h1>CDI Field Producer</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
- <p>This example shows the usage of the @Produces annotation. @Produces is a CDI mechanism which allows defining a source<br/> for injection. This example shows one of two ways of declaring a producer. Instead of a producer method (see CDI-produces-disposes example)<br/>a producer field can be used. A producer field can be used instead of a simple getter method. It could be used to inject resources, such as persistence contexts. One caveat to using producer fields over producer<br/> methods is that a @Disposes method cannot be used in conjunction with @Produces field.</p>
-<p>For the purposes of this example, the type is hard-coded to a specific value. A Logger implementation shall contain a list of LogHandlers. We shall have three implementations of the LogHandler interface.</p>
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>This example shows the usage of the @Produces annotation. @Produces is a CDI mechanism which allows defining a source
+ for injection. This example shows one of two ways of declaring a producer. Instead of a producer method (see CDI-produces-disposes example)
+a producer field can be used. A producer field can be used instead of a simple getter method. It could be used to
+inject resources, such as persistence contexts. One caveat to using producer fields over producer
+ methods is that a @Disposes method cannot be used in conjunction with @Produces field.</p>
+</div>
+<div class="paragraph">
+<p>For the purposes of this example, the type is hard-coded to a specific value.
+A Logger implementation shall contain a list of LogHandlers. We shall have three implementations of the LogHandler interface.</p>
+</div>
+<div class="ulist">
<ul>
- <li>A DatabaseHandler</li>
- <li>A FileHandler</li>
- <li>A ConsoleHandler</li>
+<li>
+<p>A DatabaseHandler</p>
+</li>
+<li>
+<p>A FileHandler</p>
+</li>
+<li>
+<p>A ConsoleHandler</p>
+</li>
</ul>
-<p>The DatabaseHandler would seemingly write the logs to a database. The FileHandler would write the same logs to a file. The ConsoleHandler would just print the logs to a console (Standard out). This example is just an illustration of how the concepts within CDI work and is not intended to provide a logging framework design/implementation.</p>
-<h2>ConsoleHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+</div>
+<div class="paragraph">
+<p>The DatabaseHandler would seemingly write the logs to a database. The FileHandler would write the same logs to a file.
+The ConsoleHandler would just print the logs to a console (Standard out). This example is just an illustration of how
+the concepts within CDI work and is not intended to provide a logging framework design/implementation.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_consolehandler">ConsoleHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public class ConsoleHandler implements LogHandler {
@@ -121,12 +150,19 @@ public class ConsoleHandler implements L
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
}
-}
-</code></pre>
-<h2>DatabaseHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_databasehandler">DatabaseHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public class DatabaseHandler implements LogHandler {
@@ -143,13 +179,20 @@ public class DatabaseHandler implements
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
// Use connection to write log to database
}
-}
-</code></pre>
-<h2>FileHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_filehandler">FileHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public class FileHandler implements LogHandler {
@@ -166,13 +209,20 @@ public class FileHandler implements LogH
@Override
public void writeLog(String s) {
- System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+ System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
// Write to log file
}
-}
-</code></pre>
-<h2>LogFactory</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logfactory">LogFactory</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
import javax.enterprise.inject.Produces;
@@ -184,40 +234,54 @@ public class LogFactory {
LogHandler handler;
public LogFactory(){
- handler = getLogHandler();
+ handler = getLogHandler();
}
public LogHandler getLogHandler() {
switch (type) {
case 1:
- return new FileHandler("@Produces created FileHandler!");
+ return new FileHandler("@Produces created FileHandler!");
case 2:
- return new DatabaseHandler("@Produces created DatabaseHandler!");
+ return new DatabaseHandler("@Produces created DatabaseHandler!");
case 3:
default:
- return new ConsoleHandler("@Produces created ConsoleHandler!");
+ return new ConsoleHandler("@Produces created ConsoleHandler!");
}
}
-}
-</code></pre>
-<h2>Logger</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_logger">Logger</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public interface Logger {
public void log(String s);
public LogHandler getHandler();
-}
-</code></pre>
-<h2>LoggerImpl</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggerimpl">LoggerImpl</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
import javax.inject.Inject;
import javax.inject.Named;
-@Named("logger")
+@Named("logger")
public class LoggerImpl implements Logger {
@Inject
@@ -231,27 +295,48 @@ public class LoggerImpl implements Logge
public LogHandler getHandler() {
return handler;
}
-}
-</code></pre>
-<h2>LogHandler</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loghandler">LogHandler</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
public interface LogHandler {
public String getName();
public void writeLog(String s);
-}
-</code></pre>
-<h2>beans.xml</h2>
-<pre><code><beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
-
-</beans>
-</code></pre>
-<h2>LoggerTest</h2>
-<pre><code>package org.superbiz.cdi.produces.field;
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_beans_xml">beans.xml</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre><beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+</beans></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_loggertest">LoggerTest</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>package org.superbiz.cdi.produces.field;
import org.junit.After;
import org.junit.Before;
@@ -276,7 +361,7 @@ public class LoggerTest {
public void setUp() {
try {
ctxt = EJBContainer.createEJBContainer().getContext();
- ctxt.bind("inject", this);
+ ctxt.bind("inject", this);
} catch (Exception e) {
e.printStackTrace();
}
@@ -285,7 +370,7 @@ public class LoggerTest {
@After
public void cleanUp() {
try {
- ctxt.unbind("inject");
+ ctxt.unbind("inject");
ctxt.close();
} catch (Exception e) {
e.printStackTrace();
@@ -295,17 +380,22 @@ public class LoggerTest {
@Test
public void testLogHandler() {
assertNotNull(logger);
- assertFalse("Handler should not be a ConsoleHandler", logger.getHandler() instanceof ConsoleHandler);
- assertFalse("Handler should not be a FileHandler", logger.getHandler() instanceof FileHandler);
- assertTrue("Handler should be a DatabaseHandler", logger.getHandler() instanceof DatabaseHandler);
- logger.log("##### Testing write\n");
+ assertFalse("Handler should not be a ConsoleHandler", logger.getHandler() instanceof ConsoleHandler);
+ assertFalse("Handler should not be a FileHandler", logger.getHandler() instanceof FileHandler);
+ assertTrue("Handler should be a DatabaseHandler", logger.getHandler() instanceof DatabaseHandler);
+ logger.log("##### Testing write\n");
logger = null;
}
-}
-</code></pre>
-<h1>Running</h1>
-<pre><code>-------------------------------------------------------
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<h1 id="_running" class="sect0">Running</h1>
+<div class="literalblock">
+<div class="content">
+<pre>-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.superbiz.cdi.produces.field.LoggerTest
@@ -321,13 +411,13 @@ INFO - openejb.home = /home/daniel/proje
INFO - openejb.base = /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@a81b1fb
INFO - succeeded in installing singleton service
-INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
INFO - Cannot find the configuration file [conf/openejb.xml]. Will attempt to create one for the beans deployed.
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Creating TransactionManager(id=Default Transaction Manager)
INFO - Creating SecurityService(id=Default Security Service)
-INFO - Inspecting classpath for applications: 26 urls. Consider adjusting your exclude/include. Current settings: openejb.deployments.classpath.exclude='', openejb.deployments.classpath.include='.*'
+INFO - Inspecting classpath for applications: 26 urls. Consider adjusting your exclude/include. Current settings: openejb.deployments.classpath.exclude='', openejb.deployments.classpath.include='.*'
INFO - Searched 26 classpath urls in 2015 milliseconds. Average 77 milliseconds per url.
INFO - Beginning load: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field/target/classes
INFO - Configuring enterprise application: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
@@ -336,7 +426,7 @@ INFO - Configuring Service(id=Default Ma
INFO - Auto-creating a container for bean cdi-produces-field.Comp: Container(type=MANAGED, id=Default Managed Container)
INFO - Creating Container(id=Default Managed Container)
INFO - Using directory /tmp for stateful session passivation
-INFO - Enterprise application "/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field" loaded.
+INFO - Enterprise application "/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field" loaded.
INFO - Assembling app: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
INFO - ignoreXmlConfiguration == true
INFO - ignoreXmlConfiguration == true
@@ -352,8 +442,9 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
Results :
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-</code></pre>
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</pre>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/master/examples/cdi-request-scope.html
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/cdi-request-scope.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/master/examples/cdi-request-scope.html (original)
+++ tomee/site/trunk/content/master/examples/cdi-request-scope.html Sun Dec 30 19:02:51 2018
@@ -95,12 +95,34 @@
<div class="row">
<div class="col-md-12">
- <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 beans that inject it throughout a same request.</p>
-<h1>Example</h1>
-<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>
-<h2>Waiter</h2>
-<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>
-<pre><code>@Stateless
+ <div id="preamble">
+<div class="sectionbody">
+<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
+beans that inject it throughout a same request.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_example">Example</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>This example depicts a similar scenario to cdi-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="sect2">
+<h3 id="_waiter">Waiter</h3>
+<div class="paragraph">
+<p>The <code>Waiter</code> session bean receives a request from the test class via the <code>orderSoup()</code> method.
+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="literalblock">
+<div class="content">
+<pre>@Stateless
public class Waiter {
@Inject
@@ -113,18 +135,26 @@ public class Waiter {
soup.setName(name);
return chef.prepareSoup().getName();
}
-}
-</code></pre>
-<h2>Soup</h2>
-<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>
-<pre><code>@RequestScoped
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_soup">Soup</h3>
+<div class="paragraph">
+<p>The <code>Soup</code> class is an injectable POJO, defined as <code>@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="literalblock">
+<div class="content">
+<pre>@RequestScoped
public class Soup {
- private String name = "Soup of the day";
+ private String name = "Soup of the day";
@PostConstruct
public void afterCreate() {
- System.out.println("Soup created");
+ System.out.println("Soup created");
}
public String getName() {
@@ -134,11 +164,20 @@ public class Soup {
public void setName(String name){
this.name = name;
}
-}
-</code></pre>
-<h2>Chef</h2>
-<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>
-<pre><code>@Stateless
+}</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_chef">Chef</h3>
+<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="literalblock">
+<div class="content">
+<pre>@Stateless
public class Chef {
@Inject
@@ -147,13 +186,23 @@ public class Chef {
public Soup prepareSoup() {
return soup;
}
-}
-</code></pre>
-<h1>Test Case</h1>
+}</pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_test_case">Test Case</h2>
+<div class="sectionbody">
+<div class="paragraph">
<p>This is the entry class for this example.</p>
-<pre><code>public class RestaurantTest {
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>public class RestaurantTest {
- private static String TOMATO_SOUP = "Tomato Soup";
+ private static String TOMATO_SOUP = "Tomato Soup";
private EJBContainer container;
@EJB
@@ -162,7 +211,7 @@ public class Chef {
@Before
public void startContainer() throws Exception {
container = EJBContainer.createEJBContainer();
- container.getContext().bind("inject", this);
+ container.getContext().bind("inject", this);
}
@Test
@@ -177,11 +226,21 @@ public class Chef {
public void closeContainer() throws Exception {
container.close();
}
-}
-</code></pre>
-<h1>Running</h1>
-<p>In the output you can see that there were two <code>Soup</code> instances created - one for each request.</p>
-<pre><code>-------------------------------------------------------
+}</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_running">Running</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>In the output you can see that there were two <code>Soup</code> instances created - one for
+each request.</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.superbiz.cdi.requestscope.RestaurantTest
@@ -189,7 +248,7 @@ Apache OpenEJB 7.0.0-SNAPSHOT build:
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 - 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
@@ -199,12 +258,12 @@ INFO - Configuring Service(id=Default Ma
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 - 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 - 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)
@@ -217,8 +276,11 @@ Tests run: 1, Failures: 0, Errors: 0, Sk
Results :
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
-</code></pre>
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</pre>
+</div>
+</div>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/master/examples/cdi-session-scope.html
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/cdi-session-scope.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/master/examples/cdi-session-scope.html (original)
+++ tomee/site/trunk/content/master/examples/cdi-session-scope.html Sun Dec 30 19:02:51 2018
@@ -88,95 +88,189 @@
<div class="col-md-12">
<div class='page-header'>
- <h1>CDI @SessionScoped</h1>
+ <h1>null</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
- <p>This example show the use of <code>@SessionScoped</code> annotation for injected objects. An object which is defined as <code>@SessionScoped</code> is created once for every HTTPSession and is shared by all the beans that inject it throughout the same HTTPSession.</p>
-<h5>Run the application:</h5>
-<pre><code>mvn clean install tomee:run
-</code></pre>
-<h1>Example</h1>
-<p>This example has an end point wherein a user provides a request parameter 'name' which is persisted as a feild in a session scoped bean SessionBean and then retrieved through another endpoint.</p>
-<h1>Request</h1>
-<p>GET <a href="http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/set-name?name=Puneeth">http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/set-name?name=Puneeth</a></p>
-<h1>Response</h1>
-<p>done, go to /name servlet </p>
-<h1>Request</h1>
-<p>GET <a href="http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/name">http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/name</a></p>
-<h1>Response</h1>
-<p>name = {Puneeth} </p>
-<h2>SessionBean</h2>
-<p>The annotation @SessionScoped specifies that a bean is session scoped ie there will be only one instance of the class associated with a particular HTTPSession. </p>
-<p>@SessionScoped<br/>public class SessionBean implements Serializable {</p>
-<pre><code>private String name;
-
-public String getName() {
- return name;
-}
-
-public void setName(String name) {
- this.name = name;
-}
-</code></pre>
-<p>} </p>
-<h2>InputServlet</h2>
-<p>InputServlet is a generic servlet which is mapped to the url pattern '/set-name'. The session scoped bean 'SessionBean' has been injected into this servlet, and the incoming request parameter is set to the feild name of the bean. </p>
-<p>@WebServlet(name = "input-servlet", urlPatterns = {"/set-name"})<br/>public class InputServlet extends HttpServlet {</p>
-<pre><code>@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");
- }
-
-}
-</code></pre>
-<p>}</p>
-<h2>AnswerBean</h2>
+ <div class="paragraph">
+<p>index-group=Unrevised
+type=page
+status=unpublished</p>
+</div>
+<h1 id="_cdi_sessionscoped" class="sect0">CDI @SessionScoped</h1>
+<div class="paragraph">
+<p>This example show the use of <code>@SessionScoped</code> annotation for injected objects. An object
+which is defined as <code>@SessionScoped</code> is created once for every HTTPSession and is shared by all the
+beans that inject it throughout the same HTTPSession.</p>
+</div>
+<div class="sect1">
+<h2 id="_run_the_application">Run the application:</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>mvn clean install tomee:run</pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_example">Example</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>This example has an end point wherein a user provides a request parameter 'name' which is persisted as a feild in a session scoped bean SessionBean and
+then retrieved through another endpoint.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_request">Request</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>GET <a href="http://localhost:8080/cdi-session-scope/set-name?name=Puneeth" class="bare">http://localhost:8080/cdi-session-scope/set-name?name=Puneeth</a></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_response">Response</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>done, go to /name servlet</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_request_2">Request</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>GET <a href="http://localhost:8080/cdi-session-scope/name" class="bare">http://localhost:8080/cdi-session-scope/name</a></p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_response_2">Response</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>name = {Puneeth}</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_sessionbean">SessionBean</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The annotation @SessionScoped specifies that a bean is session scoped ie there will be only one instance of the class associated with a particular HTTPSession.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code class="language-java" data-lang="java">@SessionScoped
+public class SessionBean implements Serializable {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_inputservlet">InputServlet</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>InputServlet is a generic servlet which is mapped to the url pattern '/set-name'.
+The session scoped bean 'SessionBean' has been injected into this servlet, and the incoming request parameter is set to the feild name of the bean.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code class="language-java" data-lang="java">@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");
+ }
+
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_answerbean">AnswerBean</h2>
+<div class="sectionbody">
+<div class="paragraph">
<p>AnswerBean is a request scoped bean with an injected 'SessionBean'. It has an postconstruct method wherein the value from the sessionBean is retrieved and set to a feild.</p>
-<p>public class AnswerBean {</p>
-<pre><code>@Inject
-private SessionBean bean;
-
-private String value;
-
-@PostConstruct
-public void init() {
- value = '{' + bean.getName() + '}';
-}
-
-public String value() {
- return value;
-}
-</code></pre>
-<p>}</p>
-<h2>OutputServlet</h2>
-<p>OutputServlet is another servlet with 'AnswerBean' as an injected feild. When '/name' is called the value from 'Answerbean' is read and written to the response.</p>
-<p>@WebServlet(name = "output-servlet", urlPatterns = {"/name"})<br/>public class OutputServlet extends HttpServlet {</p>
-<pre><code>@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);
- }
-}
-</code></pre>
-<p>}</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code class="language-java" data-lang="java">public class AnswerBean {
+
+ @Inject
+ private SessionBean bean;
+
+ private String value;
+
+ @PostConstruct
+ public void init() {
+ value = '{' + bean.getName() + '}';
+ }
+
+ public String value() {
+ return value;
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_outputservlet">OutputServlet</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>OutputServlet is another servlet with 'AnswerBean' as an injected feild. When '/name' is called the value from 'Answerbean' is read and written to the response.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code class="language-java" data-lang="java">@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);
+ }
+ }
+}</code></pre>
+</div>
+</div>
+</div>
+</div>
</div>
</div>
Modified: tomee/site/trunk/content/master/examples/index.html
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/index.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/master/examples/index.html (original)
+++ tomee/site/trunk/content/master/examples/index.html Sun Dec 30 19:02:51 2018
@@ -93,6 +93,20 @@
</div>
<div class="row">
<div class="col-md-4">
+ <div class="group-title">CDI</div>
+ <ul class="group">
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-application-scope.html">CDI @ApplicationScoped</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-basic.html">CDI @Inject</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-request-scope.html">CDI @RequestScoped</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-events.html">CDI Events - Loose Coupling and Extensibility</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-produces-field.html">CDI Field Producer</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-interceptors.html">CDI Interceptors</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-produces-disposes.html">CDI Produces Disposes</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="decorators.html">Decorators</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-cdi-interceptor.html">Simple CDI Interceptor</a></li>
+ </ul>
+ </div>
+ <div class="col-md-4">
<div class="group-title">Web Services</div>
<ul class="group">
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="webservice-handlerchain.html">@WebService handlers with @HandlerChain</a></li>
@@ -106,18 +120,6 @@
</ul>
</div>
<div class="col-md-4">
- <div class="group-title">CDI</div>
- <ul class="group">
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-application-scope.html">CDI @ApplicationScoped</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-basic.html">CDI @Inject</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-request-scope.html">CDI @RequestScoped</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-alternative-and-stereotypes.html">CDI Alternative and Stereotypes</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-produces-disposes.html">CDI Produces Disposes</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="decorators.html">Decorators</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-cdi-interceptor.html">Simple CDI Interceptor</a></li>
- </ul>
- </div>
- <div class="col-md-4">
<div class="group-title">EJB</div>
<ul class="group">
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="access-timeout.html">@AccessTimeout Annotation</a></li>
@@ -193,10 +195,10 @@
<div class="col-md-4">
<div class="group-title">Unknown</div>
<ul class="group">
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-session-scope.html">cdi-session-scope</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="java-modules.html">Java modules example with a simple REST resource</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-custom-healthcheck.html">MicroProfile Custom Health Check</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-faulttolerance-fallback.html">Microprofile Fault Tolerance - Fallback</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-opentracing-traced.html">mp-opentracing-traced</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="projectstage-demo.html">projectstage-demo</a></li>
</ul>
</div>
<div class="col-md-4">
@@ -277,29 +279,17 @@
</ul>
</div>
<div class="col-md-4">
- <div class="group-title">Histogram</div>
- <ul class="group">
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-histogram.html">Microprofile Metrics Histogram</a></li>
- </ul>
- </div>
- <div class="col-md-4">
<div class="group-title">Java EE Connectors</div>
<ul class="group">
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="quartz-app.html">Quartz Resource Adapter usage</a></li>
</ul>
</div>
- </div>
- <div class="row">
<div class="col-md-4">
<div class="group-title">JPA Providers</div>
<ul class="group">
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="multi-jpa-provider-testing.html">Multiple JPA providers test</a></li>
</ul>
</div>
- <div class="col-md-4">
- </div>
- <div class="col-md-4">
- </div>
</div>
<div class="row">
<div class="col-md-12">
@@ -332,6 +322,36 @@
</div>
<div class="row">
<div class="col-md-12">
+ <div class="group-title large">MicroProfile</div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-4">
+ <ul class="group">
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-config-example.html">MicroProfile Config</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-custom-healthcheck.html">MicroProfile Custom Health Check</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-faulttolerance-fallback.html">MicroProfile Fault Tolerance - Fallback</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-faulttolerance-retry.html">MicroProfile Fault Tolerance - Retry Policy</a></li>
+ </ul>
+ </div>
+ <div class="col-md-4">
+ <ul class="group">
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-rest-jwt.html">MicroProfile JWT</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-counted.html">MicroProfile Metrics Counted</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-histogram.html">MicroProfile Metrics Histogram</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-metered.html">MicroProfile Metrics Metered</a></li>
+ </ul>
+ </div>
+ <div class="col-md-4">
+ <ul class="group">
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-timed.html">MicroProfile Metrics Timed</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-opentracing-traced.html">MicroProfile OpenTracing @Traced</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-rest-client.html">MicroProfile Rest Client</a></li>
+ </ul>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-12">
<div class="group-title large">Unrevised</div>
</div>
</div>
@@ -341,38 +361,27 @@
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="deltaspike-fullstack.html">Apache DeltaSpike Demo</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="arquillian-jpa.html">Arquillian Persistence Extension</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-session-scope.html">CDI @SessionScoped</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-events.html">CDI Events</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-produces-field.html">CDI field producer</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-interceptors.html">CDI Interceptors</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="change-jaxws-url.html">Change JAXWS URL</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="resources-jmx-example.html">Custom resources in an EAR archive</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="datasource-versioning.html">DataSource Versioning</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="realm-in-tomee.html">DataSourceRealm and TomEE DataSource</a></li>
+ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="javamail.html">Javamail API</a></li>
</ul>
</div>
<div class="col-md-4">
<ul class="group">
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="javamail.html">Javamail API</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-config-example.html">Microprofile Config</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-faulttolerance-retry.html">Microprofile Fault Tolerance Retry</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-counted.html">Microprofile Metrics Counted</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-timed.html">Microprofile Metrics Timed</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-rest-client.html">Microprofile Rest Client</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-rest-jwt.html">Microprofile Rest JWT</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="connector-war.html">Movies Complete</a></li>
- <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-metered.html">mp-metrics-metered</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mtom.html">mtom</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="myfaces-codi-demo.html">MyFaces CODI Demo</a></li>
- </ul>
- </div>
- <div class="col-md-4">
- <ul class="group">
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="persistence-fragment.html">Persistence Fragment</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="reload-persistence-unit-properties.html">Reload Persistence Unit Properties</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="schedule-events.html">Schedule CDI Events</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-mdb-and-cdi.html">Simple MDB and CDI</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="rest-xml-json.html">Simple REST</a></li>
+ </ul>
+ </div>
+ <div class="col-md-4">
+ <ul class="group">
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="rest-cdi.html">Simple REST with CDI</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-stateful-callbacks.html">Simple Stateful with callback methods</a></li>
<li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-stateless-callbacks.html">Simple Stateless with callback methods</a></li>
Modified: tomee/site/trunk/content/master/examples/mp-config-example.html
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/mp-config-example.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/master/examples/mp-config-example.html (original)
+++ tomee/site/trunk/content/master/examples/mp-config-example.html Sun Dec 30 19:02:51 2018
@@ -88,7 +88,7 @@
<div class="col-md-12">
<div class='page-header'>
- <h1>Microprofile Config</h1>
+ <h1>MicroProfile Config</h1>
</div>
</div>
</div>
Modified: tomee/site/trunk/content/master/examples/mp-custom-healthcheck.html
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/mp-custom-healthcheck.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/master/examples/mp-custom-healthcheck.html (original)
+++ tomee/site/trunk/content/master/examples/mp-custom-healthcheck.html Sun Dec 30 19:02:51 2018
@@ -95,8 +95,10 @@
<div class="row">
<div class="col-md-12">
- <div class="sect3">
-<h4 id="_health_feature">Health Feature</h4>
+ <div class="paragraph">
+<p>This is an example of how to use MicroProfile Custom Health Check in TomEE.</p>
+</div>
+<h4 id="_health_feature" class="discrete">Health Feature</h4>
<div class="paragraph">
<p>Health checks are used to probe the state of services and resources that an application might depend on or even to expose its
state, e.g. in a cluster environment, where an unhealthy node needs to be discarded (terminated, shutdown) and eventually
@@ -112,7 +114,7 @@ replaced by another healthy instance.</p
</div>
</div>
<div class="paragraph">
-<p>To provide a customized output, Letâs say we have an application that uses a Weather API, and if the service becomes
+<p>To provide a customized output, Let’s say we have an application that uses a Weather API, and if the service becomes
unavailable, we should report the service as DOWN.</p>
</div>
<div class="paragraph">
@@ -148,26 +150,21 @@ public class WeatherServiceHealthCheck i
<p>In the example above, the health probe name is <a href="https://openweathermap.org/appid">OpenWeatherMap</a> (<em>illustrative only</em>) which provides a
subscription plan to access its services and if the limit of calls is exceeded the API becomes unavailable until it’s renewed.</p>
</div>
-</div>
-<div class="sect2">
-<h3 id="_examples">Examples</h3>
-<div class="sect4">
-<h5 id="_running_the_application">Running the application</h5>
+<h3 id="_examples" class="discrete">Examples</h3>
<div class="listingblock">
+<div class="title">Running the application</div>
<div class="content">
-<pre class="highlight"><code> mvn clean install tomee:run</code></pre>
-</div>
+<pre> mvn clean install tomee:run</pre>
</div>
</div>
-<div class="sect3">
-<h4 id="_example_1">Example 1</h4>
+<h4 id="_example_1" class="discrete">Example 1</h4>
<div class="paragraph">
<p>When hitting /health endpoint, OpenWeatherMap tell us that our remaining calls are running out and we should take
an action before it gets unavailable.</p>
</div>
<div class="listingblock">
<div class="content">
-<pre class="highlight"><code>curl http://localhost:8080/mp-custom-healthcheck/health</code></pre>
+<pre>curl http://localhost:8080/mp-custom-healthcheck/health</pre>
</div>
</div>
<div class="listingblock">
@@ -190,15 +187,13 @@ an action before it gets unavailable.</p
}</code></pre>
</div>
</div>
-</div>
-<div class="sect3">
-<h4 id="_example_2">Example 2</h4>
+<h4 id="_example_2" class="discrete">Example 2</h4>
<div class="paragraph">
<p>Weather API still working fine.</p>
</div>
<div class="listingblock">
<div class="content">
-<pre class="highlight"><code>curl http://localhost:8080/mp-custom-healthcheck/weather/day/status</code></pre>
+<pre>curl http://localhost:8080/mp-custom-healthcheck/weather/day/status</pre>
</div>
</div>
<div class="listingblock">
@@ -206,16 +201,14 @@ an action before it gets unavailable.</p
<pre class="highlight"><code class="language-text" data-lang="text">Hi, today is a sunny day!</code></pre>
</div>
</div>
-</div>
-<div class="sect3">
-<h4 id="_example_3">Example 3</h4>
+<h4 id="_example_3" class="discrete">Example 3</h4>
<div class="paragraph">
<p>When hitting one more time /health endpoint, OpenWeatherMap tell us that our account is temporary blocked and this
service is being reported as DOWN.</p>
</div>
<div class="listingblock">
<div class="content">
-<pre class="highlight"><code>curl http://localhost:8080/mp-custom-healthcheck/health</code></pre>
+<pre>curl http://localhost:8080/mp-custom-healthcheck/health</pre>
</div>
</div>
<div class="listingblock">
@@ -237,15 +230,13 @@ service is being reported as DOWN.</p>
}</code></pre>
</div>
</div>
-</div>
-<div class="sect3">
-<h4 id="_example_4">Example 4</h4>
+<h4 id="_example_4" class="discrete">Example 4</h4>
<div class="paragraph">
<p>Weather API has stopped.</p>
</div>
<div class="listingblock">
<div class="content">
-<pre class="highlight"><code>curl http://localhost:8080/mp-custom-healthcheck/weather/day/status</code></pre>
+<pre>curl http://localhost:8080/mp-custom-healthcheck/weather/day/status</pre>
</div>
</div>
<div class="listingblock">
@@ -253,24 +244,20 @@ service is being reported as DOWN.</p>
<pre class="highlight"><code class="language-text" data-lang="text">Weather Service is unavailable at moment, retry later.</code></pre>
</div>
</div>
-<div class="sect4">
-<h5 id="_running_the_tests">Running the tests</h5>
+<h5 id="_running_the_tests" class="discrete">Running the tests</h5>
<div class="paragraph">
<p>You can also try it out using the <a href="src/test/java/org/superbiz/rest/WeatherServiceTest.java">WeatherServiceTest.java</a> available in the project.</p>
</div>
-<div class="literalblock">
+<div class="listingblock">
<div class="content">
<pre>mvn clean test</pre>
</div>
</div>
<div class="listingblock">
<div class="content">
-<pre class="highlight"><code>[INFO] Results:
+<pre>[INFO] Results:
[INFO]
-[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped:</code></pre>
-</div>
-</div>
-</div>
+[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped:</pre>
</div>
</div>
</div>
Modified: tomee/site/trunk/content/master/examples/mp-faulttolerance-fallback.html
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/mp-faulttolerance-fallback.html?rev=1849998&r1=1849997&r2=1849998&view=diff
==============================================================================
--- tomee/site/trunk/content/master/examples/mp-faulttolerance-fallback.html (original)
+++ tomee/site/trunk/content/master/examples/mp-faulttolerance-fallback.html Sun Dec 30 19:02:51 2018
@@ -88,14 +88,21 @@
<div class="col-md-12">
<div class='page-header'>
- <h1>Microprofile Fault Tolerance - Fallback</h1>
+ <h1>MicroProfile Fault Tolerance - Fallback</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
- <div class="sect1">
+ <div id="preamble">
+<div class="sectionbody">
+<div class="paragraph">
+<p>This is an example of how to use Microprofile @Fallback in TomEE.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
<h2 id="_fallback_feature">Fallback Feature</h2>
<div class="sectionbody">
<div class="paragraph">