zoukankan      html  css  js  c++  java
  • eclipse中如何获得feature与plugin的list

    eclipse中如何获得feature与plugin的list

          做一些基于eclipse的开发,如RCP,经常需要查找当前platform中所有已经安装的feature和plug-in。其实,eclipse的“about eclipse platform”对话框就需要使用这个功能。通过阅读该对话框的代码,作者发现了以下方法。约定本文中Plugin与Bundle概念相同。
          1.获得所有feature的list
             首先,通过Platform,得到一个IBundleGroupProvider数组;
             然后,通过IBundleGroupProvider,获得相应的IBundleGroup数组;
             最后,通过IBundleGroup,得到Bundle数组。
             代码如下:
           

    for (int i=0;i<providers.length;i++){
          IBundleGroupProvider provider = providers[i];
          System.out.println("Provider name: "+ provider.getName());
          IBundleGroup[] groups=provider.getBundleGroups();
          
          for (int j=0;j<groups.length;j++){
            IBundleGroup group = groups[j];
            System.out.println("  Feature name: "+group.getName());      
          }
        }


          2. 获得plug-in的list
          原本可以通过上例的IBundleGroup列出,每个BundleGroup下的Bundle。但是,考虑到有的Plugin不属于任何一个feature,所以上述方法得到的bundle list可能不完全。通过BundleContext的getBundles()方法,可以达到这个目的。但是,如果某些class没有继承Bundle,Plugin或者BundleActivator,就无法获得BundleContext参数。因此,需要采用另一种方式得到所有bundle list。不通过BundleContext获得bundle list的代码如下:

    BundleDescription[] descriptions = Platform.getPlatformAdmin().getState().getBundles();
        for (int i=0;i<descriptions.length;i++){
          System.out.println("Bundle name:"+descriptions[i].getSymbolicName());
        }



         

  • 相关阅读:
    Oracle性能调整ASH,AWR,ADDM
    子网掩码、子网划分详解
    10046事件sql_trace跟踪
    find详解
    date详解
    touch详解
    [转]lsof详解
    iftop、ifstat详解
    iotop详解
    关于Unity的入门游戏飞机大战的开发(上)
  • 原文地址:https://www.cnblogs.com/daition/p/6908825.html
Copyright © 2011-2022 走看看