@Aspect @Component public class ServiceMonitor { @Pointcut("execution(* sample..*Service.*(..))") public void recordLog(){} @Around("recordLog()") public Object around(ProceedingJoinPoint pjp) throws Throwable{ Object obj; System.out.println("The operation log has been recorded before @Around method is executed"); obj = pjp.proceed (); System.out.println("The operation log has been recorded after the @Around method is executed"); return obj; } @AfterReturning("recordLog()") public void logServiceAccess(JoinPoint joinPoint) { System.out.println("Completed: " + joinPoint); } @Before("recordLog()") public void logServiceAcces1(JoinPoint joinPoint) { System.out.println("start: " + joinPoint); } @After("recordLog()") public void logServiceAcces2(JoinPoint joinPoint) { System.out.println("After: " + joinPoint); } }
@Aspect annotation interceptor
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326508964&siteId=291194637
Recommended
Ranking