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

me.wuwenbin.modules.mongodb.support.MongoContextHolder Maven / Gradle / Ivy

There is a newer version: 1.11.0.RELEASE
Show newest version
package me.wuwenbin.modules.mongodb.support;


import me.wuwenbin.modules.mongodb.support.bo.MongoContext;

/**
 * 处理同一线程下的切换数据源的问题
 * Created by wuwenbin on 2017/5/4.
 */
public class MongoContextHolder {

    private static final ThreadLocal mongoContextHolder = new ThreadLocal<>();

    public static void setHolder(String key, String database) {
        mongoContextHolder.set(MongoContext.create(key, database));
    }

    public static MongoContext getHolder() {
        return mongoContextHolder.get();
    }

    public static void clearHolder() {
        mongoContextHolder.remove();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy