gembin

          OSGi, Eclipse Equinox, ECF, Virgo, Gemini, Apache Felix, Karaf, Aires, Camel, Eclipse RCP

          HBase, Hadoop, ZooKeeper, Cassandra

          Flex4, AS3, Swiz framework, GraniteDS, BlazeDS etc.

          There is nothing that software can't fix. Unfortunately, there is also nothing that software can't completely fuck up. That gap is called talent.

          About Me

           

          基于Tuscany的Web應用程序分析

          Tuscany下典型的Web架構:

          乍一看,平淡無奇,這不就是我們常用的Web目錄結構么?沒錯!

          但玄機出在Web.xml和Calculator.composite上,下面我們分別看下這兩個文件:

          Web.xml

          <?xml version="1.0" encoding="ISO-8859-1"?>
          <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
          Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
          <web-app>

          <display-name>Apache Tuscany Calculator Web Service Sample</display-name>

          <filter>
          <filter-name>tuscany</filter-name>
          <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
          </filter>

          <filter-mapping>
          <filter-name>tuscany</filter-name>
          <url-pattern>/*</url-pattern>
          </filter-mapping>

          <welcome-file-list id="WelcomeFileList">
          <welcome-file>calc.jsp</welcome-file>
          </welcome-file-list>

          </web-app>

          這里使用了TuscanyServletFilter過濾器,此過濾器的作用我們會在后文提到。

          Calculator.composite

          <?xml version="1.0" encoding="UTF-8"?>
          <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
          targetNamespace="http://sample"
          xmlns:sample="http://sample"
          name="Calculator">

          <component name="CalculatorServiceComponent">
          <implementation.java class="calculator.CalculatorServiceImpl"/>
          <reference name="addService" target="AddServiceComponent"></reference>
          <reference name="subtractService" target="SubtractServiceComponent"></reference>
          <reference name="multiplyService" target="MultiplyServiceComponent"></reference>
          <reference name="divideService" target="DivideServiceComponent"></reference>
          </component>

          <component name="AddServiceComponent">
          <implementation.java class="calculator.AddServiceImpl"/>
          </component>

          <component name="SubtractServiceComponent">
          <implementation.java class="calculator.SubtractServiceImpl"/>
          </component>

          <component name="MultiplyServiceComponent">
          <implementation.java class="calculator.MultiplyServiceImpl"/>
          </component>

          <component name="DivideServiceComponent">
          <implementation.java class="calculator.DivideServiceImpl"/>
          </component>

          </composite>
          此文件類似Spring,是Tuscany的服務配置文件,在此文件中提供了組件、實現的聲明及配置。

          下面,再結合調用時序圖,來詳述Tuscany在此應用中的位置及作用。

          由此時序圖可知,整個流程如下:

          1、應用服務器啟動;

          2、客戶端訪問calc.jsp頁面,服務器調用Web.xml中的配置TuscanyServletFilter過濾器;

          3、在TuscanyServletFilter過濾器中,首先得到一個WebAppServletHost實例,WebAppServletHost是在Web應用環境中使用的Tuscany功能提供者;

          4、在WebAppServletHost中,得到一個SCADomain實例,并將之放入ServletContext上下文中,以后可藉由相應的key得到此SCADomain實例;

          5、calc.jsp中成功取得SCADomain實例;

          6、通過SCADomain實例取得CalculatorServiceComponent組件;

          7、調用CalculatorServiceComponent組件的各種業務方法實施計算。

          這一個完整的過程,演示了Tuscany在一個Web應用中所充當的角色,在某種意義上Tuscany和Spring是相同的,只不過粒度不一樣,

          Spring注重的是bean的管理,是技術層面的,粒度相對較細;而Tuscany關注 則是業務組件的管理,是業務層面的,粒度相對較粗。

          從軟件重用角度講,業務重用比技術重用更加受歡迎,操作起來也更加容易。業務重用是趨勢。現在的SAAS熱潮更加證明,軟件即服務的

          時代已經到來。

          posted on 2008-04-27 21:35 gembin 閱讀(640) 評論(0)  編輯  收藏 所屬分類: SCASOA

          導航

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(440)

          隨筆檔案(378)

          文章檔案(6)

          新聞檔案(1)

          相冊

          收藏夾(9)

          Adobe

          Android

          AS3

          Blog-Links

          Build

          Design Pattern

          Eclipse

          Favorite Links

          Flickr

          Game Dev

          HBase

          Identity Management

          IT resources

          JEE

          Language

          OpenID

          OSGi

          SOA

          Version Control

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          free counters
          主站蜘蛛池模板: 时尚| 阿克| 紫阳县| 金华市| 衡南县| 连州市| 绥滨县| 盐亭县| 盱眙县| 金昌市| 呼和浩特市| 军事| 长汀县| 陆川县| 定结县| 乾安县| 分宜县| 株洲县| 汕头市| 桃江县| 江北区| 罗定市| 泉州市| 长海县| 北京市| 勐海县| 洪江市| 商城县| 临汾市| 美姑县| 尤溪县| 库车县| 青岛市| 涿鹿县| 大埔县| 山西省| 漳州市| 阳东县| 盈江县| 天津市| 南昌县|