Skip to content

Commit 55515a8

Browse files
AoP
1 parent 4d57c32 commit 55515a8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.naturalprogrammer.spring5tutorial.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 Log log = LogFactory.getLog(RequestMonitor.class);
15+
16+
@Around("within(com.naturalprogrammer.spring5tutorial.controllers.*)")
17+
public Object wrap(ProceedingJoinPoint pjp) throws Throwable {
18+
19+
log.info("Before handler " + pjp.getSignature().getName()
20+
+ ". Thread " + Thread.currentThread().getName());
21+
22+
Object retval = pjp.proceed();
23+
24+
log.info("Handler " + pjp.getSignature().getName()
25+
+ " execution successful.");
26+
27+
return retval;
28+
}
29+
}

0 commit comments

Comments
 (0)