Commit 8be5ce1f by s_guodong

优化

parent c913d44b
package com.brilliance.mda.runtime.mda.driver;
import com.brilliance.mda.runtime.annotation.Check;
import com.brilliance.mda.runtime.annotation.NeedInit;
import com.brilliance.mda.runtime.annotation.Rule;
import com.brilliance.mda.runtime.mda.driver.compile.processor.ModuleAnnotationProcess;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
......@@ -23,7 +18,6 @@ import org.springframework.stereotype.Component;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
......@@ -100,30 +94,6 @@ public class MdaScanner implements ResourceLoaderAware, BeanDefinitionRegistryPo
if (clazz.isAnnotationPresent(annotationClass)) {
Set<Class<?>> set = map.computeIfAbsent(annotationClass, k -> new LinkedHashSet<>());
set.add(clazz);
Method[] declaredMethods = clazz.getDeclaredMethods();
for (Method method : declaredMethods) {
if (method.isAnnotationPresent(NeedInit.class)) {
NeedInit needInit = method.getAnnotation(NeedInit.class);
boolean need = needInit.value();
if (need) {
if (method.isAnnotationPresent(Rule.class)) {
Rule rule = method.getAnnotation(Rule.class);
path = rule.target();
if (!StringUtils.isBlank(path)) {
Set<String> needInitRule = ModuleAnnotationProcess.needInitRule;
needInitRule.add(clazz.getSimpleName().toLowerCase() + "@" + path);
}
} else if (method.isAnnotationPresent(Check.class)) {
Check check = method.getAnnotation(Check.class);
path = check.target();
if (!StringUtils.isBlank(path)) {
Set<String> needInitCheck = ModuleAnnotationProcess.needInitCheck;
needInitCheck.add(clazz.getSimpleName().toLowerCase() + "@" + path);
}
}
}
}
}
}
}
......
......@@ -53,8 +53,6 @@ public class EmitterFactory implements InitializingBean {
//log.info("注册TableMeta {}个", TableMetaManager.getTableMetaCount());
log.info("注册ModuleInfo {}个", ModuleInfoManager.getModuleInfoCount());
log.info("注册Transaction {}个", transSet.size());
log.info("需要初始化的check方法有:{}", ModuleAnnotationProcess.needInitCheck.toString());
log.info("需要初始化的rule方法有:{}", ModuleAnnotationProcess.needInitRule.toString());
} catch (Exception e) {
log.error("动态Emitter扫描包发生错误", e);
}
......
package com.brilliance.mda.runtime.mda.driver.compile.processor;
import com.brilliance.mda.runtime.annotation.*;
import com.brilliance.mda.runtime.annotation.Check;
import com.brilliance.mda.runtime.annotation.Default;
import com.brilliance.mda.runtime.annotation.Init;
import com.brilliance.mda.runtime.annotation.Rule;
import com.brilliance.mda.runtime.mda.FieldHolder;
import com.brilliance.mda.runtime.mda.IModule;
import com.brilliance.mda.runtime.mda.IModuleList;
......@@ -23,9 +26,6 @@ public class ModuleAnnotationProcess {
public static Map<String, ModuleRuleContext> cache = new HashMap<>();
public static Set<String> needInitRule = new HashSet<>();
public static Set<String> needInitCheck = new HashSet<>();
private ModuleRuleContext moduleRuleContext;
private Class<? extends IModule> moduleClass;
private IModule instatnce;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment