Commit 25292594 by zhanghou

提交最新的整合版本(存在问题那几个jar不是最新的私有仓库也推送不上去)

parent 773007a6
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>gjjs-bd-common</artifactId>
<groupId>com.brilliance</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gjjs-bd-annonation-enhance</artifactId>
<version>0.0.1</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.brilliance</groupId>
<artifactId>gjjs-bd-runtime</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${basedir}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArgument>
-proc:none
</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.brilliance.annotation.processor;
import com.sun.tools.javac.tree.JCTree;
import java.util.List;
public class AnnotationEnhanceUtils {
public static String findAnnotationArguments(List<JCTree.JCExpression> args, String key) {
return findAnnotationArguments(args, key, null);
}
public static String findAnnotationArguments(List<JCTree.JCExpression> args, String key, String defaultValue) {
String value = defaultValue;
if (null != args && args.size() > 0) {
for (JCTree.JCExpression jcExpression : args) {
if (jcExpression instanceof JCTree.JCAssign) {
JCTree.JCAssign jcAssign = (JCTree.JCAssign) jcExpression;
if (key.equals(jcAssign.lhs.toString())) {
value = jcAssign.rhs.toString();
break;
}
}
}
}
return value;
}
public static int findAnnotationArgumentsInt(List<JCTree.JCExpression> args, String key, int defaultValue) {
String value = findAnnotationArguments(args, key, null);
if (null == value || "".equals(value)) {
return defaultValue;
}
try {
return Integer.parseInt(value);
} catch (Exception e) {
return defaultValue;
}
}
protected static boolean findAnnotationArgumentsBoolean(List<JCTree.JCExpression> args, String key, Boolean defaultValue) {
String value = findAnnotationArguments(args, key, null);
if (null == value || "".equals(value)) {
return true;
}
try {
return Boolean.valueOf(value);
} catch (Exception e) {
return defaultValue;
}
}
}
package com.brilliance.annotation.processor;
import com.sun.source.util.Trees;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.Names;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.tools.Diagnostic;
public abstract class BaseProcessor extends AbstractProcessor {
/**
* 用于在编译器打印消息的组件
*/
Messager messager;
/**
* 语法树
*/
Trees trees;
/**
* 用来构造语法树节点
*/
TreeMaker treeMaker;
/**
* 用于创建标识符的对象
*/
Name.Table names;
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
super.init(processingEnvironment);
messager = processingEnvironment.getMessager();
trees = Trees.instance(processingEnvironment);
Context context = ((JavacProcessingEnvironment) processingEnvironment).getContext();
treeMaker = TreeMaker.instance(context);
names = Names.instance(context).table;
messager.printMessage(Diagnostic.Kind.NOTE, "父类BaseProcessor执行init()方法");
}
}
package com.brilliance.annotation.processor;
import com.brilliance.annotation.processor.enhance.AbstractAnnotationEnhance;
import com.brilliance.annotation.processor.enhance.impl.*;
import com.brilliance.mda.runtime.annotation.BDGetter;
import com.brilliance.mda.runtime.annotation.Module;
import com.brilliance.mda.runtime.annotation.TDGetter;
import com.brilliance.mda.runtime.annotation.TDSetter;
import com.sun.source.tree.Tree;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.TreeTranslator;
import com.sun.tools.javac.util.Name;
import javax.annotation.processing.Messager;
import javax.lang.model.element.Modifier;
import javax.tools.Diagnostic;
import java.util.List;
import java.util.Set;
public class ModuleAnnotationTranslator extends TreeTranslator {
private Name.Table names;
private TreeMaker treeMaker;
private Name moduleName;
private Messager messager;
public ModuleAnnotationTranslator(Name.Table names, TreeMaker treeMaker, Name moduleName, Messager messager) {
this.names = names;
this.treeMaker = treeMaker;
this.moduleName = moduleName;
this.messager = messager;
}
@Override
public void visitClassDef(JCTree.JCClassDecl jcClassDecl) {
if (moduleName.toString().equals("Txlp")) {
messager.printMessage(Diagnostic.Kind.NOTE, "正在增强-----------------------");
}
if (jcClassDecl.name == moduleName) {
for (JCTree it : jcClassDecl.defs) {
if (it.getKind() == Tree.Kind.VARIABLE) {
JCTree.JCVariableDecl jcVariableDecl = (JCTree.JCVariableDecl) it;
JCTree.JCModifiers modifiers = jcVariableDecl.getModifiers();
List<JCTree.JCAnnotation> annotations = modifiers.getAnnotations();
for (JCTree.JCAnnotation annotation : annotations) {
AbstractAnnotationEnhance annotationEnhance = getAnnotationEnhance(annotation);
if (annotationEnhance != null) {
processAnnotationEnhance(annotationEnhance, annotation, jcClassDecl, jcVariableDecl);
}
}
if (needGenerateMethod(annotations, TDSetter.class.getName()) && isValidField(jcVariableDecl)) {
AbstractAnnotationEnhance annotationEnhance = new ModuleSetterEnhance();
processAnnotationEnhance(annotationEnhance, null, jcClassDecl, jcVariableDecl);
}
if (needGenerateMethod(annotations, TDGetter.class.getName()) && isValidField(jcVariableDecl)) {
AbstractAnnotationEnhance annotationEnhance = new ModuleGetterEnhance();
processAnnotationEnhance(annotationEnhance, null, jcClassDecl, jcVariableDecl);
}
if (needGenerateMethod(annotations, BDGetter.class.getName()) && isValidField(jcVariableDecl)) {
AbstractAnnotationEnhance annotationEnhance = new ModuleGetterEnhance();
processAnnotationEnhance(annotationEnhance, null, jcClassDecl, jcVariableDecl);
}
}
}
}
super.visitClassDef(jcClassDecl);
}
/**
* 注解增强处理方法
* 1.先找到对应的注解增强实现类
* 2.生成方法名
* 3.找到是否存在该方法
* 4.构造方法体
*
* @param annotationEnhance
* @param annotation
* @param jcClassDecl
* @param it
*/
private void processAnnotationEnhance(AbstractAnnotationEnhance annotationEnhance, JCTree.JCAnnotation annotation, JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl it) {
annotationEnhance.setNames(names);
annotationEnhance.setTreeMaker(treeMaker);
String methodName = annotationEnhance.getMethodName(it);
JCTree.JCMethodDecl methodDecl = annotationEnhance.findJCMethodDecl(jcClassDecl, it, methodName);
if (null == methodDecl) {
messager.printMessage(Diagnostic.Kind.NOTE, "正在增强:" + jcClassDecl.name.toString() + "." + methodName);
List<JCTree.JCExpression> args = annotation == null ? null : annotation.getArguments();
JCTree.JCMethodDecl setterMethod = annotationEnhance.createJCMethodDecl(jcClassDecl, it, methodName, args);
if (setterMethod != null) {
messager.printMessage(Diagnostic.Kind.NOTE, "已增强:" + jcClassDecl.name.toString() + "." + methodName);
jcClassDecl.defs = jcClassDecl.defs.append(setterMethod);
}
} else {
messager.printMessage(Diagnostic.Kind.NOTE, jcClassDecl.name.toString() + "." + methodName + "已经存在,跳过增强");
}
}
/**
* 是否存在注解(@param annotationName)
*
* @param annotations
* @param annotationName
* @return
*/
private boolean includeAnnotation(List<JCTree.JCAnnotation> annotations, String annotationName) {
for (JCTree.JCAnnotation annotation : annotations) {
if (annotation.annotationType.type.toString().equals(annotationName)) {
return true;
}
}
return false;
}
/**
* 根据注解找到对应的实现类
*
* @param annotation
* @return
*/
private AbstractAnnotationEnhance getAnnotationEnhance(JCTree.JCAnnotation annotation) {
if (annotation.annotationType.type.toString().equals(TDSetter.class.getName())) {
return new TDSetterEnhance();
} else if (annotation.annotationType.type.toString().equals(TDGetter.class.getName())) {
return new TDGetterEnhance();
} else if (annotation.annotationType.type.toString().equals(BDGetter.class.getName())) {
return new BDGetterEnhance();
} else {
return null;
}
}
/**
* 字段如果是 final 或者static 修饰的, 不生产getset方法
*
* @param it
* @return
*/
private boolean isValidField(JCTree.JCVariableDecl it) {
Set<Modifier> flagSets = it.getModifiers().getFlags();
return (!flagSets.contains(Modifier.STATIC)
&& !flagSets.contains(Modifier.FINAL));
}
/**
* 是否需要生成对应的getter 或者 setter 方法
* 1. module getter setter
* 2. 是否已经存在TDSetter TDGetter
*
* @param annotations
* @param annotationName
* @return
*/
private boolean needGenerateMethod(List<JCTree.JCAnnotation> annotations, String annotationName) {
boolean flag = true;
String key = "";
if (annotationName.lastIndexOf(".") > -1) {
key = annotationName.substring(annotationName.lastIndexOf(".") + 3).toLowerCase();
} else {
key = annotationName.substring(2).toLowerCase();
}
for (JCTree.JCAnnotation annotation : annotations) {
if (annotation.annotationType.type.toString().equals(Module.class.getName())) {
flag = AnnotationEnhanceUtils.findAnnotationArgumentsBoolean(annotation.getArguments(), key, Boolean.TRUE);
}
}
return flag && !includeAnnotation(annotations, annotationName);
}
}
package com.brilliance.annotation.processor;
import com.sun.source.util.TreePath;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.Name;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@SupportedAnnotationTypes("com.brilliance.mda.runtime.annotation.Module")
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class ModuleProcessor extends BaseProcessor {
@Override
public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) {
if (null != set && set.size() > 0) {
messager.printMessage(Diagnostic.Kind.NOTE, "开始编译增强Module");
TypeElement tmpTypeElement = null;
try {
for (TypeElement annotation : set) {
messager.printMessage(Diagnostic.Kind.NOTE, String.format("正在处理增强:%s", annotation.getSimpleName()));
List<TypeElement> typeElementList = roundEnvironment.getElementsAnnotatedWith(annotation)
.stream().filter(it -> (it instanceof TypeElement))
.map(it -> (TypeElement) it)
.collect(Collectors.toList());
messager.printMessage(Diagnostic.Kind.NOTE, String.format("增强Module数量:%d", typeElementList.size()));
for (TypeElement it : typeElementList) {
TreePath treePath = trees.getPath(it);
JCTree.JCCompilationUnit cu = (JCTree.JCCompilationUnit) treePath.getCompilationUnit();
addImport(cu);
JCTree jcTree = (JCTree) trees.getTree(it);
tmpTypeElement = it;
translate(it, jcTree);
}
}
} catch (Exception e) {
messager.printMessage(Diagnostic.Kind.ERROR, "编译增强模型[" + tmpTypeElement.getSimpleName().toString() + "]发生错误, 错误原因 : " + e.getMessage());
}
messager.printMessage(Diagnostic.Kind.NOTE, "结束编译增强");
}
return true;
}
private void translate(TypeElement curElement, JCTree curTree) {
treeMaker.pos = curTree.pos;
curTree.accept(new ModuleAnnotationTranslator(names, treeMaker, (Name) curElement.getSimpleName(), messager));
}
private void addImport(JCTree.JCCompilationUnit cu) {
addImport(cu,
"com.brilliance.mda.runtime.mda.impl.StreamImpl",
"com.brilliance.mda.runtime.mda.impl.ModuleList",
"com.brilliance.mda.runtime.mda.util.MdaUtils",
"java.lang.*");
}
private void addImport(JCTree.JCCompilationUnit cu, String... importPackages) {
if (null == importPackages)
return;
List<JCTree.JCImport> jcImports = cu.defs.stream()
.filter(it -> (it instanceof JCTree.JCImport))
.map(it -> (JCTree.JCImport) it)
.collect(Collectors.toList());
boolean[] exists = new boolean[importPackages.length];
for (JCTree.JCImport jcImport : jcImports) {
for (int i = 0; i < importPackages.length; i++) {
if (jcImport.toString().equals(importPackages[i])) {
exists[i] = true;
break;
}
}
}
for (int i = 0; i < exists.length; i++) {
if (!exists[i]) {
JCTree.JCFieldAccess fieldAccess = treeMaker.Select(
treeMaker.Ident(names.fromString(importPackages[i].substring(0, importPackages[i].lastIndexOf(".")))),
names.fromString(importPackages[i].substring(importPackages[i].lastIndexOf(".") + 1)));
cu.defs = cu.defs.append(treeMaker.Import(fieldAccess, false));
}
}
}
}
package com.brilliance.annotation.processor;
public enum PrimitiveEnums {
INT("int", "Integer"),
SHORT("short", "Short"),
FLOAT("float", "Float"),
DOUBLE("double", "Double"),
BYTE("byte", "Byte"),
CHAR("char", "Char"),
BOOLEAN("boolean", "Boolean"),
LONG("long", "Long");
private String code;
private String value;
PrimitiveEnums(String code, String value) {
this.code = code;
this.value = value;
}
public static PrimitiveEnums getValues(String code) {
for (PrimitiveEnums e : values()) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.brilliance.annotation.processor.enhance;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.util.Name;
import java.util.List;
public abstract class AbstractAnnotationEnhance implements AnnotationEnhance{
protected Name.Table names;
protected TreeMaker treeMaker;
public void setNames(Name.Table names) {
this.names = names;
}
public void setTreeMaker(TreeMaker treeMaker) {
this.treeMaker = treeMaker;
}
}
package com.brilliance.annotation.processor.enhance;
import com.sun.tools.javac.tree.JCTree;
import java.util.List;
public interface AnnotationEnhance {
/**
* 得到要增强的方法名称
* @param variableDecl
* @return
*/
String getMethodName(JCTree.JCVariableDecl variableDecl);
/**
* 找到是否存在已增加的注解方法
* @param jcClassDecl
* @param variableDecl
* @param methodName
* @return
*/
JCTree.JCMethodDecl findJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName);
/**
* 增强注解方法
* @param jcClassDecl
* @param variableDecl
* @param methodName
* @param args
* @return
*/
JCTree.JCMethodDecl createJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName, List<JCTree.JCExpression> args);
}
package com.brilliance.annotation.processor.enhance.impl;
import com.brilliance.annotation.processor.AnnotationEnhanceUtils;
import com.brilliance.annotation.processor.enhance.AbstractAnnotationEnhance;
import com.brilliance.mda.runtime.mda.IModuleList;
import com.brilliance.mda.runtime.mda.IStream;
import com.brilliance.mda.runtime.mda.impl.ModuleList;
import com.brilliance.mda.runtime.mda.impl.StreamImpl;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.ListBuffer;
import java.util.List;
import java.util.stream.Collectors;
/**
* BDGetter注解增强实现类
*/
public class BDGetterEnhance extends AbstractAnnotationEnhance {
@Override
public String getMethodName(JCTree.JCVariableDecl variableDecl) {
String variableName = variableDecl.name.toString();
return "get" + variableName.substring(0, 1).toUpperCase() + variableName.substring(1);
}
@Override
public JCTree.JCMethodDecl findJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName) {
List<JCTree.JCMethodDecl> jcMethodDecls = jcClassDecl.defs
.stream().filter(it -> (it instanceof JCTree.JCMethodDecl))
.map(it -> (JCTree.JCMethodDecl) it)
.collect(Collectors.toList());
for (JCTree.JCMethodDecl jcMethodDecl : jcMethodDecls) {
if (jcMethodDecl.name.toString().equals(methodName)
&& jcMethodDecl.params.size() == 0
&& jcMethodDecl.restype.type.toString().equals(variableDecl.vartype.type.toString())) {
return jcMethodDecl;
}
}
return null;
}
@Override
public JCTree.JCMethodDecl createJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName, List<JCTree.JCExpression> args) {
ListBuffer<JCTree.JCStatement> body = new ListBuffer<>();
String instance = variableDecl.name.toString();
if ("tmpint".equals(instance.trim())) {
instance = "int";
}
JCTree.JCNewClass jcNewClass = null;
if (variableDecl.vartype.type.toString().startsWith(IModuleList.class.getName() + "<")
|| variableDecl.vartype.type.toString().startsWith(ModuleList.class.getName() + "<")) {
JCTree.JCTypeApply typeApply = (JCTree.JCTypeApply) variableDecl.vartype;
List<JCTree.JCExpression> argsuments = typeApply.arguments;
String tClass = argsuments.get(0).toString();
jcNewClass = treeMaker.NewClass(null,
com.sun.tools.javac.util.List.nil(),
treeMaker.TypeApply(treeMaker.Ident(names.fromString("ModuleList")),
com.sun.tools.javac.util.List.nil()),
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(variableDecl.name.toString()))
.append(treeMaker.Ident(names.fromString("this")))
.append(treeMaker.Select(treeMaker.Ident(names.fromString(tClass)), names.fromString("class")))
.toList(),
null);
} else if (IStream.class.getName().equals(variableDecl.vartype.type.toString())
|| StreamImpl.class.getName().equals(variableDecl.vartype.type.toString())) {
jcNewClass = treeMaker.NewClass(null,
com.sun.tools.javac.util.List.nil(),
treeMaker.Ident(names.fromString("StreamImpl")),
com.sun.tools.javac.util.List.nil(),
null);
} else if ((!variableDecl.vartype.type.isPrimitive() && variableDecl.vartype.type.toString().startsWith("com.ceb"))) {
jcNewClass = treeMaker.NewClass(null,
com.sun.tools.javac.util.List.nil(),
variableDecl.vartype,
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(instance))
.append(treeMaker.Ident(names.fromString("this")))
.toList(),
null);
}
//当jcNewClass == null 时 生成简单的get方法
if (null != jcNewClass) {
body.append(
treeMaker.If(
treeMaker.Parens(treeMaker.Binary(JCTree.Tag.EQ, treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name), treeMaker.Literal(TypeTag.BOT, "null"))),
treeMaker.Exec(treeMaker.Assign(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name), jcNewClass)), null));
}
body.append(treeMaker.Return(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name)));
JCTree.JCBlock jcBlock = treeMaker.Block(0, body.toList());
return treeMaker.MethodDef(
treeMaker.Modifiers(Flags.PUBLIC), //方法可见性
names.fromString(methodName), //方法名称
variableDecl.vartype, //返回值类型
com.sun.tools.javac.util.List.nil(), //泛型参数列表
com.sun.tools.javac.util.List.nil(), //参数列表
com.sun.tools.javac.util.List.nil(), //抛出异常列表
jcBlock, null);
}
}
package com.brilliance.annotation.processor.enhance.impl;
import com.brilliance.annotation.processor.AnnotationEnhanceUtils;
import com.brilliance.annotation.processor.PrimitiveEnums;
import com.brilliance.annotation.processor.enhance.AbstractAnnotationEnhance;
import com.brilliance.mda.runtime.mda.IStream;
import com.brilliance.mda.runtime.mda.impl.StreamImpl;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.ListBuffer;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* BDSetter注解增强实现类
*/
public class BDSetterEnhance extends AbstractAnnotationEnhance {
@Override
public String getMethodName(JCTree.JCVariableDecl variableDecl) {
String variableName = variableDecl.name.toString();
return "set" + variableName.substring(0, 1).toUpperCase() + variableName.substring(1);
}
@Override
public JCTree.JCMethodDecl findJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName) {
List<JCTree.JCMethodDecl> jcMethodDecls = jcClassDecl.defs
.stream().filter(it -> (it instanceof JCTree.JCMethodDecl))
.map(it -> (JCTree.JCMethodDecl) it)
.collect(Collectors.toList());
for (JCTree.JCMethodDecl jcMethodDecl : jcMethodDecls) {
if (jcMethodDecl.name.toString().equals(methodName)
&& jcMethodDecl.params.size() == 1
&& jcMethodDecl.params.get(0).vartype.type.toString().equals(variableDecl.vartype.type.toString())) {
return jcMethodDecl;
}
}
return null;
}
@Override
public JCTree.JCMethodDecl createJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName, List<JCTree.JCExpression> args) {
ListBuffer<JCTree.JCStatement> body = new ListBuffer<>();
boolean isNotifyDefault = AnnotationEnhanceUtils.findAnnotationArguments(args, "notifyDefault", "true").equals("true");
if (String.class.getName().equals(variableDecl.vartype.type.toString())) {
int maxLength = AnnotationEnhanceUtils.findAnnotationArgumentsInt(args, "max", 0);
body.append(treeMaker.VarDef(
treeMaker.Modifiers(Flags.PARAMETER),
names.fromString("rs"),
treeMaker.TypeApply(treeMaker.Ident(names.fromString("Result")),
new ListBuffer<JCTree.JCExpression>().append(variableDecl.vartype).toList()),
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("this")), names.fromString("compareAndGetStr")),
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(variableDecl.name.toString()))
.append(treeMaker.Ident(names.fromString(variableDecl.name.toString())))
.append(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name))
.append(treeMaker.Literal(maxLength))
.toList()
)));
body.append(treeMaker.Exec(
treeMaker.Assign(
treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("value")))));
if (isNotifyDefault) {
body.append(treeMaker.Exec(
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("notifyDefault")),
com.sun.tools.javac.util.List.nil()
)
));
}
} else if (BigDecimal.class.getName().equals(variableDecl.vartype.type.toString())) {
int scale = AnnotationEnhanceUtils.findAnnotationArgumentsInt(args, "scale", 2);
body.append(treeMaker.VarDef(
treeMaker.Modifiers(Flags.PARAMETER),
names.fromString("rs"),
treeMaker.TypeApply(treeMaker.Ident(names.fromString("Result")),
new ListBuffer<JCTree.JCExpression>().append(variableDecl.vartype).toList()),
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("this")), names.fromString("compareAndGetDecimal")),
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(variableDecl.name.toString()))
.append(treeMaker.Ident(names.fromString(variableDecl.name.toString())))
.append(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name))
.append(treeMaker.Literal(scale))
.toList()
)));
body.append(treeMaker.Exec(
treeMaker.Assign(
treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("value")))));
if (isNotifyDefault) {
body.append(treeMaker.Exec(
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("notifyDefault")),
com.sun.tools.javac.util.List.nil()
)
));
}
} else if (Date.class.getName().equals(variableDecl.vartype.type.toString())
|| IStream.class.getName().equals(variableDecl.vartype.type.toString())
|| StreamImpl.class.getName().equals(variableDecl.vartype.type.toString())
|| variableDecl.vartype.type.isPrimitive()) {
body.append(treeMaker.VarDef(
treeMaker.Modifiers(Flags.PARAMETER),
names.fromString("rs"),
treeMaker.TypeApply(treeMaker.Ident(names.fromString("Result")),
variableDecl.vartype.type.isPrimitive() ?
new ListBuffer<JCTree.JCExpression>().append(treeMaker.Ident(names.fromString(PrimitiveEnums.getValues(variableDecl.vartype.toString()).getValue()))).toList()
: new ListBuffer<JCTree.JCExpression>().append(variableDecl.vartype).toList()
),
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("this")), names.fromString("compareAndGet")),
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(variableDecl.name.toString()))
.append(treeMaker.Ident(names.fromString(variableDecl.name.toString())))
.append(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name))
.toList()
)));
body.append(treeMaker.Exec(
treeMaker.Assign(
treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("value")))));
if (isNotifyDefault) {
body.append(treeMaker.Exec(
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("notifyDefault")),
com.sun.tools.javac.util.List.nil()
)
));
}
} else {
return null;
}
JCTree.JCBlock jcBlock = treeMaker.Block(0, body.toList());
return treeMaker.MethodDef(
treeMaker.Modifiers(Flags.PUBLIC), //方法可见性
names.fromString(methodName), //方法名称
treeMaker.TypeIdent(TypeTag.VOID), //方法返回值
com.sun.tools.javac.util.List.nil(), //泛型参数列表
new ListBuffer<JCTree.JCVariableDecl>()
.append(treeMaker.VarDef(treeMaker.Modifiers(Flags.PARAMETER), variableDecl.name, variableDecl.vartype, null))
.toList(),
com.sun.tools.javac.util.List.nil(), //抛出异常列表
jcBlock, null);
}
}
package com.brilliance.annotation.processor.enhance.impl;
import com.brilliance.annotation.processor.enhance.AbstractAnnotationEnhance;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.ListBuffer;
import java.util.List;
import java.util.stream.Collectors;
/**
* Module 注解增强类
* 实现普通的get方法
*/
public class ModuleGetterEnhance extends AbstractAnnotationEnhance {
@Override
public String getMethodName(JCTree.JCVariableDecl variableDecl) {
String variableName = variableDecl.name.toString();
return "get" + variableName.substring(0, 1).toUpperCase() + variableName.substring(1);
}
@Override
public JCTree.JCMethodDecl findJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName) {
List<JCTree.JCMethodDecl> jcMethodDecls = jcClassDecl.defs
.stream().filter(it -> (it instanceof JCTree.JCMethodDecl))
.map(it -> (JCTree.JCMethodDecl) it)
.collect(Collectors.toList());
for (JCTree.JCMethodDecl jcMethodDecl : jcMethodDecls) {
if (jcMethodDecl.name.toString().equals(methodName)
&& jcMethodDecl.params.size() == 0) {
return jcMethodDecl;
}
}
return null;
}
@Override
public JCTree.JCMethodDecl createJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName, List<JCTree.JCExpression> args) {
ListBuffer<JCTree.JCStatement> body = new ListBuffer<>();
body.append(treeMaker.Return(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name)));
JCTree.JCBlock jcBlock = treeMaker.Block(0, body.toList());
return treeMaker.MethodDef(
treeMaker.Modifiers(Flags.PUBLIC), //方法可见性
names.fromString(methodName), //方法名称
variableDecl.vartype, //返回值类型
com.sun.tools.javac.util.List.nil(), //泛型参数列表
com.sun.tools.javac.util.List.nil(), //参数列表
com.sun.tools.javac.util.List.nil(), //抛出异常列表
jcBlock, null);
}
}
package com.brilliance.annotation.processor.enhance.impl;
import com.brilliance.annotation.processor.enhance.AbstractAnnotationEnhance;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.ListBuffer;
import java.util.List;
import java.util.stream.Collectors;
/**
* Module 注解增强类
* 实现普通的set方法
*/
public class ModuleSetterEnhance extends AbstractAnnotationEnhance {
@Override
public String getMethodName(JCTree.JCVariableDecl variableDecl) {
String variableName = variableDecl.name.toString();
return "set" + variableName.substring(0, 1).toUpperCase() + variableName.substring(1);
}
@Override
public JCTree.JCMethodDecl findJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName) {
List<JCTree.JCMethodDecl> jcMethodDecls = jcClassDecl.defs
.stream().filter(it -> (it instanceof JCTree.JCMethodDecl))
.map(it -> (JCTree.JCMethodDecl) it)
.collect(Collectors.toList());
for (JCTree.JCMethodDecl jcMethodDecl : jcMethodDecls) {
if (jcMethodDecl.name.toString().equals(methodName)
&& jcMethodDecl.params.size() == 1
&& jcMethodDecl.params.get(0).vartype.type.toString().equals(variableDecl.vartype.type.toString())) {
return jcMethodDecl;
}
}
return null;
}
@Override
public JCTree.JCMethodDecl createJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName, List<JCTree.JCExpression> args) {
ListBuffer<JCTree.JCStatement> body = new ListBuffer<>();
//添加语句 " this.xxx = xxx; "
body.append(
treeMaker.Exec(
treeMaker.Assign(
treeMaker.Select(
treeMaker.Ident(names.fromString("this")),
variableDecl.name
),
treeMaker.Ident(variableDecl)
)
)
);
JCTree.JCBlock jcBlock = treeMaker.Block(0, body.toList());
return treeMaker.MethodDef(
treeMaker.Modifiers(Flags.PUBLIC), //方法可见性
names.fromString(methodName), //方法名称
treeMaker.TypeIdent(TypeTag.VOID), //方法返回值
com.sun.tools.javac.util.List.nil(), //泛型参数列表
new ListBuffer<JCTree.JCVariableDecl>()
.append(treeMaker.VarDef(treeMaker.Modifiers(Flags.PARAMETER), variableDecl.name, variableDecl.vartype, null))
.toList(),
com.sun.tools.javac.util.List.nil(), //抛出异常列表
jcBlock, null);
}
}
package com.brilliance.annotation.processor.enhance.impl;
import com.brilliance.annotation.processor.AnnotationEnhanceUtils;
import com.brilliance.annotation.processor.enhance.AbstractAnnotationEnhance;
import com.brilliance.mda.runtime.mda.IModuleList;
import com.brilliance.mda.runtime.mda.IStream;
import com.brilliance.mda.runtime.mda.impl.ModuleList;
import com.brilliance.mda.runtime.mda.impl.StreamImpl;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.ListBuffer;
import java.util.List;
import java.util.stream.Collectors;
/**
* TDGetter注解增强实现类
*/
public class TDGetterEnhance extends AbstractAnnotationEnhance {
@Override
public String getMethodName(JCTree.JCVariableDecl variableDecl) {
String variableName = variableDecl.name.toString();
return "get" + variableName.substring(0, 1).toUpperCase() + variableName.substring(1);
}
@Override
public JCTree.JCMethodDecl findJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName) {
List<JCTree.JCMethodDecl> jcMethodDecls = jcClassDecl.defs
.stream().filter(it -> (it instanceof JCTree.JCMethodDecl))
.map(it -> (JCTree.JCMethodDecl) it)
.collect(Collectors.toList());
for (JCTree.JCMethodDecl jcMethodDecl : jcMethodDecls) {
if (jcMethodDecl.name.toString().equals(methodName)
&& jcMethodDecl.params.size() == 0
&& jcMethodDecl.restype.type.toString().equals(variableDecl.vartype.type.toString())) {
return jcMethodDecl;
}
}
return null;
}
@Override
public JCTree.JCMethodDecl createJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName, List<JCTree.JCExpression> args) {
ListBuffer<JCTree.JCStatement> body = new ListBuffer<>();
String instance = variableDecl.name.toString();
if ("tmpint".equals(instance.trim())) {
instance = "int";
}
JCTree.JCNewClass jcNewClass = null;
if (variableDecl.vartype.type.toString().startsWith(IModuleList.class.getName() + "<")
|| variableDecl.vartype.type.toString().startsWith(ModuleList.class.getName() + "<")) {
JCTree.JCTypeApply typeApply = (JCTree.JCTypeApply) variableDecl.vartype;
List<JCTree.JCExpression> argsuments = typeApply.arguments;
String tClass = argsuments.get(0).toString();
int initSize = AnnotationEnhanceUtils.findAnnotationArgumentsInt(args, "initSize", 0);
jcNewClass = treeMaker.NewClass(null,
com.sun.tools.javac.util.List.nil(),
treeMaker.TypeApply(treeMaker.Ident(names.fromString("ModuleList")),
com.sun.tools.javac.util.List.nil()),
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(variableDecl.name.toString()))
.append(treeMaker.Ident(names.fromString("this")))
.append(treeMaker.Literal(initSize))
.append(treeMaker.Select(treeMaker.Ident(names.fromString(tClass)), names.fromString("class")))
.toList(),
null);
} else if (IStream.class.getName().equals(variableDecl.vartype.type.toString())
|| StreamImpl.class.getName().equals(variableDecl.vartype.type.toString())) {
jcNewClass = treeMaker.NewClass(null,
com.sun.tools.javac.util.List.nil(),
treeMaker.Ident(names.fromString("StreamImpl")),
com.sun.tools.javac.util.List.nil(),
null);
} else if ((!variableDecl.vartype.type.isPrimitive() && variableDecl.vartype.type.toString().startsWith("com.ceb"))) {
jcNewClass = treeMaker.NewClass(null,
com.sun.tools.javac.util.List.nil(),
variableDecl.vartype,
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(instance))
.append(treeMaker.Ident(names.fromString("this")))
.toList(),
null);
}
//当jcNewClass == null 时 生成简单的get方法
if (null != jcNewClass) {
body.append(
treeMaker.If(
treeMaker.Parens(treeMaker.Binary(JCTree.Tag.EQ, treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name), treeMaker.Literal(TypeTag.BOT, "null"))),
treeMaker.Exec(treeMaker.Assign(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name), jcNewClass)), null));
}
body.append(treeMaker.Return(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name)));
JCTree.JCBlock jcBlock = treeMaker.Block(0, body.toList());
return treeMaker.MethodDef(
treeMaker.Modifiers(Flags.PUBLIC), //方法可见性
names.fromString(methodName), //方法名称
variableDecl.vartype, //返回值类型
com.sun.tools.javac.util.List.nil(), //泛型参数列表
com.sun.tools.javac.util.List.nil(), //参数列表
com.sun.tools.javac.util.List.nil(), //抛出异常列表
jcBlock, null);
}
}
package com.brilliance.annotation.processor.enhance.impl;
import com.brilliance.annotation.processor.AnnotationEnhanceUtils;
import com.brilliance.annotation.processor.PrimitiveEnums;
import com.brilliance.annotation.processor.enhance.AbstractAnnotationEnhance;
import com.brilliance.mda.runtime.mda.IStream;
import com.brilliance.mda.runtime.mda.impl.StreamImpl;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.TypeTag;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.ListBuffer;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* TDSetter注解增强实现类
*/
public class TDSetterEnhance extends AbstractAnnotationEnhance {
@Override
public String getMethodName(JCTree.JCVariableDecl variableDecl) {
String variableName = variableDecl.name.toString();
return "set" + variableName.substring(0, 1).toUpperCase() + variableName.substring(1);
}
@Override
public JCTree.JCMethodDecl findJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName) {
List<JCTree.JCMethodDecl> jcMethodDecls = jcClassDecl.defs
.stream().filter(it -> (it instanceof JCTree.JCMethodDecl))
.map(it -> (JCTree.JCMethodDecl) it)
.collect(Collectors.toList());
for (JCTree.JCMethodDecl jcMethodDecl : jcMethodDecls) {
if (jcMethodDecl.name.toString().equals(methodName)
&& jcMethodDecl.params.size() == 1
&& jcMethodDecl.params.get(0).vartype.type.toString().equals(variableDecl.vartype.type.toString())) {
return jcMethodDecl;
}
}
return null;
}
@Override
public JCTree.JCMethodDecl createJCMethodDecl(JCTree.JCClassDecl jcClassDecl, JCTree.JCVariableDecl variableDecl, String methodName, List<JCTree.JCExpression> args) {
ListBuffer<JCTree.JCStatement> body = new ListBuffer<>();
boolean isNotifyDefault = AnnotationEnhanceUtils.findAnnotationArguments(args, "notifyDefault", "true").equals("true");
if (String.class.getName().equals(variableDecl.vartype.type.toString())) {
int maxLength = AnnotationEnhanceUtils.findAnnotationArgumentsInt(args, "max", 0);
body.append(treeMaker.VarDef(
treeMaker.Modifiers(Flags.PARAMETER),
names.fromString("rs"),
treeMaker.TypeApply(treeMaker.Ident(names.fromString("Result")),
new ListBuffer<JCTree.JCExpression>().append(variableDecl.vartype).toList()),
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("this")), names.fromString("compareAndGetStr")),
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(variableDecl.name.toString()))
.append(treeMaker.Ident(names.fromString(variableDecl.name.toString())))
.append(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name))
.append(treeMaker.Literal(maxLength))
.toList()
)));
body.append(treeMaker.Exec(
treeMaker.Assign(
treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("value")))));
if (isNotifyDefault) {
body.append(treeMaker.Exec(
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("notifyDefault")),
com.sun.tools.javac.util.List.nil()
)
));
}
} else if (BigDecimal.class.getName().equals(variableDecl.vartype.type.toString())) {
int scale = AnnotationEnhanceUtils.findAnnotationArgumentsInt(args, "scale", 2);
body.append(treeMaker.VarDef(
treeMaker.Modifiers(Flags.PARAMETER),
names.fromString("rs"),
treeMaker.TypeApply(treeMaker.Ident(names.fromString("Result")),
new ListBuffer<JCTree.JCExpression>().append(variableDecl.vartype).toList()),
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("this")), names.fromString("compareAndGetDecimal")),
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(variableDecl.name.toString()))
.append(treeMaker.Ident(names.fromString(variableDecl.name.toString())))
.append(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name))
.append(treeMaker.Literal(scale))
.toList()
)));
body.append(treeMaker.Exec(
treeMaker.Assign(
treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("value")))));
if (isNotifyDefault) {
body.append(treeMaker.Exec(
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("notifyDefault")),
com.sun.tools.javac.util.List.nil()
)
));
}
} else if (Date.class.getName().equals(variableDecl.vartype.type.toString())
|| IStream.class.getName().equals(variableDecl.vartype.type.toString())
|| StreamImpl.class.getName().equals(variableDecl.vartype.type.toString())
|| variableDecl.vartype.type.isPrimitive()) {
body.append(treeMaker.VarDef(
treeMaker.Modifiers(Flags.PARAMETER),
names.fromString("rs"),
treeMaker.TypeApply(treeMaker.Ident(names.fromString("Result")),
variableDecl.vartype.type.isPrimitive() ?
new ListBuffer<JCTree.JCExpression>().append(treeMaker.Ident(names.fromString(PrimitiveEnums.getValues(variableDecl.vartype.toString()).getValue()))).toList()
: new ListBuffer<JCTree.JCExpression>().append(variableDecl.vartype).toList()
),
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("this")), names.fromString("compareAndGet")),
new ListBuffer<JCTree.JCExpression>()
.append(treeMaker.Literal(variableDecl.name.toString()))
.append(treeMaker.Ident(names.fromString(variableDecl.name.toString())))
.append(treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name))
.toList()
)));
body.append(treeMaker.Exec(
treeMaker.Assign(
treeMaker.Select(treeMaker.Ident(names.fromString("this")), variableDecl.name),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("value")))));
if (isNotifyDefault) {
body.append(treeMaker.Exec(
treeMaker.Apply(
com.sun.tools.javac.util.List.nil(),
treeMaker.Select(treeMaker.Ident(names.fromString("rs")), names.fromString("notifyDefault")),
com.sun.tools.javac.util.List.nil()
)
));
}
} else {
return null;
}
JCTree.JCBlock jcBlock = treeMaker.Block(0, body.toList());
return treeMaker.MethodDef(
treeMaker.Modifiers(Flags.PUBLIC), //方法可见性
names.fromString(methodName), //方法名称
treeMaker.TypeIdent(TypeTag.VOID), //方法返回值
com.sun.tools.javac.util.List.nil(), //泛型参数列表
new ListBuffer<JCTree.JCVariableDecl>()
.append(treeMaker.VarDef(treeMaker.Modifiers(Flags.PARAMETER), variableDecl.name, variableDecl.vartype, null))
.toList(),
com.sun.tools.javac.util.List.nil(), //抛出异常列表
jcBlock, null);
}
}
com.brilliance.annotation.processor.ModuleProcessor
\ No newline at end of file
......@@ -114,6 +114,131 @@
<scope>system</scope>
<systemPath>${pom.basedir}/lib/be-esb-core-2.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.brilliance</groupId>
<artifactId>gjjs-bd-runtime</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${basedir}/../lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.brilliance</groupId>
<artifactId>gjjs-bd-runtime</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!--pageHelper-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>3.5.3.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo5</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>12.1.0.2</version>
<scope>system</scope>
<systemPath>${basedir}/../lib/ojdbc6-12.1.0.2.jar</systemPath>
</dependency>
</dependencies>
<build>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>gjjs-bd-common</artifactId>
<groupId>com.brilliance</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gjjs-bd-mybatis-support</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.brilliance</groupId>
<artifactId>gjjs-bd-runtime</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!--pageHelper-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>3.5.3.1</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.brilliance.mda.support.mybatis;
import com.brilliance.mda.runtime.mda.ILocker;
import com.brilliance.mda.runtime.mda.LockInfo;
import org.springframework.stereotype.Component;
import java.io.Serializable;
@Component
public class DBLocker implements ILocker {
@Override
public boolean lock(Serializable key) {
return false;
}
@Override
public boolean lock(Serializable key, int expireflg) {
return false;
}
@Override
public boolean lock(Serializable key, long timeout) {
return false;
}
@Override
public LockInfo lock(String userName, Serializable key) {
return null;
}
@Override
public boolean unlock(Serializable key) {
return false;
}
@Override
public boolean unlock(String lockname, Serializable key) {
return false;
}
}
package com.brilliance.mda.support.mybatis;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
import java.util.HashMap;
/**
* @Description 注册数据源头
* @Author s_guodong
* @Date 2023/5/24
*/
@Configuration
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
public class DataSourceConfiguration {
/**
* 数据源ipsnew
*/
@Bean(name = "ipsnew")
@Qualifier("ipsnew")
@ConfigurationProperties(prefix = "spring.ipsnew")
public DruidDataSource ipsnew() {
return new DruidDataSource();
}
@Bean(name = "dynamicDataSource")
@Primary
public DataSource dynamicDataSource() {
DynamicDataSource dynamicDataSource = new DynamicDataSource();
dynamicDataSource.myMap = new HashMap<>();
dynamicDataSource.myMap.put("ipsnew", ipsnew());
dynamicDataSource.setTargetDataSources(dynamicDataSource.myMap);
dynamicDataSource.setDefaultTargetDataSource(ipsnew());
DynamicDataSourceContextHolder.dataSourceIds.addAll(dynamicDataSource.myMap.keySet());
return dynamicDataSource;
}
}
package com.brilliance.mda.support.mybatis;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import java.util.Map;
/**
* @Description
* @Author s_guodong
* @Date 2023/5/24
*/
public class DynamicDataSource extends AbstractRoutingDataSource {
public Map<Object, Object> myMap = null;
@Override
protected Object determineCurrentLookupKey() {
return DynamicDataSourceContextHolder.getDataSourceType();
}
}
package com.brilliance.mda.support.mybatis;
import java.util.ArrayList;
import java.util.List;
/**
* @Description
* @Author s_guodong
* @Date 2023/5/24
*/
public class DynamicDataSourceContextHolder {
private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
public static List<Object> dataSourceIds = new ArrayList<Object>();
public static void setDataSourceType(String dataSourceType) {
contextHolder.set(dataSourceType);
}
public static String getDataSourceType() {
return contextHolder.get();
}
public static void clearDataSourceType() {
contextHolder.remove();
}
public static boolean containsDataSource(String dataSourceId) {
return dataSourceIds.contains(dataSourceId);
}
}
package com.brilliance.mda.support.mybatis;
import com.brilliance.mda.runtime.mda.IDisplay;
import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
/**
* 快照保存器
* @author fukai
*
*/
@Component
public class FileDisplayManager implements IDisplay {
@Override
public boolean saveDisplay(String filePathOrKey,String data) {
File file = new File(filePathOrKey);
File parentFolder = file.getParentFile();
if(!parentFolder.exists() && !parentFolder.mkdirs())
return false;
FileWriter fr = null;
try{
file.createNewFile();
fr = new FileWriter(file);
IOUtils.write(data, fr);
}catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
@SuppressWarnings("deprecation")
@Override
public String readDisplay(String filePathOrKey) {
File file = new File(filePathOrKey);
if(!file.exists())
return null;
FileReader fr = null;
try{
fr = new FileReader(file);
return IOUtils.toString(fr);
}catch(Exception e)
{
e.printStackTrace();
}finally
{
IOUtils.closeQuietly(fr);
}
return null;
}
}
package com.brilliance.mda.support.mybatis.config;
import lombok.Data;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class MybatisDbUtil {
private static Properties properties = new Properties();
static {
try {
InputStream inputStream = MybatisDbUtil.class.getResourceAsStream("/mybatis.properties");
properties.load(inputStream);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static boolean isMultilDb() {
//不加/会从当前包进行寻找,加上/会从src开始找
String pro = properties.getProperty("multidb");
return pro == null ? false : Boolean.valueOf(pro);
}
public static void main(String[] args) throws IOException {
System.out.println(isMultilDb());
}
}
package com.brilliance.mda.support.mybatis.count;
public class Cnt {
private String nam; //配置名称
private int val; //配置名称
private int stp; //配置名称
}
package com.brilliance.mda.support.mybatis.count;
import com.brilliance.mda.support.mybatis.count.mapper.CounterMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
/**
* @author hulei
* dbcounter基于oracle自主事务的实现
*/
//@Service
public class CounterImplWithOracleTransaction implements CounterService {
Logger logger = LoggerFactory.getLogger(this.getClass().getName());
@Resource
public CounterMapper counterMapper;
public int dbCounter(String seqname) {
String seq = "SEQ_" + seqname.toUpperCase();
return counterMapper.seqNextval(seq);
}
}
package com.brilliance.mda.support.mybatis.count;
import com.brilliance.mda.runtime.mda.RuleExecuteException;
import com.brilliance.mda.support.mybatis.count.mapper.CounterMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.concurrent.locks.ReentrantLock;
@Service
public class CounterImplWithSpringTransaction implements CounterService {
Logger logger = LoggerFactory.getLogger(this.getClass().getName());
@Resource
public CounterMapper counterMapper;
public ReentrantLock lock = new ReentrantLock();
@Transactional(propagation=Propagation.REQUIRES_NEW)
public int dbCounter(String seqname)
{
Integer cnt = counterMapper.getCountValWithUpdate(seqname);
if(cnt == null) cnt = 0;
if(cnt == 0)
{
lock.lock();
try {
cnt = counterMapper.getCountValWithUpdate(seqname);
if(cnt == null) {
cnt = 0;
counterMapper.insertNewCounter(seqname, 1); //插入新数
}
else
counterMapper.updateCounter(seqname); //计算器增加
}catch (Exception e)
{
throw(new RuleExecuteException("主键生成异常",e));
}finally {
lock.unlock();
}
}
else
counterMapper.updateCounter(seqname); //计算器增加
return cnt;
}
}
package com.brilliance.mda.support.mybatis.count;
public interface CounterService {
int dbCounter(String seqname);
}
package com.brilliance.mda.support.mybatis.count.mapper;
import java.util.HashMap;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
@Component
public class CounterMapper{
final String FNAME = this.getClass().getName();
@Autowired
public SqlSessionTemplate template;
public Integer getCountValWithUpdate(@Param("nam") String seqName){
return template.selectOne(FNAME+".getCountValWithUpdate",seqName);
}
public int insertNewCounter(@Param("nam") String nam, @Param("stp") int stp){
Map<String, Object> map = new HashMap<>();
map.put("nam", nam);
map.put("start",1);
map.put("stp", stp);
return template.insert(FNAME+".insertNewCounter",map);
}
public void updateCounter(@Param("nam") String seqName){
template.selectOne(FNAME+".updateCounter",seqName);
}
public int seqNextval(String seqName) {
return template.selectOne(FNAME+".seqNextval",seqName);
}
public int dbCounter(String seqName){
return template.selectOne(FNAME+".dbCounter",seqName);
}
}
\ No newline at end of file
package com.brilliance.mda.support.mybatis.dync;
import com.brilliance.mda.runtime.mda.impl.AbstractModule;
public class DbExecute extends AbstractModule{
}
package com.brilliance.mda.support.mybatis.dync.mapper;
import com.brilliance.mda.support.mybatis.DynamicDataSourceContextHolder;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component
public class DbExecuteMapper {
@Autowired
SqlSessionTemplate sqlSessionTemplate;
final String FNAME = this.getClass().getName();
public List<Map<String,Object>> dyncReadForMap(Map<String,Object> params){
return sqlSessionTemplate.selectList(FNAME+".dyncReadForMap",params);
}
public int dyncUpdateForMap(Map<String,Object> params){
return sqlSessionTemplate.update(FNAME+".dyncUpdateForMap",params);
}
}
package com.brilliance.mda.support.mybatis.entity;
import java.lang.annotation.*;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Column {
public String value();
}
package com.brilliance.mda.support.mybatis.entity;
import java.lang.annotation.*;
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Table {
public String value();
}
package com.brilliance.mda.support.mybatis.listener;
import com.brilliance.mda.runtime.mda.IDaoSession;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Map;
@Component
public class StartListener implements ApplicationListener<ContextRefreshedEvent>{
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
ApplicationContext context = event.getApplicationContext();
}
}
package com.brilliance.mda.support.mybatis.typehandle;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.io.StringReader;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@MappedTypes({Object.class, String.class})
@MappedJdbcTypes(value = {JdbcType.LONGVARCHAR})
public class OracleLongTypeHandle extends BaseTypeHandler<Object> {
@Override
public void setNonNullParameter(PreparedStatement preparedStatement, int i, Object parameter, JdbcType jdbcType) throws SQLException {
String parameterStr = (String) parameter;
StringReader reader = new StringReader(parameterStr);
preparedStatement.setCharacterStream(i, reader, parameterStr.length());
}
@Override
public Object getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
String str = resultSet.getString(columnName);
return str != null ? str : "";
}
@Override
public Object getNullableResult(ResultSet resultSet, int columnIndex) throws SQLException {
String str = resultSet.getString(columnIndex);
return str != null ? str : "";
}
@Override
public Object getNullableResult(CallableStatement callableStatement, int columnIndex) throws SQLException {
String str = callableStatement.getString(columnIndex);
return str != null ? str : "";
}
}
\ No newline at end of file
#数据库相关配置信息
#是否是多数据库true false
multidb=false
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>gjjs-bd-common</artifactId>
<groupId>com.brilliance</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gjjs-bd-runtime</artifactId>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo5</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>12.1.0.2</version>
<scope>system</scope>
<systemPath>${basedir}/../lib/ojdbc6-12.1.0.2.jar</systemPath>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface BDGetter {
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
/**
* check函数
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Check {
int order();
String target();
String[] value() default {};
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
/**
* default函数
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Default {
int order() default 100;
String target() default "";
String[] value() default {};
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
/**
* 初始化函数
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Init {
int order();
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD})
public @interface Module {
boolean getter() default true;
boolean setter() default true;
}
package com.brilliance.mda.runtime.annotation;
import com.brilliance.mda.runtime.mda.DirType;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 视图映射注解
* @author fukai
*
*/
@Documented
@Retention(RUNTIME)
@Target({TYPE,FIELD})
public @interface RelPath {
String value(); //路径
DirType dir() default DirType.BOTH ; //输入输出方向
boolean recursion() default false; //是否递归关联
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
/**
* 事件函数
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Rule {
String target();
int order();
String[] value() default {};
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 用于引用模型的get函数
*/
@Documented
@Retention(RUNTIME)
@Target(ElementType.TYPE)
@Repeatable(Setters.class)
public @interface Setter {
String path();
String value();
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 用于引用模型的get函数
*/
@Documented
@Retention(RUNTIME)
@Target(ElementType.TYPE)
public @interface Setters {
Setter[] value();
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
/**
* 标记为已简化处理
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface SimpleType {
Class type();
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface TDGetter {
String i18n() default "";
int initSize() default 0;
}
package com.brilliance.mda.runtime.annotation;
import java.lang.annotation.*;
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface TDSetter {
int max() default 0;
int scale() default 2;
boolean notifyDefault() default true;
}
package com.brilliance.mda.runtime.annotation;
import com.brilliance.mda.runtime.mda.EmptyVO;
import java.lang.annotation.*;
/**
* 交易注解
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Transaction {
String value() default "";
Class<?> vo() default EmptyVO.class;
}
package com.brilliance.mda.runtime.mda;
public enum AttrType {
ATTRIBUTE,
MODIFIED,
ENABLED,
VALUES,
VISIABLE;
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2023/6/5
*/
public class CacheOption {
public long cacheTimeout;
public boolean paging;
public CacheOption(long cacheTimeout) {
this(cacheTimeout, false);
}
public CacheOption(boolean paging) {
this(0L, paging);
}
public CacheOption(long cacheTimeout, boolean paging) {
this.cacheTimeout = cacheTimeout;
this.paging = paging;
}
}
package com.brilliance.mda.runtime.mda;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
public class CodeEntity {
public String path;
public List<String> values;
public boolean visited;
}
package com.brilliance.mda.runtime.mda;
public class CodetableItem
{
private String label;
private String value;
private String description;
public CodetableItem(String label, String value, String description)
{
this.label = label;
this.value = value;
this.description = description;
}
public CodetableItem(String label, String value)
{
this.label = label;
this.value = value;
}
public String getLabel()
{
return this.label;
}
public void setLabel(String label)
{
this.label = label;
}
public String getValue()
{
return this.value;
}
public void setValue(String value)
{
this.value = value;
}
public String getDescription()
{
return this.description;
}
public void setDescription(String description)
{
this.description = description;
}
}
package com.brilliance.mda.runtime.mda;
import org.springframework.util.ResourceUtils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
public class Constants {
public static final String NULLSTR = "";
public static final Date NULLDATE = null;
public static final Date NULLDATETIME = null;
public static final String CRLF = "\r\n";
public static Date EMPDATE = null;
//public static Class<?> Dynamic_class;
public static Class<?> Platform_class;
public static Properties packageInfo;
private static String GLOBAL_PACK_KEY = "global.package";
static {
packageInfo = new Properties();
try {
packageInfo.load(ResourceUtils.getURL("classpath:package-info.properties").openStream());
String busipack = packageInfo.getProperty(GLOBAL_PACK_KEY, "");
// Dynamic_class = Class.forName(busipack + ".Dynamic");
Platform_class = Class.forName(busipack + ".Platform");
EMPDATE = new SimpleDateFormat("yyyyMMdd").parse("19900806");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
public static final int NO_ERROR = 0;
public static final int NO_MORE_ROW = 228;
public static final int ERROR_SQL = 200;
public static final int ERROR_COLUMN = 251;
public static final int ERROR_LOCK = 225;
public static final int ERROR_LOCKED = 226;
public static final int DATE_DAY = 5;
public static final int DATE_HOUR = 11;
public static final int DATE_MINUTE = 12;
public static final int DATE_SECOND = 13;
public static final int tdDataTypeNil = 25;
public static final int NO_SUCH_FIELD = 27;
public static final int NO_NAN = -37;
public static final int tdDataParentIsNull = 111;
public static final String TRUE = "X";
public static final String FALSE = "";
public static final String CR = "\r\n";
public static final String CALLER = "";
public static final String FIRST = "_1st_";
public static final String LASTTAG = "_tag_";
public static final OpType EQ = OpType.EQ;
public static final OpType NE = OpType.NE;
public static final OpType GE = OpType.GE;
public static final OpType LE = OpType.LE;
public static final OpType GT = OpType.GT;
public static final OpType LT = OpType.LT;
public static final OpType IN = OpType.IN;
public static final OpType LIKE = OpType.LIKE;
public static final OpType NOTLIKE = OpType.NOTLIKE;
public static final OpType BETWEEN = OpType.BETWEEN;
public static final OpType OR = OpType.OR;
public static final OpType AND = OpType.AND;
public static final OpType NOT = OpType.NOT;
public static final OpType ISNULL = OpType.ISNULL;
public static final OpType ISNOTNULL = OpType.ISNOTNULL;
public static final OpType DESC = OpType.DESC;
public static final OpType ASC = OpType.ASC;
public static final RuleType INIT = RuleType.INIT;
public static final RuleType CHECK = RuleType.CHECK;
public static final DecodeType DECODE_BASE64 = DecodeType.DECODE_BASE64;
public static final DecodeType DECODE_SHA = DecodeType.DECODE_SHA;
public static final String tdContextPOSTQUEUE = "tdContextPOSTQUEUE";
public static final String tdAttrSelectedIdx = "tdAttrSelectedIdx";
public static final String tdAttrChecked = "tdAttrChecked";
public static final String tdAttrCheckedIdx = "tdAttrCheckedIdx";
public static final String tdAttrSelected = "tdAttrSelected";
public static final String tdAttrName = "tdAttrName";
public static final String tdAttrFullName = "0";
public static final String tdAttrVisible = "tdAttrVisible";
public static final String tdAttrEnabled = "tdAttrEnabled";
public static final String tdAttrDecpos = "tdAttrDecpos";
public static final String tdAttrLines = "tdAttrLines";
public static final String tdAttrLength = "tdAttrLength";
public static final String tdAttrDatatype = "tdAttrDatatype";
public static final String tdAttrViewtype = "tdAttrViewtype";
public static final String tdAttrModified = "MODIFIED";
public static final String tdAttrKeyList = "KeyList";
public static final String tdAttrContent = "tdAttrContent";
public static final String tdPanelFullName = "tdPanelFullName";
public static final String tdPanelName = "tdPanelName";
public static final String tdAttrCalendar = "tdAttrCalendar";
public static final String tdAttrCodeValues = "tdAttrCodeValues";
public static final String tdAttrFirstValue = "tdAttrFirstValue";
public static final String tdAttrCurrency = "tdAttrCurrency";
public static final String tdAttrFieldViewtype = "tdAttrFieldViewtype";
public static final String tdAttrInfo = "tdAttrInfo";
public static final String tdContextDBSERVICENAME = "tdContextDBSERVICENAME";
public static final String tdContextLANGUAGE = "tdContextLANGUAGE";
public static final String tdContextDBDRIVERNAME = "tdContextDBDRIVERNAME";
public static final String tdContextCALLSTACK = "CALLSTACK";
public static final String tdContextLASTUSERACTIONTIME = "tdContextLASTUSERACTIONTIME";
public static final String tdAttrCodetable = "tdAttrCodetable";
public static final String tdContextFORM = "tdContextFORM";
public static final String ATTR_CODE_VALUES = "ATTR_CODE_VALUES";
public static final EventType onChange = EventType.ON_CHANGE;;
public static final EventType onClick = EventType.ON_CLICK;
}
package com.brilliance.mda.runtime.mda;
public enum DecodeType {
DECODE_BASE64, DECODE_MD5, DECODE_SHA, DECODE_SHA256, DECODE_SHA384, DECODE_SHA512;
}
package com.brilliance.mda.runtime.mda;
public enum DirType {
IN,OUT,BOTH
}
package com.brilliance.mda.runtime.mda;
/**
* 标记无VO
* @author fukai
*
*/
public class EmptyVO {
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public class Event {
public static final int UNSELECTED_INDEX = -1;
private IAttribute target;
private EventType type;
private Object data;
public Event(IAttribute target, EventType type, Object data) {
this.target = target;
this.type = type;
this.data = data;
}
public IAttribute getTarget() {
return this.target;
}
public final EventType getType() {
return this.type;
}
public final Object getData() {
return this.data;
}
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public enum EventType {
DEFAULT, ON_KEY_PRESS, ON_PULL_DOWN, ON_PULL_UP, ON_CHANGE, ON_CLICK, ON_DBLCLICK, ON_ROW_INSERT, ON_ROW_REMOVE, ON_STREAM_UPLOAD, ON_STREAM_DOWNLOAD, ON_PANEL_SHOW, ON_PANEL_CLOSE, ON_TIMER;
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public class ExitEventException extends RuntimeException {
}
package com.brilliance.mda.runtime.mda;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
@JsonIgnoreType
public interface FieldHolder<T> {
void setValue(T t);
T getValue();
String getPath();
}
package com.brilliance.mda.runtime.mda;
import java.util.Locale;
public interface I18n {
public static final String I18N_IDENT = "/";
String getString(Locale paramLocale, String paramString1, String paramString2, int paramInt);
String getString(Locale paramLocale, String paramString1, String paramString2);
String getString(Locale paramLocale, String paramString, int paramInt);
String getString(Locale paramLocale, String paramString);
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public interface IAttribute<E> {
public static final String ID = "ID";
public static final String DESCRIPTION = "DESCRIPTION";
public static final String REQUIRED = "REQUIRED";
public static final String VISIBLE = "VISIBLE";
public static final String ENABLE = "ENABLE";
public static final String MODIFY = "MODIFY";
public static final String BYINPUT = "BYINPUT";
public static final String CODEVALUES = "CODEVALUES";
public static final String FORMAT = "FORMAT";
public static final String WIDTH = "WIDTH";
public static final String COLSPAN = "COLSPAN";
public static final String ROWSPAN = "ROWSPAN";
public static final String HEIGHT = "HEIGHT";
public static final String LENGTH = "LENGTH";
public static final String LINE = "LINE";
public static final String VIEWTYPE = "VIEWTYPE";
public static final String STYLE = "STYLE";
public static final String STYLECLASS = "STYLECLASS";
public static final String HINT = "HINT";
public static final String ARGS = "ARGS";
public static final String SAVEDISPLAY = "SAVEDISPLAY";
Object setAttribute(String paramString, Object paramObject);
Object getAttribute(String paramString);
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public interface IAttributeValue<E> extends IValue<E>, IAttribute {
void addCheckRule(IRule paramIRule);
void addEventRule(IEventRule paramIEventRule);
boolean invokeCheckRules(IContext paramIContext);
boolean invokeEventRules(IContext paramIContext, EventType paramEventType, Object paramObject, int... paramVarArgs);
}
package com.brilliance.mda.runtime.mda;
public interface IAuthInfo {
//获取当前用户登录ID
String getUsrInr();
//获取当前用户的机构ID
String getPtyInr();
String getTerminalType();
String getNeedSign();
String getCn();
String getAlgorithm();
String getCert();
//获取errorText
String getErrorText();
IStream getSysStream();
IStream getDdsStream();
IStream getKeepAuthInfo();
void recoveryAuthInfo();
}
package com.brilliance.mda.runtime.mda;
import java.io.Serializable;
public interface IBaseObject extends Serializable {
String separator = "\\";
String getName();
IModule getParent();
String getPath();
void clear();
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/15
*/
public interface ICallback {
Object invoke(Object... paramVarArgs);
}
package com.brilliance.mda.runtime.mda;
import com.brilliance.mda.runtime.mda.impl.EnvConfig;
import java.io.Serializable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public interface IContext extends Serializable {
String DISPLAY_KEY = "DISPLAY_KEY";
String getTransName();
Map<String, Object> getModified();
Map<String, String> getFieldErrors();
String getMessage();
String getErrorNo();
void setModified(String path, Object value);//Platform.setModified()
void setFieldError(IModule m, String path, String errMsg);//Platform.error()
void setFieldError(IBaseObject baseobj, String errMsg);//Platform.error()
void setMessage(String errorNo, Object message);//Platform.message()
IModule getRoot();
boolean checkAll(IModule module);
boolean postRule(RuleType ruleType, String target);
boolean postInit();
boolean postRule(IModule m, String target);
boolean postRule(IBaseObject baseObject);
boolean postCheck(String target);
void setParams(Map<String, Object> params);
Map<String, Object> getRetMap();
IDaoSession getDaoSession();
Pagination getPagination(String path);
Object restoreData(String key);
void storeData(String key, Object data);
EnvConfig getEnvConfig();
boolean saveDisplay(String fileName);
int getErrorCode();
void setErrorCode(int errorCode);
ILocker getLocker();
Locale getLocale();
void setEmitter(IRuleEmitter emitter);
IRuleEmitter getEmitter();
void logout();
<T> T getVo();
void setVo(Object vo);
<T> T absGet(Class<T> clazz);
<T> T absGet(Class<T> clazz, String instName);
void setConcurrentCallStack(String path);
String getConcurrentCallStack();
void pushEventPath(String path);
String getEventPath();
void popEventPath();
void visitValues();
Map<String, CodeEntity> getValuesSet();
String getErrorMessage();
void resetParams(Map<String, Object> params);
<T> void setAttribute(Object parent, String prop, String ATTR, T val);
<T> T getAttribute(Object parent, String prop, String ATTR);
<T> T getParam(String key);
<T> void setParam(String key, T t);
}
package com.brilliance.mda.runtime.mda;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
@JsonIgnoreType
public interface IControl extends IBaseObject {
}
package com.brilliance.mda.runtime.mda;
import com.brilliance.mda.runtime.mda.impl.Argument;
import com.brilliance.mda.runtime.mda.impl.ModuleList;
import java.util.List;
public interface IDaoSession {
void dbBegin();
void dbCommit();
void dbRollback();
<T extends IModule> int dbInsert(T modull);
<T extends IModule> int dbDelete(T module);
<T extends IModule> int dbUpdate(T module);
@SuppressWarnings("rawtypes")
<T extends IModule> T dbRead(T module, Argument... args);
<T extends IModule> T dbReadByInr(T module, String inr);
@SuppressWarnings("rawtypes")
<T extends IModule> int dbDelete(T module, Argument... args);
@SuppressWarnings("rawtypes")
<T extends IModule> int dbReadset(IModuleList<T> list, Argument... args);
<T extends IModule> int dbReadset(ModuleList<T> list, CacheOption cacheOption, Argument... args);
<T extends IModule> int dbReadset(IModuleList<T>[] list, CacheOption cacheOption,String whereSql, Object[] param);
<T extends IModule> int dbReadset(IModuleList<T> list, String whereSql);
<T extends IModule> int dbReadset(IModuleList<T> list, String whereSql,Object[] params);
<T extends IModule> int dbReadset(IModuleList<T> list, String whereSql,String... params);
void dbReadset(IModuleList[] lists, String whereClause, Object[] datas);
void dbExecuteSQL(String sql,Object... params);
void dbFetchFields(IResult<? extends Object>... args);
void dbCloseCursor();
void putDao(Class<?> key, Object dao);
boolean isOpenTrans();
/**
* TODO 还需补充数据库会话切换支持
*/
int dbCounter(String seqname);
void dbConnect();
void dbReadset(IModuleList list, int maxSize, String whereClause, Object[] datas);
void dbDisconnect();
void dbReadset(IModuleList list, int maxSize, String sql);
String dbName();
List<String> dbColumnNames();
}
package com.brilliance.mda.runtime.mda;
import java.io.File;
import java.io.IOException;
import java.util.List;
public interface IDataGrid {
String getLine(int idx);
String deleteLine(int idx);
void sortLines();
int countLines();
int searchLine(String line);
void setRows(List<String> list);
List<String> getRows();
void insertLine(int idx,String line);
void setLine(int idx,String line);
void clearLines();
void addLine(String line);
void saveLines(File file)throws IOException;
void loadLines(File file) throws IOException;
boolean isLinesChanged();
<T> void setAttribute(String attr,T t);
<T> T getAttribute(String attr);
String defaultColDelimiter = "\t";
}
package com.brilliance.mda.runtime.mda;
public interface IDatafield<T> extends IBaseObject{
T getValue();
void setValue(T value);
Class<T> getDataType();
}
package com.brilliance.mda.runtime.mda;
/**
* 快照保存接口,保存的东西,可以使文件路径/或者是文件保存key。具体实现由实施情况决定。
* 可以使保存至数据库/保存至NOSQL数据库/保存至文件存储器
* @author fukai
*
*/
public interface IDisplay {
boolean saveDisplay(String filePathOrKey, String data);
String readDisplay(String filePathOrKey);
}
package com.brilliance.mda.runtime.mda;
import java.io.Serializable;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public interface IEventRule extends Serializable {
int getOrder();
EventType getType();
boolean invoke(IContext paramIContext, Event paramEvent);
}
package com.brilliance.mda.runtime.mda;
import java.io.Serializable;
public interface ILocker {
boolean lock(Serializable key);
boolean lock(Serializable key, int expireflg);
boolean lock(Serializable key, long timeout);
LockInfo lock(String userName, Serializable key);
boolean unlock(Serializable key);
boolean unlock(String lockname, Serializable key);
}
package com.brilliance.mda.runtime.mda;
/**
* TODO 认证实现类,实现登录签发Token,认证Token
* @author fukai
*
*/
public interface ILoginContext {
Object login(String id, String pwd);
Object auth(String token);
Object logout(String token);
}
package com.brilliance.mda.runtime.mda;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public interface IModule extends IBaseObject {
void copyValue(IModule src);
void copyValues(IModule src);
String getFieldPath(String fieldName);
/**
* 废弃的方法,不要再使用了
*
* @return
*/
@Deprecated
default Collection<IDatafield> getDatafields() {
return null;
}
;
/**
* 基于反射实现的,尽量不要用了
*
* @return
*/
@Deprecated
default List<IModule> getModules() {
return null;
}
;
default String getTableName() {
return null;
}
IBaseObject get(String paramString);
void assignSerialNum();
String getSerialNum();
Map<String, Object> getAttrMaps();
void setPageSize(int paramInt);
void setPaging(boolean paramBoolean);
void setPage(int paramInt);
int getPageSize();
int getPage();
int getRealIndex(int paramInt);
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public interface IModuleAttribute extends IModule {
// void clearIdAttribute();
}
package com.brilliance.mda.runtime.mda;
import java.util.List;
public interface IModuleList<T extends IModule> extends IModule,List<T> {
int getFullDbSize();
int fullSize();
Class<T> getDataClass();
void removeAll();
@Override
default String getSerialNum() {
return null;
}
@Override
default void assignSerialNum() {};
/**
* 废弃的方法,不建议使用
* @param args IDatafield Argument 两项参数
*/
@Deprecated
T add(Object... args);
void addElement(T em);
void addElement(int index,T em);
default void copyValues(IModule src){
}
default void copyValue(IModule src)
{
copyValues(src);
}
boolean executeInit();
boolean executeInit(int idx);
void executeDefault(String... paths);
void executeDefault(int idx,String... paths);
void executeCheckAll();
void delete(int index);
}
\ No newline at end of file
package com.brilliance.mda.runtime.mda;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public interface IModuleRoot extends IModuleAttribute {
public static final Logger log = LoggerFactory.getLogger(IModuleRoot.class);
}
package com.brilliance.mda.runtime.mda;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/15
*/
public interface IPanel extends IBaseObject {
public static final Log log = LogFactory.getLog(IPanel.class);
IModule getModule();
String getTitleI18nKey();
void setWindow(Object paramObject);
Object getWindow();
void addEventRule(IEventRule paramIEventRule);
boolean invokeEventRules(IContext paramIContext, Event paramEvent);
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/15
*/
public interface IParent extends IBaseObject {
public static final IParent[] EMPTY = new IParent[0];
void addChild();
void bindEvents(IContext paramIContext);
void init(IContext paramIContext);
void copyValues(IParent paramIParent);
Object getAttribute(IBaseObject paramIBaseObject, String paramString);
Object setAttribute(IBaseObject paramIBaseObject, String paramString, Object paramObject);
void updateSubUrls(int paramInt);
String getSubUrl(Object paramObject);
}
package com.brilliance.mda.runtime.mda;
public interface IResult<E> extends IValue<E> {
String getName();
}
\ No newline at end of file
package com.brilliance.mda.runtime.mda;
import java.io.Serializable;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public interface IRule extends Serializable {
int getOrder();
boolean invoke(IContext paramIContext, IAttributeValue paramIAttributeValue);
}
package com.brilliance.mda.runtime.mda;
import java.util.List;
import java.util.Map;
public interface IRuleEmitter {
String EMITTER_PRE = "emitter2.";
boolean executeInit();
boolean executeInit(int order);
boolean executeRule(String target);
boolean executeCheck(String target);
boolean executeRule(String target,int order);
boolean executeCheck(String target,int order);
boolean executeCheckAll();
boolean executeDefault(String target);
boolean executeDefault(String target, int order);
boolean executeDefaultAfterInit();
boolean executeDefaultAll();
// boolean executeDefaultAfterRule(String target);
Map<String,Object> getDefaultRuleQue();
IModule getRoot();
String getModuleName();
Class<?> relatedTransaction();
String getRealPath(String path);
List<IModuleList> getAllModuleList();
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/15
*/
public interface IState {
boolean getContinued();
void sleep();
void setStopCallback(IStopCallback paramIStopCallback);
public static interface IStopCallback {
void stop();
}
}
package com.brilliance.mda.runtime.mda;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
@JsonIgnoreType
public interface IStream extends IDataGrid, Serializable {
InputStream getInputStream();
OutputStream getOutputStream();
void close();
boolean isEmpty();
void setType(String type);
String getType();
void setName(String name);
String getName();
String setValue(String value);
String getValue();
}
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public interface IValue<E> extends Comparable<IValue<E>> {
E setValue(E value);
E getValue();
Class getDataType();
}
package com.brilliance.mda.runtime.mda;
import java.text.SimpleDateFormat;
import java.util.Date;
public class LockInfo
{
public Date date;
public String name;
public LockInfo(Date date, String name)
{
this.date = date;
this.name = name;
}
public String toString()
{
return String.format("Lock by %s at %s", new Object[] { this.name, new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(this.date) });
}
}
\ No newline at end of file
package com.brilliance.mda.runtime.mda;
/**
* @Description
* @Author s_guodong
* @Date 2022/11/11
*/
public enum MessageType {
INFORMATION, ERROR, QUESTION;
}
package com.brilliance.mda.runtime.mda;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
@JsonIgnoreType
@FunctionalInterface
public interface ModuleHolder<T> {
T get();
}
package com.brilliance.mda.runtime.mda;
import com.brilliance.mda.runtime.mda.impl.ModuleList;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
@JsonIgnoreType
@FunctionalInterface
public interface ModuleListHolder<T> {
ModuleList get();
}
package com.brilliance.mda.runtime.mda;
public enum OpType
{
EQ, NE, GE, LE, GT, LT, IN, LIKE, NOTLIKE, BETWEEN, OR, AND, NOT, ISNULL, ISNOTNULL, ASC, DESC;
}
package com.brilliance.mda.runtime.mda;
public class Pagination {
public String dir; //排序方向
public String sortField; //排序字段
public int pageno; //从0开始计算
public int total; //总数量
}
package com.brilliance.mda.runtime.mda;
public class RuleExecuteException extends RuntimeException {
public RuleExecuteException(String message,Throwable e)
{
super(message,e);
}
}
package com.brilliance.mda.runtime.mda;
public class RuleExitException extends RuntimeException {
public RuleExitException(String message)
{
super(message);
}
}
package com.brilliance.mda.runtime.mda;
/**
* 设置为弹出处理的异常
*/
public class RulePromptException extends RuntimeException {
public RulePromptException(String message)
{
super(message);
}
}
package com.brilliance.mda.runtime.mda;
public enum RuleType {
RULE("RULE"),
INIT("INIT"),
CHECK("CHECK");
private String type;
private RuleType(String type){
this.type = type;
}
public String toString(){
return this.type;
}
}
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