使用Equinox P2 实现RCP程序更新
2013-12-18 11:12
387 查看
Eclipse的软件管理很方便,尤其是在E3.4以及以后的版本中使用了Equinox P2框架以后,本文将如何使用Equinox P2框架实现RCP 程序的软件安装、更新、管理等进行介绍。
使用旧的UpdateManagerUI 实现更新RCP程序(E3.4以前)请见:
http://www.ibm.com/developerworks/cn/opensource/os-ecl-rcpum/
Equinox P2方式进行Eclipse插件安装介绍请见:
http://www.ibm.com/developerworks/cn/opensource/os-eclipse-equinox-p2/index.html
Equinox P2 进行Update另见:
http://www.vogella.de/articles/EclipseP2Update/article.html#firstfeature_category
http://wiki.eclipse.org/Equinox/p2/Adding_Self-Update_to_an_RCP_Application
http://www.ralfebert.de/blog/eclipsercp/p2_updates_tutorial/
Equinox P2
Placid Systems写道
插件更新设备在 Eclipse V3.4 中已经完全重写,它现在使用 Equinox p2 框架代替了原来的更新管理器。Equinox p2 是一个新的、非常高级的配置系统,用于安装、搜索和管理 Eclipse 安装,并且比以前的更新管理器更容易使用。
使用Equinox P2框架实现RCP 更新,首先需要获得P2相关的插件。Eclipse SDK版本都会包这些插件,如果您的版本中没有,那么请到eclipse.org上自行下载,或者使用Eclipse的Installer New Software功能在线更新。
主要用到的插件为org.eclispe.equinox.p2.ui以及其依赖的其他插件。
Feature
Feature用来组织插件,更新时需要使用Feature。RCP程序都会包含一个基础Feature——org.eclipse.rcp,它包含了 RCP程序需要的基础插件,内容为见eclipse目录下 features/org.eclipse.rcp_3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11。
先创建一个用于更新的RCP程序,org.eclipse.update.example。具体过程略。运行效果为:
下面来创建一个Feature Project。
File——New——Project——Plug-in Development——Feature Project,Feature工程一般命名为XXXX.featue,主要目的是为了与Plug-in工程区别开,但是Feature的ID却不一定以 feature结尾。
Feature Initialize Plug-in设置,这里设置为org.eclipse.update.example和org.eclipse.ui.forms。
配置Product
先给org.eclipse.update.example添加一个product configuration,添加完毕以后,进行product配置。在product中有很多依赖插件,没有这些插件,RCP程序将无法启动。默认情况 下product是基于plug-in的,在这里需要修改为基于feature。修改位置:
这时候以feature为依赖项的product就配置好了。但是运行提示失败,因为还没有给它添加以来的feature,在product的 Dependencies中添加我们刚刚创建feature“org.eclipse.update.example”。具体原因和步骤可以参考“ Equinox P2方式进行Eclipse插件”。
现在我们让插件依赖于feature,所以在对应的feature中必须定义包含的插件,不然RCP会因为找不到依赖项而无法启动。
配置Feature
feature的配置包括以下几个方面:
1,包含插件:这些插件就是上面prodcut的依赖项
2,包含feature:如果使用了eclipse定义的基本feature,那么使用它们会减少工作量。主要是向feature中添加plug-in的 工作量
3,Update site:更新源URL,可以是一个网址,也可以使本地文件,这里使用本地文件测试。
首先在feature.xml的Included Feature中添加 org.eclispe.rcp,org.eclipse.equinox.p2.user.ui,org.eclipse.help,这样它们所包含的 插件就无需再添加到包含插件中了。接着在feature.xml的Plug-in中添加org.eclipse.update.example。更新源 URL的设置比较简单,在feature.xml的Overview中,进行设置。注意URL的格式,这里使用本地文件E:/updates。
4, Dependencies:Feature自己也有依赖项。这里添加org.eclipse.ui, org.eclipse.core.runtime. org.eclipse.equinox.p2.ui.
如果配置正确,这时候再启动org.eclipse.update.example(使用product),就会发现多出一些菜单项和首选项了。
更新相关首选项:
这时候更新功能是不能用的,需要继续配置。
注意这时候Export Product时一定要记得选中Generate Metadata Repository选项,否则Update功能不能使用。大家可以发现选中与不选中时,产生的config.ini文件是不一样的。
配置Equinox P2
P2提供了自定义Update UI的功能,你可以通过扩展 org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy来实现UI的定制。
比如UpdatePolicy:
Java代码
package org.eclipse.update.example.policy;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
/**
* @author salever
*
*/
public class UpdatePolicy extends Policy{
public UpdatePolicy() {
// Disable the ability to manipulate repositories.
setRepositoryManipulator(null);
// View everything in the repository.
IUViewQueryContext context =
new IUViewQueryContext(IUViewQueryContext.AVAILABLE_VIEW_FLAT);
context.setVisibleAvailableIUProperty(null);
setQueryContext(context);
}
}
然后在Activtor中使用这个policy.
Java代码
public void start(BundleContext context) throws Exception {
plugin = this;
registration = context.registerService(Policy.class.getName(),
new UpdatePolicy(), null);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
context.ungetService(registration.getReference());
registration = null;
}
同时你还可以使用扩展点org.eclipse.ui.about.installationPages来定义软件安装页面。
配置Update Site
New——Plug-in Development——Update Site Project,然后添加Category和要更新的Feature。
点击上面的Build按钮,在工程目录下会生成更新源文件,将这些文件复制到update site目录中。
稍后会给出实例源码。
注意Eclipse3.5 下使用Equinox p2方式更新Feature时有2种情况,一种是针对新安装的插件的更新,另一种是针对打包时就有的插件的更新,两种方式下更新源文件的制作方式不同。
1,新安装的插件的更新:给插件对应的Feature建立category.xml,然后使用这个XML导出metadata repository,就可以作为更新源,也可以使用上面的Update Site Project方法。
2,打包时就有的feature则麻烦一些,必须使用每次打包时生成的repository文件夹下的内容作为更新源,单独导出feature是无效的。
demo_ws.rar (66 KB)
下载次数: 388
使用旧的UpdateManagerUI 实现更新RCP程序(E3.4以前)请见:
http://www.ibm.com/developerworks/cn/opensource/os-ecl-rcpum/
Equinox P2方式进行Eclipse插件安装介绍请见:
http://www.ibm.com/developerworks/cn/opensource/os-eclipse-equinox-p2/index.html
Equinox P2 进行Update另见:
http://www.vogella.de/articles/EclipseP2Update/article.html#firstfeature_category
http://wiki.eclipse.org/Equinox/p2/Adding_Self-Update_to_an_RCP_Application
http://www.ralfebert.de/blog/eclipsercp/p2_updates_tutorial/
Equinox P2
Placid Systems写道
插件更新设备在 Eclipse V3.4 中已经完全重写,它现在使用 Equinox p2 框架代替了原来的更新管理器。Equinox p2 是一个新的、非常高级的配置系统,用于安装、搜索和管理 Eclipse 安装,并且比以前的更新管理器更容易使用。
使用Equinox P2框架实现RCP 更新,首先需要获得P2相关的插件。Eclipse SDK版本都会包这些插件,如果您的版本中没有,那么请到eclipse.org上自行下载,或者使用Eclipse的Installer New Software功能在线更新。
主要用到的插件为org.eclispe.equinox.p2.ui以及其依赖的其他插件。
Feature
Feature用来组织插件,更新时需要使用Feature。RCP程序都会包含一个基础Feature——org.eclipse.rcp,它包含了 RCP程序需要的基础插件,内容为见eclipse目录下 features/org.eclipse.rcp_3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11。
先创建一个用于更新的RCP程序,org.eclipse.update.example。具体过程略。运行效果为:
下面来创建一个Feature Project。
File——New——Project——Plug-in Development——Feature Project,Feature工程一般命名为XXXX.featue,主要目的是为了与Plug-in工程区别开,但是Feature的ID却不一定以 feature结尾。
Feature Initialize Plug-in设置,这里设置为org.eclipse.update.example和org.eclipse.ui.forms。
配置Product
先给org.eclipse.update.example添加一个product configuration,添加完毕以后,进行product配置。在product中有很多依赖插件,没有这些插件,RCP程序将无法启动。默认情况 下product是基于plug-in的,在这里需要修改为基于feature。修改位置:
这时候以feature为依赖项的product就配置好了。但是运行提示失败,因为还没有给它添加以来的feature,在product的 Dependencies中添加我们刚刚创建feature“org.eclipse.update.example”。具体原因和步骤可以参考“ Equinox P2方式进行Eclipse插件”。
现在我们让插件依赖于feature,所以在对应的feature中必须定义包含的插件,不然RCP会因为找不到依赖项而无法启动。
配置Feature
feature的配置包括以下几个方面:
1,包含插件:这些插件就是上面prodcut的依赖项
2,包含feature:如果使用了eclipse定义的基本feature,那么使用它们会减少工作量。主要是向feature中添加plug-in的 工作量
3,Update site:更新源URL,可以是一个网址,也可以使本地文件,这里使用本地文件测试。
首先在feature.xml的Included Feature中添加 org.eclispe.rcp,org.eclipse.equinox.p2.user.ui,org.eclipse.help,这样它们所包含的 插件就无需再添加到包含插件中了。接着在feature.xml的Plug-in中添加org.eclipse.update.example。更新源 URL的设置比较简单,在feature.xml的Overview中,进行设置。注意URL的格式,这里使用本地文件E:/updates。
4, Dependencies:Feature自己也有依赖项。这里添加org.eclipse.ui, org.eclipse.core.runtime. org.eclipse.equinox.p2.ui.
如果配置正确,这时候再启动org.eclipse.update.example(使用product),就会发现多出一些菜单项和首选项了。
更新相关首选项:
这时候更新功能是不能用的,需要继续配置。
注意这时候Export Product时一定要记得选中Generate Metadata Repository选项,否则Update功能不能使用。大家可以发现选中与不选中时,产生的config.ini文件是不一样的。
配置Equinox P2
P2提供了自定义Update UI的功能,你可以通过扩展 org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy来实现UI的定制。
比如UpdatePolicy:
Java代码
package org.eclipse.update.example.policy;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
/**
* @author salever
*
*/
public class UpdatePolicy extends Policy{
public UpdatePolicy() {
// Disable the ability to manipulate repositories.
setRepositoryManipulator(null);
// View everything in the repository.
IUViewQueryContext context =
new IUViewQueryContext(IUViewQueryContext.AVAILABLE_VIEW_FLAT);
context.setVisibleAvailableIUProperty(null);
setQueryContext(context);
}
}
然后在Activtor中使用这个policy.
Java代码
public void start(BundleContext context) throws Exception {
plugin = this;
registration = context.registerService(Policy.class.getName(),
new UpdatePolicy(), null);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
context.ungetService(registration.getReference());
registration = null;
}
同时你还可以使用扩展点org.eclipse.ui.about.installationPages来定义软件安装页面。
配置Update Site
New——Plug-in Development——Update Site Project,然后添加Category和要更新的Feature。
点击上面的Build按钮,在工程目录下会生成更新源文件,将这些文件复制到update site目录中。
稍后会给出实例源码。
注意Eclipse3.5 下使用Equinox p2方式更新Feature时有2种情况,一种是针对新安装的插件的更新,另一种是针对打包时就有的插件的更新,两种方式下更新源文件的制作方式不同。
1,新安装的插件的更新:给插件对应的Feature建立category.xml,然后使用这个XML导出metadata repository,就可以作为更新源,也可以使用上面的Update Site Project方法。
2,打包时就有的feature则麻烦一些,必须使用每次打包时生成的repository文件夹下的内容作为更新源,单独导出feature是无效的。
demo_ws.rar (66 KB)
下载次数: 388
相关文章推荐
- 使用RCP组件实现程序在线升级更新
- (转)使用RCP组件实现程序在线升级更新
- 使用pclzip实现的在线更新核心程序,远程下载zip更新包
- 在Mac Cocoa程序里使用多个xib,实现多个窗口切换
- 使用jQuery实现一个类似GridView的编辑,更新,取消和删除的功能
- Android手机平板两不误,使用Fragment实现兼容手机和平板的程序
- 一段软件更新程序(使用WinRar压缩包)
- 使用TCP/IP协议实现聊天程序
- 微信小程序例子——使用text组件实现转义符换行
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- struts2:使用struts2实现之前的MVC程序
- 使用spring-loaded开源项目,实现java程序和web应用的热部署
- 使用.net反射机制实现 “热”更新动态库(dll文件)
- 使用android自带的DownloadManager来实现版本更新
- 1.通过使用handler 和 runnable 实现动态程序启动界面
- 使用Visual Studio(VS)开发Qt程序代码提示功能的实现
- 使用SQLCOMMAND实现批量更新
- 使用MFC类库实现回声程序
- 原创:微信小程序+WEB使用JS实现注册【60s】倒计时功能
- Android异步处理一:使用Thread+Handler实现非UI线程更新UI界面