Commit 5cb80ae3 authored by frank.xa.zhang's avatar frank.xa.zhang

add aop log

parent d3c9c6c5
package pwc.taxtech.atms.common;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
@Aspect
public class AopLogger {
private static Logger logger = LoggerFactory.getLogger(AopLogger.class);
@Pointcut("execution(public * pwc.taxtech.atms.service.*.*(..))")
public void pointCut() {
// 定义Pointcut 此方法不能有返回值,该方法只是一个标示
}
@Before("pointCut()")
public void before(JoinPoint joinPoint) {
if (logger.isDebugEnabled()) {
logger.debug("aop before:{}", joinPoint);
}
}
@After("pointCut()")
public void after(JoinPoint joinPoint) {
if (logger.isDebugEnabled()) {
logger.debug("aop after:{}", joinPoint);
}
}
@AfterThrowing(pointcut = "pointCut()", throwing = "error")
public void afterThrowing(JoinPoint joinPoint, Throwable error) {
if (logger.isWarnEnabled()) {
logger.warn("aop afterThrowing:{}, exception class:{}, exception message:{} ", joinPoint,
error.getClass().toString(), error.getMessage());
}
}
// @After("pointCut()")
// public void doAfter(JoinPoint joinPoint) {
// System.out.println("AOP After Advice...");
// }
//
// @AfterReturning(pointcut = "pointCut()", returning = "returnVal")
// public void afterReturn(JoinPoint joinPoint, Object returnVal) {
// System.out.println("AOP AfterReturning Advice:" + returnVal);
// }
//
//
// @Around("pointCut()")
// public void around(ProceedingJoinPoint pjp) {
// System.out.println("AOP Aronud before...");
// try {
// pjp.proceed();
// } catch (Throwable e) {
// e.printStackTrace();
// }
// System.out.println("AOP Aronud after...");
// }
}
\ No newline at end of file
......@@ -19,5 +19,4 @@ public class ModelConfigurationServiceImpl extends AbstractService implements Mo
map.put("industryId",industryId);
return modelConfigMapper.getModelListByIndustry(map);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment