Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
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
YZG
yzg-util
Commits
09b61120
Commit
09b61120
authored
Jan 08, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异常处理显示
parent
cf8775c6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
TokenServiceCall.java
.../java/com/yanzuoguang/cloud/service/TokenServiceCall.java
+16
-14
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/service/TokenServiceCall.java
View file @
09b61120
...
@@ -6,7 +6,6 @@ import com.yanzuoguang.token.TokenLoad;
...
@@ -6,7 +6,6 @@ import com.yanzuoguang.token.TokenLoad;
import
com.yanzuoguang.util.cache.MemoryCache
;
import
com.yanzuoguang.util.cache.MemoryCache
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.log.Log
;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -26,7 +25,7 @@ public class TokenServiceCall implements TokenLoad {
...
@@ -26,7 +25,7 @@ public class TokenServiceCall implements TokenLoad {
private
int
flagCount
=
3
;
private
int
flagCount
=
3
;
private
MemoryCache
<
Boolean
>
countCache
=
new
MemoryCache
<>();
private
MemoryCache
<
Integer
>
countCache
=
new
MemoryCache
<>();
public
TokenServiceCall
()
{
public
TokenServiceCall
()
{
TokenHelper
.
setTokenLoad
(
this
);
TokenHelper
.
setTokenLoad
(
this
);
...
@@ -53,14 +52,14 @@ public class TokenServiceCall implements TokenLoad {
...
@@ -53,14 +52,14 @@ public class TokenServiceCall implements TokenLoad {
*/
*/
public
boolean
tokenInit
()
{
public
boolean
tokenInit
()
{
init
();
init
();
addHave
();
if
(
tokenService
==
null
)
{
if
(
tokenService
==
null
)
{
return
false
;
return
false
;
}
}
if
(
isHave
()
)
{
if
(
addHave
(
0
)
==
1
)
{
return
false
;
return
false
;
}
}
tokenService
.
tokenInit
();
tokenService
.
tokenInit
();
setHave
();
return
true
;
return
true
;
}
}
...
@@ -69,11 +68,13 @@ public class TokenServiceCall implements TokenLoad {
...
@@ -69,11 +68,13 @@ public class TokenServiceCall implements TokenLoad {
*/
*/
public
void
tokenFinish
()
{
public
void
tokenFinish
()
{
init
();
init
();
subHave
();
if
(
tokenService
==
null
)
{
if
(
tokenService
==
null
)
{
return
;
return
;
}
}
if
(
addHave
(
0
)
==
0
)
{
tokenService
.
tokenFinish
();
tokenService
.
tokenFinish
();
removeHave
();
}
}
}
/**
/**
...
@@ -91,18 +92,19 @@ public class TokenServiceCall implements TokenLoad {
...
@@ -91,18 +92,19 @@ public class TokenServiceCall implements TokenLoad {
return
tokenService
.
load
(
token
);
return
tokenService
.
load
(
token
);
}
}
private
boolean
isHave
(
)
{
private
int
addHave
(
int
flag
)
{
String
id
=
StringHelper
.
toString
(
Thread
.
currentThread
().
getId
());
String
id
=
StringHelper
.
toString
(
Thread
.
currentThread
().
getId
());
return
StringHelper
.
toBoolean
(
countCache
.
get
(
id
));
int
from
=
StringHelper
.
toInt
(
countCache
.
get
(
id
));
int
to
=
from
+
flag
;
countCache
.
put
(
id
,
to
);
return
to
;
}
}
private
void
setHave
()
{
private
int
addHave
()
{
String
id
=
StringHelper
.
toString
(
Thread
.
currentThread
().
getId
());
return
addHave
(
1
);
countCache
.
put
(
id
,
true
);
}
}
private
void
removeHave
()
{
private
int
subHave
()
{
String
id
=
StringHelper
.
toString
(
Thread
.
currentThread
().
getId
());
return
addHave
(-
1
);
countCache
.
remove
(
id
);
}
}
}
}
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