如何在骡子中定义当地的春豆

时间:2013-01-23 15:53:58

标签: spring mule

我的mule-config.xml中有几个流,但有些bean只说一个流。有没有办法定义流本地的bean。我知道我可以定义如下的内联bean:

<custom-transformer name="soapFaultTransformer" class="com.xxx.xx.transformer.VelocityMessageTransformer">
    <spring:property name="velocityEngine"  ref="velocityEngine" />
    <spring:property name="templateName"    value="soapFault.vm" />
    <spring:property name="beanClass">
        <spring:bean class="com.xxx.services.xx.Soap11Fault">
                <spring:property name="faultCode"   value="Client" />
                <spring:property name="faultString" value="Invalid Request" />
                <spring:property name="detail"      value="..." />
        </spring:bean>
    </spring:property>
</custom-transformer>

但是在一个流程中需要在2个位置使用内联spring bean?我是否仍然可以在一个地方定义它并在2个地方引用它而不使其成为全局bean?

谢谢

2 个答案:

答案 0 :(得分:1)

如何将单个流所需的所有spring bean收集到仅由该流导入的单独spring配置文件中?

你的mule配置如下所示:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
    http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
    <spring:import resource="encapsulated-beans.xml" />

    <flow name="flow" >
        ...
    </flow>


</mule>

其中 encapsulated-beans.xml 将是配置文件,其中包括,例如,您的com.xxx.services.xx.Soap11Fault bean

答案 1 :(得分:1)

正如@David所说,不可能声明特定于单个流的bean。声明的bean将可用于所有流程。