File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
src/main/java/com/naturalprogrammer/spring/tutorial/aop Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .naturalprogrammer .spring .tutorial .aop ;
2+
3+ import org .apache .commons .logging .Log ;
4+ import org .apache .commons .logging .LogFactory ;
5+ import org .aspectj .lang .ProceedingJoinPoint ;
6+ import org .aspectj .lang .annotation .Around ;
7+ import org .aspectj .lang .annotation .Aspect ;
8+ import org .springframework .stereotype .Component ;
9+
10+ @ Component
11+ @ Aspect
12+ public class RequestMonitor {
13+
14+ private static final Log log = LogFactory .getLog (RequestMonitor .class );
15+
16+ @ Around ("within(com.naturalprogrammer.spring.tutorial.controllers.*)" )
17+ public Object wrap (ProceedingJoinPoint pjp ) throws Throwable {
18+
19+ log .info ("Before handler '"
20+ + pjp .getSignature ().getName () + "'. Thread "
21+ + Thread .currentThread ().getName ()); // toString gives more info
22+
23+ Object retVal = pjp .proceed ();
24+
25+ log .info ("Handler '"
26+ + pjp .getSignature ().getName ()
27+ + "' execution successful" );
28+
29+ return retVal ;
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments