Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Object Graph using aspectj

> For situation when any object adds/removes a reference to another object
>
>  pointcut assignments(Object assigned, Object to):
>
>        set(Object *.*) && args(assigned && target(to) &&
>          !within(edu.testing.lib.*) ;
>
> seems to work accepts assignments with in methods. Any suggestions on how to
> do that?

Are you saying that this only works for assignments occurring outside
of methods? So, in initializers and field declarations?  Doesn't make
sense.  Can you be more specific?



>
>  pointcut constructor() : (call(*.new(..)) || call(*.new())) &&
>    !within(edu.testing.lib.*)    ;

You need to bind these arguments.  So, you want to do something like this:

pointcut constructor(Object caller, Object created) : (call(*.new(..))
|| call(*.new())) &&
    !within(edu.testing.lib.*)  && target(created) && this(caller);

after (Object caller) returning (Object created) : constructor(caller,
created) {
  ...
}


Back to the top