Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nouiWithSpringMVC
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
gechengyang
nouiWithSpringMVC
Commits
1bf77695
Commit
1bf77695
authored
Jan 12, 2021
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加缓存机制
增加文件上传拦截
parent
fcef01f2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
13 deletions
+132
-13
AbstractCache.java
...n/java/org/sss/presentation/noui/cache/AbstractCache.java
+65
-0
RedisCache.java
...main/java/org/sss/presentation/noui/cache/RedisCache.java
+49
-0
eIBS.xml
src/main/resources/eIBS.xml
+18
-13
No files found.
src/main/java/org/sss/presentation/noui/cache/AbstractCache.java
0 → 100644
View file @
1bf77695
package
org
.
sss
.
presentation
.
noui
.
cache
;
import
org.hibernate.Criteria
;
import
org.hibernate.Query
;
import
org.sss.common.model.CacheController
;
import
java.util.List
;
public
abstract
class
AbstractCache
implements
CacheController
{
protected
final
String
cacheName
;
final
String
SPLIT
=
"__"
;
public
AbstractCache
(
String
redis_cache
)
{
this
.
cacheName
=
redis_cache
;
}
@Override
public
List
cacheRead
(
Object
o
,
long
keepAlive
,
int
maxSize
,
int
offset
)
{
List
lst
=
null
;
String
key
=
generateKey
(
o
,
maxSize
,
offset
);
lst
=
doCacheRead
(
key
);
if
(
lst
==
null
)
{
if
(
o
instanceof
Criteria
)
{
Criteria
criteria
=
(
Criteria
)
o
;
if
(
maxSize
>
0
)
{
criteria
.
setMaxResults
(
maxSize
);
}
if
(
offset
>
0
)
{
criteria
.
setFirstResult
(
offset
);
}
lst
=
criteria
.
list
();
}
else
if
(
o
instanceof
Query
)
{
Query
query
=
(
Query
)
o
;
if
(
maxSize
>
0
)
{
query
.
setMaxResults
(
maxSize
);
}
if
(
offset
>
0
)
{
query
.
setFirstResult
(
offset
);
}
lst
=
query
.
list
();
}
doCacheWrite
(
key
,
lst
,
keepAlive
);
}
return
lst
;
}
private
String
generateKey
(
Object
o
,
int
maxSize
,
int
offset
)
{
StringBuffer
sb
=
new
StringBuffer
(
cacheName
);
sb
.
append
(
SPLIT
.
intern
());
sb
.
append
(
o
.
toString
());
if
(
maxSize
>
0
)
{
sb
.
append
(
SPLIT
.
intern
());
sb
.
append
(
maxSize
);
}
if
(
offset
>
0
)
{
sb
.
append
(
SPLIT
.
intern
());
sb
.
append
(
offset
);
}
return
sb
.
toString
();
}
protected
abstract
List
doCacheRead
(
String
key
);
protected
abstract
void
doCacheWrite
(
String
key
,
List
lst
,
long
keepAlive
);
}
src/main/java/org/sss/presentation/noui/cache/RedisCache.java
0 → 100644
View file @
1bf77695
package
org
.
sss
.
presentation
.
noui
.
cache
;
import
org.sss.presentation.noui.api.exception.NoUiException
;
import
org.sss.presentation.noui.util.RedisUtil
;
import
java.util.List
;
public
class
RedisCache
extends
AbstractCache
{
public
RedisCache
()
{
super
(
"REDIS_CACHE"
);
}
@Override
protected
List
doCacheRead
(
String
key
)
{
try
{
return
(
List
)
RedisUtil
.
get
(
key
);
}
catch
(
Exception
e
)
{
throw
new
NoUiException
(
"从缓存["
+
this
.
cacheName
+
"]中获取key="
+
key
+
"的值出现异常"
,
e
);
}
}
@Override
protected
void
doCacheWrite
(
String
key
,
List
lst
,
long
keepAlive
)
{
try
{
RedisUtil
.
set
(
key
,
lst
,
(
int
)
(
keepAlive
/
1000
));
}
catch
(
Exception
e
)
{
throw
new
NoUiException
(
"将key="
+
key
+
"的值放入缓存["
+
this
.
cacheName
+
"]出现异常"
,
e
);
}
}
@Override
public
Object
cacheRead
(
String
key
)
{
try
{
return
RedisUtil
.
get
(
key
);
}
catch
(
Exception
e
)
{
throw
new
NoUiException
(
"从缓存["
+
this
.
cacheName
+
"]中获取key="
+
key
+
"的值出现异常"
,
e
);
}
}
@Override
public
boolean
cacheWrite
(
String
key
,
Object
val
)
{
try
{
RedisUtil
.
set
(
key
,
val
);
return
true
;
}
catch
(
Exception
e
)
{
throw
new
NoUiException
(
"将key="
+
key
+
"的值放入缓存["
+
this
.
cacheName
+
"]出现异常"
,
e
);
}
}
}
src/main/resources/eIBS.xml
View file @
1bf77695
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configuration>
<!-- <service class="org.sss.util.ContainerUtils" initMethodName="init" deinitMethodName="deinit">
<service
class=
"org.sss.util.ContainerUtils"
initMethodName=
"init"
deinitMethodName=
"deinit"
>
交易DAT文件是否采用压缩
<property
name=
"cacheClassName"
value=
"org.sss.presentation.noui.cache.RedisCache"
class=
"java.lang.String"
/>
<property name="isCompressed" value="false" class="boolean" />
<!-- 开启后台自动检核-->
日志系统是否通过JSON进行格式化
<property
name=
"checkWithXML"
value=
"true"
class=
"boolean"
/>
<property name="jsonUsed" value="false" class="boolean" />
<!-- 未发现检查文件时返回值-->
是否采用集群通过本地MQ进行文件同步(FILE_SVR/FILE_QM/SEND_O_FILE/RECV_I_FILE)
<property
name=
"valueNoCheckXML"
value=
"true"
class=
"boolean"
/>
<property name="clusterUsed" value="false" class="boolean" />
<!-- 交易DAT文件是否采用压缩 -->
<property name="queueHostName" value="127.0.0.1" />
<!-- <property name="isCompressed" value="false" class="boolean" /> -->
<property name="remoteHostName" value="192.168.0.178" />
<!-- 日志系统是否通过JSON进行格式化 -->
<property name="queuePort" value="1419" class="int" />
<!-- <property name="jsonUsed" value="false" class="boolean" /> -->
是否让平台主动进行Java的GC收集
<!-- 是否采用集群通过本地MQ进行文件同步(FILE_SVR/FILE_QM/SEND_O_FILE/RECV_I_FILE) -->
<property name="autoGC" value="true" class="boolean" />
<!-- <property name="clusterUsed" value="false" class="boolean" /> -->
</service> -->
<!-- <property name="queueHostName" value="127.0.0.1" /> -->
<!-- <property name="remoteHostName" value="192.168.0.178" /> -->
<!-- <property name="queuePort" value="1419" class="int" /> -->
<!-- 是否让平台主动进行Java的GC收集 -->
<!-- <property name="autoGC" value="true" class="boolean" /> -->
</service>
<!--
<!--
<service class="cn.com.brilliance.eibs.auth.LdapLoginContext">
<service class="cn.com.brilliance.eibs.auth.LdapLoginContext">
<property name="ldapServer" value="192.1.1.9" />
<property name="ldapServer" value="192.1.1.9" />
...
...
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