KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > exception > ExceptionHandlingAspect


1 package examples.exception;
2
3 import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
4 import org.codehaus.aspectwerkz.joinpoint.CatchClauseRtti;
5 import org.codehaus.aspectwerkz.joinpoint.Rtti;
6
7 /**
8  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
9  */

10 public class ExceptionHandlingAspect {
11
12     /**
13      * before handler(java.lang.Exception) && withincode(public static void
14      * examples.exception.Target.main(String[]))
15      *
16      * @Before handler(java.lang.Exception) && within(examples.exception.Target)
17      */

18     public void logEntry(final JoinPoint joinPoint) throws Throwable JavaDoc {
19         CatchClauseRtti crtti = (CatchClauseRtti) joinPoint.getRtti();
20         Exception JavaDoc e = (Exception JavaDoc) crtti.getParameterValue();
21         System.out.println("[From advice] exception catched:" + e.toString());
22     }
23 }
Popular Tags