<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開發
    1. interface來定義系統對外提供的服務,有抽象類來做擴展。盡量用interface作為參數類型。

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

    3. Eclipse plug in開發中可以實現IRuntimeClasspathProvider接口。可以提供用launch configuration去獲得unresolvedresolved classpath。開發人員可以在resolveClasspath方法中加入自定義的classpath。實現類需要注冊在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 開發中可以用JavaRuntime 去得到運行環境的信息。        
    IRuntimeClasspathProvider provider = JavaRuntime
    .getClasspathProvider(configuration);

    其中configurationILaunchConfiguration類型的。

    4. Eclipse plug in開發中獲取文件。兩種解決辦法:1.plug in實例中讀取文件的URL,然后用FileLocator把這個URL轉化成文件路徑;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 實例創建至少一個Entry,可以調用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();

     然后可以依次得到對應elements


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


    網站導航:
     

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

    Copyright © 遲來的兵

    主站蜘蛛池模板: 亚洲毛片免费视频| 久久精品亚洲一区二区| 国产成人亚洲综合一区| 免费观看黄色的网站| 亚洲黄色网址在线观看| 精品无码国产污污污免费网站 | 无人在线直播免费观看| 亚洲精品中文字幕无码AV| 免费观看激色视频网站(性色) | 亚洲gv猛男gv无码男同短文| 少妇性饥渴无码A区免费 | 亚洲成av人片天堂网老年人| 黄色a级免费网站| 国产啪亚洲国产精品无码| v片免费在线观看| 国产∨亚洲V天堂无码久久久| 日本高清高色视频免费| 亚洲欧洲自拍拍偷午夜色| 欧亚精品一区三区免费| 亚洲av无码专区首页| 亚洲无码视频在线| 国产精品免费AV片在线观看| 亚洲欧洲自拍拍偷午夜色| 日本xxwwxxww在线视频免费| 免费无遮挡无码视频在线观看 | 性生交片免费无码看人| 久久久久久亚洲精品无码| 亚洲精品亚洲人成在线观看下载| 巨胸喷奶水视频www免费视频| 91久久亚洲国产成人精品性色| 一个人看www在线高清免费看 | 国产免费一级高清淫曰本片 | 亚洲人色婷婷成人网站在线观看| 国产一级片免费看| 中中文字幕亚洲无线码| 啊v在线免费观看| 最近免费中文字幕大全高清大全1| 亚洲一区二区三区国产精华液| 亚洲午夜精品一级在线播放放 | 野花高清在线观看免费完整版中文| 国产精品亚洲lv粉色|