
io.lsn.java.common.middleware.businesslog.BusinessTimeLogAspect Maven / Gradle / Ivy
package io.lsn.java.common.middleware.businesslog;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.stream.Collectors;
/**
* aspect that can log execution time of annotated method
*
* @author Patryk Szlagowski
*/
@Aspect
@Component
public class BusinessTimeLogAspect extends AbstractLoggingAspect {
private final Logger logger = Logger.getLogger(BusinessTimeLogAspect.class);
@Pointcut("@annotation(io.lsn.spring.common.middleware.businesslog.BusinessTimeLoggable)")
public void annotation(){}
@Pointcut("execution(* *(..))")
public void execute() {}
@Around("annotation() && execute()")
public Object log(ProceedingJoinPoint point) throws Throwable {
String[] tags = ((MethodSignature) point.getSignature()).getMethod().getAnnotation(BusinessTimeLoggable.class).tags();
String signature = Arrays.asList(tags).stream().collect(Collectors.joining("."));
return log(point, signature);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy