| 1234567891011121314151617181920212223242526272829303132 |
- package com.jeesite.modules.sys.log;
- /**
- * 当前请求的 JSON 返回体,供访问日志落库使用。
- */
- public final class LogJsonResultHolder {
- private static final ThreadLocal<String> HOLDER = new ThreadLocal<>();
- private LogJsonResultHolder() {
- }
- public static void set(String json) {
- if (json == null || json.isEmpty()) {
- HOLDER.remove();
- } else {
- HOLDER.set(json);
- }
- }
- public static String getAndRemove() {
- try {
- return HOLDER.get();
- } finally {
- HOLDER.remove();
- }
- }
- public static void remove() {
- HOLDER.remove();
- }
- }
|