1

为了实现模块化方法(类似于 oSGI),我正在使用 spring 插件框架(https://github.com/spring-projects/spring-plugin),我提供了一个特定的接口作为我的插件实现的扩展点实施

首先需要做两件事:扫描类路径中的所有类并获取实现该接口的实现(扩展点)

第二:将那些实现bean添加到应用程序上下文中

第一部分 m 能够实现作为 spring 插件提供 PluginRegistry 查找给定插件类型的所有实现

registry.getPluginFor(ProductType.SOFTWARE);
// Returns the first plugin supporting SOFTWARE, or DefaultPlugin if none found
registry.getPluginFor(ProductType.SOFTWARE, new DefaultPlugin());
// Returns all plugins supporting HARDWARE, throwing the given exception if none found
registry.getPluginsFor(ProductType.HARDWARE, new MyException("Damn!");

第二部分:我现在应该如何将此 bean 列表注册到应用程序上下文,而不会引起任何冲突

4

1 回答 1

1

可能想看看这个,为你的扩展点提供一个特定的接口,然后允许插件实现它们可能是一个更好的主意。在本文中,我将描述一种使用 Annotations 和 Spring 实现此目的的方法

https://devnotesblog.wordpress.com/2011/03/20/adding-plug-ins-to-your-application-with-spring/

于 2018-06-06T10:18:47.270 回答