3 Replies Latest reply on Aug 5, 2004 7:20 PM by Bill Burke

    Pointcut expression for methods that take arrays as argument

    rkadayam Newbie

      I could'nt find it in the forums. Does anyone know how to frame a pointcut expression for a method such as

      POJO.methodOne(Object[] array, CustomObject[] array2);

      I need to fine grain every method in POJO so the generic stuff (..) will not work for me.


        • 1. Re: Pointcut expression for methods that take arrays as argu
          Bill Burke Master

          This should work

          execution(void java.lang.Object[],com.pkg.CustomObject[])

          Don't forget that any class, even if it is in java.lang package must be fully qualified.


          • 2. Re: Pointcut expression for methods that take arrays as argu
            Tomasz Nazar Newbie

            Hi, there.
            This is my first post after checking out JBossAOP, and implementing persistance and transaction layer for my POJOs with it.

            So ...

            Is it possible to intercept element-of-an-array assignment?
            I mean:

            //I'd like some code here (through Interceptor, of course)
            myArray[5] = newElement;
            //maybe I also would like some code 'around'..
            //maybe sth like this: myArray[5] = getCachedMyElement;
            //or even 'after': UPDATE OBJECT_TABLE .... WHERE ...

            And the binding in jboss-aop.xml, would look like this:
             <bind pointcut="array-element-set(myClass.myArray)"...
             <bind pointcut="array-element-get(myClass.myArray)" ...

            If I had the functionality, then I would write persistance-layer with no limitations on collections classes, or whatever limitations existing persistance layers may have. More deeply: One would not write bindings for every collection class, i.e. collection.add(), collection.get(i)....
            One would write generic persistance, by: intercepting every-variable-change-including-array-element-assignment.

            And the real example of this is: java.util.ArrayList, where it stores data internally in an array:
            package java.util;
            public class ArrayList {
            private transient Object[] elementData
            public boolean add(Object o) {
             ensureCapacity(size + 1); // Increments modCount!!
             elementData[size++] = o;
             return true;

            I think you know what I mean now. I'd like to have simple
            <bind poincut="array-element-set(java.util.ArrayList->elementData)">

            instead of binding, and implementing every "collection" class' method which manages data.

            PS. Of course AspectJ also doesn't have functionality mentioned above, either

            • 3. Re: Pointcut expression for methods that take arrays as argu
              Bill Burke Master

              We don't support this. If you'd like to contribute it, it would be most welcome.