eclipse扩展点
编码Eclipse扩展点评估有点冗长,而且很少能自我解释。 当我最近忙于自己忙于这个话题时,我写了一个小助手,目的是减少通用编程步骤的样板代码,同时增加开发指导和可读性。
它原来是不容易找到一个表现的解决方案,其中所有的使用情况下,我可以从目前的项目中提取匹配。 因此,我认为分享我的发现并看看其他人对此有何想法是一个好主意。
Eclipse扩展点评估
考虑一个简单的扩展点定义,该定义支持扩展的无限贡献。 这些贡献中的每一个都应该提供Runnable
实现来执行某种操作:
通常的评估任务是检索所有贡献,创建可执行扩展并调用以下每个扩展 :
public class ContributionEvaluation {
private static final String EP_ID
= "com.codeaffine.post.contribution";
public void evaluate() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] elements
= registry.getConfigurationElementsFor( EP_ID );
Collection<Runnable> contributions = new ArrayList<Runnable>();
for( IConfigurationElement element : elements ) {
Object extension;
try {
extension = element.createExecutableExtension( "class" );
} catch( CoreException