Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)

AltStyle によって変換されたページ (->オリジナル) /