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

org.teasoft.beex.mongodb.ds.MongoContext Maven / Gradle / Ivy

/*
 * Copyright 2016-2023 the original author.All rights reserved.
 * Kingstar([email protected])
 * The license,see the LICENSE file.
 */

package org.teasoft.beex.mongodb.ds;

import com.mongodb.client.MongoClient;

/**
 * @author Kingstar
 * @since  2.0
 */
public class MongoContext {

	private static ThreadLocal currentMongoClient;

	static {
		currentMongoClient = new InheritableThreadLocal<>();
	}

	public static MongoClient getCurrentMongoClient() {
		return currentMongoClient.get();
	}

	public static void setCurrentMongoClient(MongoClient client) {
		currentMongoClient.set(client);
	}

	public static void removeMongoClient() {
		currentMongoClient.remove();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy