[jboss-dev-forums] [Design of AOP on JBoss (Aspects/JBoss)] - Re: Array interception needed for jboss cache

kabir.khan@jboss.com do-not-reply at jboss.com
Wed Jan 3 16:17:44 EST 2007


Please take a look at the tests

1) Yes, this is done in AOPArrayTestCase

2) & 3)By querying the ArrayRegistry, you get the full path to the array as it is referenced - with the "root" instance (or the class in the case of a static field), field name, and if a nested array the sub elements.

ArrayReferenceTestCase has examples of this, but a quick summary here: 

  | class POJOx{
  |    int[] array;
  | }
  | 
  | class POJOy{
  |    static Object[] array = new Object[][]{new Object[3]}, new Object[3], new Object[3]}};
  | }
  | 
  | int[] arr = new int[]{1,2,3};
  | POJOx x1 = new POJOx(); //POJOx at 1111
  | POJOx x2 = new POJOx(); //POJOx at 2222
  | x1.array = arr;
  | x2.array = arr;
  | POJOy.array[1][2] = arr;
  | 

If we now do

  | List<ArrayReference> refs = ArrayRegistry.getInstance().getArrayOwners(arr);
  | 

We get the following 3 array references for arr:


  | ArrayReference-1: root=POJOx at 1111; rootField="array"; nestedIndices=null
  | ArrayReference-2: root=POJOx at 2222; rootField="array"; nestedIndices=null
  | ArrayReference-3: root=POJOy.class; rootField="array"; nestedIndeces=[1,2]
  | 

4) Not sure what you mean by "Region", but with the reference counting you should be able to determine if there is only one reference or if more than one reference to use the special reference area in the cache. One thing which might be an issue is that I update the references in the woven code before creating an invocation

5) Yes, the ArrayElementInvocation base class getTargetObject() method returns the array

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3997709#3997709

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3997709



More information about the jboss-dev-forums mailing list