做项目的时候RCP程序在eclipse调试环境下面运行正常,但是打包成RCP product后却运行不正常了。利用RCP远程调试,发现:
IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(ExtensionPointId);
无法取得扩展点信息,原因是要在plugin.xml中的Extension Points界面中增加扩展点信息,点击add按钮,就会在工程schema文件夹下面生成.exsd文件。
有了这个文件,plugin.xml中自定义的扩展点才会被识别。
Plug-in with extension point (plugin_id ):
plugin.xml > Extension Points > Add > ID=point_id , Name
point_id .exsd > Definition > New Element > Name=element_name
element_name > New Attribute > Name=class_name , Type=java, Implements=package_name .InterfaceName > Implements
point_id .exsd > Definition > extension > New Choice > right-click > New > element_name
plugin.xml > Runtime > Exported Packages > Add > package_name
Activator.start (for example):
IConfigurationElement[] elements = Platform.getExtensionRegistry ().getConfigurationElementsFor ("plugin_id.point_id "); for (IConfigurationElement e : elements) { Object o = e.createExecutableExtension ("class_name "); if (o instanceof InterfaceName) { } }
Plug-in with extension:
MANIFEST.MF > Dependencies > Required Plug-ins > plugin with extension point
MANIFEST.MF > Extensions > Add > plugin_id.point_id > right-click > New > element_name > class_name
Add plug-in with extension to run configuration.