🎨 #1430 WxMpConfigStorageHolder提供remove方法,方便使用者调用

This commit is contained in:
Binary Wang
2020-03-12 18:54:52 +08:00
parent c184ae1e4c
commit 07a1d26622

View File

@ -1,13 +1,11 @@
package me.chanjar.weixin.mp.util; package me.chanjar.weixin.mp.util;
/** /**
* @Author: yd * @author yd
* @Date: 2019-03-20 22:06 * @date 2019-03-20 22:06
*/ */
public class WxMpConfigStorageHolder { public class WxMpConfigStorageHolder {
private final static ThreadLocal<String> THREAD_LOCAL = new ThreadLocal<String>() {
private final static ThreadLocal<String> WX_MP_CONFIG_STORAGE_CHOSE = new ThreadLocal<String>() {
@Override @Override
protected String initialValue() { protected String initialValue() {
return "default"; return "default";
@ -15,11 +13,17 @@ public class WxMpConfigStorageHolder {
}; };
public static String get() { public static String get() {
return WX_MP_CONFIG_STORAGE_CHOSE.get(); return THREAD_LOCAL.get();
} }
public static void set(String label) { public static void set(String label) {
WX_MP_CONFIG_STORAGE_CHOSE.set(label); THREAD_LOCAL.set(label);
} }
/**
* 此方法需要用户根据自己程序代码在适当位置手动触发调用本SDK里无法判断调用时机
*/
public static void remove() {
THREAD_LOCAL.remove();
}
} }