Eclipse自动插件依赖的一种配置解决方式
2013-08-15 23:30
288 查看
Eclipse的插件具有以下特点:
(1)每一个插件有自己独立的classloader
(2)插件资源的交互通过MENIFEST.MF中"Export-Package, Require-Bundle, Import-Package"等属性控制
(3)插件不能相互依赖
最近开发的系统需要进行权限控制,控制粒度到视图的定义、命令的定义等等。当系统启动的时候,需要根据配置(数据库保存)加载当前用户可用的配置,这样问题就来了:
Eclipse的插件是需要依赖的,才能引用。例如B依赖A,则B可以引用A,但A不依赖B,A不能调用B的资源。这意味着,如果A作为权限检测并加载插件配置的类,是不能引用B的类的。一种解决方案,就是A加入对B的依赖。但是当系统变大,不可能是一个开发组开发时,A怎么会知道到底有些什么插件呢?显然它不可能先知先觉。因此存在问题。
幸好,Eclipse提供了对MENIFEST文件的扩展,扩展了Eclipse-BuddyPolicy指令。
网址:http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fbundle_manifest.html 给出了此指令的介绍
The Eclipse-BuddyPolicy header is used to specify the buddy classloading policies for a bundle.The Eclipse-BuddyPolicy header must use the following syntax:
registered - indicates that the buddy mechanism will consult bundlesthat have been registered to it. Bundle willing to be registered to a particular bundle add in their manifest: "Eclipse-RegisterBuddy: <bundleSymbolicName>";
dependent - indicates that the classes/resources will be looked uptransitively in all the dependent of the bundle;
global - indicates that the classes/resources will be looked up in theglobal pool of exported package;
app - indicates that the application classloader will be consulted;
ext - indicates that the extensiont classloader will be consulted;
boot - indicates that the boot classloader will be consulted.
于是根据上述描述,在A插件MENIFEST文件中插入
指令,然后B引用A,A不需要引用B,但是在A中需要调用的B的资源,需要在B中Export出来。这样,就可以在A中使用B的资源了。
通过这种方式,实现了根据用户角色,过滤界面的功能,很好地实现了界面部分权限的控制。
(1)每一个插件有自己独立的classloader
(2)插件资源的交互通过MENIFEST.MF中"Export-Package, Require-Bundle, Import-Package"等属性控制
(3)插件不能相互依赖
最近开发的系统需要进行权限控制,控制粒度到视图的定义、命令的定义等等。当系统启动的时候,需要根据配置(数据库保存)加载当前用户可用的配置,这样问题就来了:
Eclipse的插件是需要依赖的,才能引用。例如B依赖A,则B可以引用A,但A不依赖B,A不能调用B的资源。这意味着,如果A作为权限检测并加载插件配置的类,是不能引用B的类的。一种解决方案,就是A加入对B的依赖。但是当系统变大,不可能是一个开发组开发时,A怎么会知道到底有些什么插件呢?显然它不可能先知先觉。因此存在问题。
幸好,Eclipse提供了对MENIFEST文件的扩展,扩展了Eclipse-BuddyPolicy指令。
网址:http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fbundle_manifest.html 给出了此指令的介绍
The Eclipse-BuddyPolicy header is used to specify the buddy classloading policies for a bundle.The Eclipse-BuddyPolicy header must use the following syntax:
Eclipse-BuddyPolicy ::= ( policy-name ) ( ',' policy-name ) * policy-name ::= ( 'dependent' | 'global' | 'registered' | 'app' | 'ext' | 'boot' | 'parent' )
registered - indicates that the buddy mechanism will consult bundlesthat have been registered to it. Bundle willing to be registered to a particular bundle add in their manifest: "Eclipse-RegisterBuddy: <bundleSymbolicName>";
dependent - indicates that the classes/resources will be looked uptransitively in all the dependent of the bundle;
global - indicates that the classes/resources will be looked up in theglobal pool of exported package;
app - indicates that the application classloader will be consulted;
ext - indicates that the extensiont classloader will be consulted;
boot - indicates that the boot classloader will be consulted.
于是根据上述描述,在A插件MENIFEST文件中插入
Eclipse-BuddyPolicy: global
指令,然后B引用A,A不需要引用B,但是在A中需要调用的B的资源,需要在B中Export出来。这样,就可以在A中使用B的资源了。
通过这种方式,实现了根据用户角色,过滤界面的功能,很好地实现了界面部分权限的控制。
相关文章推荐
- Eclipse自动插件依赖的一种配置解决方式
- Eclipse中Android项目R.java文件不会自动生成的一种情况的解决方式
- 解决在Eclipse中配置JBoss、Tomcat等插件时遇到的问题 (转)
- 解决eclipse使用lombok插件问题!最正确的解决方式!
- Eclipse配置PyDev插件的两种方式
- Eclipse导入颜色配置文件导致代码自动提示功能失效的解决方法
- eclipse代码自动提示设置、如何配置eclipse的代码自动提示功能(同时解决自动补全变量名的问题)?
- 比较全面的Eclipse配置详解(包括智能提示设置、智能提示插件修改,修改空格自动上屏、JDK配置、各种快捷键列表……) Eclipse编辑器基本设置 1、添加行号 在边缘处右
- Ubuntu系统下eclipse配置mapreduce插件常见错误和解决办法汇总
- myeclipse中eclipse PHP插件的安装及代码自动提示配置
- eclipse安装ADT插件重启后不显示Android SDK Manager和Android Virtual Device Manager图标的一种解决办法
- eclipse安装ADT插件重启后不显示Android SDK Manager和Android Virtual Device Manager图标的一种解决办法
- 比较全面的Eclipse配置详解(包括智能提示设置、智能提示插件修改,修改空格自动上屏、JDK配置、各种快捷键列表……)
- 安装配置hadoop和eclipse插件遇到的坑和解决办法
- eclipse配置spket插件不提示解决办法
- eclipse4.6安装tomcate插件 Eclipse4.6(neno)配置Tomcat插件的两种方式
- 关于eclipse4.7 OXYGEN版本无法在线安装插件的解决方式
- eclipse 用link方式 离线安装 maven 插件,eclipse配置maven
- 1.Maven+SpringMVC+Eclipse软件安装配置,Maven报插件错误,Eclipse总是卡死的解决办法,导入一个maven工程后 一直显示importing maven project
- 解决在Eclipse中配置JBoss、Tomcat等插件时遇到的问题