是否可以用 JSR-330 @Scope 变体替换 Spring @Scope(“request”)?
或者,我可以将 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()); }
现在我想将它用作,
@Component
@Conversation
class Topic { ... }
而不是,
@Component
@org.springframework.context.annotation.Scope("conversation")
class Topic { ... }
可以吗?
spring-context 中有类似“AnnotationPostProcessor”的东西吗?
Or, can I bound a custom implementation of org.springframework.beans.factory.config.Scope
interface with a specific @Scope
-annotated annotation?
For example, I have customized a new scope type:
@javax.inject.Scope @Retention(RUNTIME)
@interface Conversation {}
class ConversationScope implements Scope { ... }
class ConversationScopeConfigurer extends BeanFactoryPostProcessor
{ beanFactory.registerScope("conversation", new ConversationScope()); }
Now I want to use it as,
@Component
@Conversation
class Topic { ... }
instead of,
@Component
@org.springframework.context.annotation.Scope("conversation")
class Topic { ... }
Is it possible?
Is there something like "AnnotationPostProcessor" in spring-context?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎可以通过注册 自定义范围解析器与您的
例如:
另请参阅 JSR-299 注释的桥梁(如果您需要进一步自定义您的解决方案)。
It seems to be possible by registering a custom scope resolver with your
<context:component-scan>
For example:
See also this example of a bridge for JSR-299 annotations if you need to customize your solution a little bit more.