1. 程式人生 > >spring中使用mule的配置經驗總結

spring中使用mule的配置經驗總結

在spring中使用mule時,有兩種主要的方式,一種是將mule中的bean直接配置在spring的bean.xml檔案中,統一由spring來管理;另一種是由mule自帶的SpringConfigurationBuilder類來載入mule自己的配置檔案mule-config.xml;採用第二種方式時,在spring中可以直接使用mule的配置檔案,而不用再寫配置檔案。SpringConfigurationBuilder類在載入mule-config.xml檔案時,由MuleApplicationContext類呼叫mule-to-spring.xsl檔案,對mule-config.xml檔案進行transform(轉換),實際上就是在mule-config.xml檔案的頭上加入三個bean的定義,以實現對mule的啟動、初始化、服務的註冊(mule-config.xml檔案中的服務),bean的定義如下(可以檢視mule-to-spring.xsl):
<bean id="muleManager" class="org.mule.extras.spring.config.AutowireUMOManagerFactoryBean"/>
<bean id="muleNameProcessor" class="org.mule.extras.spring.config.MuleObjectNameProcessor"/>
<bean name="muleConfiguratrion" class="org.mule.config.MuleConfiguration">
            <property name="model">
                <value>
                    <xsl:value-of select="@model"/>
                </value>
            </property>
            <property name="recoverableMode">
                <value>
                    <xsl:value-of select="@recoverableMode"/>
                </value>
            </property>
            <property name="synchronous">
                <value>
                    <xsl:value-of select="@synchronous"/>
                </value>
            </property>
            <property name="synchronousReceive">
                <value>
                    <xsl:value-of select="@synchronousReceive"/>
                </value>
            </property>
            <property name="workingDirectory">
                <value>
                    <xsl:value-of select="@workingDirectory"/>
                </value>
            </property>
            <property name="serverUrl">
                <value>
                    <xsl:value-of select="@serverUrl"/>
                </value>
            </property>

            <xsl:apply-templates select="threading-profile" mode="global"/>
            <xsl:apply-templates select="queue-profile"/>
            <xsl:apply-templates select="pooling-profile"/>
            <xsl:apply-templates select="persistence-strategy"/>
            <xsl:apply-templates select="connection-strategy"/>
        </bean>