Nutch 1.0 原始碼分析[3] Plugin(2),nutchplugin

來源:互聯網
上載者:User

Nutch 1.0 原始碼分析[3] Plugin(2),nutchplugin

                                                                               Nutch 1.0 原始碼分析[3] Plugin(2) 

                                                                                  來自: http://c.tieba.baidu.com/p/3439551436

在URLNormalizers建構函式中,有一句沒有看:

this.extensionPoint =PluginRepository.get(conf).getExtensionPoint(

       URLNormalizer.X_POINT_ID);

    看一下PluginRepository.get函數:

public static synchronizedPluginRepository get(Configuration conf) {

    PluginRepository result = CACHE.get(conf);

    if (result ==null) {

       result = newPluginRepository(conf);

       CACHE.put(conf,result);

    }

    returnresult;

}

    先試著從CACHE取,如果沒有被緩衝過,那麼就調用PluginRepository的建構函式:

publicPluginRepository(Configuration conf)throwsRuntimeException {

    fActivatedPlugins =newHashMap<String, Plugin>();

    fExtensionPoints =newHashMap<String, ExtensionPoint>();

    this.conf =conf;

    this.auto =conf.getBoolean("plugin.auto-activation",true);

    String[] pluginFolders = conf.getStrings("plugin.folders");

    PluginManifestParsermanifestParser = new PluginManifestParser(conf,

           this);

    Map<String, PluginDescriptor>allPlugins = manifestParser

           .parsePluginFolder(pluginFolders);

    Pattern excludes = Pattern.compile(conf.get("plugin.excludes",""));

    Pattern includes = Pattern.compile(conf.get("plugin.includes",""));

    Map<String, PluginDescriptor>filteredPlugins = filter(excludes,

           includes, allPlugins);

    fRegisteredPlugins =getDependencyCheckedPlugins(filteredPlugins,

           this.auto ?allPlugins : filteredPlugins);

    installExtensionPoints(fRegisteredPlugins);

    try {

       installExtensions(fRegisteredPlugins);

    } catch(PluginRuntimeException e) {

       LOG.fatal(e.toString());

       thrownewRuntimeException(e.getMessage());

    }

    displayStatus();

}

    這裡拷貝一點《Nutch外掛程式系統淺析》裡的介紹:

1.       plugin.folders:外掛程式所在的目錄,預設位置在 plugins 目錄下。

<property>

   <name>plugin.folders</name>

   <value>plugins</value>

</property>

2.       plugin.auto-activation:當被配置為過濾(即不載入),但是又被其他外掛程式依賴的時候,是否自動啟動,預設為 true。

<property>

 <name>plugin.auto-activation</name>

 <value>true</value>

</property>

3.        plugin.includes:要包含的外掛程式名稱列表,支援Regex方式定義。

<property>


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.