posts - 495,comments - 227,trackbacks - 0
          <2011年2月>
          303112345
          6789101112
          13141516171819
          20212223242526
          272812345
          6789101112

          常用鏈接

          留言簿(46)

          隨筆分類(476)

          隨筆檔案(495)

          最新隨筆

          搜索

          •  

          積分與排名

          • 積分 - 1396804
          • 排名 - 16

          最新評論

          閱讀排行榜

          評論排行榜

          http://blog.sharpplus.com/content/%E5%9C%A8google-appegine%E4%B8%8A%E9%83%A8%E7%BD%B2blazeds%E5%92%8Cspring%E7%A8%8B%E5%BA%8F

          在Google appegine上部署BlazeDS和Spring程序(一)

          作者:陳省

          首先參考http://ria.dzone.com/articles/introduction-spring- blazeds?page=0,2這篇文章,這里我們使用Spring Blazeds Integration包來替代SpringFactory的解決方案來實現Spring和BlazeDS的集成.

          1.首先修改Flex Builder3默認創建的web.xml文件。

          1.1刪除默認的MessageBroker Servlet

              <!-- MessageBroker Servlet -->
              <servlet>
                  <servlet-name>MessageBrokerServlet</servlet-name>
                  <display-name>MessageBrokerServlet</display-name>
                  <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
                  <init-param>
                      <param-name>services.configuration.file</param-name>
                      <param-value>/WEB-INF/flex/services-config.xml</param-value>
                 </init-param>
                  <load-on-startup>1</load-on-startup>
              </servlet>

          換成Spring的DispatcherServlet
              <!-- MessageBroker Servlet -->
              <servlet>
                  <servlet-name>MessageBrokerServlet</servlet-name>
                  <display-name>MessageBrokerServlet</display-name>
                  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                  <load-on-startup>1</load-on-startup>
              </servlet>

          注意,Spring加載MessageBrokerServlet的時候,會同時查找WEB-INF\MessageBrokerServlet- servlet.xml文件,添加WEB-INF\MessageBrokerServlet-servlet.xml文件,內容是加載spring的 xsd

          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
              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.0.xsd">

          </beans>

          刪除默認的Flex Listener和上下文配置

              <context-param>
                  <param-name>flex.class.path</param-name>
                  <param-value>/WEB-INF/flex/hotfixes,/WEB-INF/flex/jars</param-value>
              </context-param>

              <!-- Http Flex Session attribute and binding listener support -->
              <listener>
                  <listener-class>flex.messaging.HttpFlexSession</listener-class>
              </listener>

          換成Spring的上下文和Spring用Filter

              <context-param>
                  <param-name>contextConfigLocation</param-name>
                  <param-value>
                      /WEB-INF/config/web-application-config.xml
                      /WEB-INF/config/web-application-security.xml
                  </param-value>
              </context-param>
             
              <filter>
                  <filter-name>springSecurityFilterChain</filter-name>
                  <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
              </filter>

              <filter-mapping>
                <filter-name>springSecurityFilterChain</filter-name>
                <url-pattern>/*</url-pattern>
              </filter-mapping>
             
              <listener>
                  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
              </listener>

          1.2集成Spring的安全認證

          可以從http://coenraets.org/blog/2009/05/new-test-drive-for-spring- blazeds-integration-rc1/下載Spring Blazeds TestDrive集成包,查考里面的WEB-INF\config\web-application-security.xml文件
           

          1.3開放Spring Bean提供給Flex Remoting使用,修改testdrive的WEB-INF\config\web-application-config.xml內容為

          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
              xmlns:flex="http://www.springframework.org/schema/flex" xmlns:security="http://www.springframework.org/schema/security"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:context="http://www.springframework.org/schema/context"
              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
                  http://www.springframework.org/schema/security
                  http://www.springframework.org/schema/security/spring-security-2.0.4.xsd
                  http://www.springframework.org/schema/context
                  http://www.springframework.org/schema/context/spring-context-2.5.xsd">

           
              <flex:message-broker/>

              <bean id="UserService" class="com.sharpplus.UserService" >
              </bean>

              <!-- Expose the productDAO bean for BlazeDS remoting -->
              <flex:remoting-destination ref="UserService" />
          </beans>
           

          UserService Bean只有一個GetUser方法,返回一個Hello Blazeds的字符串

          package com.sharpplus;

          public class UserService {
              public String getUser(){
                  return "Hello Blazeds";
              }
          }

          創建Flex客戶端界面,調用我們的UserService,顯示字符串信息

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
              <mx:Script>
                  <![CDATA[
                      import mx.rpc.events.ResultEvent;
                      import mx.controls.Alert;
                     
                      private function onClick():void{
                          ro.getUser.addEventListener(ResultEvent.RESULT, onResult);
                          ro.getUser();
                      }
                     
                      private function onResult(event:ResultEvent):void{
                          var s:String=event.result as String;
                          Alert.show(s);
                      }
                  ]]>
              </mx:Script>
              <mx:Button x="257" y="193" label="Hello BlazeDS"  click="onClick()"/>
              <mx:RemoteObject id="ro" destination="UserService">
                 
              </mx:RemoteObject>
             
          </mx:Application>
           

          JDBC for Google appengine

          http://www.jiql.org/



          posted on 2011-02-25 15:56 SIMONE 閱讀(665) 評論(0)  編輯  收藏 所屬分類: flash
          主站蜘蛛池模板: 搜索| 沧州市| 金堂县| 司法| 大足县| 上犹县| 潼关县| 太湖县| 垫江县| 邻水| 西青区| 哈尔滨市| 周至县| 军事| 邢台县| 遵化市| 康乐县| 南昌县| 东乌珠穆沁旗| 湟源县| SHOW| 六盘水市| 榆林市| 黄骅市| 聂荣县| 肇庆市| 张家川| 宣恩县| 白城市| 沈阳市| 宜州市| 绥中县| 古蔺县| 彩票| 呼玛县| 华安县| 邵阳市| 榕江县| 华阴市| 黄大仙区| 突泉县|