package com.ssyf.common.web.filter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* 业务上下文对象存储类
* @author huwei
* @date 2022/7/15 16:03
*/
public class RequestContextHolder {
    private static final ThreadLocal<RequestContext> container = new InheritableThreadLocal<>();

    public static RequestContext getContext(){
        return container.get();
    }

    static void setContext(HttpServletRequest request ,HttpServletResponse response){
        container.set(new RequestContext().setRequest(request).setResponse(response));
    }

    static void setContext(RequestContext serviceContext){
        container.set(serviceContext);
    }

    static void clear() {
        container.remove();
    }

}
