2 Replies Latest reply on Aug 24, 2005 5:07 PM by bill.burke

    How AOP can help

    sharman

      Hello everyone,

      I am writing a program to catch exception at runtime. What I want to do is I have a J2EE application, deployed on JBoss app server. I want to add an aop interceptor which should catch any exception occuring in the j2ee application. Can anyone tell me how JBoss AOP can be of help and what part of AOP should I investigate to get the solution.

      ANy ideas are welcomed.

      Thanx,
      NS

        • 1. Re: How AOP can help

          My $0.02.

          If you want to soften checked exceptions then I will not help - I doubt if that's possible.

          If you want to catch all runtime exceptions at some places, then there is nothing simpler:

          1) specify pointcuts - places where you suspect (know) some exceptions might occur
          1a) you can do it in several ways - the most standard approach is by using 'execution' pointcuts in jboss-aop.xml
          1b) you might consider to do it via @annotations if that's reasonable

          2) write an aspect and advice within it that does the logic you need:

          public MyExceptionHandler
          {
           public void myAdvice(Invocation invocation)
           {
           try
           {
           return invocation.invokeNext();
           }
           catch (MyException or Exception)
           {
           //do something...
           }
           return null (or something else);
           }
          }


          3) that's all


          Any more questions.. just ask

          Best regards,
          Tomasz Nazar




          • 2. Re: How AOP can help
            bill.burke

            I always thought softening checked exceptions in AspectJ was a really bad idea...Just my opinion though.