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

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

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

    itstarting:IT進(jìn)行時(shí)

    想自己所想,做自己所愛

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      28 隨筆 :: 3 文章 :: 55 評(píng)論 :: 0 Trackbacks

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

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

    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.????? 評(píng)價(jià)

    這種方法是比較純的 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.????? 評(píng)價(jià)

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

    推薦使用。

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

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

    我們的自定義模型配置加載方式的目標(biāo)是:

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

    2、????????????? 可以更多的干預(yù)系統(tǒng)默認(rèn)的加載方式。

    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>

    ?

    這里有一個(gè)重要的 Listener ,用來在系統(tǒng)啟動(dòng)的時(shí)候自動(dòng)加載配置信息,其核心代碼如下:

    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;

    ??? }

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

    posted on 2006-08-29 16:00 IT進(jìn)行時(shí) 閱讀(6147) 評(píng)論(0)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 一级成人a毛片免费播放| 久久亚洲精品11p| 久久久久国产免费| 国产亚洲精品不卡在线| 猫咪社区免费资源在线观看| 国产一级高清视频免费看| 亚洲色大情网站www| 美女被免费视频网站a国产| 亚洲精品无码mⅴ在线观看| 日韩激情淫片免费看| 亚洲天堂中文字幕| 日韩免费人妻AV无码专区蜜桃| 亚洲国产人成在线观看69网站| 亚洲人成免费电影| 亚洲国产日韩综合久久精品| 影音先锋在线免费观看| 国产精品亚洲二区在线| 亚洲男人在线无码视频| 日韩a级无码免费视频| 青青草原精品国产亚洲av| 成年在线观看网站免费| 亚洲国产欧美国产综合一区| 又粗又硬又黄又爽的免费视频| 又黄又大的激情视频在线观看免费视频社区在线 | 在线美女免费观看网站h| vvvv99日韩精品亚洲| 中文字幕在线视频免费| 亚洲综合久久久久久中文字幕| 波多野结衣免费在线| 国产午夜亚洲精品不卡电影| 亚洲日韩v无码中文字幕| 91精品免费高清在线| 亚洲乱理伦片在线观看中字| 中文字幕亚洲电影| 曰批全过程免费视频网址| 亚洲国产成人AV在线播放| 国产亚洲欧洲精品| 成人免费毛片观看| 免费萌白酱国产一区二区三区| 亚洲国产成人久久| 久久亚洲色一区二区三区|