com.suchtool.nicelog.aspect.impl.ScheduledLogAspect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nicelog-spring-boot-starter Show documentation
Show all versions of nicelog-spring-boot-starter Show documentation
collect log automatically for SpringBoot project
The newest version!
package com.suchtool.nicelog.aspect.impl;
import com.suchtool.nicelog.aspect.LogAspectProcessor;
import com.suchtool.nicelog.aspect.LogCommonAspectExecutor;
import com.suchtool.nicelog.constant.EntryTypeEnum;
import com.suchtool.nicelog.constant.NiceLogPointcutExpression;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.Ordered;
import java.lang.reflect.Method;
/**
* Scheduled注解的日志
*/
@Aspect
public class ScheduledLogAspect extends LogAspectProcessor implements Ordered {
private final LogCommonAspectExecutor logCommonAspectExecutor;
private final int order;
public ScheduledLogAspect(int order) {
this.logCommonAspectExecutor = new LogCommonAspectExecutor(this);
this.order = order;
}
@Override
public int getOrder() {
return order;
}
@Override
public String pointcutExpression() {
return NiceLogPointcutExpression.SCHEDULED_LOG_ASPECT;
}
@Pointcut(NiceLogPointcutExpression.SCHEDULED_LOG_ASPECT + " && "
+ "!" + NiceLogPointcutExpression.NICE_LOG_ANNOTATION_ASPECT)
public void pointcut() {
}
@Before("pointcut()")
public void before(JoinPoint joinPoint) {
logCommonAspectExecutor.before(joinPoint);
}
@AfterReturning(value = "pointcut()", returning = "returnValue")
public void afterReturning(JoinPoint joinPoint, Object returnValue) {
logCommonAspectExecutor.afterReturning(joinPoint, returnValue);
}
@AfterThrowing(value = "pointcut()", throwing = "throwingValue")
public void afterThrowing(JoinPoint joinPoint, Throwable throwingValue) {
logCommonAspectExecutor.afterThrowing(joinPoint, throwingValue);
}
/**
* 正常返回或者抛异常的处理
*/
@Override
public void returningOrThrowingProcess() {
}
@Override
public EntryTypeEnum provideEntryType() {
return EntryTypeEnum.SCHEDULED;
}
}