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

import cn.orionsec.kit.lang.utils.collect.Maps;
import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;

@Component
public class PipelineSessionHolder {

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

    /**
     * 添加 session
     *
     * @param processor processor
     */
    public void addSession(IPipelineProcessor processor) {
        session.put(processor.getTaskId(), processor);
    }

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

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

}
