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 {
  • 相关阅读:
    React页面插入script
    Node Sass does not yet support your current environment解决办法
    ReactNative项目结构目录详解
    Android Studio模拟器磁盘空间不足(Not enough disk space to run AVD)
    React Native在window下的环境搭建(二):创建新项目
    React Native在window下的环境搭建(一)
    转:解决AndroidStudio连不上Android设备真机的问题
    ios中设置input为readonly后,解决弹起软键盘的问题
    转: rem与px的转换
    Python中模块之collections系列
  • 原文地址:https://www.cnblogs.com/openfire/p/3047620.html
Copyright © 2011-2022 走看看