package com.lightinit.hsdataplatformresdir.spring;

import org.springframework.util.StringUtils;

/**
 * Created by Mr.Yao on 2017/4/14.
 */
public class DynamicDataContextHolder {
    public static final String DEFAULT="dataSource";
    public static final String CAMRS="camrsDataSource";

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
    public static void setCustomerType(String customerType) {
        contextHolder.set(customerType);
    }
    public static String getCustomerType() {
        String dataSource = contextHolder.get();
        if (StringUtils.isEmpty(dataSource)) {
            return DEFAULT;
        }else {
            return dataSource;
        }
    }
    public static void clearCustomerType() {
        contextHolder.remove();
    }
}
