West Farm
          吾本布衣,生于川北,躬耕于代碼的田地上。
          posts - 16,  comments - 15,  trackbacks - 0
          本文用英文寫的,主要是考慮到本文分享的內(nèi)容即使在google上也搜索不到(至少我是沒有搜索到)。

          My English is at a very low level, don't care about this fact, just focus on the idea shared here.

          The idea comes from the source code of ConfigurationElement which is located in package org.eclipse.core.internal.registry, If you read through the source code, you can also get it. But I found there is no documentation about this topic, so I wrote this.

          Sometimes we need to contribute java class to a extension point. And we can use ConfigurationElement#
          createExecutableExtension(String attributeName) to create an instance of it, if such a class is just a normal class, eclipse will  call class#newInstance(). But there is obvious restriction for using this approach, can't pass parameter in to create instance for example.

          There are three different way how eclipse create instance of your class.

          1. normal, call class#newInstance()
          2. if your calss implements IExecutableExtension interface, IExecutableExtension#setInitializationData(IConfigurationElement config, String propertyName, Object data) will be called on the instance returned by class#newInstance()
          3. if your calss implements IExecutableExtensionFactory interface, IExecutableExtensionFactory#create() will be called

          When you use the second method or the third method, you can pass in parameters, check the source code of ConfigurationElement, you will know how to do that. :D forgive me, I'm lazy. 
          posted on 2012-04-15 16:33 West Farmer 閱讀(337) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          <2012年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          相冊

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 沐川县| 灵宝市| 精河县| 剑川县| 肥城市| 依兰县| 十堰市| 太保市| 平潭县| 大丰市| 崇阳县| 息烽县| 汉阴县| 呼图壁县| 东城区| 武清区| 大庆市| 齐齐哈尔市| 荔波县| 高密市| 徐州市| 吐鲁番市| 五原县| 通道| 宁明县| 含山县| 台北市| 泸溪县| 达拉特旗| 穆棱市| 吴川市| 囊谦县| 山东省| 海南省| 长子县| 彭泽县| 岑溪市| 大方县| 桑日县| 秦皇岛市| 镇赉县|