Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - Use annotations and intercept methods?

Is there a simple way to intercept methods in java. I need to add an annotation to required methods so that a piece of logic gets called before going through the method.

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
}

EDIT:

The recommended guice library for android apps does not contain AOP. Is it possible to achieve this using reflection without adding any libraries?

like image 810
aryaxt Avatar asked Oct 10 '22 07:10

aryaxt


1 Answers

Guice provides easy way of implementing annotations. Check this out.

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

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

like image 118
Sid Malani Avatar answered Oct 11 '22 22:10

Sid Malani