<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 遲來的兵 閱讀(561) 評論(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 是當(dāng)前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 © 遲來的兵

    主站蜘蛛池模板: 久久精品国产精品亚洲下载 | 国产亚洲精品第一综合| 7m凹凸精品分类大全免费| 亚洲国产精品高清久久久| 国产在线国偷精品免费看| 永久亚洲成a人片777777| 国产免费高清69式视频在线观看 | 亚洲国产成人九九综合| 啦啦啦完整版免费视频在线观看| 亚洲国产精久久久久久久| 一级成人a毛片免费播放| 亚洲电影中文字幕| 黄色网址免费观看| 亚洲日韩中文字幕无码一区| 亚洲欧洲自拍拍偷午夜色| 日韩电影免费观看| 亚洲AV无码专区国产乱码电影| 青青操免费在线观看| 亚洲国产精品不卡在线电影| 欧洲乱码伦视频免费| 在线观看亚洲AV日韩A∨| 暖暖在线日本免费中文| 特色特黄a毛片高清免费观看| 亚洲熟妇av一区二区三区| 国产精成人品日日拍夜夜免费| 91亚洲国产成人久久精品 | 春意影院午夜爽爽爽免费| 国产亚洲精品激情都市| 99久热只有精品视频免费观看17| 亚洲人成综合在线播放| 国产在线播放免费| 国产成人免费AV在线播放| 亚洲无砖砖区免费| 免费亚洲视频在线观看| 免费无码又爽又刺激网站直播| 亚洲午夜电影在线观看高清| 国产传媒在线观看视频免费观看 | 亚洲国产成人无码av在线播放| 又黄又大又爽免费视频| 久久青草免费91线频观看不卡 | 亚洲AV永久无码精品一福利|