All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.easy.core.loadbalancer.EnvHolder Maven / Gradle / Ivy

The newest version!
package com.easy.core.loadbalancer;


import java.util.HashMap;
import java.util.Map;

/**
 * 环境标识 threadLocal
 */
public class EnvHolder {

    private EnvHolder(){

    }

    private static final ThreadLocal> envLocal = ThreadLocal.withInitial(HashMap::new);

    public static void setEnv(String env,String value){
        Map map = envLocal.get();
        map.put(env,value);
    }

    public static String getEnv(String env){
        Map map = envLocal.get();
        return map.getOrDefault(env,null);
    }

    public static void clear(){
        envLocal.remove();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy