Skip to content

Instantly share code, notes, and snippets.

@mathieuancelin
Created February 1, 2012 08:52
Show Gist options
  • Save mathieuancelin/1716023 to your computer and use it in GitHub Desktop.
Save mathieuancelin/1716023 to your computer and use it in GitHub Desktop.
public class AOPConfig {
public void configure(@Observes AOPConfigEvent config) {
config.add( intercept(Service.class).onAllMethodsReturning(String.class) );
}
}
public void intercept(@Observes @Return(String.class)
@MethodName("doSomething")
@MethodAnnotated(CutHere.class) Before before) {
if (getHourOfTheDay() == 0) {
before.preventAndReturn("Impossible d'utiliser cette méthode maintenant");
} else {
logger.info("Méthode " + before.getMethod() + " accédée par " + before.getParameter(0));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment