Search in sources :

Example 1 with BaseRequest

use of com.dtflys.forest.annotation.BaseRequest in project forest by dromara.

the class ForestMethod method processMethodAnnotations.

/**
 * 处理方法上的注解列表
 */
private void processMethodAnnotations() {
    List<Annotation> annotationList = new LinkedList<>();
    fetchAnnotationsFromClasses(annotationList, new Class[] { interfaceProxyHandler.getInterfaceClass() });
    for (Annotation ann : method.getAnnotations()) {
        annotationList.add(ann);
    }
    List<ForestAnnotation> requestAnns = new LinkedList<>();
    List<ForestAnnotation> methodAnns = new LinkedList<>();
    // 对注解分类
    for (Annotation ann : annotationList) {
        if (ann instanceof BaseRequest) {
            continue;
        }
        Map<Annotation, Class<? extends Interceptor>> lifeCycleClassMap = getAnnotationLifeCycleClassMap(ann);
        if (lifeCycleClassMap != null && !lifeCycleClassMap.isEmpty()) {
            for (Map.Entry<Annotation, Class<? extends Interceptor>> entry : lifeCycleClassMap.entrySet()) {
                Annotation subAnn = entry.getKey();
                Class<? extends Interceptor> lifeCycleClass = entry.getValue();
                if (RequestLifeCycle.class.isAssignableFrom(lifeCycleClass)) {
                    requestAnns.add(new ForestAnnotation(subAnn, lifeCycleClass));
                } else {
                    methodAnns.add(new ForestAnnotation(subAnn, lifeCycleClass));
                }
            }
        }
    }
    // 先添加请求类注解
    addMetaRequestAnnotations(requestAnns);
    // 再添加普通方法类注解
    addMetaRequestAnnotations(methodAnns);
    // 处理请求元信息
    if (this.metaRequest != null) {
        processMetaRequest(this.metaRequest);
    }
    returnClass = method.getReturnType();
}
Also used : BaseRequest(com.dtflys.forest.annotation.BaseRequest) Interceptor(com.dtflys.forest.interceptor.Interceptor) ForestQueryMap(com.dtflys.forest.http.ForestQueryMap) Annotation(java.lang.annotation.Annotation)

Aggregations

BaseRequest (com.dtflys.forest.annotation.BaseRequest)1 ForestQueryMap (com.dtflys.forest.http.ForestQueryMap)1 Interceptor (com.dtflys.forest.interceptor.Interceptor)1 Annotation (java.lang.annotation.Annotation)1