Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] How to get object reference (not parent) using get pointcut

Here's the situation:  I'm using JAXB to read and write XML data.  I want to use aspects to populate a JTree as it unmarshals the data to the object tree.  To do this, I'm visualizing that I need the parent object as well as the child object.  Getting the child object reference is simple:
 
   pointcut populateList():
      call(* ArrayList.add*(..));
   after(): populateList()
   {
      ArrayList lTarget = (ArrayList) thisJoinPoint.getTarget();
   }
For the parent object I have the following aspect:
   pointcut getContainer():
      get(protected ArrayList *.*);
   after(): getContainer()
   {
      ...
   }
 
Using these two aspects, I see getParent() executed and then populateList().  However, the unmarshalling occurs as a depth-first traversal which makes determining at what level a particular list is getting populated.  In trying to determine these things, I've found that I can't get the object reference of the field being referenced, only it's parent object.  In other words, populateList() only knows about the array list but not the container.  getContainer() only knows about the containing object, but not the actual array list being referenced.  I don't want to put structure information into the aspects so that they can generically handle depth-first traversal of any object graph.
 
So... how will I know when and how far to back out of a graph?

Back to the top