I want modify my code on runtime by @annotation and interceptor. I created a simple example to explain my need on the stackoverflow website.
How change i = i + 1;
to i = i + 3;
on runtime (in my invoke
of MyRetryInterceptor
).
My original (public) code:
@MyRetry(value = 3)
public void testforRetry() {
int i = 0;
logger.info("testforRetry " + i);
i = i + 1;
logger.info("testforRetry " + i);
}
My Method Interceptor:
public class MyRetryInterceptor implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Method m = invocation.getMethod();
Object result = invocation.proceed();
return result;
}
}
Aucun commentaire:
Enregistrer un commentaire