
top.gotoeasy.framework.spring.aop.annotation.Throwing Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gotoeasy-aop Show documentation
Show all versions of gotoeasy-aop Show documentation
基于JavaCompiler的继承方式AOP实现,在性能优良的基础上,提供更多的简易性,2.x.x版本集成使用Spring容器
The newest version!
package top.gotoeasy.framework.spring.aop.annotation;
import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 用于声明一个异常拦截处理,在捕获到异常时执行
*
* 相应类有@Aop声明才能被自动扫描
* 同一方法上可用多个@Throwing声明拦截对象,相互之间为“或”的关系
*
*
* 【注】
* 拦截编程需要非常清楚的知道所要拦截的目标方法,避免多拦截或漏拦截而产生问题,特别是目标程序经常修改的情况下
* 本拦截模块的初衷之一,是使用注解的方式来提升自由度,接口已经不是必须的了
* 换言之,在享受方法名参数等书写自由及性能提升的同时,需要自行对方法参数的正确性负责,即使本拦截模块会有必要的检查
*
*
* 【拦截处理方法中最安全的参数写法】 (Enhance enhance, Method method, AopContext context, Exception ex, Object ...
* args)
* Throwing拦截处理方法不应该有返回值,即使写了也不会起作用
*
*
* @since 2018/01
* @author 青松
*/
@Repeatable(Throwings.class)
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD })
public @interface Throwing {
/**
* 要拦截的方法名,支持通配符(*代表0或多个任意字符),默认为*全部
*
* @return 要拦截的方法名
*/
String value() default "*";
/**
* 指定拦截目标所属类的包名范围
*
* 默认空白等同当前AOP类所在的父包
* 多个包时用逗号分隔
*
*
* @return 包名范围
*/
String packages() default "";
/**
* 指定拦截目标的类注解
*
* 默认Annotation注解,即不限定类注解
*
*
* @return 类注解
*/
Class extends Annotation>[] typeAnnotations() default Annotation.class;
/**
* 指定拦截目标的类
*
* 默认void即指定类
*
*
* @return 类
*/
Class>[] classes() default void.class;
/**
* 指定目标方法需带的注解,默认Annotation注解,即不指定
*
* @return 指定目标方法需带的注解
*/
Class extends Annotation>[] annotations() default Annotation.class;
/**
* 异常拦截的执行顺序
*
* 同一方法有多个异常拦截时,按此排序属性升序执行
* 默认为100,不修改则按无序执行,可通过此排序属性调整执行顺序
*
*
* @return 序号
*/
int order() default 100;
/**
* 是否要拦截父类方法
*
* @return true:包含父类声明的方法/false:仅限于类自己声明的方法
*/
boolean matchSuperMethod() default false;
/**
* 是否把equals()方法作为拦截匹配对象
*
* @return true:作为拦截匹配对象/false:不作为拦截匹配对象
*/
boolean matchEquals() default false;
/**
* 是否把toString()方法作为拦截匹配对象
*
* @return true:作为拦截匹配对象/false:不作为拦截匹配对象
*/
boolean matchToString() default false;
/**
* 是否把hashCode()方法作为拦截匹配对象
*
* @return true:作为拦截匹配对象/false:不作为拦截匹配对象
*/
boolean matchHashCode() default false;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy