From commits-return-45923-archive-asf-public=cust-asf.ponee.io@tomee.apache.org Sun Dec 30 22:47:49 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 53F1A18062A for ; Sun, 30 Dec 2018 22:47:48 +0100 (CET) Received: (qmail 14892 invoked by uid 500); 30 Dec 2018 21:47:47 -0000 Mailing-List: contact commits-help@tomee.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tomee.apache.org Delivered-To: mailing list commits@tomee.apache.org Received: (qmail 14882 invoked by uid 99); 30 Dec 2018 21:47:47 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Dec 2018 21:47:47 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 86C963A26E6 for ; Sun, 30 Dec 2018 21:47:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1850005 [2/2] - in /tomee/site/trunk/content: community/ latest/examples/ master/examples/ tomee-8.0/examples/ Date: Sun, 30 Dec 2018 21:47:45 -0000 To: commits@tomee.apache.org From: dblevins@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20181230214746.86C963A26E6@svn01-us-west.apache.org> Modified: tomee/site/trunk/content/master/examples/decorators.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/decorators.html?rev=1850005&r1=1850004&r2=1850005&view=diff ============================================================================== --- tomee/site/trunk/content/master/examples/decorators.html (original) +++ tomee/site/trunk/content/master/examples/decorators.html Sun Dec 30 21:47:45 2018 @@ -88,16 +88,25 @@
-

Help us document this example! Click the blue pencil icon in the upper right to edit this page.

-

AccessDeniedException

-
package org.superbiz.cdi.decorators;
+                
+

index-group=CDI +type=page +status=published

+
+

Decorators

+
+

AccessDeniedException

+
+
+
+
package org.superbiz.cdi.decorators;
 
 import javax.ejb.ApplicationException;
 
@@ -109,10 +118,17 @@ public class AccessDeniedException exten
     public AccessDeniedException(String s) {
         super(s);
     }
-}
-
-

Calculator

-
package org.superbiz.cdi.decorators;
+}
+
+
+
+
+
+

Calculator

+
+
+
+
package org.superbiz.cdi.decorators;
 
 /**
  * @version $Revision$ $Date$
@@ -128,10 +144,17 @@ public interface Calculator {
     public int divide(int a, int b);
 
     public int remainder(int a, int b);
-}
-
-

CalculatorBean

-
package org.superbiz.cdi.decorators;
+}
+
+
+
+
+
+

CalculatorBean

+
+
+
+
package org.superbiz.cdi.decorators;
 
 import javax.annotation.Resource;
 import javax.ejb.SessionContext;
@@ -164,10 +187,17 @@ public class CalculatorBean implements C
     public int remainder(int a, int b) {
         return a % b;
     }
-}
-
-

CalculatorLogging

-
package org.superbiz.cdi.decorators;
+}
+
+
+
+
+
+

CalculatorLogging

+
+
+
+
package org.superbiz.cdi.decorators;
 
 import javax.decorator.Decorator;
 import javax.decorator.Delegate;
@@ -177,7 +207,7 @@ import java.util.logging.Logger;
 @Decorator
 public class CalculatorLogging implements Calculator {
 
-    private Logger logger = Logger.getLogger("Calculator");
+    private Logger logger = Logger.getLogger("Calculator");
 
     @Inject
     @Delegate
@@ -185,7 +215,7 @@ public class CalculatorLogging implement
 
     @Override
     public int add(int a, int b) {
-        logger.fine(String.format("add(%s, %s)", a, b));
+        logger.fine(String.format("add(%s, %s)", a, b));
         return calculator.add(a, b);
     }
 
@@ -196,7 +226,7 @@ public class CalculatorLogging implement
 
     @Override
     public int multiply(int a, int b) {
-        logger.finest(String.format("multiply(%s, %s)", a, b));
+        logger.finest(String.format("multiply(%s, %s)", a, b));
         return calculator.multiply(a, b);
     }
 
@@ -207,13 +237,20 @@ public class CalculatorLogging implement
 
     @Override
     public int remainder(int a, int b) {
-        logger.info(String.format("remainder(%s, %s)", a, b));
+        logger.info(String.format("remainder(%s, %s)", a, b));
         return calculator.remainder(a, b);
     }
-}
-
-

CalculatorSecurity

-
package org.superbiz.cdi.decorators;
+}
+
+
+
+
+
+

CalculatorSecurity

+
+
+
+
package org.superbiz.cdi.decorators;
 
 import javax.decorator.Decorator;
 import javax.decorator.Delegate;
@@ -238,7 +275,7 @@ public class CalculatorSecurity implemen
     @Override
     public int subtract(int a, int b) {
         // Caller must pass a security check to call subtract
-        if (!sessionContext.isCallerInRole("Manager")) throw new AccessDeniedException(sessionContext.getCallerPrincipal().getName());
+        if (!sessionContext.isCallerInRole("Manager")) throw new AccessDeniedException(sessionContext.getCallerPrincipal().getName());
 
         return calculator.subtract(a, b);
     }
@@ -257,10 +294,17 @@ public class CalculatorSecurity implemen
     public int remainder(int a, int b) {
         return calculator.remainder(a, b);
     }
-}
-
-

beans.xml

-
<beans>
+}
+
+
+
+
+
+

beans.xml

+
+
+
+
<beans>
   <!--
   Explicitly declaring decorators is required by the CDI specification.
   The order decorators are listed in the xml is the order in which they are invoked.
@@ -269,10 +313,17 @@ public class CalculatorSecurity implemen
     <class>org.superbiz.cdi.decorators.CalculatorSecurity</class>
     <class>org.superbiz.cdi.decorators.CalculatorLogging</class>
   </decorators>
-</beans>
-
-

CalculatorTest

-
package org.superbiz.cdi.decorators;
+</beans>
+
+
+
+
+
+

CalculatorTest

+
+
+
+
package org.superbiz.cdi.decorators;
 
 import junit.framework.TestCase;
 
@@ -296,7 +347,7 @@ public class CalculatorTest extends Test
      * @throws Exception
      */
     protected void setUp() throws Exception {
-        EJBContainer.createEJBContainer().getContext().bind("inject", this);
+        EJBContainer.createEJBContainer().getContext().bind("inject", this);
     }
 
     /**
@@ -315,7 +366,7 @@ public class CalculatorTest extends Test
         try {
             calculator.subtract(4, 6);
 
-            fail("AccessDeniedException should have been thrown for unauthenticated access");
+            fail("AccessDeniedException should have been thrown for unauthenticated access");
         } catch (AccessDeniedException expected) {
             // pass
         }
@@ -354,7 +405,7 @@ public class CalculatorTest extends Test
     }
 
     @Stateless
-    @RunAs("Manager")
+    @RunAs("Manager")
     public static class ManagerBean {
 
         public <V> V call(Callable<V> callable) {
@@ -365,10 +416,17 @@ public class CalculatorTest extends Test
             }
         }
     }
-}
-
-

Running

-
-------------------------------------------------------
+}
+
+
+
+
+
+

Running

+
+
+
+
-------------------------------------------------------
  T E S T S
 -------------------------------------------------------
 Running org.superbiz.cdi.decorators.CalculatorTest
@@ -376,7 +434,7 @@ Apache OpenEJB 4.0.0-beta-1    build: 20
 http://tomee.apache.org/
 INFO - openejb.home = /Users/dblevins/examples/decorators
 INFO - openejb.base = /Users/dblevins/examples/decorators
-INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
 INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
 INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
 INFO - Found EjbModule in classpath: /Users/dblevins/examples/decorators/target/classes
@@ -384,21 +442,21 @@ INFO - Found EjbModule in classpath: /Us
 INFO - Beginning load: /Users/dblevins/examples/decorators/target/classes
 INFO - Beginning load: /Users/dblevins/examples/decorators/target/test-classes
 INFO - Configuring enterprise application: /Users/dblevins/examples/decorators
-WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
+WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
 INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
 INFO - Auto-creating a container for bean decorators.Comp: Container(type=MANAGED, id=Default Managed Container)
 INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
 INFO - Auto-creating a container for bean CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
-INFO - Enterprise application "/Users/dblevins/examples/decorators" loaded.
+INFO - Enterprise application "/Users/dblevins/examples/decorators" loaded.
 INFO - Assembling app: /Users/dblevins/examples/decorators
-INFO - Jndi(name="java:global/decorators/decorators.Comp!org.apache.openejb.BeanContext$Comp")
-INFO - Jndi(name="java:global/decorators/decorators.Comp")
-INFO - Jndi(name="java:global/decorators/CalculatorBean!org.superbiz.cdi.decorators.Calculator")
-INFO - Jndi(name="java:global/decorators/CalculatorBean")
-INFO - Jndi(name="java:global/decorators/ManagerBean!org.superbiz.cdi.decorators.CalculatorTest$ManagerBean")
-INFO - Jndi(name="java:global/decorators/ManagerBean")
-INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest!org.superbiz.cdi.decorators.CalculatorTest")
-INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest")
+INFO - Jndi(name="java:global/decorators/decorators.Comp!org.apache.openejb.BeanContext$Comp")
+INFO - Jndi(name="java:global/decorators/decorators.Comp")
+INFO - Jndi(name="java:global/decorators/CalculatorBean!org.superbiz.cdi.decorators.Calculator")
+INFO - Jndi(name="java:global/decorators/CalculatorBean")
+INFO - Jndi(name="java:global/decorators/ManagerBean!org.superbiz.cdi.decorators.CalculatorTest$ManagerBean")
+INFO - Jndi(name="java:global/decorators/ManagerBean")
+INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest!org.superbiz.cdi.decorators.CalculatorTest")
+INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest")
 INFO - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
 INFO - Created Ejb(deployment-id=decorators.Comp, ejb-name=decorators.Comp, container=Default Managed Container)
 INFO - Created Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
@@ -470,7 +528,11 @@ Tests run: 5, Failures: 0, Errors: 0, Sk
 Results :
 
 Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
-
+....
+
+
+ + Modified: tomee/site/trunk/content/master/examples/index.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/master/examples/index.html?rev=1850005&r1=1850004&r2=1850005&view=diff ============================================================================== --- tomee/site/trunk/content/master/examples/index.html (original) +++ tomee/site/trunk/content/master/examples/index.html Sun Dec 30 21:47:45 2018 @@ -102,7 +102,6 @@
  • CDI Field Producer
  • CDI Interceptors
  • CDI Produces Disposes
  • -
  • Decorators
  • Simple CDI Interceptor
  • @@ -153,6 +152,18 @@ + +
    +
    Meta-Annotations
    -
    -
    Session Beans
    +
    +
    Other Features
    -
    -
    EntityManagers
    +
    +
    Security
    -
    -
    JMS and MDBs
    +
    +
    Proxy Beans
    -
    -
    -
      +
    • Simple REST
    • Simple REST with CDI
    • Simple Stateful with callback methods
    • Simple Stateless with callback methods
    • Modified: tomee/site/trunk/content/tomee-8.0/examples/connector-war.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/tomee-8.0/examples/connector-war.html?rev=1850005&r1=1850004&r2=1850005&view=diff ============================================================================== --- tomee/site/trunk/content/tomee-8.0/examples/connector-war.html (original) +++ tomee/site/trunk/content/tomee-8.0/examples/connector-war.html Sun Dec 30 21:47:45 2018 @@ -88,17 +88,25 @@
    -

    Help us document this example! Click the blue pencil icon in the upper right to edit this page.

    -

    Try it out in Codenvy

    -

    AddInterceptor

    -
    package org.superbiz.injection.tx;
    +                
    +

    index-group=Java EE Connectors +type=page +status=published

    +
    +

    Connectors in WAR Files

    +
    +

    AddInterceptor

    +
    +
    +
    +
    package org.superbiz.injection.tx;
     
     import javax.interceptor.AroundInvoke;
     import javax.interceptor.InvocationContext;
    @@ -113,10 +121,17 @@ public class AddInterceptor {
             // Log Add
             return context.proceed();
         }
    -}
    -
    -

    DeleteInterceptor

    -
    package org.superbiz.injection.tx;
    +}
    +
    +
    +
    +
    +
    +

    DeleteInterceptor

    +
    +
    +
    +
    package org.superbiz.injection.tx;
     
     import javax.interceptor.AroundInvoke;
     import javax.interceptor.InvocationContext;
    @@ -131,10 +146,17 @@ public class DeleteInterceptor {
             // Log Delete
             return context.proceed();
         }
    -}
    -
    -

    Movie

    -
    package org.superbiz.injection.tx;
    +}
    +
    +
    +
    +
    +
    +

    Movie

    +
    +
    +
    +
    package org.superbiz.injection.tx;
     
     import javax.persistence.Entity;
     
    @@ -178,10 +200,17 @@ public class Movie {
             this.year = year;
         }
     
    -}
    -
    -

    Movies

    -
    package org.superbiz.injection.tx;
    +}
    +
    +
    +
    +
    +
    +

    Movies

    +
    +
    +
    +
    package org.superbiz.injection.tx;
     
     import javax.annotation.security.PermitAll;
     import javax.annotation.security.RolesAllowed;
    @@ -199,17 +228,17 @@ import java.util.List;
     @Stateful
     public class Movies {
     
    -    @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
    +    @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.TRANSACTION)
         private EntityManager entityManager;
     
    -    @RolesAllowed({"Employee", "Manager"})
    +    @RolesAllowed({"Employee", "Manager"})
         @TransactionAttribute(TransactionAttributeType.REQUIRED)
         @Interceptors(AddInterceptor.class)
         public void addMovie(Movie movie) throws Exception {
             entityManager.persist(movie);
         }
     
    -    @RolesAllowed({"Manager"})
    +    @RolesAllowed({"Manager"})
         @TransactionAttribute(TransactionAttributeType.MANDATORY)
         @Interceptors(DeleteInterceptor.class)
         public void deleteMovie(Movie movie) throws Exception {
    @@ -219,13 +248,20 @@ public class Movies {
         @PermitAll
         @TransactionAttribute(TransactionAttributeType.SUPPORTS)
         public List<Movie> getMovies() throws Exception {
    -        Query query = entityManager.createQuery("SELECT m from Movie as m");
    +        Query query = entityManager.createQuery("SELECT m from Movie as m");
             return query.getResultList();
         }
    -}
    -
    -

    ReadInterceptor

    -
    package org.superbiz.injection.tx;
    +}
    +
    +
    +
    +
    +
    +

    ReadInterceptor

    +
    +
    +
    +
    package org.superbiz.injection.tx;
     
     import javax.interceptor.AroundInvoke;
     import javax.interceptor.InvocationContext;
    @@ -241,27 +277,48 @@ public class ReadInterceptor {
             return context.proceed();
         }
     }
    -
    -

    persistence.xml

    -
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
    -
    -  <persistence-unit name="movie-unit">
    -    <jta-data-source>movieDatabase</jta-data-source>
    -    <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>
    -    <class>org.superbiz.injection.tx.Movie</class>
    +....
    +
    +== persistence.xml
     
    -    <properties>
    -      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
    +[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

    -
    package org.superbiz.injection.tx;
    -
    -import junit.framework.TestCase;
    -
    -import javax.annotation.security.RunAs;
    +</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; @@ -269,114 +326,172 @@ import javax.ejb.TransactionAttributeTyp 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; - -/** +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 + * 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); +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;
             }
    -
    -        assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
    -    }
    -
    -    public void testWithTransaction() throws Exception {
    -        transactionalCaller.call(new Callable() {
    +    });
    +}
    +
    +
    +
    +
    +
    public void testWithoutTransaction() throws Exception {
    +    try {
    +        nonTransactionalCaller.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 {
    +        fail("The Movies bean should be using TransactionAttributeType.MANDATORY");
    +    } catch (javax.ejb.EJBException e) {
    +        // good, our Movies bean is using TransactionAttributeType.MANDATORY as we want
    +    }
    +}
    +
    +
    +
    +
    +
    public static interface Caller {
    +    public <V> V call(Callable<V> callable) throws Exception;
    +}
    +
    +
    +
    +
    +
    /**
    + * This little bit of magic allows our test code to execute in
    + * the scope of a container controlled transaction.
    + */
    +@Stateless
    +@RunAs("Manager")
    +@TransactionAttribute(REQUIRES_NEW)
    +public static class TransactionBean implements Caller {
    +
    +
    +
    +
    +
        public <V> V call(Callable<V> callable) throws Exception {
    +        return callable.call();
    +    }
    +}
    +
    +
    +
    +
    +
    @Stateless
    +@RunAs("Manager")
    +@TransactionAttribute(TransactionAttributeType.NEVER)
    +public static class NoTransactionBean implements Caller {
    +
    +
    +
    +
    +
            public <V> V call(Callable<V> callable) throws Exception {
                 return callable.call();
             }
         }
    -}
    -
    -

    Running

    -
    -------------------------------------------------------
    - T E S T S
    --------------------------------------------------------
    -Running org.superbiz.injection.tx.MoviesTest
    +}
    +
    +
    +
    +
    +
    == Running
    +
    +
    +
    +
    +
     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/ +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 - 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) @@ -392,20 +507,20 @@ INFO - Auto-creating a container for bea 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 - 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 - 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 - 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) @@ -416,12 +531,21 @@ INFO - Started Ejb(deployment-id=Transac 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 -

    +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.418 sec

    +
    +
    +

    Results :

    +
    +
    +

    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

    +
    +
    +
    +
    
    +
    +
    +
    +
    Modified: tomee/site/trunk/content/tomee-8.0/examples/decorators.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/tomee-8.0/examples/decorators.html?rev=1850005&r1=1850004&r2=1850005&view=diff ============================================================================== --- tomee/site/trunk/content/tomee-8.0/examples/decorators.html (original) +++ tomee/site/trunk/content/tomee-8.0/examples/decorators.html Sun Dec 30 21:47:45 2018 @@ -88,16 +88,25 @@
    -

    Help us document this example! Click the blue pencil icon in the upper right to edit this page.

    -

    AccessDeniedException

    -
    package org.superbiz.cdi.decorators;
    +                
    +

    index-group=CDI +type=page +status=published

    +
    +

    Decorators

    +
    +

    AccessDeniedException

    +
    +
    +
    +
    package org.superbiz.cdi.decorators;
     
     import javax.ejb.ApplicationException;
     
    @@ -109,10 +118,17 @@ public class AccessDeniedException exten
         public AccessDeniedException(String s) {
             super(s);
         }
    -}
    -
    -

    Calculator

    -
    package org.superbiz.cdi.decorators;
    +}
    +
    +
    +
    +
    +
    +

    Calculator

    +
    +
    +
    +
    package org.superbiz.cdi.decorators;
     
     /**
      * @version $Revision$ $Date$
    @@ -128,10 +144,17 @@ public interface Calculator {
         public int divide(int a, int b);
     
         public int remainder(int a, int b);
    -}
    -
    -

    CalculatorBean

    -
    package org.superbiz.cdi.decorators;
    +}
    +
    +
    +
    +
    +
    +

    CalculatorBean

    +
    +
    +
    +
    package org.superbiz.cdi.decorators;
     
     import javax.annotation.Resource;
     import javax.ejb.SessionContext;
    @@ -164,10 +187,17 @@ public class CalculatorBean implements C
         public int remainder(int a, int b) {
             return a % b;
         }
    -}
    -
    -

    CalculatorLogging

    -
    package org.superbiz.cdi.decorators;
    +}
    +
    +
    +
    +
    +
    +

    CalculatorLogging

    +
    +
    +
    +
    package org.superbiz.cdi.decorators;
     
     import javax.decorator.Decorator;
     import javax.decorator.Delegate;
    @@ -177,7 +207,7 @@ import java.util.logging.Logger;
     @Decorator
     public class CalculatorLogging implements Calculator {
     
    -    private Logger logger = Logger.getLogger("Calculator");
    +    private Logger logger = Logger.getLogger("Calculator");
     
         @Inject
         @Delegate
    @@ -185,7 +215,7 @@ public class CalculatorLogging implement
     
         @Override
         public int add(int a, int b) {
    -        logger.fine(String.format("add(%s, %s)", a, b));
    +        logger.fine(String.format("add(%s, %s)", a, b));
             return calculator.add(a, b);
         }
     
    @@ -196,7 +226,7 @@ public class CalculatorLogging implement
     
         @Override
         public int multiply(int a, int b) {
    -        logger.finest(String.format("multiply(%s, %s)", a, b));
    +        logger.finest(String.format("multiply(%s, %s)", a, b));
             return calculator.multiply(a, b);
         }
     
    @@ -207,13 +237,20 @@ public class CalculatorLogging implement
     
         @Override
         public int remainder(int a, int b) {
    -        logger.info(String.format("remainder(%s, %s)", a, b));
    +        logger.info(String.format("remainder(%s, %s)", a, b));
             return calculator.remainder(a, b);
         }
    -}
    -
    -

    CalculatorSecurity

    -
    package org.superbiz.cdi.decorators;
    +}
    +
    +
    +
    +
    +
    +

    CalculatorSecurity

    +
    +
    +
    +
    package org.superbiz.cdi.decorators;
     
     import javax.decorator.Decorator;
     import javax.decorator.Delegate;
    @@ -238,7 +275,7 @@ public class CalculatorSecurity implemen
         @Override
         public int subtract(int a, int b) {
             // Caller must pass a security check to call subtract
    -        if (!sessionContext.isCallerInRole("Manager")) throw new AccessDeniedException(sessionContext.getCallerPrincipal().getName());
    +        if (!sessionContext.isCallerInRole("Manager")) throw new AccessDeniedException(sessionContext.getCallerPrincipal().getName());
     
             return calculator.subtract(a, b);
         }
    @@ -257,10 +294,17 @@ public class CalculatorSecurity implemen
         public int remainder(int a, int b) {
             return calculator.remainder(a, b);
         }
    -}
    -
    -

    beans.xml

    -
    <beans>
    +}
    +
    +
    +
    +
    +
    +

    beans.xml

    +
    +
    +
    +
    <beans>
       <!--
       Explicitly declaring decorators is required by the CDI specification.
       The order decorators are listed in the xml is the order in which they are invoked.
    @@ -269,10 +313,17 @@ public class CalculatorSecurity implemen
         <class>org.superbiz.cdi.decorators.CalculatorSecurity</class>
         <class>org.superbiz.cdi.decorators.CalculatorLogging</class>
       </decorators>
    -</beans>
    -
    -

    CalculatorTest

    -
    package org.superbiz.cdi.decorators;
    +</beans>
    +
    +
    +
    +
    +
    +

    CalculatorTest

    +
    +
    +
    +
    package org.superbiz.cdi.decorators;
     
     import junit.framework.TestCase;
     
    @@ -296,7 +347,7 @@ public class CalculatorTest extends Test
          * @throws Exception
          */
         protected void setUp() throws Exception {
    -        EJBContainer.createEJBContainer().getContext().bind("inject", this);
    +        EJBContainer.createEJBContainer().getContext().bind("inject", this);
         }
     
         /**
    @@ -315,7 +366,7 @@ public class CalculatorTest extends Test
             try {
                 calculator.subtract(4, 6);
     
    -            fail("AccessDeniedException should have been thrown for unauthenticated access");
    +            fail("AccessDeniedException should have been thrown for unauthenticated access");
             } catch (AccessDeniedException expected) {
                 // pass
             }
    @@ -354,7 +405,7 @@ public class CalculatorTest extends Test
         }
     
         @Stateless
    -    @RunAs("Manager")
    +    @RunAs("Manager")
         public static class ManagerBean {
     
             public <V> V call(Callable<V> callable) {
    @@ -365,10 +416,17 @@ public class CalculatorTest extends Test
                 }
             }
         }
    -}
    -
    -

    Running

    -
    -------------------------------------------------------
    +}
    +
    +
    +
    +
    +
    +

    Running

    +
    +
    +
    +
    -------------------------------------------------------
      T E S T S
     -------------------------------------------------------
     Running org.superbiz.cdi.decorators.CalculatorTest
    @@ -376,7 +434,7 @@ Apache OpenEJB 4.0.0-beta-1    build: 20
     http://tomee.apache.org/
     INFO - openejb.home = /Users/dblevins/examples/decorators
     INFO - openejb.base = /Users/dblevins/examples/decorators
    -INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
    +INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
     INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
     INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
     INFO - Found EjbModule in classpath: /Users/dblevins/examples/decorators/target/classes
    @@ -384,21 +442,21 @@ INFO - Found EjbModule in classpath: /Us
     INFO - Beginning load: /Users/dblevins/examples/decorators/target/classes
     INFO - Beginning load: /Users/dblevins/examples/decorators/target/test-classes
     INFO - Configuring enterprise application: /Users/dblevins/examples/decorators
    -WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
    +WARN - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
     INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
     INFO - Auto-creating a container for bean decorators.Comp: Container(type=MANAGED, id=Default Managed Container)
     INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
     INFO - Auto-creating a container for bean CalculatorBean: Container(type=STATELESS, id=Default Stateless Container)
    -INFO - Enterprise application "/Users/dblevins/examples/decorators" loaded.
    +INFO - Enterprise application "/Users/dblevins/examples/decorators" loaded.
     INFO - Assembling app: /Users/dblevins/examples/decorators
    -INFO - Jndi(name="java:global/decorators/decorators.Comp!org.apache.openejb.BeanContext$Comp")
    -INFO - Jndi(name="java:global/decorators/decorators.Comp")
    -INFO - Jndi(name="java:global/decorators/CalculatorBean!org.superbiz.cdi.decorators.Calculator")
    -INFO - Jndi(name="java:global/decorators/CalculatorBean")
    -INFO - Jndi(name="java:global/decorators/ManagerBean!org.superbiz.cdi.decorators.CalculatorTest$ManagerBean")
    -INFO - Jndi(name="java:global/decorators/ManagerBean")
    -INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest!org.superbiz.cdi.decorators.CalculatorTest")
    -INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest")
    +INFO - Jndi(name="java:global/decorators/decorators.Comp!org.apache.openejb.BeanContext$Comp")
    +INFO - Jndi(name="java:global/decorators/decorators.Comp")
    +INFO - Jndi(name="java:global/decorators/CalculatorBean!org.superbiz.cdi.decorators.Calculator")
    +INFO - Jndi(name="java:global/decorators/CalculatorBean")
    +INFO - Jndi(name="java:global/decorators/ManagerBean!org.superbiz.cdi.decorators.CalculatorTest$ManagerBean")
    +INFO - Jndi(name="java:global/decorators/ManagerBean")
    +INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest!org.superbiz.cdi.decorators.CalculatorTest")
    +INFO - Jndi(name="java:global/EjbModule628834558/org.superbiz.cdi.decorators.CalculatorTest")
     INFO - Created Ejb(deployment-id=CalculatorBean, ejb-name=CalculatorBean, container=Default Stateless Container)
     INFO - Created Ejb(deployment-id=decorators.Comp, ejb-name=decorators.Comp, container=Default Managed Container)
     INFO - Created Ejb(deployment-id=ManagerBean, ejb-name=ManagerBean, container=Default Stateless Container)
    @@ -470,7 +528,11 @@ Tests run: 5, Failures: 0, Errors: 0, Sk
     Results :
     
     Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
    -
    +....
    +
    +
    + + Modified: tomee/site/trunk/content/tomee-8.0/examples/index.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/tomee-8.0/examples/index.html?rev=1850005&r1=1850004&r2=1850005&view=diff ============================================================================== --- tomee/site/trunk/content/tomee-8.0/examples/index.html (original) +++ tomee/site/trunk/content/tomee-8.0/examples/index.html Sun Dec 30 21:47:45 2018 @@ -102,7 +102,6 @@
  • CDI Field Producer
  • CDI Interceptors
  • CDI Produces Disposes
  • -
  • Decorators
  • Simple CDI Interceptor
  • @@ -153,6 +152,18 @@ + +
    +
    Meta-Annotations
    -
    -
    Session Beans
    +
    +
    Other Features
    -
    -
    EntityManagers
    +
    +
    Security
    -
    -
    JMS and MDBs
    +
    +
    Proxy Beans
    -
    -