3 Replies Latest reply on Sep 22, 2003 9:02 AM by Bill Burke

    Intercepting Collection access

    Eric Jain Newbie

      Does JBoss AOP include any mechanism for intercepting read or write access to collection classes? For example, I may have a class A with a field 'children' that is a List. I am not only interested in intercepting calls to setChildren, but also to invocations such as getChildren().add(...) or .remove(...).

        • 1. Re: Intercepting Collection access
          Bill Burke Master

          We do some of this in our caching framework by replacing the field with a proxy.

          I haven't tested it yet, but you should be able to apply a caller pointcut, although you wouldn't be able to say "for this field I want to intercept this method", but you could say, that "I want to intercept this class and method from within this other class and method."

          Thanks,

          Bill

          • 2. Re: Intercepting Collection access
            Eric Jain Newbie

            > We do some of this in our caching framework by
            > replacing the field with a proxy.

            This replacement, is it done by JBoss AOP, or manually?

            > I haven't tested it yet, but you should be able to
            > apply a caller pointcut

            That would be a solution, though it may not always be practical, as sometimes I have no idea who is calling my objects :-)

            • 3. Re: Intercepting Collection access
              Bill Burke Master

              Exactly. It is not always practical.....

              Another feature of Javassist, is that you can replace all references of one class with another. We may use this feature so that we can make system classes like the collection api Adviseable.

              I also want to research how AspectJ and/or AspectWerkz can describe this sort of scenario. Where you want to be able to intercept a method of a particular field of a particular class. This is definately implementable with Javassist and the current AOP framework, I would just like to know the best syntax to do this in.

              Bill