http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/972cc356/src/main/jbake/content/examples/simple-cdi-interceptor.adoc
----------------------------------------------------------------------
diff --git a/src/main/jbake/content/examples/simple-cdi-interceptor.adoc 
b/src/main/jbake/content/examples/simple-cdi-interceptor.adoc
new file mode 100755
index 0000000..f29d9be
--- /dev/null
+++ b/src/main/jbake/content/examples/simple-cdi-interceptor.adoc
@@ -0,0 +1,127 @@
+= simple-cdi-interceptor
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-cdi-interceptor can be browsed at 
https://github.com/apache/tomee/tree/master/examples/simple-cdi-interceptor
+
+= 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 
+
+
+[source,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 {
+}
+----
+
+
+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.
+
+
+[source,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();
+    }
+}
+----
+
+
+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 ! 
+
+
+[source,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
+}
+----
+
+
+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]
+
+
+[source,xml]
+----
+<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://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

http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/972cc356/src/main/jbake/content/examples/simple-cmp2.adoc
----------------------------------------------------------------------
diff --git a/src/main/jbake/content/examples/simple-cmp2.adoc 
b/src/main/jbake/content/examples/simple-cmp2.adoc
new file mode 100755
index 0000000..ffddbc9
--- /dev/null
+++ b/src/main/jbake/content/examples/simple-cmp2.adoc
@@ -0,0 +1,361 @@
+= EJB 2.1 CMP EntityBeans (CMP2)
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-cmp2 can be browsed at 
https://github.com/apache/tomee/tree/master/examples/simple-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 
link:dynamic-dao-implementation.html[Dynamic DAO] 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
+
+
+[source,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);
+
+}
+----
+
+
+==  CMP2 Home interface, Movies
+
+
+[source,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;
+}
+----
+
+
+==  CMP2 mapping in ejb-jar.xml
+
+
+[source,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
+
+
+[source,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
+
+
+[source,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());
+    }
+}
+----
+
+
+=  Running
+
+    
+
+[source]
+----
+-------------------------------------------------------
+ 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
+----
+
+
+=  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
+
+
+[source,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>
+----
+
+
+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.
+
+
+[source,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>
+----
+

http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/972cc356/src/main/jbake/content/examples/simple-mdb-and-cdi.adoc
----------------------------------------------------------------------
diff --git a/src/main/jbake/content/examples/simple-mdb-and-cdi.adoc 
b/src/main/jbake/content/examples/simple-mdb-and-cdi.adoc
new file mode 100755
index 0000000..e64b8c9
--- /dev/null
+++ b/src/main/jbake/content/examples/simple-mdb-and-cdi.adoc
@@ -0,0 +1,211 @@
+= Simple MDB and CDI
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-mdb-and-cdi can be browsed at 
https://github.com/apache/tomee/tree/master/examples/simple-mdb-and-cdi
+
+
+*Help us document this example! Click the blue pencil icon in the upper right 
to edit this page.*
+
+==  ChatBean
+
+
+[source,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();
+        }
+    }
+}
+----
+
+
+==  ChatRespondCreator
+
+
+[source,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;
+    }
+}
+----
+
+
+==  beans.xml
+
+
+[source,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
+
+
+[source,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();
+    }
+}
+----
+

http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/972cc356/src/main/jbake/content/examples/simple-mdb-with-descriptor.adoc
----------------------------------------------------------------------
diff --git a/src/main/jbake/content/examples/simple-mdb-with-descriptor.adoc 
b/src/main/jbake/content/examples/simple-mdb-with-descriptor.adoc
new file mode 100755
index 0000000..1d37a81
--- /dev/null
+++ b/src/main/jbake/content/examples/simple-mdb-with-descriptor.adoc
@@ -0,0 +1,268 @@
+= Simple MDB with Descriptor
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-mdb-with-descriptor can be browsed at 
https://github.com/apache/tomee/tree/master/examples/simple-mdb-with-descriptor
+
+
+*Help us document this example! Click the blue pencil icon in the upper right 
to edit this page.*
+
+==  ChatBean
+
+
+[source,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();
+        }
+    }
+}
+----
+
+
+==  ejb-jar.xml
+
+
+[source,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
+
+
+[source,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();
+    }
+}
+----
+
+
+=  Running
+
+    
+
+[source]
+----
+-------------------------------------------------------
+ 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
+----
+
+    

http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/972cc356/src/main/jbake/content/examples/simple-mdb.adoc
----------------------------------------------------------------------
diff --git a/src/main/jbake/content/examples/simple-mdb.adoc 
b/src/main/jbake/content/examples/simple-mdb.adoc
new file mode 100755
index 0000000..db6c6d0
--- /dev/null
+++ b/src/main/jbake/content/examples/simple-mdb.adoc
@@ -0,0 +1,233 @@
+= Simple MDB
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-mdb can be browsed at 
https://github.com/apache/tomee/tree/master/examples/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="../../resources/mdb-flow.png" alt=""/>
+
+==  ChatBean
+
+
+[source,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();
+        }
+    }
+}
+----
+
+
+==  ChatBeanTest
+
+
+[source,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();
+    }
+}
+----
+
+
+=  Running
+
+    
+
+[source]
+----
+-------------------------------------------------------
+ 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
+----
+
+    

http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/972cc356/src/main/jbake/content/examples/simple-rest.adoc
----------------------------------------------------------------------
diff --git a/src/main/jbake/content/examples/simple-rest.adoc 
b/src/main/jbake/content/examples/simple-rest.adoc
new file mode 100755
index 0000000..f35d8df
--- /dev/null
+++ b/src/main/jbake/content/examples/simple-rest.adoc
@@ -0,0 +1,148 @@
+= Simple REST
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-rest can be browsed at 
https://github.com/apache/tomee/tree/master/examples/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.
+
+
+[source,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();
+    }
+}
+----
+
+
+=  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.
+
+
+[source,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);
+    }
+}
+----
+
+
+= 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
+

http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/972cc356/src/main/jbake/content/examples/simple-singleton.adoc
----------------------------------------------------------------------
diff --git a/src/main/jbake/content/examples/simple-singleton.adoc 
b/src/main/jbake/content/examples/simple-singleton.adoc
new file mode 100755
index 0000000..7dac9e8
--- /dev/null
+++ b/src/main/jbake/content/examples/simple-singleton.adoc
@@ -0,0 +1,376 @@
+= Simple Singleton
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-singleton can be browsed at 
https://github.com/apache/tomee/tree/master/examples/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 link:../../singleton-beans.html[Singleton Beans] 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.
+
+
+[source,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);
+    }
+}
+----
+
+
+==  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)`).
+
+
+[source,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);
+    }
+}
+----
+
+
+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 link:../../singleton-beans.html[Singleton Beans] page for  more 
advanced details on Container-Managed Concurrency.
+
+=  Testing
+
+
+==  ComponentRegistryTest
+
+
+[source,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();
+    }
+}
+----
+
+
+==  PropertiesRegistryTest
+
+
+[source,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();
+    }
+}
+----
+
+
+
+= Running
+
+Running the example is fairly simple. In the "simple-singleton" directory run:
+
+    $ mvn clean install
+
+Which should create output like the following.
+
+
+
+[source]
+----
+-------------------------------------------------------
+ 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
+----
+
+

http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/972cc356/src/main/jbake/content/examples/simple-stateful-callbacks.adoc
----------------------------------------------------------------------
diff --git a/src/main/jbake/content/examples/simple-stateful-callbacks.adoc 
b/src/main/jbake/content/examples/simple-stateful-callbacks.adoc
new file mode 100755
index 0000000..f3c4506
--- /dev/null
+++ b/src/main/jbake/content/examples/simple-stateful-callbacks.adoc
@@ -0,0 +1,324 @@
+= Simple Stateful with callback methods
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-stateful-callbacks can be browsed at 
https://github.com/apache/tomee/tree/master/examples/simple-stateful-callbacks
+
+
+This example shows how to create a stateful session bean that uses the 
@PrePassivate, @PostActivate, @PostConstruct, @PreDestroy and @AroundInvoke 
annotations.
+
+==  CallbackCounter
+
+
+[source,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);
+    }
+}
+----
+
+
+==  ExecutionChannel
+
+
+[source,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);
+        }
+    }
+}
+----
+
+
+==  ExecutionObserver
+
+
+[source,java]
+----
+package org.superbiz.counter;
+
+public interface ExecutionObserver {
+
+    void onExecution(Object value);
+
+}
+----
+
+
+==  CounterCallbacksTest
+
+
+[source,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);
+    }
+}
+----
+
+
+=  Running
+
+
+[source]
+----
+-------------------------------------------------------
+ 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
+----
+
+
+    [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] 
------------------------------------------------------------------------
+
+

Reply via email to