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

com.yuweix.kuafu.sharding.context.ShardingContext Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.yuweix.kuafu.sharding.context;


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


/**
 * @author yuwei
 */
public final class ShardingContext {
	private static final Map DB_SETTING = new HashMap<>();
	private static final Map TABLE_SETTING = new HashMap<>();

	private ShardingContext() {

	}

	public static void putDatabaseSetting(Map map) {
		if (map == null) {
			return;
		}
		DB_SETTING.putAll(map);
	}
	public static void putTableSetting(Map map) {
		if (map == null) {
			return;
		}
		TABLE_SETTING.putAll(map);
	}

	/**
	 * 根据逻辑库名获取配置
	 */
	public static DatabaseSetting getShardDatabaseSetting(String dbName) {
		return DB_SETTING.get(dbName);
	}

	/**
	 * 根据逻辑表名获取配置
	 */
	public static TableSetting getShardSetting(String tableName) {
		return TABLE_SETTING.get(tableName);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy