package com.qs.mp.framework.security.handle;

import com.qs.mp.core.domain.LoginUser;
import org.springframework.stereotype.Component;

/**
 * 利用ThreadLocal保存当前会话user对象
 * @author duota
 *
 */
@Component
public class HostHolder {
    
    private static ThreadLocal<LoginUser> userThreadLocal = new ThreadLocal<LoginUser>();

    public LoginUser getUser() {
        return userThreadLocal.get();
    }

    public void setUser(LoginUser user) {
        userThreadLocal.set(user);
    }

    public void clear() {
        userThreadLocal.remove();
    }
    
}
