http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/lookup-of-ejbs-with-descriptor.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/lookup-of-ejbs-with-descriptor.adoc b/src/main/jbake/content/examples/lookup-of-ejbs-with-descriptor.adoc deleted file mode 100755 index cf72a6a..0000000 --- a/src/main/jbake/content/examples/lookup-of-ejbs-with-descriptor.adoc +++ /dev/null @@ -1,229 +0,0 @@ -= Lookup Of Ejbs with Descriptor -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example lookup-of-ejbs-with-descriptor can be browsed at https://github.com/apache/tomee/tree/master/examples/lookup-of-ejbs-with-descriptor - - -*Help us document this example! Click the blue pencil icon in the upper right to edit this page.* - -== BlueBean - - -[source,java] ----- -package org.superbiz.ejblookup; - -import javax.ejb.EJBException; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -//START SNIPPET: code -public class BlueBean implements Friend { - - public String sayHello() { - return "Blue says, Hello!"; - } - - public String helloFromFriend() { - try { - Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); - return "My friend " + friend.sayHello(); - } catch (NamingException e) { - throw new EJBException(e); - } - } -} ----- - - -== Friend - - -[source,java] ----- -package org.superbiz.ejblookup; - -/** - * This is an EJB 3 local business interface - * A local business interface may be annotated with the @Local - * annotation, but it's optional. A business interface which is - * not annotated with @Local or @Remote is assumed to be Local - * if the bean does not implement any other interfaces - */ -//START SNIPPET: code -public interface Friend { - - public String sayHello(); - - public String helloFromFriend(); -} ----- - - -== RedBean - - -[source,java] ----- -package org.superbiz.ejblookup; - -import javax.ejb.EJBException; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -//START SNIPPET: code -public class RedBean implements Friend { - - public String sayHello() { - return "Red says, Hello!"; - } - - public String helloFromFriend() { - try { - Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); - return "My friend " + friend.sayHello(); - } catch (NamingException e) { - throw new EJBException(e); - } - } -} ----- - - -== ejb-jar.xml - - -[source,xml] ----- -<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"> - - <!-- Notice this changes the global jndi name --> - <module-name>wombat</module-name> - - <enterprise-beans> - - <session> - <ejb-name>BlueBean</ejb-name> - <business-local>org.superbiz.ejblookup.Friend</business-local> - <ejb-class>org.superbiz.ejblookup.BlueBean</ejb-class> - <session-type>Stateless</session-type> - <transaction-type>Container</transaction-type> - <ejb-local-ref> - <ejb-ref-name>myFriend</ejb-ref-name> - <local>org.superbiz.ejblookup.Friend</local> - <ejb-link>RedBean</ejb-link> - </ejb-local-ref> - </session> - - <session> - <ejb-name>RedBean</ejb-name> - <business-local>org.superbiz.ejblookup.Friend</business-local> - <ejb-class>org.superbiz.ejblookup.RedBean</ejb-class> - <session-type>Stateless</session-type> - <transaction-type>Container</transaction-type> - <ejb-local-ref> - <ejb-ref-name>myFriend</ejb-ref-name> - <local>org.superbiz.ejblookup.Friend</local> - <ejb-link>BlueBean</ejb-link> - </ejb-local-ref> - </session> - - </enterprise-beans> -</ejb-jar> ----- - - - -== EjbDependencyTest - - -[source,java] ----- -package org.superbiz.ejblookup; - -import junit.framework.TestCase; - -import javax.ejb.embeddable.EJBContainer; -import javax.naming.Context; - -//START SNIPPET: code -public class EjbDependencyTest extends TestCase { - - private Context context; - - protected void setUp() throws Exception { - context = EJBContainer.createEJBContainer().getContext(); - } - - public void testRed() throws Exception { - - Friend red = (Friend) context.lookup("java:global/wombat/RedBean"); - - assertNotNull(red); - assertEquals("Red says, Hello!", red.sayHello()); - assertEquals("My friend Blue says, Hello!", red.helloFromFriend()); - } - - public void testBlue() throws Exception { - - Friend blue = (Friend) context.lookup("java:global/wombat/BlueBean"); - - assertNotNull(blue); - assertEquals("Blue says, Hello!", blue.sayHello()); - assertEquals("My friend Red says, Hello!", blue.helloFromFriend()); - } -} ----- - - -= Running - - - -[source] ----- -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running org.superbiz.ejblookup.EjbDependencyTest -Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06 -http://tomee.apache.org/ -INFO - openejb.home = /Users/dblevins/examples/lookup-of-ejbs-with-descriptor -INFO - openejb.base = /Users/dblevins/examples/lookup-of-ejbs-with-descriptor -INFO - Using 'javax.ejb.embeddable.EJBContainer=true' -INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) -INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) -INFO - Found EjbModule in classpath: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor/target/classes -INFO - Beginning load: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor/target/classes -INFO - Configuring enterprise application: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor -INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container) -INFO - Auto-creating a container for bean BlueBean: Container(type=STATELESS, id=Default Stateless Container) -INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) -INFO - Auto-creating a container for bean org.superbiz.ejblookup.EjbDependencyTest: Container(type=MANAGED, id=Default Managed Container) -INFO - Enterprise application "/Users/dblevins/examples/lookup-of-ejbs-with-descriptor" loaded. -INFO - Assembling app: /Users/dblevins/examples/lookup-of-ejbs-with-descriptor -INFO - Jndi(name="java:global/wombat/BlueBean!org.superbiz.ejblookup.Friend") -INFO - Jndi(name="java:global/wombat/BlueBean") -INFO - Jndi(name="java:global/wombat/RedBean!org.superbiz.ejblookup.Friend") -INFO - Jndi(name="java:global/wombat/RedBean") -INFO - Jndi(name="java:global/EjbModule136565368/org.superbiz.ejblookup.EjbDependencyTest!org.superbiz.ejblookup.EjbDependencyTest") -INFO - Jndi(name="java:global/EjbModule136565368/org.superbiz.ejblookup.EjbDependencyTest") -INFO - Created Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container) -INFO - Started Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container) -INFO - Deployed Application(path=/Users/dblevins/examples/lookup-of-ejbs-with-descriptor) -INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.679 sec - -Results : - -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 ----- - -
http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/lookup-of-ejbs.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/lookup-of-ejbs.adoc b/src/main/jbake/content/examples/lookup-of-ejbs.adoc deleted file mode 100755 index e11c8ee..0000000 --- a/src/main/jbake/content/examples/lookup-of-ejbs.adoc +++ /dev/null @@ -1,196 +0,0 @@ -= Lookup Of Ejbs -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example lookup-of-ejbs can be browsed at https://github.com/apache/tomee/tree/master/examples/lookup-of-ejbs - - -*Help us document this example! Click the blue pencil icon in the upper right to edit this page.* - -== BlueBean - - -[source,java] ----- -package org.superbiz.ejblookup; - -import javax.ejb.EJB; -import javax.ejb.EJBException; -import javax.ejb.Stateless; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -//START SNIPPET: code -@Stateless -@EJB(beanInterface = Friend.class, beanName = "RedBean", name = "myFriend") -public class BlueBean implements Friend { - - public String sayHello() { - return "Blue says, Hello!"; - } - - public String helloFromFriend() { - try { - Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); - return "My friend " + friend.sayHello(); - } catch (NamingException e) { - throw new EJBException(e); - } - } -} ----- - - -== Friend - - -[source,java] ----- -package org.superbiz.ejblookup; - -import javax.ejb.Local; - -/** - * This is an EJB 3 local business interface - * A local business interface may be annotated with the @Local - * annotation, but it's optional. A business interface which is - * not annotated with @Local or @Remote is assumed to be Local - * if the bean does not implement any other interfaces - */ -//START SNIPPET: code -@Local -public interface Friend { - - public String sayHello(); - - public String helloFromFriend(); -} ----- - - -== RedBean - - -[source,java] ----- -package org.superbiz.ejblookup; - -import javax.ejb.EJB; -import javax.ejb.EJBException; -import javax.ejb.Stateless; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -//START SNIPPET: code -@Stateless -@EJB(beanInterface = Friend.class, beanName = "BlueBean", name = "myFriend") -public class RedBean implements Friend { - - public String sayHello() { - return "Red says, Hello!"; - } - - public String helloFromFriend() { - try { - Friend friend = (Friend) new InitialContext().lookup("java:comp/env/myFriend"); - return "My friend " + friend.sayHello(); - } catch (NamingException e) { - throw new EJBException(e); - } - } -} ----- - - -== EjbDependencyTest - - -[source,java] ----- -package org.superbiz.ejblookup; - -import junit.framework.TestCase; - -import javax.ejb.embeddable.EJBContainer; -import javax.naming.Context; - -//START SNIPPET: code -public class EjbDependencyTest extends TestCase { - - private Context context; - - protected void setUp() throws Exception { - context = EJBContainer.createEJBContainer().getContext(); - } - - public void testRed() throws Exception { - - Friend red = (Friend) context.lookup("java:global/lookup-of-ejbs/RedBean"); - - assertNotNull(red); - assertEquals("Red says, Hello!", red.sayHello()); - assertEquals("My friend Blue says, Hello!", red.helloFromFriend()); - } - - public void testBlue() throws Exception { - - Friend blue = (Friend) context.lookup("java:global/lookup-of-ejbs/BlueBean"); - - assertNotNull(blue); - assertEquals("Blue says, Hello!", blue.sayHello()); - assertEquals("My friend Red says, Hello!", blue.helloFromFriend()); - } -} ----- - - -= Running - - - -[source] ----- -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running org.superbiz.ejblookup.EjbDependencyTest -Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06 -http://tomee.apache.org/ -INFO - openejb.home = /Users/dblevins/examples/lookup-of-ejbs -INFO - openejb.base = /Users/dblevins/examples/lookup-of-ejbs -INFO - Using 'javax.ejb.embeddable.EJBContainer=true' -INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) -INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) -INFO - Found EjbModule in classpath: /Users/dblevins/examples/lookup-of-ejbs/target/classes -INFO - Beginning load: /Users/dblevins/examples/lookup-of-ejbs/target/classes -INFO - Configuring enterprise application: /Users/dblevins/examples/lookup-of-ejbs -INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container) -INFO - Auto-creating a container for bean RedBean: Container(type=STATELESS, id=Default Stateless Container) -INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) -INFO - Auto-creating a container for bean org.superbiz.ejblookup.EjbDependencyTest: Container(type=MANAGED, id=Default Managed Container) -INFO - Enterprise application "/Users/dblevins/examples/lookup-of-ejbs" loaded. -INFO - Assembling app: /Users/dblevins/examples/lookup-of-ejbs -INFO - Jndi(name="java:global/lookup-of-ejbs/RedBean!org.superbiz.ejblookup.Friend") -INFO - Jndi(name="java:global/lookup-of-ejbs/RedBean") -INFO - Jndi(name="java:global/lookup-of-ejbs/BlueBean!org.superbiz.ejblookup.Friend") -INFO - Jndi(name="java:global/lookup-of-ejbs/BlueBean") -INFO - Jndi(name="java:global/EjbModule1374821456/org.superbiz.ejblookup.EjbDependencyTest!org.superbiz.ejblookup.EjbDependencyTest") -INFO - Jndi(name="java:global/EjbModule1374821456/org.superbiz.ejblookup.EjbDependencyTest") -INFO - Created Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container) -INFO - Started Ejb(deployment-id=RedBean, ejb-name=RedBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=BlueBean, ejb-name=BlueBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=org.superbiz.ejblookup.EjbDependencyTest, ejb-name=org.superbiz.ejblookup.EjbDependencyTest, container=Default Managed Container) -INFO - Deployed Application(path=/Users/dblevins/examples/lookup-of-ejbs) -INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.267 sec - -Results : - -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 ----- - - http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/mbean-auto-registration.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/mbean-auto-registration.adoc b/src/main/jbake/content/examples/mbean-auto-registration.adoc deleted file mode 100755 index 724382d..0000000 --- a/src/main/jbake/content/examples/mbean-auto-registration.adoc +++ /dev/null @@ -1,172 +0,0 @@ -= Mbean Auto Registration -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example mbean-auto-registration can be browsed at https://github.com/apache/tomee/tree/master/examples/mbean-auto-registration - - -This example shows how to automatically create and register mbeans using TomEE features. - -= Dependencies - -To be able to use it you need to import the mbean api (annotations): - - -[source,xml] ----- -<dependency> - <groupId>org.apache.openejb</groupId> - <artifactId>mbean-annotation-api</artifactId> - <version>4.5.0</version> - <scope>provided</scope> -</dependency> ----- - - -= The MBean - -The mbean implements a simple game where the goal is to guess a number. - -It allows the user to change the value too. - - -[source,java] ----- -package org.superbiz.mbean; - -import javax.management.Description; -import javax.management.MBean; -import javax.management.ManagedAttribute; -import javax.management.ManagedOperation; - -@MBean -@Description("play with me to guess a number") -public class GuessHowManyMBean { - private int value = 0; - - @ManagedAttribute - @Description("you are cheating!") - public int getValue() { - return value; - } - - @ManagedAttribute - public void setValue(int value) { - this.value = value; - } - - @ManagedOperation - public String tryValue(int userValue) { - if (userValue == value) { - return "winner"; - } - return "not the correct value, please have another try"; - } -} ----- - - -To register a MBean you simply have to specify a property either in system.properties, -or in intial context properties. - - Properties properties = new Properties(); - properties.setProperty("openejb.user.mbeans.list", GuessHowManyMBean.class.getName()); - EJBContainer.createEJBContainer(properties); - -= Accessing the MBean - -Then simply get the platform server and you can play with parameters and operations: - - -[source,java] ----- -package org.superbiz.mbean; - -import org.junit.Test; - -import javax.ejb.embeddable.EJBContainer; -import javax.management.Attribute; -import javax.management.MBeanInfo; -import javax.management.MBeanServer; -import javax.management.ObjectName; -import java.lang.management.ManagementFactory; -import java.util.Properties; - -import static junit.framework.Assert.assertEquals; - -public class GuessHowManyMBeanTest { - private static final String OBJECT_NAME = "openejb.user.mbeans:group=org.superbiz.mbean,application=mbean-auto-registration,name=GuessHowManyMBean"; - - @Test - public void play() throws Exception { - Properties properties = new Properties(); - properties.setProperty("openejb.user.mbeans.list", GuessHowManyMBean.class.getName()); - EJBContainer container = EJBContainer.createEJBContainer(properties); - - MBeanServer server = ManagementFactory.getPlatformMBeanServer(); - ObjectName objectName = new ObjectName(OBJECT_NAME); - MBeanInfo infos = server.getMBeanInfo(objectName); - assertEquals(0, server.getAttribute(objectName, "value")); - server.setAttribute(objectName, new Attribute("value", 3)); - assertEquals(3, server.getAttribute(objectName, "value")); - assertEquals("winner", server.invoke(objectName, "tryValue", new Object[]{3}, null)); - assertEquals("not the correct value, please have another try", server.invoke(objectName, "tryValue", new Object[]{2}, null)); - - container.close(); - } -} ----- - - -==== Note - -If OpenEJB can't find any module it can't start. So to force him to start even if the example has only the mbean -as java class, we added a `beans.xml` file to turn our project into a Java EE module. - -= Running - - - -[source] ----- -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running org.superbiz.mbean.GuessHowManyMBeanTest -Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06 -http://tomee.apache.org/ -INFO - openejb.home = /Users/dblevins/examples/mbean-auto-registration -INFO - openejb.base = /Users/dblevins/examples/mbean-auto-registration -INFO - Using 'javax.ejb.embeddable.EJBContainer=true' -INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) -INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) -INFO - Found EjbModule in classpath: /Users/dblevins/examples/mbean-auto-registration/target/classes -INFO - Beginning load: /Users/dblevins/examples/mbean-auto-registration/target/classes -INFO - Configuring enterprise application: /Users/dblevins/examples/mbean-auto-registration -INFO - MBean openejb.user.mbeans:application=,group=org.superbiz.mbean,name=GuessHowManyMBean registered. -INFO - MBean openejb.user.mbeans:application=mbean-auto-registration,group=org.superbiz.mbean,name=GuessHowManyMBean registered. -INFO - MBean openejb.user.mbeans:application=EjbModule1847652919,group=org.superbiz.mbean,name=GuessHowManyMBean registered. -INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) -INFO - Auto-creating a container for bean mbean-auto-registration.Comp: Container(type=MANAGED, id=Default Managed Container) -INFO - Enterprise application "/Users/dblevins/examples/mbean-auto-registration" loaded. -INFO - Assembling app: /Users/dblevins/examples/mbean-auto-registration -INFO - Jndi(name="java:global/mbean-auto-registration/mbean-auto-registration.Comp!org.apache.openejb.BeanContext$Comp") -INFO - Jndi(name="java:global/mbean-auto-registration/mbean-auto-registration.Comp") -INFO - Jndi(name="java:global/EjbModule1847652919/org.superbiz.mbean.GuessHowManyMBeanTest!org.superbiz.mbean.GuessHowManyMBeanTest") -INFO - Jndi(name="java:global/EjbModule1847652919/org.superbiz.mbean.GuessHowManyMBeanTest") -INFO - Created Ejb(deployment-id=mbean-auto-registration.Comp, ejb-name=mbean-auto-registration.Comp, container=Default Managed Container) -INFO - Created Ejb(deployment-id=org.superbiz.mbean.GuessHowManyMBeanTest, ejb-name=org.superbiz.mbean.GuessHowManyMBeanTest, container=Default Managed Container) -INFO - Started Ejb(deployment-id=mbean-auto-registration.Comp, ejb-name=mbean-auto-registration.Comp, container=Default Managed Container) -INFO - Started Ejb(deployment-id=org.superbiz.mbean.GuessHowManyMBeanTest, ejb-name=org.superbiz.mbean.GuessHowManyMBeanTest, container=Default Managed Container) -INFO - Deployed Application(path=/Users/dblevins/examples/mbean-auto-registration) -INFO - Undeploying app: /Users/dblevins/examples/mbean-auto-registration -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.063 sec - -Results : - -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 ----- - - http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/moviefun-rest.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/moviefun-rest.adoc b/src/main/jbake/content/examples/moviefun-rest.adoc deleted file mode 100755 index 161fb12..0000000 --- a/src/main/jbake/content/examples/moviefun-rest.adoc +++ /dev/null @@ -1,9 +0,0 @@ -= moviefun-rest -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example moviefun-rest can be browsed at https://github.com/apache/tomee/tree/master/examples/moviefun-rest - -No README.md yet, be the first to contribute one! http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/moviefun.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/moviefun.adoc b/src/main/jbake/content/examples/moviefun.adoc deleted file mode 100755 index bd2ccd9..0000000 --- a/src/main/jbake/content/examples/moviefun.adoc +++ /dev/null @@ -1,385 +0,0 @@ -= Movies Complete -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example moviefun can be browsed at https://github.com/apache/tomee/tree/master/examples/moviefun - - -*Help us document this example! Click the blue pencil icon in the upper right to edit this page.* - -== AddInterceptor - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.interceptor.AroundInvoke; -import javax.interceptor.InvocationContext; - -/** - * @version $Revision$ $Date$ - */ -public class AddInterceptor { - - @AroundInvoke - public Object invoke(InvocationContext context) throws Exception { - // Log Add - return context.proceed(); - } -} ----- - - -== DeleteInterceptor - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.interceptor.AroundInvoke; -import javax.interceptor.InvocationContext; - -/** - * @version $Revision$ $Date$ - */ -public class DeleteInterceptor { - - @AroundInvoke - public Object invoke(InvocationContext context) throws Exception { - // Log Delete - return context.proceed(); - } -} ----- - - -== Movie - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.persistence.Entity; - -@Entity -public class Movie { - - private String director; - private String title; - private int year; - - public Movie() { - } - - public Movie(String director, String title, int year) { - this.director = director; - this.title = title; - this.year = year; - } - - public String getDirector() { - return director; - } - - public void setDirector(String director) { - this.director = director; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } - -} ----- - - -== Movies - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.ejb.Stateful; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.interceptor.Interceptors; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceContextType; -import javax.persistence.Query; -import java.util.List; - -//START SNIPPET: code -@Stateful -public class Movies { - - @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION) - private EntityManager entityManager; - - @RolesAllowed({"Employee", "Manager"}) - @TransactionAttribute(TransactionAttributeType.REQUIRED) - @Interceptors(AddInterceptor.class) - public void addMovie(Movie movie) throws Exception { - entityManager.persist(movie); - } - - @RolesAllowed({"Manager"}) - @TransactionAttribute(TransactionAttributeType.MANDATORY) - @Interceptors(DeleteInterceptor.class) - public void deleteMovie(Movie movie) throws Exception { - entityManager.remove(movie); - } - - @PermitAll - @TransactionAttribute(TransactionAttributeType.SUPPORTS) - public List<Movie> getMovies() throws Exception { - Query query = entityManager.createQuery("SELECT m from Movie as m"); - return query.getResultList(); - } -} ----- - - -== ReadInterceptor - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.interceptor.AroundInvoke; -import javax.interceptor.InvocationContext; - -/** - * @version $Revision$ $Date$ - */ -public class ReadInterceptor { - - @AroundInvoke - public Object invoke(InvocationContext context) throws Exception { - // Log Delete - return context.proceed(); - } -} ----- - - -== persistence.xml - - -[source,xml] ----- -<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> - - <persistence-unit name="movie-unit"> - <jta-data-source>movieDatabase</jta-data-source> - <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source> - <class>org.superbiz.injection.tx.Movie</class> - - <properties> - <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> - </properties> - </persistence-unit> -</persistence> ----- - - -== MoviesTest - - -[source,java] ----- -package org.superbiz.injection.tx; - -import junit.framework.TestCase; - -import javax.annotation.security.RunAs; -import javax.ejb.EJB; -import javax.ejb.Stateless; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.ejb.embeddable.EJBContainer; -import java.util.List; -import java.util.Properties; -import java.util.concurrent.Callable; - -import static javax.ejb.TransactionAttributeType.REQUIRES_NEW; - -/** - * See the transaction-rollback example as it does the same thing - * via UserTransaction and shows more techniques for rollback - */ -//START SNIPPET: code -public class MoviesTest extends TestCase { - - @EJB - private Movies movies; - - @EJB(beanName = "TransactionBean") - private Caller transactionalCaller; - - @EJB(beanName = "NoTransactionBean") - private Caller nonTransactionalCaller; - - protected void setUp() throws Exception { - final Properties p = new Properties(); - p.put("movieDatabase", "new://Resource?type=DataSource"); - p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver"); - p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); - - EJBContainer.createEJBContainer(p).getContext().bind("inject", this); - } - - private void doWork() throws Exception { - - movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992)); - movies.addMovie(new Movie("Joel Coen", "Fargo", 1996)); - movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998)); - - List<Movie> list = movies.getMovies(); - assertEquals("List.size()", 3, list.size()); - - for (Movie movie : list) { - movies.deleteMovie(movie); - } - - assertEquals("Movies.getMovies()", 0, movies.getMovies().size()); - } - - public void testWithTransaction() throws Exception { - transactionalCaller.call(new Callable() { - public Object call() throws Exception { - doWork(); - return null; - } - }); - } - - public void testWithoutTransaction() throws Exception { - try { - nonTransactionalCaller.call(new Callable() { - public Object call() throws Exception { - doWork(); - return null; - } - }); - fail("The Movies bean should be using TransactionAttributeType.MANDATORY"); - } catch (javax.ejb.EJBException e) { - // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want - } - } - - - public static interface Caller { - public <V> V call(Callable<V> callable) throws Exception; - } - - /** - * This little bit of magic allows our test code to execute in - * the scope of a container controlled transaction. - */ - @Stateless - @RunAs("Manager") - @TransactionAttribute(REQUIRES_NEW) - public static class TransactionBean implements Caller { - - public <V> V call(Callable<V> callable) throws Exception { - return callable.call(); - } - } - - @Stateless - @RunAs("Manager") - @TransactionAttribute(TransactionAttributeType.NEVER) - public static class NoTransactionBean implements Caller { - - public <V> V call(Callable<V> callable) throws Exception { - return callable.call(); - } - } -} ----- - - -= Running - - - -[source] ----- -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running org.superbiz.injection.tx.MoviesTest -Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06 -http://tomee.apache.org/ -INFO - openejb.home = /Users/dblevins/examples/movies-complete -INFO - openejb.base = /Users/dblevins/examples/movies-complete -INFO - Using 'javax.ejb.embeddable.EJBContainer=true' -INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) -INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) -INFO - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database) -INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/classes -INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/test-classes -INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/classes -INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/test-classes -INFO - Configuring enterprise application: /Users/dblevins/examples/movies-complete -INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container) -INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container) -INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container) -INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container) -INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) -INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container) -INFO - Configuring PersistenceUnit(name=movie-unit) -INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'. -INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase) -INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged' -INFO - Enterprise application "/Users/dblevins/examples/movies-complete" loaded. -INFO - Assembling app: /Users/dblevins/examples/movies-complete -INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 402ms -INFO - Jndi(name="java:global/movies-complete/Movies!org.superbiz.injection.tx.Movies") -INFO - Jndi(name="java:global/movies-complete/Movies") -INFO - Jndi(name="java:global/movies-complete/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller") -INFO - Jndi(name="java:global/movies-complete/TransactionBean") -INFO - Jndi(name="java:global/movies-complete/NoTransactionBean!org.superbiz.injection.tx.MoviesTest$Caller") -INFO - Jndi(name="java:global/movies-complete/NoTransactionBean") -INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest") -INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest") -INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container) -INFO - Created Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container) -INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container) -INFO - Started Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container) -INFO - Deployed Application(path=/Users/dblevins/examples/movies-complete) -INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.418 sec - -Results : - -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 ----- - - http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/movies-complete-meta.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/movies-complete-meta.adoc b/src/main/jbake/content/examples/movies-complete-meta.adoc deleted file mode 100755 index a4b50a6..0000000 --- a/src/main/jbake/content/examples/movies-complete-meta.adoc +++ /dev/null @@ -1,502 +0,0 @@ -= Movies Complete Meta -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example movies-complete-meta can be browsed at https://github.com/apache/tomee/tree/master/examples/movies-complete-meta - - -*Help us document this example! Click the blue pencil icon in the upper right to edit this page.* - -== AddInterceptor - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.interceptor.AroundInvoke; -import javax.interceptor.InvocationContext; - -/** - * @version $Revision$ $Date$ - */ -public class AddInterceptor { - - @AroundInvoke - public Object invoke(InvocationContext context) throws Exception { - // Log Add - return context.proceed(); - } -} ----- - - -== Add - - -[source,java] ----- -package org.superbiz.injection.tx.api; - -import org.superbiz.injection.tx.AddInterceptor; - -import javax.annotation.security.RolesAllowed; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.interceptor.Interceptors; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Metatype -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) - -public @interface Add { - public interface $ { - - @Add - @RolesAllowed({"Employee", "Manager"}) - @TransactionAttribute(TransactionAttributeType.REQUIRED) - @Interceptors(AddInterceptor.class) - public void method(); - } -} ----- - - -== Delete - - -[source,java] ----- -package org.superbiz.injection.tx.api; - -import org.superbiz.injection.tx.DeleteInterceptor; - -import javax.annotation.security.RolesAllowed; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.interceptor.Interceptors; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Metatype -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) - -public @interface Delete { - public interface $ { - - @Delete - @RolesAllowed({"Manager"}) - @TransactionAttribute(TransactionAttributeType.MANDATORY) - @Interceptors(DeleteInterceptor.class) - public void method(); - } -} ----- - - -== Metatype - - -[source,java] ----- -package org.superbiz.injection.tx.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Metatype -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface Metatype { -} ----- - - -== MovieUnit - - -[source,java] ----- -package org.superbiz.injection.tx.api; - -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceContextType; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -@Metatype -@Target({ElementType.METHOD, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) - -@PersistenceContext(name = "movie-unit", unitName = "movie-unit", type = PersistenceContextType.EXTENDED) -public @interface MovieUnit { -} ----- - - -== Read - - -[source,java] ----- -package org.superbiz.injection.tx.api; - -import javax.annotation.security.PermitAll; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Metatype -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) - -public @interface Read { - public interface $ { - - @Read - @PermitAll - @TransactionAttribute(TransactionAttributeType.SUPPORTS) - public void method(); - } -} ----- - - -== DeleteInterceptor - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.interceptor.AroundInvoke; -import javax.interceptor.InvocationContext; - -/** - * @version $Revision$ $Date$ - */ -public class DeleteInterceptor { - - @AroundInvoke - public Object invoke(InvocationContext context) throws Exception { - // Log Delete - return context.proceed(); - } -} ----- - - -== Movie - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.persistence.Entity; - -@Entity -public class Movie { - - private String director; - private String title; - private int year; - - public Movie() { - } - - public Movie(String director, String title, int year) { - this.director = director; - this.title = title; - this.year = year; - } - - public String getDirector() { - return director; - } - - public void setDirector(String director) { - this.director = director; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } - -} ----- - - -== Movies - - -[source,java] ----- -package org.superbiz.injection.tx; - -import org.superbiz.injection.tx.api.Add; -import org.superbiz.injection.tx.api.Delete; -import org.superbiz.injection.tx.api.MovieUnit; -import org.superbiz.injection.tx.api.Read; - -import javax.ejb.Stateful; -import javax.persistence.EntityManager; -import javax.persistence.Query; -import java.util.List; - -//END SNIPPET: code - -//START SNIPPET: code -@Stateful -public class Movies { - - @MovieUnit - private EntityManager entityManager; - - @Add - public void addMovie(Movie movie) throws Exception { - entityManager.persist(movie); - } - - @Delete - public void deleteMovie(Movie movie) throws Exception { - entityManager.remove(movie); - } - - @Read - public List<Movie> getMovies() throws Exception { - Query query = entityManager.createQuery("SELECT m from Movie as m"); - return query.getResultList(); - } -} ----- - - -== persistence.xml - - -[source,xml] ----- -<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> - - <persistence-unit name="movie-unit"> - <jta-data-source>movieDatabase</jta-data-source> - <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source> - <class>org.superbiz.injection.tx.Movie</class> - - <properties> - <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> - </properties> - </persistence-unit> -</persistence> ----- - - -== MoviesTest - - -[source,java] ----- -package org.superbiz.injection.tx; - -import junit.framework.TestCase; - -import javax.annotation.security.RunAs; -import javax.ejb.EJB; -import javax.ejb.Stateless; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.ejb.embeddable.EJBContainer; -import java.util.List; -import java.util.Properties; -import java.util.concurrent.Callable; - -import static javax.ejb.TransactionAttributeType.REQUIRES_NEW; - -/** - * See the transaction-rollback example as it does the same thing - * via UserTransaction and shows more techniques for rollback - */ -//START SNIPPET: code -public class MoviesTest extends TestCase { - - @EJB - private Movies movies; - - @EJB(beanName = "TransactionBean") - private Caller transactionalCaller; - - @EJB(beanName = "NoTransactionBean") - private Caller nonTransactionalCaller; - - protected void setUp() throws Exception { - final Properties p = new Properties(); - p.put("movieDatabase", "new://Resource?type=DataSource"); - p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver"); - p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); - - EJBContainer.createEJBContainer(p).getContext().bind("inject", this); - } - - private void doWork() throws Exception { - - movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992)); - movies.addMovie(new Movie("Joel Coen", "Fargo", 1996)); - movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998)); - - List<Movie> list = movies.getMovies(); - assertEquals("List.size()", 3, list.size()); - - for (Movie movie : list) { - movies.deleteMovie(movie); - } - - assertEquals("Movies.getMovies()", 0, movies.getMovies().size()); - } - - public void testWithTransaction() throws Exception { - transactionalCaller.call(new Callable() { - public Object call() throws Exception { - doWork(); - return null; - } - }); - } - - public void testWithoutTransaction() throws Exception { - try { - nonTransactionalCaller.call(new Callable() { - public Object call() throws Exception { - doWork(); - return null; - } - }); - fail("The Movies bean should be using TransactionAttributeType.MANDATORY"); - } catch (javax.ejb.EJBException e) { - // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want - } - } - - - public static interface Caller { - public <V> V call(Callable<V> callable) throws Exception; - } - - /** - * This little bit of magic allows our test code to execute in - * the scope of a container controlled transaction. - */ - @Stateless - @RunAs("Manager") - @TransactionAttribute(REQUIRES_NEW) - public static class TransactionBean implements Caller { - - public <V> V call(Callable<V> callable) throws Exception { - return callable.call(); - } - } - - @Stateless - @RunAs("Manager") - @TransactionAttribute(TransactionAttributeType.NEVER) - public static class NoTransactionBean implements Caller { - - public <V> V call(Callable<V> callable) throws Exception { - return callable.call(); - } - } -} ----- - - -= Running - - - -[source] ----- -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running org.superbiz.injection.tx.MoviesTest -Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06 -http://tomee.apache.org/ -INFO - openejb.home = /Users/dblevins/examples/movies-complete-meta -INFO - openejb.base = /Users/dblevins/examples/movies-complete-meta -INFO - Using 'javax.ejb.embeddable.EJBContainer=true' -INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) -INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) -INFO - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database) -INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete-meta/target/test-classes -INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete-meta/target/classes -INFO - Beginning load: /Users/dblevins/examples/movies-complete-meta/target/test-classes -INFO - Beginning load: /Users/dblevins/examples/movies-complete-meta/target/classes -INFO - Configuring enterprise application: /Users/dblevins/examples/movies-complete-meta -INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container) -INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container) -INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container) -INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container) -INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) -INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container) -INFO - Configuring PersistenceUnit(name=movie-unit) -INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'. -INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase) -INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged' -INFO - Enterprise application "/Users/dblevins/examples/movies-complete-meta" loaded. -INFO - Assembling app: /Users/dblevins/examples/movies-complete-meta -INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 408ms -INFO - Jndi(name="java:global/movies-complete-meta/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller") -INFO - Jndi(name="java:global/movies-complete-meta/TransactionBean") -INFO - Jndi(name="java:global/movies-complete-meta/NoTransactionBean!org.superbiz.injection.tx.MoviesTest$Caller") -INFO - Jndi(name="java:global/movies-complete-meta/NoTransactionBean") -INFO - Jndi(name="java:global/movies-complete-meta/Movies!org.superbiz.injection.tx.Movies") -INFO - Jndi(name="java:global/movies-complete-meta/Movies") -INFO - Jndi(name="java:global/EjbModule1861413442/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest") -INFO - Jndi(name="java:global/EjbModule1861413442/org.superbiz.injection.tx.MoviesTest") -INFO - Created Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container) -INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container) -INFO - Started Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container) -INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container) -INFO - Deployed Application(path=/Users/dblevins/examples/movies-complete-meta) -INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.869 sec - -Results : - -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 ----- - - http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/movies-complete.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/movies-complete.adoc b/src/main/jbake/content/examples/movies-complete.adoc deleted file mode 100755 index 42fed35..0000000 --- a/src/main/jbake/content/examples/movies-complete.adoc +++ /dev/null @@ -1,385 +0,0 @@ -= Movies Complete -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example movies-complete can be browsed at https://github.com/apache/tomee/tree/master/examples/movies-complete - - -*Help us document this example! Click the blue pencil icon in the upper right to edit this page.* - -== AddInterceptor - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.interceptor.AroundInvoke; -import javax.interceptor.InvocationContext; - -/** - * @version $Revision$ $Date$ - */ -public class AddInterceptor { - - @AroundInvoke - public Object invoke(InvocationContext context) throws Exception { - // Log Add - return context.proceed(); - } -} ----- - - -== DeleteInterceptor - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.interceptor.AroundInvoke; -import javax.interceptor.InvocationContext; - -/** - * @version $Revision$ $Date$ - */ -public class DeleteInterceptor { - - @AroundInvoke - public Object invoke(InvocationContext context) throws Exception { - // Log Delete - return context.proceed(); - } -} ----- - - -== Movie - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.persistence.Entity; - -@Entity -public class Movie { - - private String director; - private String title; - private int year; - - public Movie() { - } - - public Movie(String director, String title, int year) { - this.director = director; - this.title = title; - this.year = year; - } - - public String getDirector() { - return director; - } - - public void setDirector(String director) { - this.director = director; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } - -} ----- - - -== Movies - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.annotation.security.PermitAll; -import javax.annotation.security.RolesAllowed; -import javax.ejb.Stateful; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.interceptor.Interceptors; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceContextType; -import javax.persistence.Query; -import java.util.List; - -//START SNIPPET: code -@Stateful -public class Movies { - - @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION) - private EntityManager entityManager; - - @RolesAllowed({"Employee", "Manager"}) - @TransactionAttribute(TransactionAttributeType.REQUIRED) - @Interceptors(AddInterceptor.class) - public void addMovie(Movie movie) throws Exception { - entityManager.persist(movie); - } - - @RolesAllowed({"Manager"}) - @TransactionAttribute(TransactionAttributeType.MANDATORY) - @Interceptors(DeleteInterceptor.class) - public void deleteMovie(Movie movie) throws Exception { - entityManager.remove(movie); - } - - @PermitAll - @TransactionAttribute(TransactionAttributeType.SUPPORTS) - public List<Movie> getMovies() throws Exception { - Query query = entityManager.createQuery("SELECT m from Movie as m"); - return query.getResultList(); - } -} ----- - - -== ReadInterceptor - - -[source,java] ----- -package org.superbiz.injection.tx; - -import javax.interceptor.AroundInvoke; -import javax.interceptor.InvocationContext; - -/** - * @version $Revision$ $Date$ - */ -public class ReadInterceptor { - - @AroundInvoke - public Object invoke(InvocationContext context) throws Exception { - // Log Delete - return context.proceed(); - } -} ----- - - -== persistence.xml - - -[source,xml] ----- -<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> - - <persistence-unit name="movie-unit"> - <jta-data-source>movieDatabase</jta-data-source> - <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source> - <class>org.superbiz.injection.tx.Movie</class> - - <properties> - <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> - </properties> - </persistence-unit> -</persistence> ----- - - -== MoviesTest - - -[source,java] ----- -package org.superbiz.injection.tx; - -import junit.framework.TestCase; - -import javax.annotation.security.RunAs; -import javax.ejb.EJB; -import javax.ejb.Stateless; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; -import javax.ejb.embeddable.EJBContainer; -import java.util.List; -import java.util.Properties; -import java.util.concurrent.Callable; - -import static javax.ejb.TransactionAttributeType.REQUIRES_NEW; - -/** - * See the transaction-rollback example as it does the same thing - * via UserTransaction and shows more techniques for rollback - */ -//START SNIPPET: code -public class MoviesTest extends TestCase { - - @EJB - private Movies movies; - - @EJB(beanName = "TransactionBean") - private Caller transactionalCaller; - - @EJB(beanName = "NoTransactionBean") - private Caller nonTransactionalCaller; - - protected void setUp() throws Exception { - final Properties p = new Properties(); - p.put("movieDatabase", "new://Resource?type=DataSource"); - p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver"); - p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); - - EJBContainer.createEJBContainer(p).getContext().bind("inject", this); - } - - private void doWork() throws Exception { - - movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992)); - movies.addMovie(new Movie("Joel Coen", "Fargo", 1996)); - movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998)); - - List<Movie> list = movies.getMovies(); - assertEquals("List.size()", 3, list.size()); - - for (Movie movie : list) { - movies.deleteMovie(movie); - } - - assertEquals("Movies.getMovies()", 0, movies.getMovies().size()); - } - - public void testWithTransaction() throws Exception { - transactionalCaller.call(new Callable() { - public Object call() throws Exception { - doWork(); - return null; - } - }); - } - - public void testWithoutTransaction() throws Exception { - try { - nonTransactionalCaller.call(new Callable() { - public Object call() throws Exception { - doWork(); - return null; - } - }); - fail("The Movies bean should be using TransactionAttributeType.MANDATORY"); - } catch (javax.ejb.EJBException e) { - // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want - } - } - - - public static interface Caller { - public <V> V call(Callable<V> callable) throws Exception; - } - - /** - * This little bit of magic allows our test code to execute in - * the scope of a container controlled transaction. - */ - @Stateless - @RunAs("Manager") - @TransactionAttribute(REQUIRES_NEW) - public static class TransactionBean implements Caller { - - public <V> V call(Callable<V> callable) throws Exception { - return callable.call(); - } - } - - @Stateless - @RunAs("Manager") - @TransactionAttribute(TransactionAttributeType.NEVER) - public static class NoTransactionBean implements Caller { - - public <V> V call(Callable<V> callable) throws Exception { - return callable.call(); - } - } -} ----- - - -= Running - - - -[source] ----- -------------------------------------------------------- - T E S T S -------------------------------------------------------- -Running org.superbiz.injection.tx.MoviesTest -Apache OpenEJB 4.0.0-beta-1 build: 20111002-04:06 -http://tomee.apache.org/ -INFO - openejb.home = /Users/dblevins/examples/movies-complete -INFO - openejb.base = /Users/dblevins/examples/movies-complete -INFO - Using 'javax.ejb.embeddable.EJBContainer=true' -INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) -INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) -INFO - Configuring Service(id=movieDatabase, type=Resource, provider-id=Default JDBC Database) -INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/classes -INFO - Found EjbModule in classpath: /Users/dblevins/examples/movies-complete/target/test-classes -INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/classes -INFO - Beginning load: /Users/dblevins/examples/movies-complete/target/test-classes -INFO - Configuring enterprise application: /Users/dblevins/examples/movies-complete -INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container) -INFO - Auto-creating a container for bean Movies: Container(type=STATEFUL, id=Default Stateful Container) -INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container) -INFO - Auto-creating a container for bean TransactionBean: Container(type=STATELESS, id=Default Stateless Container) -INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) -INFO - Auto-creating a container for bean org.superbiz.injection.tx.MoviesTest: Container(type=MANAGED, id=Default Managed Container) -INFO - Configuring PersistenceUnit(name=movie-unit) -INFO - Auto-creating a Resource with id 'movieDatabaseNonJta' of type 'DataSource for 'movie-unit'. -INFO - Configuring Service(id=movieDatabaseNonJta, type=Resource, provider-id=movieDatabase) -INFO - Adjusting PersistenceUnit movie-unit <non-jta-data-source> to Resource ID 'movieDatabaseNonJta' from 'movieDatabaseUnmanaged' -INFO - Enterprise application "/Users/dblevins/examples/movies-complete" loaded. -INFO - Assembling app: /Users/dblevins/examples/movies-complete -INFO - PersistenceUnit(name=movie-unit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 402ms -INFO - Jndi(name="java:global/movies-complete/Movies!org.superbiz.injection.tx.Movies") -INFO - Jndi(name="java:global/movies-complete/Movies") -INFO - Jndi(name="java:global/movies-complete/TransactionBean!org.superbiz.injection.tx.MoviesTest$Caller") -INFO - Jndi(name="java:global/movies-complete/TransactionBean") -INFO - Jndi(name="java:global/movies-complete/NoTransactionBean!org.superbiz.injection.tx.MoviesTest$Caller") -INFO - Jndi(name="java:global/movies-complete/NoTransactionBean") -INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest!org.superbiz.injection.tx.MoviesTest") -INFO - Jndi(name="java:global/EjbModule1013462002/org.superbiz.injection.tx.MoviesTest") -INFO - Created Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container) -INFO - Created Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container) -INFO - Created Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container) -INFO - Started Ejb(deployment-id=Movies, ejb-name=Movies, container=Default Stateful Container) -INFO - Started Ejb(deployment-id=NoTransactionBean, ejb-name=NoTransactionBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=TransactionBean, ejb-name=TransactionBean, container=Default Stateless Container) -INFO - Started Ejb(deployment-id=org.superbiz.injection.tx.MoviesTest, ejb-name=org.superbiz.injection.tx.MoviesTest, container=Default Managed Container) -INFO - Deployed Application(path=/Users/dblevins/examples/movies-complete) -INFO - EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.418 sec - -Results : - -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 ----- - - http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/mtom.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/mtom.adoc b/src/main/jbake/content/examples/mtom.adoc deleted file mode 100755 index b1af48a..0000000 --- a/src/main/jbake/content/examples/mtom.adoc +++ /dev/null @@ -1,8 +0,0 @@ -= mtom -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example mtom can be browsed at https://github.com/apache/tomee/tree/master/examples/mtom - http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/multi-jpa-provider-testing.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/multi-jpa-provider-testing.adoc b/src/main/jbake/content/examples/multi-jpa-provider-testing.adoc deleted file mode 100755 index 5862411..0000000 --- a/src/main/jbake/content/examples/multi-jpa-provider-testing.adoc +++ /dev/null @@ -1,9 +0,0 @@ -= multi-jpa-provider-testing -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example multi-jpa-provider-testing can be browsed at https://github.com/apache/tomee/tree/master/examples/multi-jpa-provider-testing - -No README.md yet, be the first to contribute one! http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/multiple-arquillian-adapters.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/multiple-arquillian-adapters.adoc b/src/main/jbake/content/examples/multiple-arquillian-adapters.adoc deleted file mode 100755 index e4f80a3..0000000 --- a/src/main/jbake/content/examples/multiple-arquillian-adapters.adoc +++ /dev/null @@ -1,9 +0,0 @@ -= multiple-arquillian-adapters -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example multiple-arquillian-adapters can be browsed at https://github.com/apache/tomee/tree/master/examples/multiple-arquillian-adapters - -No README.md yet, be the first to contribute one! http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/multiple-tomee-arquillian.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/multiple-tomee-arquillian.adoc b/src/main/jbake/content/examples/multiple-tomee-arquillian.adoc deleted file mode 100755 index 940285d..0000000 --- a/src/main/jbake/content/examples/multiple-tomee-arquillian.adoc +++ /dev/null @@ -1,9 +0,0 @@ -= multiple-tomee-arquillian -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example multiple-tomee-arquillian can be browsed at https://github.com/apache/tomee/tree/master/examples/multiple-tomee-arquillian - -No README.md yet, be the first to contribute one! http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/myfaces-codi-demo.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/myfaces-codi-demo.adoc b/src/main/jbake/content/examples/myfaces-codi-demo.adoc deleted file mode 100755 index 6e2dc20..0000000 --- a/src/main/jbake/content/examples/myfaces-codi-demo.adoc +++ /dev/null @@ -1,76 +0,0 @@ -= MyFaces CODI Demo -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example myfaces-codi-demo can be browsed at https://github.com/apache/tomee/tree/master/examples/myfaces-codi-demo - -Notice: Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - . - http://www.apache.org/licenses/LICENSE-2.0 - . - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -<h2>Steps to run the example</h2> - -Build and start the demo: - - mvn clean package tomee:run - -Open: - - http://localhost:8080/myfaces-codi-1.0-SNAPSHOT/ - -This example shows how to improve JSF2/CDI/BV/JPA applications with features provided by Apache MyFaces CODI and ExtVal. - -<h2>Intro of MyFaces CODI and ExtVal</h2> - -The Apache MyFaces Extensions CDI project (aka CODI) hosts portable extensions for Contexts and Dependency Injection (CDI - JSR 299). CODI is a toolbox for your CDI application. Like CDI itself CODI is focused on type-safety. It is a modularized and extensible framework. So it's easy to choose the needed parts to facilitate the daily work in your project. - -MyFaces Extensions Validator (aka ExtVal) is a JSF centric validation framework which is compatible with JSF 1.x and JSF 2.x. -This example shows how it improves the default integration of Bean-Validation (JSR-303) with JSF2 as well as meta-data based cross-field validation. - - -<h2>Illustrated Features</h2> - -<h3>Apache MyFaces CODI</h3> - -<ul> - -[source,xml] ----- -<li><a href="./src/main/java/org/superbiz/myfaces/view/config/Pages.java" target="_blank">Type-safe view-config</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/view/InfoPage.java" target="_blank">Type-safe (custom) view-meta-data</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/view/MenuBean.java" target="_blank">Type-safe navigation</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/CustomJsfModuleConfig.java" target="_blank">Type-safe (specialized) config</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/CustomProjectStage.java" target="_blank">Type-safe custom project-stage</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/view/UserHolder.java" target="_blank">@WindowScoped</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/view/MenuBean.java" target="_blank">Controlling CODI scopes with WindowContext</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/view/FeedbackPage.java" target="_blank">@ViewAccessScoped</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/view/FeedbackPage.java" target="_blank">Manual conversation handling</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/view/security/LoginAccessDecisionVoter.java" target="_blank">Secured pages (AccessDecisionVoter)</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/repository/Repository.java" target="_blank">@Transactional</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">I18n (fluent API)</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/domain/validation/UniqueUserNameValidator.java" target="_blank">Dependency-Injection for JSR303 (BV) constraint-validators</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/DebugPhaseListener.java" target="_blank">Dependency-Injection for JSF phase-listeners</a></li> -</ul> - -<h3>Apache MyFaces ExtVal</h3> - -<ul> -<li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Cross-Field validation (@Equals)</a></li> -<li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Type-safe group-validation (@BeanValidation) for JSF action-methods</a></li> -</ul> - http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/persistence-fragment.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/persistence-fragment.adoc b/src/main/jbake/content/examples/persistence-fragment.adoc deleted file mode 100755 index e200f41..0000000 --- a/src/main/jbake/content/examples/persistence-fragment.adoc +++ /dev/null @@ -1,149 +0,0 @@ -= Persistence Fragment -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example persistence-fragment can be browsed at https://github.com/apache/tomee/tree/master/examples/persistence-fragment - - -*Help us document this example! Click the blue pencil icon in the upper right to edit this page.* - -== Movie - - -[source,java] ----- -package org.superbiz.injection.jpa; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; - -@Entity -public class Movie { - @Id - @GeneratedValue - private long id; - private String director; - private String title; - private int year; - - public Movie() { - // no-op - } - - public Movie(String director, String title, int year) { - this.director = director; - this.title = title; - this.year = year; - } - - public long getId() { - return id; - } - - public String getDirector() { - return director; - } - - public void setDirector(String director) { - this.director = director; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getYear() { - return year; - } - - public void setYear(int year) { - this.year = year; - } -} ----- - - -== persistence-fragment.xml - - -[source,xml] ----- -<persistence-fragment version="2.0"> - <persistence-unit-fragment name="movie-unit"> - <class>org.superbiz.injection.jpa.Movie</class> - <exclude-unlisted-classes>true</exclude-unlisted-classes> - </persistence-unit-fragment> -</persistence-fragment> ----- - - - -== MoviesTest - - -[source,java] ----- -package org.superbiz.injection.jpa; - -import org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory; -import org.junit.Test; - -import javax.ejb.embeddable.EJBContainer; -import javax.naming.Context; -import javax.persistence.EntityManagerFactory; -import javax.persistence.PersistenceUnit; -import java.util.Properties; - -import static org.junit.Assert.assertTrue; - -public class MoviesTest { - @PersistenceUnit - private EntityManagerFactory emf; - - @Test - public void test() throws Exception { - final Properties p = new Properties(); - p.put("movieDatabase", "new://Resource?type=DataSource"); - p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver"); - p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb"); - - final EJBContainer container = EJBContainer.createEJBContainer(p); - final Context context = container.getContext(); - context.bind("inject", this); - - assertTrue(((ReloadableEntityManagerFactory) emf).getManagedClasses().contains(Movie.class.getName())); - - container.close(); - } -} ----- - - -== persistence.xml - - -[source,xml] ----- -<persistence version="2.0" - xmlns="http://java.sun.com/xml/ns/persistence" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/persistence - http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> - <persistence-unit name="movie-unit"> - <jta-data-source>movieDatabase</jta-data-source> - <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source> - <properties> - <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> - </properties> - </persistence-unit> -</persistence> ----- - - http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/pojo-webservice.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/pojo-webservice.adoc b/src/main/jbake/content/examples/pojo-webservice.adoc deleted file mode 100755 index 019f2f6..0000000 --- a/src/main/jbake/content/examples/pojo-webservice.adoc +++ /dev/null @@ -1,9 +0,0 @@ -= pojo-webservice -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example pojo-webservice can be browsed at https://github.com/apache/tomee/tree/master/examples/pojo-webservice - -No README.md yet, be the first to contribute one! http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/polling-parent.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/polling-parent.adoc b/src/main/jbake/content/examples/polling-parent.adoc deleted file mode 100755 index 9ee24f5..0000000 --- a/src/main/jbake/content/examples/polling-parent.adoc +++ /dev/null @@ -1,39 +0,0 @@ -= polling-parent -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example polling-parent can be browsed at https://github.com/apache/tomee/tree/master/examples/polling-parent - -= Sample # - -This sample implements a simple polling application. - -You can create polls and then vote (+1 or -1) for each poll (called Subject). - -The front is a JAX-RS front and the backend uses EJBs and JPA. - -= Module # - -The application contains several modules: - -* polling-domain: entities used by the client side too -* polling-core: the middle/dao layer -* polling-web: front layer (REST services) - -= What is noticeable # - -The front layer contains a MBean managed by CDI (VoteCounter) which is used by REST services to update information you -can retrieve through JMX protocol (JConsole client is fine to see it ;)). - -It manages a dynamic datasource too. It manages in the example configuration 2 clients. - -It is a simple round robin by request. That's why from the client if you simply create a poll then find it -you'll not find the persisted poll, you need to do it once again. - -= Client # - -It lets you create poll, retrieve them, find the best poll and vote for any poll. - -Please type help for more information. http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/efed31f4/src/main/jbake/content/examples/projectstage-demo.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/examples/projectstage-demo.adoc b/src/main/jbake/content/examples/projectstage-demo.adoc deleted file mode 100755 index 2b92b3f..0000000 --- a/src/main/jbake/content/examples/projectstage-demo.adoc +++ /dev/null @@ -1,9 +0,0 @@ -= projectstage-demo -:jbake-date: 2016-09-06 -:jbake-type: page -:jbake-tomeepdf: -:jbake-status: published - -Example projectstage-demo can be browsed at https://github.com/apache/tomee/tree/master/examples/projectstage-demo - -No README.md yet, be the first to contribute one!
