Java 是否可以用JSR-330@Scope变体替换Spring@Scope(“请求”)呢?

Java 是否可以用JSR-330@Scope变体替换Spring@Scope(“请求”)呢?,java,spring,jsr330,Java,Spring,Jsr330,或者,我可以将org.springframework.beans.factory.config.Scope接口的自定义实现绑定到特定的@Scope注释吗 例如,我自定义了一个新的范围类型: @javax.inject.Scope @Retention(RUNTIME) @interface Conversation {} class ConversationScope implements Scope { ... } class ConversationScopeConfigurer ext

或者,我可以将
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上下文中是否有类似“AnnotationPostProcessor”的内容?

似乎可以通过向

例如:

<context:component-scan base-package="com.company" scope-resolver="org.springframework.context.annotation.Jsr330ScopeMetadataResolver" />


如果您需要进一步定制您的解决方案,请参见此示例。

如果在
中无法开箱即用,则可能根本无法使用。