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());
        }



         

  • 相关阅读:
    Mysql(11)_Mysql权限与安全
    Mysql(10)_存储过程与流程控制
    Java(43)_AWT事件处理挂关闭生效
    6.实现合同测试用例
    6.测试库优化
    5.案例回顾及编写测试用例
    4.测试案例实现代码库与测试用例V2.0
    3.测试案例实现代码库与测试用例
    markdown语法学习
    1.faker批量随机造数据
  • 原文地址:https://www.cnblogs.com/daition/p/6908825.html
Copyright © 2011-2022 走看看