java - AspectJ pointcut in object-aspect is not working -


i can't find out why pointcut not working. compiler not give warnings, cannot explain why not working. i'm using aspectjrt 1.7.2 , aspectjtools 1.7.0 in maven javafx application.

my aspect looks this

public privileged aspect movieaspect perthis(movieinit()) {  pointcut movieinit(): execution(movie.new(..));  pointcut reloadmainpanelview(): cflow(execution(void main.views.mainframe.mainpanel.fillmainpanel(..)));  before(arraylist tar): target(tar) && reloadmainpanelview() && call(void java.util.arraylist.clear())                        && !within(movieaspect) {     system.out.println("test"); } 

my movieaspect located in package main.models

and here little explanation of happening within code


when gui loads initialize mainframe class. before aspect loads movie-objects. , when mainframe initializes views movie-objects in mainpanel first clears view-objects , reloads them. because added views listener corresponding movie-object need remove them again. of course before calling clear-method of arraylist know why pointcut not working. movieaspect-objects instantiated, tested movieinit() pointcut.


does have clue, why pointcut not work? pointcuts on outer classes in same package or not not work except in class movie.

hope can help.

edit:

this catch constructors of movie-class doesn't matter. after hours of research found solution. text explains behaviour

4.3.4 implicit limiting of join points

using per-object or per-control-flow association has side effect of implicitly limiting advice in aspect join points match scope of aspect instance. scope of aspect instance set of join points have aspect instance associated them. example, percflow() association, scope of aspect instance join points occurring inside control flow of specified pointcut. means if pointcut specified advice matches join point, advice join point won’t apply unless join point matches scope of aspect. side effect surprises developers when refactor aspect create reusable parts , need use per- associations. aspect association implies advice in aspect apply join points if:

■ perthis() associations, join point’s execution object matches aspect instance’s associated object.

■ pertarget() associations, join point’s target object matches aspect’s associated object.

■ percflow() associations, join point in control flow of aspect’s associated control flow.

■ percflowbelow() associations, join point below control flow of aspect’s associated control flow.

are sure movieinit() pointcut catches call movie constructor? movie constructor method default constructor or user-defined one?


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -