【发布时间】:2013-10-07 11:35:21
【问题描述】:
我想在 OSGi 包中查找所有使用我的自定义注释进行注释的类,
必须在包本身或从另一个包中进行实际扫描,
我曾尝试使用ClassPathScanningCandidateComponentProvider,但它会导致异常:
java.io.FileNotFoundException: URL [bundleresource://38.fwk29597962/my/base/package/] cannot be resolved to absolute file path because it does not reside in the file system: bundleresource://38.fwk29597962/my/base/package/
我 99% 确定,reflections 或其他扫描库之类的解决方案也不起作用,现在不记得为什么了
我可以像这样配置组件扫描:
<context:annotation-config />
<context:component-scan base-package="my.base.package" use-default-filters="false">
<context:include-filter type="annotation" expression="path.to.my.annotation"/>
</context:component-scan>
并从 bean factory 中获得我需要的东西,但这需要将 @Scope("prototype") 添加到我所有带注释的类中,因此 spring 默认情况下不会创建单例等。
有更好的解决方案吗?
-我的注释类没有 @Component 或任何与 spring 相关的东西
-osgi 框架(eclipse Equinox 3.8)嵌入在 Web 应用程序中
- 使用 spring 3.2.3 和 gemini-blueprint 2.0.0.M02
【问题讨论】:
标签: spring annotations osgi spring-dm