KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > interceptor > bean > TracingInterceptor


1 /*
2  * JBoss, the OpenSource EJB server
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.tutorial.interceptor.bean;
8
9 import javax.ejb.AroundInvoke;
10 import javax.ejb.InvocationContext;
11
12 public class TracingInterceptor {
13
14    @AroundInvoke
15    public Object JavaDoc log(InvocationContext ctx) throws Exception JavaDoc
16    {
17       System.out.println("*** TracingInterceptor intercepting");
18       long start = System.currentTimeMillis();
19       try
20       {
21          return ctx.proceed();
22       }
23       catch(Exception JavaDoc e)
24       {
25          throw e;
26       }
27       finally
28       {
29          long time = System.currentTimeMillis() - start;
30          String JavaDoc method = ctx.getBean().getClass().getName() + "." + ctx.getMethod().getName() + "()";
31          System.out.println("*** TracingInterceptor invocation of " + method + " took " + time + "ms");
32       }
33    }
34 }
35
Popular Tags