在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>
- 作者: snowfox2008 2005年09月23日, 星期五 17:38