0
votes

I'm trying to log a login action with AspectJ. I need to obtain the logged user. I tried this but it doesn't work. The joinpoint is never executed.

@Aspect
public class LoginActivityAspect {

    @Pointcut(value = "call(void com.android.project.activities.LoginActivity.loginSuccess(String)) && this(username)", argNames = "username")
    public void loginSuccess(String username) {}

    @Before(value = "loginSuccess(username)")
    public void logLoginSuccess(username) {
        logger.debug("loginSuccess", "Login success: " + username);
    }
}

In LoginActivity I have this method:

public void loginSuccess(String username){
    //DO STUFF
}

What am I doing wrong? Thanks.

1

1 Answers

0
votes

Solved! Sorry I'm newbie in AOP.

I have modified the pointcut into this:

 @Pointcut(value = "call(void com.android.project.activities.LoginActivity.loginSuccess(String)) && args(username)")
    public void loginSuccess(String username) {}