Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
s_guodong
gjjs-bd-common
Commits
8ec84d83
Commit
8ec84d83
authored
Dec 05, 2022
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bd整合gjjs-mda (config,driver包的文件迁移)
parent
6eb4f756
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
429 deletions
+0
-429
MdaScanner.java
...ava/com/brilliance/mda/runtime/mda/driver/MdaScanner.java
+0
-107
NamesMapper.java
...va/com/brilliance/mda/runtime/mda/driver/NamesMapper.java
+0
-65
FieldInfo.java
...e/mda/runtime/mda/driver/compile/component/FieldInfo.java
+0
-10
ModuleRuleContext.java
...ntime/mda/driver/compile/component/ModuleRuleContext.java
+0
-126
RuleItem.java
...ce/mda/runtime/mda/driver/compile/component/RuleItem.java
+0
-121
No files found.
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/MdaScanner.java
deleted
100644 → 0
View file @
6eb4f756
package
com
.
brilliance
.
mda
.
runtime
.
mda
.
driver
;
import
lombok.Data
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
;
import
org.springframework.context.ResourceLoaderAware
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.core.io.support.ResourcePatternResolver
;
import
org.springframework.core.io.support.ResourcePatternUtils
;
import
org.springframework.core.type.classreading.CachingMetadataReaderFactory
;
import
org.springframework.core.type.classreading.MetadataReader
;
import
org.springframework.core.type.classreading.MetadataReaderFactory
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.lang.annotation.Annotation
;
import
java.util.HashSet
;
import
java.util.LinkedHashSet
;
import
java.util.Map
;
import
java.util.Set
;
/**
* 扫描包路径的交易类
*
* @author fukai
*/
@Component
@Data
public
class
MdaScanner
implements
ResourceLoaderAware
,
BeanDefinitionRegistryPostProcessor
{
@Autowired
private
ResourceLoader
resourceLoader
;
private
BeanDefinitionRegistry
beanDefinitionRegistry
;
@Override
public
void
postProcessBeanDefinitionRegistry
(
BeanDefinitionRegistry
beanDefinitionRegistry
)
throws
BeansException
{
this
.
beanDefinitionRegistry
=
beanDefinitionRegistry
;
}
@Override
public
void
setResourceLoader
(
ResourceLoader
resourceLoader
)
{
this
.
resourceLoader
=
resourceLoader
;
}
/**
* @param packagePath 类路径,以"/"斜线分隔
* @return 该包下的添加了该注解的类
* @throws IOException
* @throws ClassNotFoundException
*/
public
Set
<
Class
<?>>
doScan
(
String
packagePath
,
Class
<?
extends
Annotation
>
anoclazz
)
throws
IOException
,
ClassNotFoundException
{
HashSet
<
Class
<?>>
set
=
new
HashSet
<
Class
<?>>();
ResourcePatternResolver
resolver
=
ResourcePatternUtils
.
getResourcePatternResolver
(
resourceLoader
);
MetadataReaderFactory
metaReader
=
new
CachingMetadataReaderFactory
(
resourceLoader
);
String
path
=
"classpath*:"
+
packagePath
+
"/**/*.class"
;
System
.
out
.
println
(
path
);
Resource
[]
resources
=
resolver
.
getResources
(
path
);
for
(
Resource
r
:
resources
)
{
if
(!
r
.
isReadable
())
continue
;
MetadataReader
reader
=
metaReader
.
getMetadataReader
(
r
);
if
(!
reader
.
getClassMetadata
().
isConcrete
())
// 当类型不是抽象类或接口在添加到集合
continue
;
String
className
=
reader
.
getClassMetadata
().
getClassName
();
Class
<?>
clazz
=
Class
.
forName
(
className
);
if
(
clazz
.
isAnnotationPresent
(
anoclazz
))
{
set
.
add
(
Class
.
forName
(
className
));
}
}
return
set
;
}
public
Map
<
Class
<?>,
Set
<
Class
<?>>>
doScan
(
Map
<
Class
<?>,
Set
<
Class
<?>>>
map
,
String
packagePath
,
Class
<?
extends
Annotation
>...
annotationClasses
)
throws
IOException
,
ClassNotFoundException
{
ResourcePatternResolver
resolver
=
ResourcePatternUtils
.
getResourcePatternResolver
(
resourceLoader
);
MetadataReaderFactory
metaReader
=
new
CachingMetadataReaderFactory
(
resourceLoader
);
String
path
=
"classpath*:"
+
packagePath
+
"/**/*.class"
;
Resource
[]
resources
=
resolver
.
getResources
(
path
);
for
(
Resource
r
:
resources
)
{
if
(!
r
.
isReadable
())
continue
;
MetadataReader
reader
=
metaReader
.
getMetadataReader
(
r
);
if
(!
reader
.
getClassMetadata
().
isConcrete
())
// 当类型不是抽象类或接口在添加到集合
continue
;
String
className
=
reader
.
getClassMetadata
().
getClassName
();
Class
<?>
clazz
=
Class
.
forName
(
className
);
for
(
Class
<?
extends
Annotation
>
annotationClass
:
annotationClasses
)
{
if
(
clazz
.
isAnnotationPresent
(
annotationClass
))
{
Set
<
Class
<?>>
set
=
map
.
computeIfAbsent
(
annotationClass
,
k
->
new
LinkedHashSet
<>());
set
.
add
(
Class
.
forName
(
className
));
}
}
}
return
map
;
}
@Override
public
void
postProcessBeanFactory
(
ConfigurableListableBeanFactory
configurableListableBeanFactory
)
throws
BeansException
{
}
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/NamesMapper.java
deleted
100644 → 0
View file @
6eb4f756
package
com
.
brilliance
.
mda
.
runtime
.
mda
.
driver
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
*
* @author fukai
* 扫描vo类、配置目录,实现VO长短类名检测
*/
public
class
NamesMapper
{
private
static
Map
<
String
,
Alias
>
trnAlias
=
new
HashMap
<
String
,
Alias
>();
public
static
Alias
genTransAlias
(
String
trnName
)
{
Alias
alias
=
trnAlias
.
get
(
trnName
);
if
(
alias
==
null
)
{
alias
=
new
Alias
(
trnName
);
trnAlias
.
put
(
trnName
,
alias
);
}
return
alias
;
}
public
static
Alias
getAlias
(
String
trnName
){
return
trnAlias
.
get
(
trnName
);
}
public
static
class
Alias
{
private
Map
<
String
,
String
>
pathAliasMap
=
new
HashMap
<
String
,
String
>();
private
Map
<
String
,
String
>
revertMap
=
new
HashMap
<
String
,
String
>();
private
String
trnName
;
public
Alias
(
String
trnName
)
{
this
.
trnName
=
trnName
;
}
public
Map
<
String
,
String
>
getPathAliasMap
()
{
return
pathAliasMap
;
}
public
void
setPathAliasMap
(
Map
<
String
,
String
>
pathAliasMap
)
{
this
.
pathAliasMap
=
pathAliasMap
;
}
public
Map
<
String
,
String
>
getRevertMap
()
{
return
revertMap
;
}
public
void
setRevertMap
(
Map
<
String
,
String
>
revertMap
)
{
this
.
revertMap
=
revertMap
;
}
public
String
getRelPath
(
String
alias
)
{
return
this
.
pathAliasMap
.
get
(
alias
);
}
public
String
getPathAlias
(
String
path
)
{
return
revertMap
.
get
(
path
);
}
public
String
getTrnName
()
{
return
trnName
;
}
}
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/compile/component/FieldInfo.java
deleted
100644 → 0
View file @
6eb4f756
package
com
.
brilliance
.
mda
.
runtime
.
mda
.
driver
.
compile
.
component
;
import
lombok.Data
;
@Data
public
class
FieldInfo
{
private
String
name
;
private
int
type
;
// 0 基本类型 1 模型 2 模型List 3 引用模型 4引用字段
private
String
typeName
;
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/compile/component/ModuleRuleContext.java
deleted
100644 → 0
View file @
6eb4f756
package
com
.
brilliance
.
mda
.
runtime
.
mda
.
driver
.
compile
.
component
;
import
lombok.Data
;
import
java.lang.reflect.Method
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Data
public
class
ModuleRuleContext
{
//RULE编译的层次
public
static
int
RULE_COMPILE_DEPTH
=
1
;
private
Map
<
String
,
List
<
RuleItem
>>
checkRule
=
new
LinkedHashMap
<>();
private
Map
<
String
,
List
<
RuleItem
>>
eventRule
=
new
LinkedHashMap
<>();
private
Map
<
String
,
List
<
RuleItem
>>
defaultRule
=
new
LinkedHashMap
<>();
private
List
<
RuleItem
>
initList
=
new
ArrayList
<>();
private
List
<
String
>
moduleList
=
new
ArrayList
<>();
private
Map
<
String
,
Method
>
globalMethod
=
new
HashMap
<>();
private
Map
<
String
,
RuleItem
>
staticMethod
=
new
HashMap
<>();
private
String
moduleName
;
private
boolean
useEmitter
;
private
boolean
isTrans
;
private
ModuleRuleContext
mergedContext
;
public
ModuleRuleContext
(
String
moduleName
){
this
.
moduleName
=
moduleName
;
this
.
useEmitter
=
false
;
}
public
ModuleRuleContext
(
String
moduleName
,
boolean
useEmitter
){
this
.
moduleName
=
moduleName
;
this
.
useEmitter
=
useEmitter
;
}
public
void
mergeChild
(
String
nodePath
,
ModuleRuleContext
nodeContext
){
nodeContext
.
moduleList
.
forEach
(
item
->
this
.
moduleList
.
add
(
nodePath
+
"."
+
item
));
nodeContext
.
initList
.
forEach
(
item
->{
RuleItem
newItem
=
item
.
clone
();
String
belongPath
=
nodePath
+
"."
+
newItem
.
getDotPath
();
//newItem.getBelongClass().push(this.moduleName);
newItem
.
initGetPath
(
belongPath
);
this
.
initList
.
add
(
newItem
);
});
mergeRuleMap
(
nodePath
,
this
.
checkRule
,
nodeContext
.
checkRule
);
mergeRuleMap
(
nodePath
,
this
.
defaultRule
,
nodeContext
.
defaultRule
);
mergeRuleMap
(
nodePath
,
this
.
eventRule
,
nodeContext
.
eventRule
);
nodeContext
.
staticMethod
.
forEach
((
key
,
ruleItem
)->{
RuleItem
newItem
=
ruleItem
.
clone
();
String
belongPath
=
nodePath
+
"."
+
newItem
.
getDotPath
();
newItem
.
initGetPath
(
belongPath
);
this
.
staticMethod
.
put
(
key
,
newItem
);
});
this
.
globalMethod
.
putAll
(
nodeContext
.
globalMethod
);
}
private
void
mergeRuleMap
(
String
nodePath
,
Map
<
String
,
List
<
RuleItem
>>
dest
,
Map
<
String
,
List
<
RuleItem
>>
src
){
src
.
entrySet
().
forEach
(
entry
->{
String
key
=
entry
.
getKey
();
if
(!
entry
.
getValue
().
isEmpty
()){
RuleItem
ruleItem
=
entry
.
getValue
().
get
(
0
);
if
(
ruleItem
.
getRuleType
().
equals
(
"CHECK"
)
&&
key
.
endsWith
(
"sdamod.dadsnd"
)){
return
;
}
}
//顶层交易模块,自动识别去除开始的.
// if(key.charAt(0) == '.' && useEmitter){
// key = key.substring(1);
// }
if
(
key
.
charAt
(
0
)
!=
'.'
)
{
//合并rule路径
key
=
nodePath
+
"."
+
key
;
}
List
<
RuleItem
>
ruleItemList
=
dest
.
get
(
key
);
if
(
ruleItemList
==
null
){
ruleItemList
=
new
ArrayList
<>();
dest
.
put
(
key
,
ruleItemList
);
}
List
<
RuleItem
>
finalRuleItemList
=
ruleItemList
;
String
entirePath
=
key
;
entry
.
getValue
().
forEach
(
item
->{
RuleItem
newItem
=
item
.
clone
();
String
belongPath
=
nodePath
+
"."
+
newItem
.
getDotPath
();
newItem
.
initGetPath
(
belongPath
);
newItem
.
setEntirePath
(
entirePath
);
//newItem.getBelongClass().push(this.moduleName);
finalRuleItemList
.
add
(
newItem
);
});
});
}
public
void
sortRule
(){
this
.
checkRule
.
values
().
stream
().
forEach
(
list
->
list
.
sort
(
new
RuleItem
.
RuleItemComparator
()));
this
.
eventRule
.
values
().
stream
().
forEach
(
list
->
list
.
sort
(
new
RuleItem
.
RuleItemComparator
()));
this
.
defaultRule
.
values
().
stream
().
forEach
(
list
->
list
.
sort
(
new
RuleItem
.
RuleItemComparator
()));
List
<
RuleItem
>
nInitRule
=
new
ArrayList
<>();
//EnterTransaction
List
<
RuleItem
>
tempList
=
initList
.
stream
().
filter
(
a
->
a
.
getOrder
()>
9000000
).
sorted
(
Comparator
.
comparingInt
(
RuleItem:
:
getOrder
)).
collect
(
Collectors
.
toList
());
//InitTransaction
List
<
RuleItem
>
tempList2
=
initList
.
stream
().
filter
(
a
->
a
.
getOrder
()<
9000000
&&
a
.
getOrder
()>=
900000
).
sorted
(
Comparator
.
comparingInt
(
RuleItem:
:
getOrder
)).
collect
(
Collectors
.
toList
());
//ModuleTransaction
List
<
RuleItem
>
tempList3
=
initList
.
stream
().
filter
(
a
->
a
.
getOrder
()<
900000
).
collect
(
Collectors
.
toList
());
nInitRule
.
addAll
(
tempList
);
nInitRule
.
addAll
(
tempList3
);
nInitRule
.
addAll
(
tempList2
);
initList
=
nInitRule
;
}
public
boolean
isRuleEmpty
(){
return
checkRule
.
size
()
==
0
&&
defaultRule
.
size
()
==
0
&&
eventRule
.
size
()
==
0
&&
initList
.
size
()
==
0
;
}
public
void
putGlobalMethod
(
Method
method
){
String
key
=
getMethodKey
(
method
);
globalMethod
.
put
(
key
,
method
);
}
public
static
String
getMethodKey
(
Method
method
){
StringBuilder
key
=
new
StringBuilder
(
method
.
getName
());
for
(
Class
clazz
:
method
.
getParameterTypes
()){
key
.
append
(
","
).
append
(
clazz
.
getCanonicalName
());
}
key
.
append
(
","
).
append
(
method
.
getReturnType
().
getCanonicalName
());
return
key
.
toString
();
}
}
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/compile/component/RuleItem.java
deleted
100644 → 0
View file @
6eb4f756
package
com
.
brilliance
.
mda
.
runtime
.
mda
.
driver
.
compile
.
component
;
import
com.brilliance.mda.runtime.mda.Ruleable
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Data
;
import
java.lang.reflect.Method
;
import
java.util.Comparator
;
@Data
public
class
RuleItem
{
public
static
final
String
INIT
=
"INIT"
;
public
static
final
String
RULE
=
"RULE"
;
public
static
final
String
CHECK
=
"CHECK"
;
public
static
final
String
DEFAULT
=
"DEFAULT"
;
public
static
final
String
STATIC
=
"STATIC"
;
public
static
final
String
LOCAL
=
"LOCAL"
;
public
static
final
String
GLOBAL
=
"GLOBAL"
;
public
static
final
String
LIST
=
"LIST"
;
// private String methodName;
//String or Method
@JsonIgnore
private
Object
method
;
private
int
order
;
@JsonIgnore
private
String
getPath
;
private
String
dotPath
;
@JsonIgnore
private
String
entirePath
;
@JsonIgnore
private
int
depth
;
@JsonIgnore
private
String
ruleType
;
@JsonIgnore
private
String
module
;
@JsonIgnore
private
String
transName
;
@JsonIgnore
private
Ruleable
<
Boolean
>
ruleableIns
;
//private Stack<String> belongClass = new Stack<>();
public
void
initGetPath
(
String
dotPath
)
{
if
(
dotPath
.
endsWith
(
"."
)){
dotPath
=
dotPath
.
substring
(
0
,
dotPath
.
length
()-
1
);
}
this
.
dotPath
=
dotPath
;
if
(
dotPath
.
length
()
==
0
)
{
this
.
getPath
=
""
;
this
.
depth
=
0
;
return
;
}
String
[]
pathArr
=
dotPath
.
split
(
"\\."
);
this
.
depth
=
pathArr
.
length
;
// StringBuilder sb = new StringBuilder();
// for(String item:pathArr)
// {
// sb.append(".get");
// sb.append(firstUpper(item));
// sb.append("()");
// }
// getPath = sb.toString();
}
private
String
firstUpper
(
String
s
){
if
(
s
.
length
()
==
1
)
return
s
.
toUpperCase
();
return
s
.
substring
(
0
,
1
).
toUpperCase
()+
s
.
substring
(
1
);
}
public
static
class
RuleItemComparator
implements
Comparator
<
RuleItem
>
{
@Override
public
int
compare
(
RuleItem
o1
,
RuleItem
o2
)
{
if
(
o1
.
getOrder
()
>
o2
.
getOrder
())
return
1
;
else
if
(
o1
.
getOrder
()
<
o2
.
getOrder
())
return
-
1
;
//TD的Rule执行顺序,由上到下,由里到外
if
(
o1
.
getDepth
()
>
o2
.
getDepth
())
return
-
1
;
else
if
(
o1
.
getDepth
()
<
o2
.
getDepth
())
return
1
;
return
0
;
}
}
public
String
getTransName
()
{
return
transName
;
}
public
void
setTransName
(
String
transName
)
{
this
.
transName
=
transName
;
}
public
RuleItem
clone
(){
RuleItem
clone
=
new
RuleItem
();
// clone.methodName = this.methodName;
clone
.
order
=
this
.
order
;
clone
.
getPath
=
this
.
getPath
;
clone
.
dotPath
=
this
.
dotPath
;
clone
.
entirePath
=
this
.
entirePath
;
clone
.
depth
=
this
.
depth
;
clone
.
ruleType
=
this
.
ruleType
;
clone
.
module
=
this
.
module
;
clone
.
transName
=
this
.
transName
;
clone
.
method
=
this
.
method
;
// Stack<String> belongClassStack = new Stack<>();
// belongClassStack.addAll(this.belongClass);
// clone.belongClass = belongClassStack;
return
clone
;
}
public
String
getMethodName
(){
if
(
method
instanceof
Method
)
return
((
Method
)
method
).
getName
();
return
(
String
)
method
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment