Java - 使用注释和拦截方法?

ary*_*axt 5 java android annotations interception

有没有一种简单的方法来拦截java中的方法.我需要为所需的方法添加一个注释,以便在通过该方法之前调用一段逻辑.

public void verifyActivity() {
   // Asset if you are on a wrong page
}

@VerifyActivity
public void testLogin() {
   // Login for my automate test
}

@VerifyActivity
public void testSomethingElse() {
   // Test some other UI Automation stuff
}
Run Code Online (Sandbox Code Playgroud)

编辑:

Android应用程序推荐的guice库不包含AOP.是否可以在不添加任何库的情况下使用反射实现此目的?

Sid*_*ani 2

Guice 提供了实现注释的简单方法。看一下这个。

http://code.google.com/p/google-guice/wiki/AOP

http://code.google.com/p/google-guice/