Search in sources :

Example 1 with BaseURL

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

the class InterfaceProxyHandler method processBaseAnnotation.

@SuppressWarnings("deprecation")
private void processBaseAnnotation(Class parentAnnType, Annotation[] annotations) {
    for (int i = 0; i < annotations.length; i++) {
        Annotation annotation = annotations[i];
        Class<? extends Annotation> annType = annotation.annotationType();
        if (annType.getName().startsWith("java.")) {
            continue;
        }
        Annotation[] subAnnotations = annType.getAnnotations();
        if (parentAnnType != null && !annType.equals(parentAnnType)) {
            processBaseAnnotation(annType, subAnnotations);
        }
        if (annotation instanceof BaseURL) {
            BaseURL baseURLAnn = (BaseURL) annotation;
            String value = baseURLAnn.value();
            if (value == null || value.trim().length() == 0) {
                continue;
            }
            String baseURL = value.trim();
            baseMetaRequest.setUrl(baseURL);
        } else {
            BaseLifeCycle baseLifeCycle = annotation.annotationType().getAnnotation(BaseLifeCycle.class);
            MethodLifeCycle methodLifeCycle = annotation.annotationType().getAnnotation(MethodLifeCycle.class);
            if (baseLifeCycle != null || methodLifeCycle != null) {
                if (baseLifeCycle != null) {
                    Class<? extends BaseAnnotationLifeCycle> interceptorClass = baseLifeCycle.value();
                    if (interceptorClass != null) {
                        BaseAnnotationLifeCycle baseInterceptor = interceptorFactory.getInterceptor(interceptorClass);
                        baseInterceptor.onProxyHandlerInitialized(this, annotation);
                    }
                }
                baseAnnotations.add(annotation);
            }
        }
    }
}
Also used : MethodLifeCycle(com.dtflys.forest.annotation.MethodLifeCycle) BaseURL(com.dtflys.forest.annotation.BaseURL) BaseAnnotationLifeCycle(com.dtflys.forest.lifecycles.BaseAnnotationLifeCycle) Annotation(java.lang.annotation.Annotation) BaseLifeCycle(com.dtflys.forest.annotation.BaseLifeCycle)

Aggregations

BaseLifeCycle (com.dtflys.forest.annotation.BaseLifeCycle)1 BaseURL (com.dtflys.forest.annotation.BaseURL)1 MethodLifeCycle (com.dtflys.forest.annotation.MethodLifeCycle)1 BaseAnnotationLifeCycle (com.dtflys.forest.lifecycles.BaseAnnotationLifeCycle)1 Annotation (java.lang.annotation.Annotation)1