<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    itstarting:IT進行時

    想自己所想,做自己所愛

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      28 隨筆 :: 3 文章 :: 55 評論 :: 0 Trackbacks

    從形勢來看,如果應用不使用 Spring 就感覺有點落伍——說法有點別扭:好像有點過。誠然, Spring 給我們帶來了太多的好處,以至于幾乎大部分的產品都以聲稱能夠整合 Spring 為榮, Mule 也不能免俗:)

    從官方來看, mule spring 的結合有三種做法:

    1 、 Using Spring as a Component Factory

    How to configure the Spring Container with Mule so that Managed components and other Mule objects can be loaded from Spring.

    2 、 Configuring the Mule Server From a Spring Context

    A Mule server is just a bunch of beans! How to load a Mule instance from the Spring Container.

    3 、 Configuring a Spring context using Mule Xml

    There are lots of reasons why you might want to use Mule and Spring together, but configuring Mule in Spring bean Xml can be a verbose process. Now you can configure it using Mule Xml and mix Spring beans in the configuration.

    1.1.1. ???????? Using Spring as a Component Factory

    我下面首先嘗試的是第一種。

    1.1.1.1.????? web.xml

    ?????? <context-param>

    ????????????? <param-name>contextConfigLocation</param-name>

    ??????? <param-value>/WEB-INF/applicationContext-mule.xml

    ??????? </param-value>

    ?????? </context-param>

    ?

    ?????? <listener>????????????? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

    ??? </listener>

    1.1.1.2.????? 配置文件(舉例)

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

    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>

    ?????? <bean id="muleManager" class="org.mule.extras.spring.config.AutowireUMOManagerFactoryBean" destroy-method="dispose" singleton="true"/>

    ?

    ??? <bean id="muleNameProcessor" class="org.mule.extras.spring.config.MuleObjectNameProcessor"/>

    ?

    ??? <bean id="muleClient" class="org.mule.extras.client.MuleClient" depends-on="muleManager"/>

    ?

    ??? <bean id="applicationEventMulticaster" class="org.mule.extras.spring.events.MuleEventMulticaster">

    ??????? <property name="asynchronous">

    ??????????? <value>false</value>

    ??????? </property>

    ??? </bean>

    ?

    ??? <bean name="JmxAgent" class="org.mule.management.agents.JmxAgent"/>

    ??? <bean name="JdmkAgent" class="org.mule.management.agents.JdmkAgent">

    ??????? <property name="jmxAdaptorUrl" value="http://localhost:9999"/>

    ??? </bean>??

    ?

    ??? <bean id="echoDescriptor" class="org.mule.impl.MuleDescriptor">

    ??????? <property name="inboundEndpoint">

    ??????????? <ref local="echoInboundEndpoint"/>

    ??????? </property>

    ??????? <property name="implementation">

    ??????????? <value>echoComponent</value>

    ??????? </property>

    ?? </bean>

    ??

    ??? <bean id="echoInboundEndpoint" singleton="false" class="org.mule.impl.endpoint.MuleEndpoint">

    ??????? <property name="endpointURI">

    ??????????? <bean class="org.mule.impl.endpoint.MuleEndpointURI">

    ??????????????? <constructor-arg index="0">

    ??????????????????? <value>vm://echo</value>

    ??????????????? </constructor-arg>

    ??????????? </bean>

    ??????? </property>

    ??? </bean>

    ?

    ?????? <bean id="echoComponent" class="org.mule.components.simple.EchoComponent" singleton='false'/>

    </beans>

    1.1.1.3.????? 評價

    這種方法是比較純的 spring 配置手段 ( 注意在此使用的 DTD spring-beans.dtd) ,不利于把握 mule 的配置感覺。不推薦使用。

    1.1.2. ???????? Configuring a Spring context using Mule Xml

    1.1.2.1.????? Web.xml

    ?????? <context-param>

    ????????????? <param-name>contextConfigLocation</param-name>

    ??????? <param-value>/WEB-INF/applicationContext-mule.xml,

    ???????????????????? /WEB-INF/ede-config.xml

    ??????? </param-value>

    ?????? </context-param>

    ?

    ?????? <listener> ??????????? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

    ??? </listener>

    ?

    1.1.2.2.????? 配置文件(舉例, applicationContext-ede-core.xml

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

    <!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN" "http://www.symphonysoft.com/dtds/mule/mule-spring-configuration.dtd">

    ?

    <mule-configuration id="EdeCore" version="2.0">

    ?????? <!-- 描述 -->

    ?????? <description>Enterprice DataExpress</description>???

    ?????? <mule-environment-properties synchronous="true" serverUrl="tcp://localhost:9999">

    ????????????? <queue-profile maxOutstandingMessages="1000" persistent="true"/>

    ?????? </mule-environment-properties>

    ?

    ??? <agents>

    ??????? <agent name="JmxAgent" className="org.mule.management.agents.JmxAgent"/>

    ??????? <agent name="JdmkAgent" className="org.mule.management.agents.JdmkAgent"/>

    ????????????? <properties>

    ???????????????????? <property name="jmxAdaptorUrl" value="http://localhost:9999"/>

    ????????????? </properties>

    ??? </agents>

    ?

    ?????? <model name="Nothing"></model>

    </mule-configuration>

    1.1.2.3.????? 配置文件(舉例, applicationContext-ede-extend.xml

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

    <!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN" "http://www.symphonysoft.com/dtds/mule/mule-spring-configuration.dtd">

    ?

    <mule-configuration id="EDE" version="1.0">

    ?????? <!--

    ?????? <description>Enterprice DataExpress</description>???

    ?????? <mule-environment-properties synchronous="true" serverUrl="tcp://localhost:9999">

    ?????? <queue-profile maxOutstandingMessages="1000" persistent="true"/>

    ?????? </mule-environment-properties>-->

    ??????

    ??? <mule-descriptor name="echoUMO" implementation="echoComponent">

    ??????? <inbound-router>

    ??????????? <endpoint address="vm://echo"/>

    ??????? </inbound-router>

    ??? </mule-descriptor>

    ?

    ?????? <bean id="echoComponent" class="org.mule.components.simple.EchoComponent" singleton="false"/>

    </mule-configuration>

    1.1.2.4.????? 評價

    這種方法是比較 Mule-friendly 的配置手段 ( 注意在此使用的 DTD mule-spring-configuration.dtd) ,從整體感覺來看,與一般的純 Mule 配置感覺類似。

    推薦使用。

    1.1.3. ???????? 自定義方式

    從產品研發來看,自定義模型配置加載方式有著諸多的好處,這里不講。

    我們的自定義模型配置加載方式的目標是:

    1、????????????? 可以兼容標準的基于 mule 配置文件配置的模型,同時也要兼容根據其他定義方式(如基于數據庫)的可編程式模型加載;

    2、????????????? 可以更多的干預系統默認的加載方式。

    1.1.3.1.????? Web.xml

    <context-param>

    ??????? <param-name>com.nci.ede.config</param-name>

    ??????? <param-value>applicationContext-ede-core.xml,

    ???????????????????? applicationContext-ede-extend.xml,

    ???????????????????? applicationContext-sample-echo2.xml

    ??????? </param-value>

    ??? </context-param>

    ?

    ??? <listener>

    ??????? <listener-class>com.nci.ede.system.config.EdeBuilderContextListener</listener-class>

    ??? </listener>

    ?

    這里有一個重要的 Listener ,用來在系統啟動的時候自動加載配置信息,其核心代碼如下:

    public void contextInitialized(ServletContextEvent event)

    ??? {

    ??????? String config = event.getServletContext().getInitParameter(CONFIG_INIT_PARAMETER);

    ??????? if (config == null) {

    ??????????? config = getDefaultConfigResource();

    ??????? }

    ??????? try {

    ??????????? createManager(config, event.getServletContext());

    ??????? } catch (ConfigurationException e) {

    ??????????? event.getServletContext().log(e.getMessage(), e);

    ??????? }

    ??? }

    ??? protected UMOManager createManager(String configResource, ServletContext context) throws ConfigurationException{

    ??????? //WebappMuleXmlConfigurationBuilder builder = new WebappMuleXmlConfigurationBuilder(context);

    ??????? SpringConfigurationBuilder builder = new SpringConfigurationBuilder();

    ??????? UMOManager manager = builder.configure(configResource);???????

    ??????? try {

    ??????? ?? // 通過 spring bean factory 獲取

    ??????? ?? EdeConfigurationLoader loader = (EdeConfigurationLoader)SpringHelper.getBean(manager,"edeConfigurationLoader");

    ??????? ?? loader.loadConfig();

    ?????????????????? } catch (ObjectNotFoundException e1) {

    ??????????????????????????? e1.printStackTrace();

    ?????????????????? } catch (EdeException e) {

    ??????????????????????????? e.printStackTrace();

    ?????????????????? }

    ??????? return manager;

    ??? }

    其中所調用的自定義加載器 edeConfigurationLoader 可以在 spring 中注入。

    posted on 2006-08-29 16:00 IT進行時 閱讀(6147) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 偷自拍亚洲视频在线观看99| 久久亚洲国产成人影院| 国产嫩草影院精品免费网址| 亚洲午夜精品在线| 污视频网站在线免费看| 6080午夜一级毛片免费看6080夜福利| 中文字幕亚洲天堂| 亚洲AV无码专区在线观看成人| 中文无码成人免费视频在线观看| 国产亚洲一区区二区在线| 中文字幕免费在线播放| 国产av无码专区亚洲av桃花庵| 亚洲精品永久在线观看| 国产高清免费的视频| 大片免费观看92在线视频线视频| 日韩版码免费福利视频| 亚洲乱亚洲乱妇24p| 免费人成在线观看网站品爱网日本| 精品一区二区三区免费毛片| 国产成人高清亚洲| 亚洲欧洲免费无码| 亚洲高清偷拍一区二区三区| 亚洲成AV人片久久| 日韩成人免费在线| 亚洲成AV人综合在线观看| 在线精品免费视频| 国产精品免费久久久久电影网| 免费看无码自慰一区二区| 亚洲黄色免费在线观看| a级精品九九九大片免费看| 免费v片在线观看| CAOPORN国产精品免费视频| 亚洲视频在线观看视频| 日韩黄色免费观看| 久久精品成人免费看| 亚洲人成www在线播放| 久久久久亚洲AV成人网人人网站| 蜜桃成人无码区免费视频网站| 国产日韩亚洲大尺度高清| 精品一区二区三区免费观看| 亚洲成a人片在线观看中文app |