templates.common.TokenContextHolder.ftl Maven / Gradle / Ivy
package ${packageName}.common.context;
import lombok.extern.slf4j.Slf4j;
/**
* @author Co.
* @name TokenContextHolder
* @date 2023/2/22 17:31
*/
@Slf4j
public class TokenContextHolder {
private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>();
/**
*
*/
public static void setToken(String token) {
CONTEXT_HOLDER.set(token);
}
/**
*
*/
public static String getToken() {
return CONTEXT_HOLDER.get();
}
/**
*
*/
public static void clearToken() {
CONTEXT_HOLDER.remove();
}
}