Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-runtime
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
model-driver
gjjs-bd-runtime
Commits
6319f3ee
Commit
6319f3ee
authored
Dec 08, 2022
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将mybatis迁移到runtime
parent
bee42545
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
308 additions
and
0 deletions
+308
-0
DBLocker.java
...ain/java/com/brilliance/mda/support/mybatis/DBLocker.java
+42
-0
FileDisplayManager.java
...om/brilliance/mda/support/mybatis/FileDisplayManager.java
+59
-0
MyBatisDaoSession.java
...com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
+0
-0
MybatisArgumentAdapter.java
...rilliance/mda/support/mybatis/MybatisArgumentAdapter.java
+0
-0
Cnt.java
...in/java/com/brilliance/mda/support/mybatis/count/Cnt.java
+8
-0
CounterImplWithOracleTransaction.java
...pport/mybatis/count/CounterImplWithOracleTransaction.java
+28
-0
CounterImplWithSpringTransaction.java
...pport/mybatis/count/CounterImplWithSpringTransaction.java
+52
-0
CounterService.java
.../brilliance/mda/support/mybatis/count/CounterService.java
+5
-0
CounterMapper.java
...iance/mda/support/mybatis/count/mapper/CounterMapper.java
+47
-0
DbExecute.java
...va/com/brilliance/mda/support/mybatis/dync/DbExecute.java
+7
-0
DbExecuteMapper.java
...ance/mda/support/mybatis/dync/mapper/DbExecuteMapper.java
+24
-0
Column.java
...ava/com/brilliance/mda/support/mybatis/entity/Column.java
+10
-0
Table.java
...java/com/brilliance/mda/support/mybatis/entity/Table.java
+10
-0
StartListener.java
...rilliance/mda/support/mybatis/listener/StartListener.java
+16
-0
No files found.
src/main/java/com/brilliance/mda/support/mybatis/DBLocker.java
0 → 100644
View file @
6319f3ee
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
;
}
}
src/main/java/com/brilliance/mda/support/mybatis/FileDisplayManager.java
0 → 100644
View file @
6319f3ee
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
;
}
}
src/main/java/com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
0 → 100644
View file @
6319f3ee
This diff is collapsed.
Click to expand it.
src/main/java/com/brilliance/mda/support/mybatis/MybatisArgumentAdapter.java
0 → 100644
View file @
6319f3ee
This diff is collapsed.
Click to expand it.
src/main/java/com/brilliance/mda/support/mybatis/count/Cnt.java
0 → 100644
View file @
6319f3ee
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
count
;
public
class
Cnt
{
private
String
nam
;
//配置名称
private
int
val
;
//配置名称
private
int
stp
;
//配置名称
}
src/main/java/com/brilliance/mda/support/mybatis/count/CounterImplWithOracleTransaction.java
0 → 100644
View file @
6319f3ee
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
);
}
}
src/main/java/com/brilliance/mda/support/mybatis/count/CounterImplWithSpringTransaction.java
0 → 100644
View file @
6319f3ee
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
;
}
}
src/main/java/com/brilliance/mda/support/mybatis/count/CounterService.java
0 → 100644
View file @
6319f3ee
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
count
;
public
interface
CounterService
{
int
dbCounter
(
String
seqname
);
}
src/main/java/com/brilliance/mda/support/mybatis/count/mapper/CounterMapper.java
0 → 100644
View file @
6319f3ee
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
count
.
mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
@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
src/main/java/com/brilliance/mda/support/mybatis/dync/DbExecute.java
0 → 100644
View file @
6319f3ee
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
dync
;
import
com.brilliance.mda.runtime.mda.impl.AbstractModule
;
public
class
DbExecute
extends
AbstractModule
{
}
src/main/java/com/brilliance/mda/support/mybatis/dync/mapper/DbExecuteMapper.java
0 → 100644
View file @
6319f3ee
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
dync
.
mapper
;
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
);
}
}
src/main/java/com/brilliance/mda/support/mybatis/entity/Column.java
0 → 100644
View file @
6319f3ee
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
entity
;
import
java.lang.annotation.*
;
@Inherited
@Target
(
ElementType
.
FIELD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Column
{
public
String
value
();
}
src/main/java/com/brilliance/mda/support/mybatis/entity/Table.java
0 → 100644
View file @
6319f3ee
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
entity
;
import
java.lang.annotation.*
;
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Table
{
public
String
value
();
}
src/main/java/com/brilliance/mda/support/mybatis/listener/StartListener.java
0 → 100644
View file @
6319f3ee
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
listener
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.stereotype.Component
;
@Component
public
class
StartListener
implements
ApplicationListener
<
ContextRefreshedEvent
>{
@Override
public
void
onApplicationEvent
(
ContextRefreshedEvent
event
)
{
ApplicationContext
context
=
event
.
getApplicationContext
();
}
}
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