You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2016/12/04 11:01:44 UTC

svn commit: r1772522 [41/45] - in /tomee/site/trunk: content/ content/admin/ content/admin/cluster/ content/admin/configuration/ content/advanced/ content/advanced/applicationcomposer/ content/advanced/client/ content/advanced/setup/ content/advanced/s...

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-singleton.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-singleton.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-singleton.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-singleton.adoc Sun Dec  4 11:01:40 2016
@@ -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
+----
+
+

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-singleton.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful-callbacks.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful-callbacks.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful-callbacks.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful-callbacks.adoc Sun Dec  4 11:01:40 2016
@@ -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] ------------------------------------------------------------------------
+
+

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful-callbacks.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful.adoc Sun Dec  4 11:01:40 2016
@@ -0,0 +1,160 @@
+= Simple Stateful
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-stateful can be browsed at https://github.com/apache/tomee/tree/master/examples/simple-stateful
+
+
+This example demonstrates a simple deployment of a Stateful session bean.
+
+
+NOTE: "As its name suggests, a stateful session bean is similar to an interactive session. A stateful session bean is not shared; 
+
+it can have only one client, in the same way that an interactive session can have only one user. 
+When the client terminates, its stateful session bean appears to terminate and is no longer associated with the client."
+
+The `Counter` class is a Stateful session bean that maintains a state in a form of a `count` integer field.
+It exposes three methods: `count()`, `increment()` and `reset()` to manipulate and view its state.
+
+Typically, Stateful and Stateless beans implement Local and/or Remote interfaces to determine which methods should
+be exposed. In this case, the bean is using a no-interface view, which means that all public methods are exposed
+as a local view. 
+
+==  Counter
+
+
+[source,java]
+----
+package org.superbiz.counter;
+
+import javax.ejb.Stateful;
+
+/**
+ * This is an EJB 3 style pojo stateful session bean
+ * Every stateful session bean implementation must be annotated
+ * using the annotation @Stateful
+ * This EJB has 2 business interfaces: CounterRemote, a remote business
+ * interface, and CounterLocal, a local business interface
+ * <p/>
+ * Per EJB3 rules when the @Remote or @Local annotation isn't present
+ * in the bean class (this class), all interfaces are considered
+ * local unless explicitly annotated otherwise.  If you look
+ * in the CounterRemote interface, you'll notice it uses the @Remote
+ * annotation while the CounterLocal interface is not annotated relying
+ * on the EJB3 default rules to make it a local interface.
+ */
+//START SNIPPET: code
+@Stateful
+public class Counter {
+
+    private int count = 0;
+
+    public int count() {
+        return count;
+    }
+
+    public int increment() {
+        return ++count;
+    }
+
+    public int reset() {
+        return (count = 0);
+    }
+}
+----
+
+
+==  CounterTest
+
+The `Counter` class is tested by obtaining a `Context` object and performing a JNDI lookup on it, to retrieve
+an instance of the `Counter` bean. After some state manipulation, a new instance is fetched from the container
+and we can see that it's a new instance.
+
+
+[source,java]
+----
+package org.superbiz.counter;
+
+import junit.framework.TestCase;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+
+public class CounterTest extends TestCase {
+
+    //START SNIPPET: local
+    public void test() throws Exception {
+
+        final Context context = EJBContainer.createEJBContainer().getContext();
+
+        Counter counterA = (Counter) context.lookup("java:global/simple-stateful/Counter");
+
+        assertEquals(0, counterA.count());
+        assertEquals(0, counterA.reset());
+        assertEquals(1, counterA.increment());
+        assertEquals(2, counterA.increment());
+        assertEquals(0, counterA.reset());
+
+        counterA.increment();
+        counterA.increment();
+        counterA.increment();
+        counterA.increment();
+
+        assertEquals(4, counterA.count());
+
+        // Get a new counter
+        Counter counterB = (Counter) context.lookup("java:global/simple-stateful/Counter");
+
+        // The new bean instance starts out at 0
+        assertEquals(0, counterB.count());
+    }
+    //END SNIPPET: local
+}
+----
+
+
+=  Running
+
+    
+
+[source]
+----
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.counter.CounterTest
+Apache OpenEJB 4.0.0-beta-1    build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/simple-stateful
+INFO - openejb.base = /Users/dblevins/examples/simple-stateful
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/simple-stateful/target/classes
+INFO - Beginning load: /Users/dblevins/examples/simple-stateful/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/simple-stateful
+INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+INFO - Auto-creating a container for bean Counter: Container(type=STATEFUL, id=Default Stateful Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.counter.CounterTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Enterprise application "/Users/dblevins/examples/simple-stateful" loaded.
+INFO - Assembling app: /Users/dblevins/examples/simple-stateful
+INFO - Jndi(name="java:global/simple-stateful/Counter!org.superbiz.counter.Counter")
+INFO - Jndi(name="java:global/simple-stateful/Counter")
+INFO - Jndi(name="java:global/EjbModule309142400/org.superbiz.counter.CounterTest!org.superbiz.counter.CounterTest")
+INFO - Jndi(name="java:global/EjbModule309142400/org.superbiz.counter.CounterTest")
+INFO - Created Ejb(deployment-id=Counter, ejb-name=Counter, container=Default Stateful Container)
+INFO - Created Ejb(deployment-id=org.superbiz.counter.CounterTest, ejb-name=org.superbiz.counter.CounterTest, container=Default Managed Container)
+INFO - Started Ejb(deployment-id=Counter, ejb-name=Counter, container=Default Stateful Container)
+INFO - Started Ejb(deployment-id=org.superbiz.counter.CounterTest, ejb-name=org.superbiz.counter.CounterTest, container=Default Managed Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/simple-stateful)
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.098 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+----
+
+    

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateful.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-callbacks.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-callbacks.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-callbacks.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-callbacks.adoc Sun Dec  4 11:01:40 2016
@@ -0,0 +1,260 @@
+= Simple Stateless with callback methods
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-stateless-callbacks can be browsed at https://github.com/apache/tomee/tree/master/examples/simple-stateless-callbacks
+
+
+This example shows how to create a stateless session bean that uses the @PostConstruct, @PreDestroy and @AroundInvoke annotations.
+
+==  CalculatorBean
+
+
+[source,java]
+----
+package org.superbiz.stateless.basic;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+@Stateless
+public class CalculatorBean {
+
+    @PostConstruct
+    public void postConstruct() {
+        ExecutionChannel.getInstance().notifyObservers("postConstruct");
+    }
+
+    @PreDestroy
+    public void preDestroy() {
+        ExecutionChannel.getInstance().notifyObservers("preDestroy");
+    }
+
+    @AroundInvoke
+    public Object intercept(InvocationContext ctx) throws Exception {
+        ExecutionChannel.getInstance().notifyObservers(ctx.getMethod().getName());
+        return ctx.proceed();
+    }
+
+    public int add(int a, int b) {
+        return a + b;
+    }
+
+    public int subtract(int a, int b) {
+        return a - b;
+    }
+
+    public int multiply(int a, int b) {
+        return a * b;
+    }
+
+    public int divide(int a, int b) {
+        return a / b;
+    }
+
+    public int remainder(int a, int b) {
+        return a % b;
+    }
+
+}
+----
+
+
+==  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);
+
+}
+----
+
+
+
+==  CalculatorTest
+
+
+[source,java]
+----
+package org.superbiz.stateless.basic;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+public class CalculatorTest implements ExecutionObserver {
+    private static final String JNDI = "java:global/simple-stateless-callbacks/CalculatorBean";
+
+    private List<Object> received = new ArrayList<Object>();
+
+    public Context getContext() throws NamingException {
+        final Properties p = new Properties();
+        p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+        return new InitialContext(p);
+
+    }
+
+    @Test
+    public void test() throws Exception {
+        ExecutionChannel.getInstance().addObserver(this);
+
+        final EJBContainer container = EJBContainer.createEJBContainer();
+
+        {
+            final CalculatorBean calculator = (CalculatorBean) getContext().lookup(JNDI);
+
+            Assert.assertEquals(10, calculator.add(4, 6));
+
+            //the bean is constructed only when it is used for the first time
+            Assert.assertEquals("postConstruct", this.received.remove(0));
+            Assert.assertEquals("add", this.received.remove(0));
+
+            Assert.assertEquals(-2, calculator.subtract(4, 6));
+            Assert.assertEquals("subtract", this.received.remove(0));
+
+            Assert.assertEquals(24, calculator.multiply(4, 6));
+            Assert.assertEquals("multiply", this.received.remove(0));
+
+            Assert.assertEquals(2, calculator.divide(12, 6));
+            Assert.assertEquals("divide", this.received.remove(0));
+
+            Assert.assertEquals(4, calculator.remainder(46, 6));
+            Assert.assertEquals("remainder", this.received.remove(0));
+        }
+
+        {
+            final CalculatorBean calculator = (CalculatorBean) getContext().lookup(JNDI);
+
+            Assert.assertEquals(10, calculator.add(4, 6));
+            Assert.assertEquals("add", this.received.remove(0));
+
+        }
+
+        container.close();
+        Assert.assertEquals("preDestroy", this.received.remove(0));
+        Assert.assertTrue(this.received.isEmpty());
+    }
+
+    @Override
+    public void onExecution(Object value) {
+        System.out.println("Test step -> " + value);
+        this.received.add(value);
+    }
+}
+----
+
+
+=  Running
+
+
+[source]
+----
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.stateless.basic.CalculatorTest
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Sat Jul 21 09:23:38 EDT 2012
+INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 4.1.0
+INFO - Build date: 20120721
+INFO - Build time: 04:06
+INFO - ********************************************************************************
+INFO - openejb.home = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+INFO - openejb.base = /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+INFO - Succeeded in installing singleton service
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one for the beans deployed.
+INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+INFO - Creating TransactionManager(id=Default Transaction Manager)
+INFO - Creating SecurityService(id=Default Security Service)
+INFO - Beginning load: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks/target/classes
+INFO - Configuring enterprise application: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+INFO - Auto-deploying ejb CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Creating Container(id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.stateless.basic.CalculatorTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Using directory /tmp for stateful session passivation
+INFO - Enterprise application "/home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks" loaded.
+INFO - Assembling app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+INFO - Jndi(name="java:global/simple-stateless-callbacks/CalculatorBean!org.superbiz.stateless.basic.CalculatorBean")
+INFO - Jndi(name="java:global/simple-stateless-callbacks/CalculatorBean")
+INFO - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@527736bd
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points are validated successfully.
+INFO - OpenWebBeans Container has started, it took 111 ms.
+INFO - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+INFO - Deployed Application(path=/home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks)
+Test step -> postConstruct
+Test step -> add
+Test step -> subtract
+Test step -> multiply
+Test step -> divide
+Test step -> remainder
+Test step -> add
+INFO - Undeploying app: /home/boto/dev/ws/openejb_trunk/openejb/examples/simple-stateless-callbacks
+Test step -> preDestroy
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.884 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+----
+

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-callbacks.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-with-descriptor.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-with-descriptor.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-with-descriptor.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-with-descriptor.adoc Sun Dec  4 11:01:40 2016
@@ -0,0 +1,205 @@
+= Simple Stateless with Descriptor
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-stateless-with-descriptor can be browsed at https://github.com/apache/tomee/tree/master/examples/simple-stateless-with-descriptor
+
+
+This test is similar to simple-stateless, with two major differences. In this case all the classes are regular POJOs without annotations.
+The EJB-specific metadata is provided via an XML descriptor. The second difference is the explicite use of Local and Remote interfaces. 
+
+==  CalculatorImpl
+
+
+[source,java]
+----
+package org.superbiz.calculator;
+
+/**
+ * This is an EJB 3 stateless session bean, configured using an EJB 3
+ * deployment descriptor as opposed to using annotations.
+ * This EJB has 2 business interfaces: CalculatorRemote, a remote business
+ * interface, and CalculatorLocal, a local business interface
+ */
+public class CalculatorImpl implements CalculatorRemote, CalculatorLocal {
+
+    public int sum(int add1, int add2) {
+        return add1 + add2;
+    }
+
+    public int multiply(int mul1, int mul2) {
+        return mul1 * mul2;
+    }
+}
+----
+
+
+==  CalculatorLocal
+
+
+[source,java]
+----
+package org.superbiz.calculator;
+
+/**
+ * This is an EJB 3 local business interface
+ * This interface is specified using the business-local tag in the deployment descriptor
+ */
+public interface CalculatorLocal {
+
+    public int sum(int add1, int add2);
+
+    public int multiply(int mul1, int mul2);
+}
+----
+
+
+==  CalculatorRemote
+
+
+[source,java]
+----
+package org.superbiz.calculator;
+
+
+/**
+ * This is an EJB 3 remote business interface
+ * This interface is specified using the business-local tag in the deployment descriptor
+ */
+public interface CalculatorRemote {
+
+    public int sum(int add1, int add2);
+
+    public int multiply(int mul1, int mul2);
+}
+----
+
+
+==  ejb-jar.xml
+
+The XML descriptor defines the EJB class and both local and remote interfaces.
+
+
+[source,xml]
+----
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+         version="3.0">
+  <enterprise-beans>
+    <session>
+      <ejb-name>CalculatorImpl</ejb-name>
+      <business-local>org.superbiz.calculator.CalculatorLocal</business-local>
+      <business-remote>org.superbiz.calculator.CalculatorRemote</business-remote>
+      <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
+      <session-type>Stateless</session-type>
+      <transaction-type>Container</transaction-type>
+    </session>
+  </enterprise-beans>
+</ejb-jar>
+----
+
+
+    
+
+==  CalculatorTest
+
+Two tests obtain a Local and Remote interface to the bean instance. This time an `InitialContext` object is directly created, 
+as opposed to getting the context from `EJBContainer`, as we did in the previous example. 
+
+
+[source,java]
+----
+package org.superbiz.calculator;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+    private InitialContext initialContext;
+
+    protected void setUp() throws Exception {
+        Properties properties = new Properties();
+        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+
+        initialContext = new InitialContext(properties);
+    }
+
+    /**
+     * Lookup the Calculator bean via its remote home interface
+     *
+     * @throws Exception
+     */
+    public void testCalculatorViaRemoteInterface() throws Exception {
+        Object object = initialContext.lookup("CalculatorImplRemote");
+
+        assertNotNull(object);
+        assertTrue(object instanceof CalculatorRemote);
+        CalculatorRemote calc = (CalculatorRemote) object;
+        assertEquals(10, calc.sum(4, 6));
+        assertEquals(12, calc.multiply(3, 4));
+    }
+
+    /**
+     * Lookup the Calculator bean via its local home interface
+     *
+     * @throws Exception
+     */
+    public void testCalculatorViaLocalInterface() throws Exception {
+        Object object = initialContext.lookup("CalculatorImplLocal");
+
+        assertNotNull(object);
+        assertTrue(object instanceof CalculatorLocal);
+        CalculatorLocal calc = (CalculatorLocal) object;
+        assertEquals(10, calc.sum(4, 6));
+        assertEquals(12, calc.multiply(3, 4));
+    }
+}
+----
+
+
+=  Running
+
+    
+
+[source]
+----
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.calculator.CalculatorTest
+Apache OpenEJB 4.0.0-beta-1    build: 20111002-04:06
+http://tomee.apache.org/
+INFO - openejb.home = /Users/dblevins/examples/simple-stateless-with-descriptor
+INFO - openejb.base = /Users/dblevins/examples/simple-stateless-with-descriptor
+INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+INFO - Found EjbModule in classpath: /Users/dblevins/examples/simple-stateless-with-descriptor/target/classes
+INFO - Beginning load: /Users/dblevins/examples/simple-stateless-with-descriptor/target/classes
+INFO - Configuring enterprise application: /Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean CalculatorImpl: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Enterprise application "/Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear" loaded.
+INFO - Assembling app: /Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear
+INFO - Jndi(name=CalculatorImplLocal) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/simple-stateless-with-descriptor/CalculatorImpl!org.superbiz.calculator.CalculatorLocal) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=CalculatorImplRemote) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/simple-stateless-with-descriptor/CalculatorImpl!org.superbiz.calculator.CalculatorRemote) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Jndi(name=global/classpath.ear/simple-stateless-with-descriptor/CalculatorImpl) --> Ejb(deployment-id=CalculatorImpl)
+INFO - Created Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/examples/simple-stateless-with-descriptor/classpath.ear)
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.475 sec
+
+Results :
+
+Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
+----
+
+    

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless-with-descriptor.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless.adoc Sun Dec  4 11:01:40 2016
@@ -0,0 +1,221 @@
+= Simple Stateless
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-stateless can be browsed at https://github.com/apache/tomee/tree/master/examples/simple-stateless
+
+
+
+NOTE: "Stateless session beans are session beans whose instances have no conversational state.
+
+This means that all bean instances are equivalent when they are not involved in servicing
+a client-invoked method. The term 'stateless' signifies that an instance has no state for a
+specific client."
+
+What this means is quite simply that stateless beans are shared. They do in fact have state
+as you can assign values to the variables, etc. in the bean instance. The only catch is there
+are a pool of identical instances and you are not guaranteed to get the exact same instance on
+every call. For each call, you get whatever instance happens to be available. This is identical
+to checking out a book from the library or renting a movie from the video store. You are essentially
+checking out or renting a new bean instance on each method call.
+
+==  CalculatorBean
+
+
+[source,java]
+----
+package org.superbiz.stateless.basic;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class CalculatorBean {
+
+    public int add(int a, int b) {
+        return a + b;
+    }
+
+    public int subtract(int a, int b) {
+        return a - b;
+    }
+
+    public int multiply(int a, int b) {
+        return a * b;
+    }
+
+    public int divide(int a, int b) {
+        return a / b;
+    }
+
+    public int remainder(int a, int b) {
+        return a % b;
+    }
+}
+----
+
+
+==  CalculatorTest
+
+Our `CalculatorBean` can be easily tested using the `EJBContainer` API in EJB 3.1
+
+
+[source,java]
+----
+package org.superbiz.stateless.basic;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.NamingException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class CalculatorTest {
+
+    private static EJBContainer ejbContainer;
+
+    private CalculatorBean calculator;
+
+    @BeforeClass
+    public static void startTheContainer() {
+        ejbContainer = EJBContainer.createEJBContainer();
+    }
+
+    @Before
+    public void lookupABean() throws NamingException {
+        Object object = ejbContainer.getContext().lookup("java:global/simple-stateless/CalculatorBean");
+
+        assertTrue(object instanceof CalculatorBean);
+
+        calculator = (CalculatorBean) object;
+    }
+
+    @AfterClass
+    public static void stopTheContainer() {
+        if (ejbContainer != null) {
+            ejbContainer.close();
+        }
+    }
+
+    /**
+     * Test Add method
+     */
+    @Test
+    public void testAdd() {
+
+        assertEquals(10, calculator.add(4, 6));
+
+    }
+
+    /**
+     * Test Subtract method
+     */
+    @Test
+    public void testSubtract() {
+
+        assertEquals(-2, calculator.subtract(4, 6));
+
+    }
+
+    /**
+     * Test Multiply method
+     */
+    @Test
+    public void testMultiply() {
+
+        assertEquals(24, calculator.multiply(4, 6));
+
+    }
+
+    /**
+     * Test Divide method
+     */
+    @Test
+    public void testDivide() {
+
+        assertEquals(2, calculator.divide(12, 6));
+
+    }
+
+    /**
+     * Test Remainder method
+     */
+    @Test
+    public void testRemainder() {
+
+        assertEquals(4, calculator.remainder(46, 6));
+
+    }
+
+}
+----
+
+
+=  Running
+
+
+Running the example should generate output similar to the following
+
+    
+
+[source]
+----
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.stateless.basic.CalculatorTest
+Infos - ********************************************************************************
+Infos - OpenEJB http://tomee.apache.org/
+Infos - Startup: Tue Aug 14 13:28:12 CEST 2012
+Infos - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+Infos - Version: 4.1.0
+Infos - Build date: 20120814
+Infos - Build time: 01:06
+Infos - ********************************************************************************
+Infos - openejb.home = /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Infos - openejb.base = /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Infos - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@33bb11
+Infos - Succeeded in installing singleton service
+Infos - Using 'javax.ejb.embeddable.EJBContainer=true'
+Infos - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one for the beans deployed.
+Infos - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+Infos - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+Infos - Creating TransactionManager(id=Default Transaction Manager)
+Infos - Creating SecurityService(id=Default Security Service)
+Infos - Beginning load: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless/target/classes
+Infos - Configuring enterprise application: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Infos - Auto-deploying ejb CalculatorBean: EjbDeployment(deployment-id=CalculatorBean)
+Infos - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+Infos - Auto-creating a container for bean CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
+Infos - Creating Container(id=Default Stateless Container)
+Infos - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+Infos - Auto-creating a container for bean org.superbiz.stateless.basic.CalculatorTest: Container(type=MANAGED, id=Default Managed Container)
+Infos - Creating Container(id=Default Managed Container)
+Infos - Using directory /tmp for stateful session passivation
+Infos - Enterprise application "/home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless" loaded.
+Infos - Assembling app: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Infos - Jndi(name="java:global/simple-stateless/CalculatorBean!org.superbiz.stateless.basic.CalculatorBean")
+Infos - Jndi(name="java:global/simple-stateless/CalculatorBean")
+Infos - Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@33bb11
+Infos - OpenWebBeans Container is starting...
+Infos - Adding OpenWebBeansPlugin : [CdiPlugin]
+Infos - All injection points are validated successfully.
+Infos - OpenWebBeans Container has started, it took 135 ms.
+Infos - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+Infos - Started Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
+Infos - Deployed Application(path=/home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless)
+Infos - Undeploying app: /home/a185558/Development/Apache/openejb-trunk/examples/simple-stateless
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.068 sec
+
+Results :
+
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
+----
+
+    

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-stateless.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice-without-interface.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice-without-interface.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice-without-interface.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice-without-interface.adoc Sun Dec  4 11:01:40 2016
@@ -0,0 +1,110 @@
+= Simple Webservice Without Interface
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-webservice-without-interface can be browsed at https://github.com/apache/tomee/tree/master/examples/simple-webservice-without-interface
+
+
+*Help us document this example! Click the blue pencil icon in the upper right to edit this page.*
+
+==  Calculator
+
+
+[source,java]
+----
+package org.superbiz.calculator;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+@Stateless
+@WebService(
+        portName = "CalculatorPort",
+        serviceName = "CalculatorWsService",
+        targetNamespace = "http://superbiz.org/wsdl")
+public class Calculator {
+    public int sum(int add1, int add2) {
+        return add1 + add2;
+    }
+
+    public int multiply(int mul1, int mul2) {
+        return mul1 * mul2;
+    }
+}
+----
+
+
+==  ejb-jar.xml
+
+
+[source,xml]
+----
+<ejb-jar/>
+----
+
+
+==  CalculatorTest
+
+
+[source,java]
+----
+package org.superbiz.calculator;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.NamingException;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+
+public class CalculatorTest {
+    private static EJBContainer container;
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        final Properties properties = new Properties();
+        properties.setProperty("openejb.embedded.remotable", "true");
+
+        container = EJBContainer.createEJBContainer(properties);
+    }
+
+    @Before
+    public void inject() throws NamingException {
+        if (container != null) {
+            container.getContext().bind("inject", this);
+        }
+    }
+
+    @AfterClass
+    public static void close() {
+        if (container != null) {
+            container.close();
+        }
+    }
+
+    @Test
+    public void wsdlExists() throws Exception {
+        final URL url = new URL("http://127.0.0.1:4204/Calculator?wsdl");
+        assertTrue(IOUtils.readLines(url.openStream()).size() > 0);
+        assertTrue(IOUtils.readLines(url.openStream()).toString().contains("CalculatorWsService"));
+    }
+}
+----
+
+
+==  ejb-jar.xml
+
+
+[source,xml]
+----
+<ejb-jar/>
+----
+

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice-without-interface.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice.adoc Sun Dec  4 11:01:40 2016
@@ -0,0 +1,386 @@
+= JAX-WS @WebService example
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example simple-webservice can be browsed at https://github.com/apache/tomee/tree/master/examples/simple-webservice
+
+
+Creating Web Services with JAX-WS is quite easy.  Little has to be done aside from annotating a class with `@WebService`.  For
+the purposes of this example we will also annotate our component with `@Stateless` which takes some of the configuration out of
+the process and gives us some nice options such as transactions and security.
+
+==  @WebService
+
+The following is all that is required.  No external xml files are needed.  This class placed in a jar or war and deployed into a compliant Java EE server like TomEE is enough to have the Calculator class discovered and deployed and the webservice online.
+
+
+[source,java]
+----
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+@Stateless
+@WebService(
+        portName = "CalculatorPort",
+        serviceName = "CalculatorService",
+        targetNamespace = "http://superbiz.org/wsdl",
+        endpointInterface = "org.superbiz.calculator.ws.CalculatorWs")
+public class Calculator implements CalculatorWs {
+
+    public int sum(int add1, int add2) {
+        return add1 + add2;
+    }
+
+    public int multiply(int mul1, int mul2) {
+        return mul1 * mul2;
+    }
+}
+----
+
+
+==  @WebService Endpoint Interface
+
+Having an endpoint interface is not required, but it can make testing and using the web service from other Java clients far easier.
+
+
+[source,java]
+----
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://superbiz.org/wsdl")
+public interface CalculatorWs {
+
+    public int sum(int add1, int add2);
+
+    public int multiply(int mul1, int mul2);
+}
+----
+
+
+==  Calculator WSDL
+
+The wsdl for our service is autmatically created for us and available at `http://127.0.0.1:4204/Calculator?wsdl`.  In TomEE or Tomcat this would be at `http://127.0.0.1:8080/simple-webservice/Calculator?wsdl`
+
+
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="CalculatorService"
+                  targetNamespace="http://superbiz.org/wsdl"
+                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+                  xmlns:tns="http://superbiz.org/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  <wsdl:types>
+    <xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
+                targetNamespace="http://superbiz.org/wsdl" xmlns:tns="http://superbiz.org/wsdl"
+                xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+      <xsd:element name="multiply" type="tns:multiply"/>
+      <xsd:complexType name="multiply">
+        <xsd:sequence>
+          <xsd:element name="arg0" type="xsd:int"/>
+          <xsd:element name="arg1" type="xsd:int"/>
+        </xsd:sequence>
+      </xsd:complexType>
+      <xsd:element name="multiplyResponse" type="tns:multiplyResponse"/>
+      <xsd:complexType name="multiplyResponse">
+        <xsd:sequence>
+          <xsd:element name="return" type="xsd:int"/>
+        </xsd:sequence>
+      </xsd:complexType>
+      <xsd:element name="sum" type="tns:sum"/>
+      <xsd:complexType name="sum">
+        <xsd:sequence>
+          <xsd:element name="arg0" type="xsd:int"/>
+          <xsd:element name="arg1" type="xsd:int"/>
+        </xsd:sequence>
+      </xsd:complexType>
+      <xsd:element name="sumResponse" type="tns:sumResponse"/>
+      <xsd:complexType name="sumResponse">
+        <xsd:sequence>
+          <xsd:element name="return" type="xsd:int"/>
+        </xsd:sequence>
+      </xsd:complexType>
+    </xsd:schema>
+  </wsdl:types>
+  <wsdl:message name="multiplyResponse">
+    <wsdl:part element="tns:multiplyResponse" name="parameters"/>
+  </wsdl:message>
+  <wsdl:message name="sumResponse">
+    <wsdl:part element="tns:sumResponse" name="parameters"/>
+  </wsdl:message>
+  <wsdl:message name="sum">
+    <wsdl:part element="tns:sum" name="parameters"/>
+  </wsdl:message>
+  <wsdl:message name="multiply">
+    <wsdl:part element="tns:multiply" name="parameters"/>
+  </wsdl:message>
+  <wsdl:portType name="CalculatorWs">
+    <wsdl:operation name="multiply">
+      <wsdl:input message="tns:multiply" name="multiply"/>
+      <wsdl:output message="tns:multiplyResponse" name="multiplyResponse"/>
+    </wsdl:operation>
+    <wsdl:operation name="sum">
+      <wsdl:input message="tns:sum" name="sum"/>
+      <wsdl:output message="tns:sumResponse" name="sumResponse"/>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="CalculatorServiceSoapBinding" type="tns:CalculatorWs">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <wsdl:operation name="multiply">
+      <soap:operation soapAction="" style="document"/>
+      <wsdl:input name="multiply">
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="multiplyResponse">
+        <soap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="sum">
+      <soap:operation soapAction="" style="document"/>
+      <wsdl:input name="sum">
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="sumResponse">
+        <soap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="CalculatorService">
+    <wsdl:port binding="tns:CalculatorServiceSoapBinding" name="CalculatorPort">
+      <soap:address location="http://127.0.0.1:4204/Calculator?wsdl"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>
+----
+
+
+==  Accessing the @WebService with javax.xml.ws.Service
+
+In our testcase we see how to create a client for our `Calculator` service via the `javax.xml.ws.Service` class and leveraging our `CalculatorWs` endpoint interface.
+
+With this we can get an implementation of the interfacce generated dynamically for us that can be used to send compliant SOAP messages to our service.
+
+
+[source,java]
+----
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CalculatorTest {
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        Properties properties = new Properties();
+        properties.setProperty("openejb.embedded.remotable", "true");
+        //properties.setProperty("httpejbd.print", "true");
+        //properties.setProperty("httpejbd.indent.xml", "true");
+        EJBContainer.createEJBContainer(properties);
+    }
+
+    @Test
+    public void test() throws Exception {
+        Service calculatorService = Service.create(
+                new URL("http://127.0.0.1:4204/Calculator?wsdl"),
+                new QName("http://superbiz.org/wsdl", "CalculatorService"));
+
+        assertNotNull(calculatorService);
+
+        CalculatorWs calculator = calculatorService.getPort(CalculatorWs.class);
+        assertEquals(10, calculator.sum(4, 6));
+        assertEquals(12, calculator.multiply(3, 4));
+    }
+}
+----
+
+
+For easy testing we'll use the Embeddable EJBContainer API part of EJB 3.1 to boot CXF in our testcase.  This will deploy our application in the embedded container and bring the web service online so we can invoke it.
+
+=  Running
+
+Running the example can be done from maven with a simple 'mvn clean install' command run from the 'simple-webservice' directory.
+
+When run you should see output similar to the following.
+
+
+[source]
+----
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running org.superbiz.calculator.ws.CalculatorTest
+INFO - ********************************************************************************
+INFO - OpenEJB http://tomee.apache.org/
+INFO - Startup: Sat Feb 18 19:11:50 PST 2012
+INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+INFO - Version: 4.0.0-beta-3
+INFO - Build date: 20120218
+INFO - Build time: 03:32
+INFO - ********************************************************************************
+INFO - openejb.home = /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+INFO - openejb.base = /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@16bdb503
+INFO - succeeded in installing singleton service
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one for the beans deployed.
+INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+INFO - Creating TransactionManager(id=Default Transaction Manager)
+INFO - Creating SecurityService(id=Default Security Service)
+INFO - Beginning load: /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice/target/classes
+INFO - Using 'openejb.embedded=true'
+INFO - Configuring enterprise application: /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+INFO - Auto-deploying ejb Calculator: EjbDeployment(deployment-id=Calculator)
+INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
+INFO - Auto-creating a container for bean Calculator: Container(type=STATELESS, id=Default Stateless Container)
+INFO - Creating Container(id=Default Stateless Container)
+INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+INFO - Auto-creating a container for bean org.superbiz.calculator.ws.CalculatorTest: Container(type=MANAGED, id=Default Managed Container)
+INFO - Creating Container(id=Default Managed Container)
+INFO - Using directory /var/folders/bd/f9ntqy1m8xj_fs006s6crtjh0000gn/T for stateful session passivation
+INFO - Enterprise application "/Users/dblevins/work/all/trunk/openejb/examples/simple-webservice" loaded.
+INFO - Assembling app: /Users/dblevins/work/all/trunk/openejb/examples/simple-webservice
+INFO - ignoreXmlConfiguration == true
+INFO - ignoreXmlConfiguration == true
+INFO - existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@16bdb503
+INFO - OpenWebBeans Container is starting...
+INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+INFO - All injection points were validated successfully.
+INFO - OpenWebBeans Container has started, it took [62] ms.
+INFO - Created Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Stateless Container)
+INFO - Started Ejb(deployment-id=Calculator, ejb-name=Calculator, container=Default Stateless Container)
+INFO - Deployed Application(path=/Users/dblevins/work/all/trunk/openejb/examples/simple-webservice)
+INFO - Initializing network services
+INFO - can't find log4j MDC class
+INFO - Creating ServerService(id=httpejbd)
+INFO - Creating ServerService(id=cxf)
+INFO - Creating ServerService(id=admin)
+INFO - Creating ServerService(id=ejbd)
+INFO - Creating ServerService(id=ejbds)
+INFO - Initializing network services
+INFO -   ** Starting Services **
+INFO -   NAME                 IP              PORT
+INFO -   httpejbd             127.0.0.1       4204
+INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from class org.superbiz.calculator.ws.CalculatorWs
+INFO - Setting the server's publish address to be http://nopath:80
+INFO - Webservice(wsdl=http://127.0.0.1:4204/Calculator, qname={http://superbiz.org/wsdl}CalculatorService) --> Ejb(id=Calculator)
+INFO -   admin thread         127.0.0.1       4200
+INFO -   ejbd                 127.0.0.1       4201
+INFO -   ejbd                 127.0.0.1       4203
+INFO - -------
+INFO - Ready!
+INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+INFO - Creating Service {http://superbiz.org/wsdl}CalculatorService from WSDL: http://127.0.0.1:4204/Calculator?wsdl
+INFO - Default SAAJ universe not set
+INFO - TX NotSupported: Suspended transaction null
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.584 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+----
+
+
+==  Inspecting the messages
+
+The above test case will result in the following SOAP messages being sent between the clien and server.
+
+===  sum(int, int)
+
+Request SOAP message:
+
+
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+  <soap:Body>
+    <ns1:sum xmlns:ns1="http://superbiz.org/wsdl">
+      <arg0>4</arg0>
+      <arg1>6</arg1>
+    </ns1:sum>
+  </soap:Body>
+</soap:Envelope>
+----
+
+
+Response SOAP message:
+
+
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+  <soap:Body>
+    <ns1:sumResponse xmlns:ns1="http://superbiz.org/wsdl">
+      <return>10</return>
+    </ns1:sumResponse>
+  </soap:Body>
+</soap:Envelope>
+----
+
+
+===  multiply(int, int)
+
+Request SOAP message:
+
+
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+  <soap:Body>
+    <ns1:multiply xmlns:ns1="http://superbiz.org/wsdl">
+      <arg0>3</arg0>
+      <arg1>4</arg1>
+    </ns1:multiply>
+  </soap:Body>
+</soap:Envelope>
+----
+
+
+Response SOAP message:
+
+
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+  <soap:Body>
+    <ns1:multiplyResponse xmlns:ns1="http://superbiz.org/wsdl">
+      <return>12</return>
+    </ns1:multiplyResponse>
+  </soap:Body>
+</soap:Envelope>
+----
+
+
+==  Inside the jar
+
+With so much going on it can make things look more complex than they are.  It can be hard to believe that so much can happen with such little code.  That's the benefit of having an app server.
+
+If we look at the jar built by maven, we'll see the application itself is quite small:
+
+    $ jar tvf target/simple-webservice-1.1.0-SNAPSHOT.jar
+         0 Sat Feb 18 19:17:06 PST 2012 META-INF/
+       127 Sat Feb 18 19:17:04 PST 2012 META-INF/MANIFEST.MF
+         0 Sat Feb 18 19:17:02 PST 2012 org/
+         0 Sat Feb 18 19:17:02 PST 2012 org/superbiz/
+         0 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/
+         0 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/ws/
+       855 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/ws/Calculator.class
+       288 Sat Feb 18 19:17:02 PST 2012 org/superbiz/calculator/ws/CalculatorWs.class
+
+This single jar could be deployed any any compliant Java EE implementation.  In TomEE you'd simply place it in the `tomee.home/webapps/` directory.  No war file necessary.  If you did want to create a war, you'd simply place the jar in the `WEB-INF/lib/` directory of the war.
+
+The server already contains the right libraries to run the code, such as Apache CXF, so no need to include anything extra beyond your own application code.
+

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/simple-webservice.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy-meta.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy-meta.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy-meta.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy-meta.adoc Sun Dec  4 11:01:40 2016
@@ -0,0 +1,20 @@
+= spring-data-proxy-meta
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example spring-data-proxy-meta can be browsed at https://github.com/apache/tomee/tree/master/examples/spring-data-proxy-meta
+
+=  Spring Data With Meta sample #
+
+This example simply simplifies the usage of spring-data sample
+providing a meta annotation @SpringRepository to do all the dynamic procy EJB job.
+
+It replaces @Proxy and @Stateless annotations.
+
+Isn't it more comfortable?
+
+To do it we defined a meta annotation "Metatype" and used it.
+
+The proxy implementation is the same than for spring-data sample.

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy-meta.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy.adoc
URL: http://svn.apache.org/viewvc/tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy.adoc?rev=1772522&view=auto
==============================================================================
--- tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy.adoc (added)
+++ tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy.adoc Sun Dec  4 11:01:40 2016
@@ -0,0 +1,22 @@
+= spring-data-proxy
+:jbake-date: 2016-09-06
+:jbake-type: page
+:jbake-tomeepdf:
+:jbake-status: published
+
+Example spring-data-proxy can be browsed at https://github.com/apache/tomee/tree/master/examples/spring-data-proxy
+
+=  Spring Data sample #
+
+This example uses OpenEJB hooks to replace an EJB implementation by a proxy
+to uses Spring Data in your preferred container.
+
+It is pretty simple: simply provide to OpenEJB an InvocationHandler using delegating to spring data
+and that's it!
+
+It is what is done in org.superbiz.dynamic.SpringDataProxy.
+
+It contains a little trick: even if it is not annotated "implementingInterfaceClass" attribute
+is injected by OpenEJB to get the interface.
+
+Then we simply create the Spring Data repository and delegate to it.

Propchange: tomee/site/trunk/generators/site-tomee-ng/src/main/jbake/content/examples/spring-data-proxy.adoc
------------------------------------------------------------------------------
    svn:executable = *