Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
357a9573
Commit
357a9573
authored
Aug 03, 2019
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改缓存插件bug
parent
294a7881
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
DefaultKeyGenerator.java
...n/java/com/ace/cache/parser/impl/DefaultKeyGenerator.java
+71
-0
No files found.
ace-common/src/main/java/com/ace/cache/parser/impl/DefaultKeyGenerator.java
0 → 100644
View file @
357a9573
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package
com
.
ace
.
cache
.
parser
.
impl
;
import
com.ace.cache.constants.CacheScope
;
import
com.ace.cache.parser.IKeyGenerator
;
import
com.ace.cache.parser.IUserKeyGenerator
;
import
com.ace.cache.utils.ReflectionUtils
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
public
class
DefaultKeyGenerator
extends
IKeyGenerator
{
@Autowired
(
required
=
false
)
private
IUserKeyGenerator
userKeyGenerator
;
public
DefaultKeyGenerator
()
{
}
public
String
buildKey
(
String
key
,
CacheScope
scope
,
Class
<?>[]
parameterTypes
,
Object
[]
arguments
)
{
boolean
isFirst
=
true
;
if
(
key
.
indexOf
(
"{"
)
>
0
)
{
key
=
key
.
replace
(
"{"
,
":{"
);
Pattern
pattern
=
Pattern
.
compile
(
"\\d+\\.?[\\w]*"
);
Matcher
matcher
=
pattern
.
matcher
(
key
);
while
(
matcher
.
find
())
{
String
tmp
=
matcher
.
group
();
String
[]
express
=
matcher
.
group
().
split
(
"\\."
);
String
i
=
express
[
0
];
int
index
=
Integer
.
parseInt
(
i
)
-
1
;
Object
value
=
arguments
[
index
];
if
(
parameterTypes
[
index
].
isAssignableFrom
(
List
.
class
))
{
List
result
=
(
List
)
arguments
[
index
];
if
(
null
!=
result
)
{
value
=
result
.
get
(
0
);
}
}
if
(
value
==
null
||
value
.
equals
(
"null"
))
{
value
=
""
;
}
if
(
express
.
length
>
1
)
{
String
field
=
express
[
1
];
value
=
ReflectionUtils
.
getFieldValue
(
value
,
field
);
}
if
(
isFirst
)
{
key
=
key
.
replace
(
"{"
+
tmp
+
"}"
,
value
.
toString
());
}
else
{
key
=
key
.
replace
(
"{"
+
tmp
+
"}"
,
"_"
+
value
.
toString
());
}
}
}
return
key
;
}
public
IUserKeyGenerator
getUserKeyGenerator
()
{
return
this
.
userKeyGenerator
;
}
}
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