[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Capturing setting inside List

Suppose I have this classes...
 
public class A implement Serializable {
  List list = new ArrayList();
  public add(Object o) {
    list.add(o);
  } 
}
 
public class B {
  int x;
  setX(int x) {
    this.x = x;
  }   
}
 
... and a main method:
 
public void main(String[] args) {
  a1 = new A();
  b1 = new B();
  a1.add(b1);
 
  a2 = new A();
  b2 = new B();
  a2.add(b2);
 
  b1.setX(3);  // a1 affected
}
 
I would like to serialize the A object every time an element in his List is modified (in this case, only a1 will be serialized).
Is it possible to intercep this pointcut using AspectJ?
 
Thanks,
 
André