shz.spring.translate.TranslateAdvisor Maven / Gradle / Ivy
package shz.spring.translate;
import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;
import org.springframework.aop.Pointcut;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import shz.core.translate.TranslateHandler;
public final class TranslateAdvisor extends DefaultPointcutAdvisor {
private static final long serialVersionUID = -1201788321489472494L;
public TranslateAdvisor() {
setPointcut(pointcut());
setAdvice(advice());
}
private Pointcut pointcut() {
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
pointcut.setExpression("@annotation(shz.core.translate.Translate)");
return pointcut;
}
private Advice advice() {
return (MethodInterceptor) invocation -> {
Object proceed = invocation.proceed();
TranslateHandler.trans(proceed);
return proceed;
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy