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

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

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



/**
 * @author yuwei
 */
public class TableHolder {
	private static final ThreadLocal THREAD_LOCAL = new ThreadLocal<>();

	public static void set(String srcName, String targetName) {
		THREAD_LOCAL.set(new TB(srcName, targetName));
	}

	public static void remove() {
		THREAD_LOCAL.remove();
	}

	public static String getSrcName() {
		final TB tb = THREAD_LOCAL.get();
		return tb == null ? null : tb.srcName;
	}

	public static String getTargetName() {
		final TB tb = THREAD_LOCAL.get();
		return tb == null ? null : tb.targetName;
	}

	private static class TB {
		private String srcName;
		private String targetName;

		public TB(String srcName, String targetName) {
			this.srcName = srcName;
			this.targetName = targetName;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy