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

com.feingto.cloud.plugin.support.PluginLoader Maven / Gradle / Ivy

package com.feingto.cloud.plugin.support;

import com.feingto.cloud.plugin.IPlugin;
import org.springframework.context.ApplicationContext;

/**
 * 插件加载器
 *
 * @author longfei
 */
public class PluginLoader {
    /**
     * 创建插件Bean
     *
     * @param clazz 插件类
     */
    public static Object createBean(ApplicationContext applicationContext, Class clazz) {
        return applicationContext.getAutowireCapableBeanFactory().createBean(clazz);
    }

    /**
     * 初始化插件
     *
     * @param clazz 插件类
     */
    public static IPlugin load(ApplicationContext applicationContext, Class clazz) {
        IPlugin plugin = (IPlugin) createBean(applicationContext, clazz);
        return plugin.init() ? plugin : null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy