You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by vi...@apache.org on 2011/12/18 19:42:07 UTC

svn commit: r1220516 - /openejb/trunk/openejb/examples/simple-cdi-interceptor/README.md

Author: vishwanathk
Date: Sun Dec 18 18:42:06 2011
New Revision: 1220516

URL: http://svn.apache.org/viewvc?rev=1220516&view=rev
Log:
Removed pre and code tags to fix alignment

Modified:
    openejb/trunk/openejb/examples/simple-cdi-interceptor/README.md

Modified: openejb/trunk/openejb/examples/simple-cdi-interceptor/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/simple-cdi-interceptor/README.md?rev=1220516&r1=1220515&r2=1220516&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/simple-cdi-interceptor/README.md (original)
+++ openejb/trunk/openejb/examples/simple-cdi-interceptor/README.md Sun Dec 18 18:42:06 2011
@@ -6,68 +6,60 @@ Let's write a simple application that wo
 
 How do we mark which methods are to be intercepted ? Wouldn't it be handy to annotate a method like 
 
-<pre><code>
-@Log
-public void aMethod(){...} 
-</code></pre>
+    @Log
+    public void aMethod(){...} 
 
 Let's create an  annotation that would "mark" a method for interception. 
 
-<pre><code>
-@InterceptorBinding
-@Target({ TYPE, METHOD })
-@Retention(RUNTIME)
-public @interface Log {
-}
-</code></pre>
+    @InterceptorBinding
+    @Target({ TYPE, METHOD })
+    @Retention(RUNTIME)
+    public @interface Log {
+    }
 
 Sure, you haven't missed the @InterceptorBinding annotation above ! Now that our custom annotation is created, lets attach it (or to use a better term for it, "bind it" )
 to an interceptor. 
 
 So here's our logging interceptor. An @AroundInvoke method and we are almost done.
-<pre><code>
-@Interceptor
-@Log  //binding the interceptor here. now any method annotated with @Log would be intercepted by logMethodEntry
-public class LoggingInterceptor {
-    @AroundInvoke
-    public Object logMethodEntry(InvocationContext ctx) throws Exception {
-        System.out.println("Entering method: " + ctx.getMethod().getName());
-        //or logger.info statement 
-        return ctx.proceed();
+
+    @Interceptor
+    @Log  //binding the interceptor here. now any method annotated with @Log would be intercepted by logMethodEntry
+    public class LoggingInterceptor {
+        @AroundInvoke
+        public Object logMethodEntry(InvocationContext ctx) throws Exception {
+            System.out.println("Entering method: " + ctx.getMethod().getName());
+            //or logger.info statement 
+            return ctx.proceed();
+        }
     }
-}
-</code></pre>
 
 Now the @Log annotation we created is bound to this interceptor.
 
 That done, let's annotate at class-level or method-level and have fun intercepting ! 
 
-<pre><code>
-@Log
-@Stateful
-public class BookForAShowOneInterceptorApplied implements Serializable {
-    private static final long serialVersionUID = 6350400892234496909L;
-    public List<String> getMoviesList() {
-        List<String> moviesAvailable = new ArrayList<String>();
-        moviesAvailable.add("12 Angry Men");
-        moviesAvailable.add("Kings speech");
-        return moviesAvailable;
+    @Log
+    @Stateful
+    public class BookForAShowOneInterceptorApplied implements Serializable {
+        private static final long serialVersionUID = 6350400892234496909L;
+        public List<String> getMoviesList() {
+            List<String> moviesAvailable = new ArrayList<String>();
+            moviesAvailable.add("12 Angry Men");
+            moviesAvailable.add("Kings speech");
+            return moviesAvailable;
+        }
+        public Integer getDiscountedPrice(int ticketPrice) {
+            return ticketPrice - 50;
+        }
+        // assume more methods are present
     }
-    public Integer getDiscountedPrice(int ticketPrice) {
-        return ticketPrice - 50;
-    }
-    // assume more methods are present
-}
-</code></pre>
 
 The `@Log` annotation applied at class level denotes that all the methods should be intercepted with `LoggingInterceptor`.
 
 Before we say "all done" there's one last thing we are left with ! To enable the interceptors ! 
 
 Lets quickly put up a [beans.xml file]
-<pre><code>
-&lt;beans&gt;<br/>  &lt;interceptors&gt;<br/>    &lt;class&gt;org.superbiz.cdi.bookshow.interceptors.LoggingInterceptor<br/>    &lt;/class&gt;<br/>  &lt;/interceptors&gt;<br/>&lt;/beans&gt;
-</code></pre>
+
+    &lt;beans&gt;<br/>  &lt;interceptors&gt;<br/>    &lt;class&gt;org.superbiz.cdi.bookshow.interceptors.LoggingInterceptor<br/>    &lt;/class&gt;<br/>  &lt;/interceptors&gt;<br/>&lt;/beans&gt;
 
  in META-INF
 
@@ -81,28 +73,26 @@ Fire up the test, and we should see a 'E
 
 [Download as zip](${zip}) 
 
-<pre><code>
 #Tests
-Apache OpenEJB 4.0.0-beta-2-SNAPSHOT    build: 20111103-01:00
-http://openejb.apache.org/
-INFO - openejb.home = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
-INFO - openejb.base = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
-INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
-INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
-INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
-INFO - Found EjbModule in classpath: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes
-INFO - Beginning load: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes
-INFO - Configuring enterprise application: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
-INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
-INFO - Auto-creating a container for bean cdi-simple-interceptors.Comp: Container(type=MANAGED, id=Default Managed Container)
-INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
-INFO - Auto-creating a container for bean BookShow: Container(type=STATEFUL, id=Default Stateful Container)
-INFO - Enterprise application "/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors" loaded.
-INFO - Assembling app: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
-INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow!org.superbiz.cdi.bookshow.beans.BookShow")
-INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow")
-INFO - Created Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container)
-INFO - Started Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container)
-INFO - Deployed Application(path=/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors)
-Entering method: getMoviesList
-</code></pre>
+    Apache OpenEJB 4.0.0-beta-2-SNAPSHOT    build: 20111103-01:00
+    http://openejb.apache.org/
+    INFO - openejb.home = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+    INFO - openejb.base = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+    INFO - Using 'javax.ejb.embeddable.EJBContainer=true' 
+    INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
+    INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
+    INFO - Found EjbModule in classpath: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes
+    INFO - Beginning load: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes
+    INFO - Configuring enterprise application: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+    INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
+    INFO - Auto-creating a container for bean cdi-simple-interceptors.Comp: Container(type=MANAGED, id=Default Managed Container)
+    INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container)
+    INFO - Auto-creating a container for bean BookShow: Container(type=STATEFUL, id=Default Stateful Container)
+    INFO - Enterprise application "/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors" loaded.
+    INFO - Assembling app: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors
+    INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow!org.superbiz.cdi.bookshow.beans.BookShow")
+    INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow")
+    INFO - Created Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container)
+    INFO - Started Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container)
+    INFO - Deployed Application(path=/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors)
+    Entering method: getMoviesList