【问题标题】:Is there a way to make a Spring bean's "request" scope work with Mule?有没有办法让 Spring bean 的“请求”范围与 Mule 一起工作?
【发布时间】:2014-03-03 15:17:19
【问题描述】:

有没有办法让 Spring bean 的“请求”范围与 Mule 一起工作?根据 Spring 文档,“请求”和“会话”范围“仅在 Web 感知 Spring ApplicationContext 的上下文中有效”。但是应该有一种方法可以让 Mule ESB 具有网络感知能力,不是吗?它绝对不能开箱即用。如果我尝试在我的应用程序中添加以下声明,Mule 甚至都不会启动;它只是挂起......

<beans xmlns="http://www.springframework.org/schema/beans">
    <bean id="accountManager" class="com.ergo.AccountManager" scope="request"/>
</beans>

【问题讨论】:

    标签: spring mule


    【解决方案1】:

    您可以在 Spring 中为请求定义 CustomScope,并使用它在 mule 中定义 bean,如下所示。

    <spring:bean
            class="org.springframework.beans.factory.config.CustomScopeConfigurer">
            <spring:property name="scopes">
                <spring:map>
                    <spring:entry key="request">
                        <spring:bean
                            class="org.springframework.context.support.SimpleThreadScope" />
                    </spring:entry>
                </spring:map>
            </spring:property>
        </spring:bean>
    

    【讨论】:

      猜你喜欢
      • 2020-03-09
      • 1970-01-01
      • 2013-03-27
      • 2010-09-12
      • 1970-01-01
      • 2013-01-21
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      相关资源
      最近更新 更多