Xiè*_*léi 5 java spring jsr330
或者,我可以org.springframework.beans.factory.config.Scope使用特定@Scope注释的注释绑定自定义接口实现吗?
例如,我已经定制了一个新的范围类型:
@javax.inject.Scope @Retention(RUNTIME)
@interface Conversation {}
class ConversationScope implements Scope { ... }
class ConversationScopeConfigurer extends BeanFactoryPostProcessor
{ beanFactory.registerScope("conversation", new ConversationScope()); }
Run Code Online (Sandbox Code Playgroud)
现在我想用它,
@Component
@Conversation
class Topic { ... }
Run Code Online (Sandbox Code Playgroud)
代替,
@Component
@org.springframework.context.annotation.Scope("conversation")
class Topic { ... }
Run Code Online (Sandbox Code Playgroud)
可能吗?
在spring-context中有类似"AnnotationPostProcessor"的东西吗?
似乎可以通过注册自定义范围解析器来实现<context:component-scan>
例如:
<context:component-scan base-package="com.company" scope-resolver="org.springframework.context.annotation.Jsr330ScopeMetadataResolver" />
Run Code Online (Sandbox Code Playgroud)
如果您需要更多地定制解决方案,请参阅JSR-299注释的桥接示例.
| 归档时间: |
|
| 查看次数: |
2632 次 |
| 最近记录: |