<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    精彩的人生

    好好工作,好好生活

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      147 Posts :: 0 Stories :: 250 Comments :: 0 Trackbacks
    其實很多人都問到了這個問題。目前插件的安裝是需要重啟的,但是很多情況下是有不重啟而安裝插件的需求。我找到的一點資料,應該會有幫助



    FAQ How do I make my plug-in dynamic aware?

    From Eclipsepedia




    Dynamic awareness requires extra steps that were not required prior to the introduction of dynamic plug-ins. Dynamic awareness requires that you remove all references to classes defined in other plug-ins when those plug-ins are removed from the system. In particular, if your plug-in defines extension points that load classes from other plug-ins—executable extensions—you need to discard those references when other plug-ins are dynamically removed. The extension registry allows you to add a listener that notifies you when extensions are being added or removed from the system. If your plug-in maintains its own cache of extensions that are installed on your extension point, your listener should update this cache for each added or removed extension.



    The following is an example of a simple class that maintains its own cache of the set of extensions installed for a given extension point. This example is a bit contrived as simply caching the extension objects has no value. Typically, your plug-in will process the extensions to extract useful information and possibly load one or more classes associated with that extension. The basic structure of this cache example is as follows:

       public class ExtCache implements IRegistryChangeListener {
          private static final String PID = "my.plugin";
          private static final String PT_ID = 
             PID + "." + "extension.point";
          private final HashSet extensions = new HashSet();
          ...
       }
    

    The extensions field stores the set of installed extensions for a particular extension point.



    The cache has a startup method that loads the initial set of extensions and then adds an extension registry listener in order to be notified of future changes:

       public void startup() {
          IExtensionRegistry reg = Platform.getExtensionRegistry();
          IExtensionPoint pt = reg.getExtensionPoint(PT_ID);
          IExtension[] ext = pt.getExtensions();
          for (int i = 0; i < ext.length; i++)
             extensions.add(ext[i]);
          reg.addRegistryChangeListener(this);
       }
    

    The class implements the IRegistryChangeListener interface, which has a single method that is called whenever the registry changes:

       public void registryChanged(IRegistryChangeEvent event) {
          IExtensionDelta[] deltas = 
                              event.getExtensionDeltas(PID, PT_ID);
          for (int i = 0; i < deltas.length; i++) {
             if (deltas[i].getKind() == IExtensionDelta.ADDED)
                extensions.add(deltas[i].getExtension());
             else
                extensions.remove(deltas[i].getExtension());
          }
       }
    

    This class is now dynamic aware but is not yet dynamic enabled; that is, the class does not yet support itself being dynamically removed. The final step is to implement a shutdown method that clears all values from the cache and removes the listener from the extension registry:

       public void shutdown() {
          extensions.clear();
          IExtensionRegistry reg = Platform.getExtensionRegistry();
          reg.removeRegistryChangeListener(this);
       }
    

    This shutdown method must be called from the shutdown method of the plug-in that defines the cache. For the complete source code of this example, see the ExtCache class in the FAQ Examples plug-in.



    Note that not only extensions points acquire and maintain references to classes defined in other plug-ins. You need to be especially aware of static fields and caches that contain references to objects whose class is defined in other plug-ins.

    If you hold onto classes defined in other plug-ins through different mechanisms, you also need to discard those references when those other plug-ins are removed.


    原文地址:http://wiki.eclipse.org/index.php/FAQ_How_do_I_make_my_plug-in_dynamic_aware%3F

    posted on 2006-03-23 11:16 hopeshared 閱讀(2579) 評論(0)  編輯  收藏 所屬分類: Eclipse
    主站蜘蛛池模板: 啦啦啦手机完整免费高清观看| 久久免费精品一区二区| 久久精品国产亚洲一区二区| 久久久久久AV无码免费网站| 亚洲国产日韩视频观看| 亚洲成A∨人片在线观看不卡 | 卡1卡2卡3卡4卡5免费视频| 水蜜桃视频在线观看免费播放高清| 亚洲精品在线播放| 最新精品亚洲成a人在线观看| 成人免费男女视频网站慢动作| 99久久婷婷免费国产综合精品| 亚洲一线产区二线产区区| 亚洲国产精品无码av| 国产免费人成视频在线观看 | 亚洲日本国产乱码va在线观看| 亚洲日本一区二区一本一道 | xxx毛茸茸的亚洲| 亚洲色偷偷av男人的天堂| 亚洲av无码潮喷在线观看| 亚洲国产免费综合| 亚洲国产精品碰碰| 亚洲中文久久精品无码ww16| 精品国产亚洲一区二区三区 | 亚欧洲精品在线视频免费观看| 国产精品亚洲一区二区三区久久| 亚洲成a人无码亚洲成av无码| 亚洲色丰满少妇高潮18p| 无码中文在线二区免费| 免费a级毛片无码a∨免费软件| 午夜亚洲WWW湿好爽| 乱人伦中文视频在线观看免费| 污污视频免费观看网站| 中文无码日韩欧免费视频| 免费人妻无码不卡中文字幕系| 美女在线视频观看影院免费天天看| 日本免费污片中国特一级| 少妇太爽了在线观看免费视频| 999国内精品永久免费观看| 日本一道在线日本一道高清不卡免费| 午夜国产大片免费观看|