package com.dev.swms.server.web.filter;

import com.dev.swms.server.model.base.Warehouse;
import com.dev.swms.server.web.servlet.SWMSLoginServlet;
import com.dev.energy.server.security.acegi.holder.SecurityContextHolder;

/**
 * @author  dev
 */
public class WarehouseHolder {
	private static ThreadLocal<Warehouse> warehouses = new InheritableThreadLocal<Warehouse>();
	public static Warehouse getWarehouse(){
		if(SecurityContextHolder.getCurrentSession() == null){
			return warehouses.get();
		}
		return (Warehouse)SecurityContextHolder.getCurrentSession().getAttribute(SWMSLoginServlet.SESSION_WAREHOUSE);
	}
	public static void setWarehouse(Warehouse warehouse) {
		warehouses.set(warehouse);
	}
}
