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 {
  • 相关阅读:
    【学习笔记】Hive
    《深入浅出数据分析》笔记
    SQL vs. HQL 语法对比
    log4net日志使用方法
    NLog日志使用方法
    VS2010,C#项目改动后无法编译
    Jquery easyui的datagrid在初始化的时候会请求两次URL?
    【硬件】Realtek RTL9210固件部分参数翻译及移动硬盘WinToGo推荐调优方案
    【小记】RedHat8(CentOS) 下连接数据库ODBC报 SSL Error:141A318A 问题
    【小记】[新手常见错误] C++ 指针的引用
  • 原文地址:https://www.cnblogs.com/openfire/p/3047620.html
Copyright © 2011-2022 走看看