我有一个问题要解决:1)我们的项目使用 Spring JavaConfig 方法(所以没有 xml 文件)2)我需要创建自定义范围,xml 中的示例如下所示:
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
<property name="scopes">
    <map>
        <entry key="workflow">
            <bean
                class="com.amazonaws.services.simpleworkflow.flow.spring.WorkflowScope" />
        </entry>
    </map>
</property>
我用 JavaConfig 弄明白了,它看起来像这样:
    @Bean
public CustomScopeConfigurer customScope () {
    CustomScopeConfigurer configurer = new CustomScopeConfigurer ();
    Map<String, Object> workflowScope = new HashMap<String, Object>();
    workflowScope.put("workflow", new WorkflowScope ());
    configurer.setScopes(workflowScope);
    return configurer;
}
如果我的假设有误,请纠正我。
3) 我需要再次将我的类注释为@Component (scope="workflow") xml 配置如下所示:
<bean id="activitiesClient" class="aws.flow.sample.MyActivitiesClientImpl" scope="workflow"/>
所以基本上问题是 - 我的假设是正确的使用 @Component (scope="workflow") 还是预期以其他方式?
谢谢