Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] nested calls

I am not sure if I understand the problem correctly. However, it seems something like the following should help towards resolving it:

pointcut extendedOp() : execution(* StatefullDatabaseObject+.*(..)) && !execution(StatefullDatabaseObject.*(..));

pointcut duringExtendedOp() : cflow(executedOp());

-Ramnivas

On Dec 18, 2007 4:24 AM, Luca Ferrari <fluca1978@xxxxxxxxxxx> wrote:
Hi all,
I've got the following Java interface:

public interface StatefullDatabaseObject extends DatabaseObject {
   public abstract boolean refresh() throws DatabaseException;
   public abstract boolean update() throws DatabaseException;
   public abstract boolean insert() throws DatabaseException;
   public abstract boolean delete() throws DatabaseException;
}

that implements a kind of CRUD support. I've got a few objects that implement
such interface and that performs something like the following:

public class Person implements StatefullDatabaseObject {
   ....

  List<Skill> skills = ....                            // skill is also a StatefullDatabaseObject

   public boolean refresh() throws DatabaseException{
       // do something

       for(Skill s : skills)
            s.refresh();               // nested call
   }

   public void addSkill(Skill s){
      if( s.insert() )
        this.skills.add(s);    // undirect call
   }
}

here I've got what I call "nested calls", that is a StatefullDatabaseObject
method that calls the same StatefullDatabaseObject method on another object,
and undirect call, that is a not StatefullDatabaseObject method that calls a
StatefullDatabaseObject method on another object. I want to refactor such
code removing the undirect calls from within the method. So I designed a
pointcut to catch calls like the one in the addSkill method:

pointcut nestedDatabaseOperation() : this(StatefullDatabaseObject)
              // I want the call to be made within a StatefullDatabaseObject
                                        &&                                     // and
               target(StatefullDatabaseObject)
              // the callee must be another StatefullDatabaseObject
                                        &&                                     // and
               call( boolean StatefullDatabaseObject.*() throws DatabaseException)
             // a method call to the main StatefullDatabaseObject methods
                                        &&                                     // and
             cflow(! call( boolean StatefullDatabaseObject.*() throws
DatabaseException ) );
            // I'm not in a StatefullObject method


My aim is to capture with this aspect all the undirect calls, that are those
performed from a StatefullDatabaseObject but not from a
StatefullDatabaseObject.*() method, so to catch all calls like that in the
addSkill method, while the weaver is advicing also the refresh method (that
I'd like to catch with another aspect).
What am I doing wrong in the aspect declaration? Even if I use cflowbelow I
still catch the refresh nested calls.

Thanks,
Luca


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top