Skip to content

Commit

Permalink
TokenManager TicketManager 添加destroyed方法
Browse files Browse the repository at this point in the history
  • Loading branch information
liyiorg committed May 21, 2015
1 parent 9bdc4ef commit e7a87fc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/main/java/weixin/popular/support/TicketManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class TicketManager {
*/
public static void init(final String appid){
if(!timerMap.containsKey(appid)){
Timer timer = new Timer(true);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
Expand All @@ -41,6 +41,15 @@ public void run() {
}
}

/**
* 取消 ticket 刷新
*/
public static void destroyed(){
for(Timer timer : timerMap.values()){
timer.cancel();
}
}

/**
* 获取 jsapi ticket
* @param appid
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/weixin/popular/support/TokenManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @author LiYi
*
*/
public class TokenManager {
public class TokenManager{

private static Map<String,String> tokenMap = new LinkedHashMap<String,String>();

Expand All @@ -30,7 +30,7 @@ public static void init(final String appid,final String secret){
if(timerMap.containsKey(appid)){
timerMap.get(appid).cancel();
}
Timer timer = new Timer(true);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
Expand All @@ -41,6 +41,15 @@ public void run() {
timerMap.put(appid,timer);
}

/**
* 取消 token 刷新
*/
public static void destroyed(){
for(Timer timer : timerMap.values()){
timer.cancel();
}
}

/**
* 获取 access_token
* @param appid
Expand Down

0 comments on commit e7a87fc

Please sign in to comment.