Created
February 1, 2012 08:52
-
-
Save mathieuancelin/1716023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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