zoukankan      html  css  js  c++  java
  • Spark研究笔记8:重要的工厂类PluginManager(原创) CVT

    PluginManager 负责装载所有的插件和Workspaces。

    私有域:

    private final List<Plugin> plugins = new ArrayList<Plugin>();//Plugin接口
    
    //PublicPlugin是注册的插件,字面含义是公开
        private final List<PublicPlugin> publicPlugins = new CopyOnWriteArrayList<PublicPlugin>();
    //单例管理器
        private static PluginManager singleton;
        private static final Object LOCK = new Object();
    
    //Plugins 目录下的文件
        public static File PLUGINS_DIRECTORY = new File(Spark.getBinDirectory().getParent(), "plugins").getAbsoluteFile();
    
        private Plugin pluginClass;
        private PluginClassLoader classLoader;
    
    //黑名单插件,也就是被禁用的插件
        private Collection<String> _blacklistPlugins;

    构造函数:
    private PluginManager() {
            try {
    //定义PLUGINS_DIRECTORY
                PLUGINS_DIRECTORY = new File(Spark.getBinDirectory().getParentFile(), "plugins").getCanonicalFile();
            }
            catch (IOException e) {
                Log.error(e);
            }
    
            // Do not use deployable plugins if not installed.
            if (System.getProperty("plugin") == null) {
                movePlugins();
            }
    
    
            // Create the extension directory if one does not exist.
            if (!PLUGINS_DIRECTORY.exists()) {
                PLUGINS_DIRECTORY.mkdirs();
            }
            
            _blacklistPlugins = Default.getPluginBlacklist();
    
    //Default.getPluginBlacklist定义了插件黑名单,在default.properties里设置,用于禁用插件,第132行:
    # Put plugins here that you dont want enabled
    # comma separated, case insensitive
    # names of plugins can be found in the plugin.xml
    # example: Fastpath,Jingle Client,Phone Client,Window Flashing Plugin
    # default is empty
    PLUGIN_BLACKLIST =
    # Disable Plugins by entrypoint Class 
    # Comma seperated, case sensitive
    # example org.jivesoftware.fastpath.FastpathPlugin
    # default is empty
    PLUGIN_BLACKLIST_CLASS =
        }

    几个重要的方法

      /**
         * 载入所有的插件(通过plugins.xml、lib)
         */
        public void loadPlugins() {
    
    
      /**
         载入已注册插件*/
        private Plugin loadPublicPlugin(File pluginDir) {
    
    
        /**
         * 插件初始化*/
        public void initializePlugins() {
    
    
        /**
         * 安装新插件*/
        public void addPlugin(PublicPlugin plugin) throws Exception {
  • 相关阅读:
    第二部分 设计类型:第8章 方法
    centos7 网卡重命名
    centos7修改主机名
    修改umask值
    mysql表字段属性
    mysql基础操作
    mysql错误代码ERROR 1045 (转载)
    sed高级用法
    shell拷贝原文件到目标对应文件夹
    函数(位置传参)
  • 原文地址:https://www.cnblogs.com/openfire/p/3047620.html
Copyright © 2011-2022 走看看