Asktalk

天行健,君子以自强不息!
posts - 21, comments - 79, trackbacks - 0, articles - 2
  BlogJava :: 首页 ::  :: 联系 :: 聚合  :: 管理

Eclipse启动机制(1)

Posted on 2007-12-22 16:33 Asktalk 阅读(4853) 评论(3)  编辑  收藏 所属分类: Eclipse/Swt/Jface
 

最近我一直在研究Eclipse的架构体系,下面我们就来看看Eclipse的启动机制吧

1Eclipse源代码       
eclipse-sourceBuild-srcIncluded-3.3.1.1.zip   
版本:3.3.1.1        大小:95.058MB
下载地址:http://download.eclipse.org/eclipse/downloads

解压后的目录结构如下图,通过执行build.bat可以编译出完整的Eclipse-sdk-3.3.1.1运行包,和我们网上下载的一样。但是这个过程可能需要一个小时左右的时间,要有耐性哦。所有的插件工程目录在plugins中,我们只需要导入现有工程即可把plugins下所有工程导入。

下面我们就先来研究一下Eclipse最核心的部分,就是RCP部分必须的插件。下面我列出了Eclipse RCP需要的插件。

将这些代码解压缩到一个空目录里,然后导入到Source InsightProject里。     

二、Eclipse启动过程

首先我们从Eclipse的启动过程开始分析。

1exe部分的引导

eclipse.exeEclipse的启动文件,是与平台相关的可执行文件。它的功能比较简单,主要是加载startup.jar文件,代码在Eclipse源代码的eclipse-sourceBuild-srcIncluded-3.3.1.1"plugins"org.eclipse.platform"launchersrc.zip,对应多个平台。对于win32平台,你可以直接运行win32目录下的build.bat文件来编译得到它(需要安装C编译器)。

2java代码部分的执行入口

对于Eclipse 3.3.1.1版本来说,如果在eclipse目录下没有找到startup.jar,则直接执行org.eclipse.equinox.launcher.Main.main方法。

当然我们可以在eclipse目录下定制我们自己的启动引导包startup.jar,现在Eclipse 3.3.1.1好像已经不建议这样做了。如果有这个包,那么这个包将是java代码的执行入口,你可以在命令行下运行java -jar startup.jar命令来启动Eclipse。它的入口是org.eclipse.core.launcher.Main类,这个类最终执行的还是org.eclipse.equinox.launcher.Main.main方法。它对应的源代码在org.eclipse.equinox.launcher目录下的Main.java。关于此文件的定制详细信息请查看eclipse-sourceBuild-srcIncluded-3.3.1.1"plugins"org.eclipse.platform"launchersrc.zip中的eclipse.c的注解部分。

我们从main函数往后跟踪,找到basicRun方法,这个是启动的主要部分。

    protectedvoid basicRun(String[] args) throws Exception {

        System.getProperties().put("eclipse.startTime", Long.toString(System.currentTimeMillis())); //$NON-NLS-1$

        commands = args;

        String[] passThruArgs = processCommandLine(args);

       

        if (!debug)

           // debug can be specified as system property as well

           debug = System.getProperty(PROP_DEBUG) != null;

        setupVMProperties();     //设置VM属性

        processConfiguration();   //读取configuration/config.ini配置文件

       

        // need to ensure that getInstallLocation is called at least once to initialize the value.

        // Do this AFTER processing the configuration to allow the configuration to set

        // the install location. 

        getInstallLocation();

        // locate boot plugin (may return -dev mode variations)

        URL[] bootPath = getBootPath(bootLocation);

        

        //Set up the JNI bridge. We need to know the install location to find the shared library

        setupJNI(bootPath);

       

        //ensure minimum Java version, do this after JNI is set up so that we can write an error message

        //with exitdata if we fail.

        if (!checkVersion(System.getProperty("java.version"), System.getProperty(PROP_REQUIRED_JAVA_VERSION))) //$NON-NLS-1$

            return;

       

        setSecurityPolicy(bootPath); //设置执行权限

        // splash handling is done here, because the default case needs to know

        // the location of the boot plugin we are going to use

        handleSplash(bootPath);

        beforeFwkInvocation();

        invokeFramework(passThruArgs, bootPath);    //启动Eclipse内核

    }


评论

# re: Eclipse启动机制(1)[未登录]  回复  更多评论   

2007-12-25 14:09 by washington
好东西,收藏了。谢谢。

# re: Eclipse启动机制(1)  回复  更多评论   

2008-01-30 10:52 by wzl
不错,学到一些东西

# re: Eclipse启动机制(1)  回复  更多评论   

2008-02-23 09:38 by Java.net
那么多项目,你是怎么导进eclipse的?一个一个导?

只有注册用户登录后才能发表评论。


网站导航: