All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.codingdebugallday.factory.PluginInfoContainer Maven / Gradle / Ivy

The newest version!
package com.github.codingdebugallday.factory;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.util.StringUtils;

/**
 * 

* 插件信息共享容器 *

* * @author isaac 2020/6/16 10:26 * @since 1.0 */ public class PluginInfoContainer { private PluginInfoContainer() { throw new IllegalStateException(); } /** * 全局插件中定义的BaneName */ private static final Map> SPRING_REGISTER_BEAN_NAMES = new ConcurrentHashMap<>(); /** * 添加注册的bean名称 * * @param pluginId 插件id * @param beanName 注册的bean名称 */ public static void addRegisterBeanName(String pluginId, String beanName) { if (!StringUtils.isEmpty(beanName)) { Set beanNames = SPRING_REGISTER_BEAN_NAMES.computeIfAbsent(pluginId, k -> new HashSet<>()); beanNames.add(beanName); } } /** * 移除注册的bean名称 * * @param pluginId 插件id * @param beanName 注册的bean名称 */ public static void removeRegisterBeanName(String pluginId, String beanName) { Set beanNames = SPRING_REGISTER_BEAN_NAMES.get(pluginId); if (beanNames != null) { beanNames.remove(beanName); } } /** * 是否存在bean名称 * * @param pluginId 插件id * @param beanName 注册的bean名称 * @return true 存在。false不存在 */ public static boolean existRegisterBeanName(String pluginId, String beanName) { Set beanNames = SPRING_REGISTER_BEAN_NAMES.get(pluginId); if (beanNames != null) { return beanNames.contains(beanName); } else { return false; } } /** * 是否存在bean名称 * * @param beanName 注册的bean名称 * @return true 存在。false不存在 */ public static boolean existRegisterBeanName(String beanName) { for (Set beanNames : SPRING_REGISTER_BEAN_NAMES.values()) { if (beanNames.contains(beanName)) { return true; } } return false; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy