Hi,
I had found a workaround this issue earlier, but once again with some new refactorings I am getting into trouble using both withincode, call, target and args together in an advice. From my understanding of AspectJ I should get what I expect but unfortunately nothing is being captured. Here is the problem:
I have a class Database with method close as follows:
public class Database {
void close(int closemode) throws HsqlException {
HsqlException he = null;
setState(DATABASE_CLOSING);
sessionManager.closeAllSessions();
sessionManager.clearAll();
//some code to refactor
....//more code in close
}
}
I want to refactor code in the Database.close method that occurs after sessionManager.clearAll( ) code. So, I create pointcuts as follows:
pointcut thisDB(Database d): this(d);
pointcut clearAllcall() : call(void SessionManager.clearAll());
pointcut inClose(int closemode): args(closemode) && withincode(void close(int ));
and then have the following advice:
after(Database d, int closemode): thisDB(d) && inClose(closemode) && clearAllcall() {
d.logger.closeLog(closemode);
}
I would hope that it would crosscut after the clearAll() call in close method, but it does not crosscut anywhere. Can someone please tell me what am I doing wrong?
Thanks a lot.
Sincerely,
Irum Godil.
pope <alexandru.popescu@xxxxxxxxx> wrote: