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

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

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

    posts - 495,comments - 227,trackbacks - 0

    Flex學習之五

    本文主要學習Flex跟spring如何集成。參考文檔是 Spring BlazeDS Integration Reference Guide。spring已經提供了與flex的集成的支持,主要的jar包下載地址:http://www.springsource.com /download/community?project=Spring%20BlazeDS%20Integration

    flex與spring集成的核心思想就是讓spring來管理 MessageBroker。如何集成?可以總結為三步。
    1、首先,修改 web.xml文件,將之前配置的 MessageBrokerServlet  去掉改成spring的,

    <servlet>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/config/web-application-config.xml
    </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    <url-pattern>/messagebroker/*</url-pattern>
    </servlet-mapping>

    2,新建文件 web-application-config.xml

    <?xml version="1.0" encoding="GB2312" ?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:flex="http://www.springframework.org/schema/flex" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/flex
               http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">

    <!-- Bootstraps and exposes the BlazeDS MessageBroker simplest form -->
    <flex:message-broker id="_messageBroker"
    services-config-path="/WEB-INF/flex/services-config.xml">
    <flex:mapping pattern="/messagebroker/*" />
    <flex:exception-translator ref="myExceptionTranslator" />
    </flex:message-broker>
           
             <!--
              上面配置是一種簡單配置,另外一種更簡單配置為:
               <flex:message-broker/> 
             
               還有一種配置為:
               <bean id="mySpringManagedMessageBroker"
    class="org.springframework.flex.core.MessageBrokerFactoryBean">
    <property name="servicesConfigPath"
    value="classpath*:flex/services-config.xml" />
                </bean>
              -->

    <!-- Maps request paths at /* to the BlazeDS MessageBroker -->
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
    <value>
    /*=_messageBroker
            </value>
    </property>
    </bean>

            <!-- 下面這個Adapter似乎不用配置,因為我注釋后照樣可以使用 -->
    <!--
    Dispatches requests mapped to a MessageBroker <bean
    class="org.springframework.flex.servlet.MessageBrokerHandlerAdapter"
    />
    -->

    </beans>

    3,寫remoting-config.xml 文件:
    <?xml version="1.0" encoding="UTF-8"?>
    <service id="remoting-service"
        class="flex.messaging.services.RemotingService">

        <adapters>
            <adapter-definition id="java-object"
                class="flex.messaging.services.remoting.adapters.JavaAdapter"
                default="true"/>
        </adapters>

        <default-channels>
            <channel ref="my-amf"/>
        </default-channels>
       
    </service>   
       
    到目前為止,flex已經跟spring集成到一起了。
    4、將spring的bean導出為flex的Destination。我們要在web-application-config.xml文件中增加。
    有三種方式:
    第一種:
             <bean id="productService" class="flex.samples.product.ProductServiceImpl" />
              <flex:remoting-destination ref="productService" />
    第二種:
            <bean id="productService" class="flex.samples.product.ProductServiceImpl" >
              <flex:remoting-destination />
            </bean>
    第三種:
            <bean id="product" class="org.springframework.flex.remoting.RemotingDestinationExporter">
        <property name="messageBroker" ref="_messageBroker"/>
        <property name="service" ref="productService"/>
        <property name="serviceId" value="productService"/>
        <property name="includeMethods" value="read, update"/>
        <property name="excludeMethods" value="create, delete"/>
        <property name="channels" value="my-amf, my-secure-amf"/>
    </bean>


    附件是一個例子工程,沒有提供jar,工程中所需要的jar
    backport-util-concurrent.jar
    cfgatewayadapter.jar
    cglib-nodep-2.1_3.jar
    commons-codec-1.3.jar
    commons-httpclient-3.0.1.jar
    commons-logging.jar
    concurrent.jar
    flex-messaging-common.jar
    flex-messaging-core.jar
    flex-messaging-opt.jar
    flex-messaging-proxy.jar
    flex-messaging-remoting.jar
    jackson-lgpl-0.9.5.jar
    org.springframework.flex-1.0.0.RC1.jar
    spring2.5.6.jar
    spring-webmvc.jar
    xalan.jar

    posted on 2011-02-25 15:55 SIMONE 閱讀(1838) 評論(0)  編輯  收藏 所屬分類: flash
    主站蜘蛛池模板: 国产成人免费ā片在线观看老同学 | 亚洲AV午夜福利精品一区二区| 免费观看成人毛片a片2008| 国产三级在线免费观看| 春意影院午夜爽爽爽免费| 亚洲欧洲尹人香蕉综合| 亚洲一区二区三区香蕉| 国产一卡二卡≡卡四卡免费乱码| 四虎在线成人免费网站| 怡红院免费全部视频在线视频| 老司机午夜在线视频免费| 亚洲欧洲日韩极速播放| 亚洲视频国产精品| 亚洲AV无码专区国产乱码电影| 不卡精品国产_亚洲人成在线| 全部免费毛片在线| 日韩免费无砖专区2020狼| 可以免费看黄的网站| 国产婷婷成人久久Av免费高清| 国产精品免费久久久久久久久| 免费无码专区毛片高潮喷水| 亚洲日韩中文字幕无码一区| 亚洲人成日本在线观看| 亚洲老熟女@TubeumTV| 久久久亚洲欧洲日产国码二区 | 亚洲AV第一成肉网| 亚洲中文精品久久久久久不卡| 亚洲av无码不卡久久| 亚洲人成网网址在线看| 亚洲影视一区二区| 亚洲不卡视频在线观看| 亚洲三级在线免费观看| 国产成人精品日本亚洲网址 | 国产h视频在线观看免费| 久久ww精品w免费人成| 鲁大师在线影院免费观看| 青青草无码免费一二三区| 免费A级毛片无码A∨中文字幕下载| 四虎成人精品永久免费AV| 一级成人a毛片免费播放| 59pao成国产成视频永久免费|