use of com.dtflys.forest.annotation.ParamLifeCycle in project forest by dromara.
the class ForestMethod method processParameterAnnotation.
/**
* 处理参数的注解
* @param parameter 方法参数-字符串模板解析对象,{@link MappingParameter}类实例
* @param anns 方法参数注解的二维数组
*/
private void processParameterAnnotation(MappingParameter parameter, Annotation[] anns) {
for (int i = 0; i < anns.length; i++) {
Annotation ann = anns[i];
Class annType = ann.annotationType();
if (annType.getPackage().getName().startsWith("java.")) {
continue;
}
Annotation[] subAnnArray = annType.getAnnotations();
if (subAnnArray.length > 0) {
processParameterAnnotation(parameter, subAnnArray);
}
ParamLifeCycle paramLifeCycleAnn = (ParamLifeCycle) annType.getAnnotation(ParamLifeCycle.class);
if (paramLifeCycleAnn != null) {
Class<? extends ParameterAnnotationLifeCycle> interceptorClass = paramLifeCycleAnn.value();
if (!Interceptor.class.isAssignableFrom(interceptorClass)) {
throw new ForestInterceptorDefineException(interceptorClass);
}
ParameterAnnotationLifeCycle lifeCycle = addInterceptor(interceptorClass);
lifeCycle.onParameterInitialized(this, parameter, ann);
}
}
}
Aggregations