use of com.dtflys.forest.annotation.MethodLifeCycle 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);
}
}
}
}
use of com.dtflys.forest.annotation.MethodLifeCycle in project forest by dromara.
the class ForestMethod method getAnnotationLifeCycleClass.
private Class<? extends Interceptor> getAnnotationLifeCycleClass(Annotation annotation) {
Class<? extends Annotation> annType = annotation.annotationType();
Class<? extends MethodAnnotationLifeCycle> interceptorClass = null;
MethodLifeCycle methodLifeCycleAnn = annType.getAnnotation(MethodLifeCycle.class);
if (methodLifeCycleAnn == null) {
BaseLifeCycle baseLifeCycle = annType.getAnnotation(BaseLifeCycle.class);
if (baseLifeCycle != null) {
Class<? extends BaseAnnotationLifeCycle> baseAnnLifeCycleClass = baseLifeCycle.value();
if (baseAnnLifeCycleClass != null) {
if (MethodAnnotationLifeCycle.class.isAssignableFrom(baseAnnLifeCycleClass)) {
interceptorClass = (Class<? extends MethodAnnotationLifeCycle>) baseAnnLifeCycleClass;
} else {
return baseAnnLifeCycleClass;
}
}
}
}
if (methodLifeCycleAnn != null || interceptorClass != null) {
if (interceptorClass == null) {
interceptorClass = methodLifeCycleAnn.value();
if (!Interceptor.class.isAssignableFrom(interceptorClass)) {
throw new ForestInterceptorDefineException(interceptorClass);
}
}
}
return interceptorClass;
}
Aggregations