java annotation for runtime preprocessing on class already coded and in use

229 Views Asked by At

I would like to define an annotation for methods that could execute some code before the method starts.

As I understand, it is possible to use proxy and invocation handler to perform this kind of task ( like for instance in : http://www.concretepage.com/java/dynamic-proxy-with-proxy-and-invocationhandler-in-java). However this means first defining an interface, then a class that implements that interface, and then use the proxy.

so if there is some existing code, already using an class, this technique will not allow me to add the annotation and leave everything else unchanged..

is there a way to make such annotations in java ?

thanks

0

There are 0 best solutions below