package com.ruoyi.xq.mq.config;

import com.ruoyi.xq.mq.handle.IHandle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class HandleConfig {

    public static Map<String, IHandle> MAP = new HashMap<>();

    @Autowired
    private List<IHandle> handles;

    @PostConstruct
    public void  init(){
        for (IHandle handle : handles) {
            MAP.put(handle.getType().name(),handle);
        }
    }

    public IHandle getHandle(String type){
        return MAP.get(type);
    }

}
