01: package examples.exception;
02:
03: import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
04: import org.codehaus.aspectwerkz.joinpoint.CatchClauseRtti;
05: import org.codehaus.aspectwerkz.joinpoint.Rtti;
06:
07: /**
08: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
09: */
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 {
19: CatchClauseRtti crtti = (CatchClauseRtti) joinPoint.getRtti();
20: Exception e = (Exception) crtti.getParameterValue();
21: System.out.println("[From advice] exception catched:"
22: + e.toString());
23: }
24: }
|