Commit 09b61120 authored by yanzg's avatar yanzg

异常处理显示

parent cf8775c6
......@@ -6,7 +6,6 @@ import com.yanzuoguang.token.TokenLoad;
import com.yanzuoguang.util.cache.MemoryCache;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.thread.ThreadHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
......@@ -26,7 +25,7 @@ public class TokenServiceCall implements TokenLoad {
private int flagCount = 3;
private MemoryCache<Boolean> countCache = new MemoryCache<>();
private MemoryCache<Integer> countCache = new MemoryCache<>();
public TokenServiceCall() {
TokenHelper.setTokenLoad(this);
......@@ -53,14 +52,14 @@ public class TokenServiceCall implements TokenLoad {
*/
public boolean tokenInit() {
init();
addHave();
if (tokenService == null) {
return false;
}
if (isHave()) {
if (addHave(0) == 1) {
return false;
}
tokenService.tokenInit();
setHave();
return true;
}
......@@ -69,11 +68,13 @@ public class TokenServiceCall implements TokenLoad {
*/
public void tokenFinish() {
init();
subHave();
if (tokenService == null) {
return;
}
tokenService.tokenFinish();
removeHave();
if (addHave(0) == 0) {
tokenService.tokenFinish();
}
}
/**
......@@ -91,18 +92,19 @@ public class TokenServiceCall implements TokenLoad {
return tokenService.load(token);
}
private boolean isHave() {
private int addHave(int flag) {
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() {
String id = StringHelper.toString(Thread.currentThread().getId());
countCache.put(id, true);
private int addHave() {
return addHave(1);
}
private void removeHave() {
String id = StringHelper.toString(Thread.currentThread().getId());
countCache.remove(id);
private int subHave() {
return addHave(-1);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment