package cd.casic.plugin.config;

import cd.casic.plugin.PluginManager;
import cd.casic.plugin.PluginProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类：用于定义和管理插件系统的Bean
 */
@Configuration
@EnableConfigurationProperties({PluginProperties.class})
public class OpsPluginConfig {
    /**
     * 定义并创建一个PluginManager Bean
     * <p>
     * 此Bean负责管理和操作插件系统，仅在没有已定义的PluginManager Bean时创建
     *
     * @param pluginProperties 插件系统的属性配置，用于初始化PluginManager
     * @return 初始化并配置好的PluginManager实例
     */
    @Bean
    @ConditionalOnMissingBean
    public PluginManager pluginManager(PluginProperties pluginProperties) {
        return new PluginManager(pluginProperties);
    }
}