3 Replies Latest reply on Sep 5, 2005 5:33 AM by kabirkhan

    pointcut $instanceof didn't work

    sharman

      Hi,

      I have written a pointcut to intercept the Exception.

      My jboss-aop.xml looks like this:


      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <aop>
       <aspect class="com.ac.detector.ExceptionHandlingAspect" scope="PER_INSTANCE"/>
       <bind pointcut="call(* $instanceof{java.lang.Exception}-&gt;*(..))">
       <advice aspect="com.ac.detector.ExceptionHandlingAspect" name="catchException"/>
       </bind>
      </aop>
      


      In my source file (which is a servlet), I have created an Exception object and calling a method on it...But it never gets intercepted. I am doing compile time weaving and then deploying it in jboss app server.

      I even tried by trying pointcut="execution(* $instanceof{java.lang.Exception}->*(..))" ...but no luck....

      Is this pointcut correct??? OR can some one give me some idea how can I define pointcut for method call on an Exception object????


      Thanx

      -NS

        • 1. Re: pointcut $instanceof didn't work
          kabirkhan

          There should be no difference between Exceptions and normal classes, neither with regard to $instanceof{} nor call/execution usage

          • 2. Re: pointcut $instanceof didn't work
            sharman

            Thanx Kabir for the reply.

            Yeah, I understand that there should be no difference between Exceptions and normal classes. But $instanceof{} somehow doesn't work on system class(like java.lang.Exception). It is working fine for me with normal classes. Can u please try this pointcut and see if the interceptor is called.

            <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
            <aop>
             <aspect class="com.ac.detector.ExceptionHandlingAspect" scope="PER_INSTANCE"/>
             <bind pointcut="call(* $instanceof{java.lang.Exception}-&gt;*(..))">
             <advice aspect="com.ac.detector.ExceptionHandlingAspect" name="catchException"/>
             </bind>
            </aop>
            


            Thanx,

            NS

            • 3. Re: pointcut $instanceof didn't work
              kabirkhan

              Create a minimal example showing everything, and I'll try to take a look