package com.elab.spring.intercept.annotation;

import org.springframework.aop.framework.ReflectiveMethodInvocation;
import org.springframework.core.Ordered;

import java.lang.annotation.Annotation;

/**
 * 注解的执行器
 *
 * @author liukaixiong
 * @Email liukx@elab-plus.com
 * @date 2021/9/27 - 10:49
 */
public interface AnnotationProcessService extends Ordered {

    @Override
    default int getOrder() {
        return LOWEST_PRECEDENCE;
    }

    /**
     * 具体的注解
     *
     * @return
     */
    public Class<? extends Annotation> annotation();

    /**
     * 上面匹配到的注解会被触发，尽量不要对结果做改变。
     *
     * @param invocation
     * @return
     * @throws Throwable
     */
    public Object invokeWithinTransaction(ReflectiveMethodInvocation invocation) throws Throwable;
}
