1 Reply Latest reply on Jan 22, 2009 11:18 AM by kabirkhan

    Ignore Field Access in Advice

    lydiachung

      I wrote a very simple entity object which has a unique field called objectID.

      public class CustomObject{
       public Long objectID;
       public String field1;
       public String field2;
      }
      


      And I have a field interceptor which intercepts all the field read and write requests.

      public class CustomObjectFieldInterceptor{
       if(invocation instanceof FieldReadInvocation){
       FieldReadInvocation readInvocation = (FieldReadInvocation) invocation;
       CustomObject object1 = (CustomObject) readInvocation.getTarget();
       Long objID = object1.objectID;
       }
      }
      


      The last line inside the if block
      Long objID = object1.objectID;
      throws StackOverflowException because there is a recursive call.

      Is there a way to tell the interceptor not intercept the field access when the request is sent from its own method?

      Thank you!



        • 1. Re: Ignore Field Access in Advice
          kabirkhan

          I think making your CustomObjectFieldInterceptor implement org.jboss.aop.instrument.Untransformable should work. Classes implementing that interface are not woven, and thus field access should not get replaced