
package cn.orionsec.ops.handler.app.build;

import cn.orionsec.kit.lang.utils.collect.Maps;
import cn.orionsec.ops.handler.app.machine.IMachineProcessor;
import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;

@Component
public class BuildSessionHolder {

    /**
     * session
     */
    private final ConcurrentHashMap<Long, IMachineProcessor> session = Maps.newCurrentHashMap();

    /**
     * 添加 session
     *
     * @param processor processor
     */
    public void addSession(Long id, IMachineProcessor processor) {
        session.put(id, processor);
    }

    /**
     * 获取 session
     *
     * @param id id
     * @return session
     */
    public IMachineProcessor getSession(Long id) {
        return session.get(id);
    }

    /**
     * 移除 session
     *
     * @param id id
     */
    public void removeSession(Long id) {
        session.remove(id);
    }

}
