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

com.talk2object.plum.interaction.session.SessionContextUtils Maven / Gradle / Ivy

package com.talk2object.plum.interaction.session;

import com.talk2object.plum.view.component.containers.window.EventThreadContext;
import com.talk2object.plum.view.component.containers.window.WindowEventThread;


public class SessionContextUtils {
	private static ThreadLocal threadLocalSessionContext = new ThreadLocal();
	
	/**
	 * session context could be attached to ThreadLocal and WindowEventThread
	 * 
	 * @return
	 */
	public static SessionContext getCurrentSessionContext() {

		if (Thread.currentThread() instanceof WindowEventThread) {
			return (SessionContext) EventThreadContext
					.getCurrentThreadContext().getSessionContext();
		} else
			return threadLocalSessionContext.get();
	}

	public static void setCurrentSessionContext(SessionContext sessionContext) {
		threadLocalSessionContext.set(sessionContext);
	}

	public static void removeCurrentSessionContext() {
		threadLocalSessionContext.remove();
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy