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

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

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

    EclEmma源代碼研究積累

    Posted on 2008-04-10 17:12 遲來的兵 閱讀(557) 評論(0)  編輯  收藏 所屬分類: Eclipse plug-in開發(fā)
    1. interface來定義系統(tǒng)對外提供的服務(wù),有抽象類來做擴展。盡量用interface作為參數(shù)類型。

    2. ThreadLocal類,定義了一個變量的本地副本,與原有變量隔離,作用類似static變量,只是不共享。可用set添加變量,get去獲取變量。變量類型不限制。

    3. Eclipse plug in開發(fā)中可以實現(xiàn)IRuntimeClasspathProvider接口。可以提供用launch configuration去獲得unresolvedresolved classpath。開發(fā)人員可以在resolveClasspath方法中加入自定義的classpath。實現(xiàn)類需要注冊在extension point中。

          /**

           *Computesandreturnsanunresolvedclasspathforthegivenlaunchconfiguration.

           *Variableandcontainerentriesarenotresolved.

           *

           *@paramconfigurationlaunchconfiguration

           *@returnunresolvedpath

           *@exceptionCoreExceptionifunabletocomputeapath

           */

          public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException;

         

          /**

           *Returnstheresolvedpathcorrespondingtothegivenpath,inthecontextofthe

           *givenlaunchconfiguration.Variableandcontainerentriesareresolved.Thereturned

           *(resolved)pathneednothavethesamenumberofentriesasthegiven(unresolved)

           *path.

           *

           *@paramentriesentriestoresolve

           *@paramconfigurationlaunchconfigurationcontexttoresolvein

           *@returnresolvedpath

           *@exceptionCoreExceptionifunabletoresolveapath

           */

          public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException;

    A provider extension is defined in plugin.xml. Following is an example definition of a runtime classpath provider extension.

     <extension point="org.eclipse.jdt.launching.classpathProviders">
       <classpathProvider 
          id="com.example.ExampleClasspathProvider"
          class="com.example.ExampleClasspathProviderImpl"
       </classpathProvider>
     </extension>

    4. plug in 開發(fā)中可以用JavaRuntime 去得到運行環(huán)境的信息。        
    IRuntimeClasspathProvider provider = JavaRuntime
    .getClasspathProvider(configuration);

    其中configurationILaunchConfiguration類型的。

    4. Eclipse plug in開發(fā)中獲取文件。兩種解決辦法:1.plug in實例中讀取文件的URL,然后用FileLocator把這個URL轉(zhuǎn)化成文件路徑;2.直接利用FileLocatorfind方法。

    方法1

                //filepath 是需要定位的文件

                String filepath = "/bin/resources/test.jar";

                //instance 是當前plug in的實例

                URL url = instance.getBundle().getEntry(filepath);

                String path = null;

                try {

                      path = FileLocator.resolve(url).getPath();

                } catch (IOException e) {

                      // TODO Auto-generated catch block

                      e.printStackTrace();

                }

                returnnew Path(path);

          }

    方法2

                String filepath = "/bin/resources/test.jar";

                URL url = FileLocator.find(instance.getBundle(),new Path(filepath),null);

                try {

                      path = FileLocator.resolve(url).getPath();

                } catch (IOException e) {

                      // TODO Auto-generated catch block

                      e.printStackTrace();

                }

    5. 可以利用JarOutputStream來寫jar包。必須為JarOutputStream 實例創(chuàng)建至少一個Entry,可以調(diào)用putNextEntry方法。

                Manifest mf = new Manifest();

                JarOutputStream jar = new JarOutputStream(new FileOutputStream("MainTest.jar")mf);

                Properties properties = new Properties();

                jar.putNextEntry(new ZipEntry("MainTest.property"));

                properties.store(jar, "this is a test");

                jar.close();

    6. 得到IJavaModle

          IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace()

                                  .getRoot());

          IJavaProject[] projects = model.getJavaProjects();

          IPackageFragmentRoot[] roots = projects[i]                                          .getPackageFragmentRoots();

     然后可以依次得到對應(yīng)elements


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


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

    posts - 6, comments - 8, trackbacks - 0, articles - 1

    Copyright © 遲來的兵

    主站蜘蛛池模板: 日韩免费观看视频| 国产成人人综合亚洲欧美丁香花| 国产又长又粗又爽免费视频 | 免费人妻无码不卡中文字幕系| 亚洲精品色播一区二区| 亚洲福利视频一区二区三区| 亚洲中文字幕久久精品无码喷水| 国产在线19禁免费观看国产| 四虎永久在线精品免费网址| 18禁美女黄网站色大片免费观看| 男女拍拍拍免费视频网站| 国产精品成人亚洲| 亚洲中文无码永久免费| 亚洲国产精品综合久久2007| 亚洲av片劲爆在线观看| 精品亚洲永久免费精品| 久久久久亚洲av成人无码电影 | 亚洲a级片在线观看| 99亚洲精品高清一二区| 亚洲色精品vr一区二区三区| 亚洲另类少妇17p| 亚洲人成色77777在线观看大| 国产成人无码a区在线观看视频免费| 在线观看日本免费a∨视频| 亚洲成人免费网址| 真实国产乱子伦精品免费| 毛片无码免费无码播放| 日韩人妻一区二区三区免费| 另类免费视频一区二区在线观看| 两个人看的www免费视频| 成人A毛片免费观看网站| 91视频免费观看| 国内少妇偷人精品视频免费| 一个人看的www免费视频在线观看 一个人免费视频观看在线www | 亚洲国产精品无码中文lv| 中文字幕精品三区无码亚洲 | 精品久久久久成人码免费动漫| 免费观看的毛片大全| 国产卡一卡二卡三免费入口| 台湾一级毛片永久免费| 在线视频免费观看www动漫|