隨筆-6  評論-2  文章-0  trackbacks-0
            2006年4月25日
          轉(zhuǎn)載自Rinso的專欄

          原文
          posted @ 2006-05-12 10:26 Allen Young 閱讀(416) | 評論 (1)編輯 收藏
          SCA Module是緊耦合component的最大的組合物,同時也是松耦合SCA System中的基本單元,也就是說,很多緊耦合的東東組成Module,然后很多Module組成松耦合的System。我們都知道一味的緊耦合及松耦 合都是不好的,過分的緊耦合會降低系統(tǒng)的靈活性、可重用性等,而過分的松耦合會導(dǎo)致系統(tǒng)性能的下降、開發(fā)難度增加、代碼不直觀、測試難做等,因此,選擇一 個合適的緊耦合和松耦合之間的臨界點是很重要的,而Module就是這個臨界點。

          Module有如下幾個標(biāo)準(zhǔn)特性:
          1. 定義了Component可見性的邊界,Component不可以在Module之外直接被引用。
          2. 在同一個Module內(nèi),Service的本地調(diào)用采用by-reference語義(除了聲明為remotable的接口)。在Module之間,Service的遠(yuǎn)程調(diào)用采用by-value語義。
          3. 定義了部署的單元。Module用來為SCA System提供business service。
          Module由sca.module中的module元素定義。下面是module的schema:
          <?xml?version="1.0"?encoding="ASCII"?>
          <module?xmlns=”http://www.osoa.org/xmlns/sca/0.9”
          ????
          xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"?name="xs:NCName">

          ????<entryPoint?name="xs:NCName" multiplicity="0..1?or?1..1?or?0..n?or?1..n"??>*
          ????????
          <interface.interface-type?/>
          ????????
          <binding.binding-type?uri="xs:anyURI"?/>+
          ????????
          <reference>wire-target-URI</reference>
          ????
          </entryPoint>

          ????<component?name="xs:NCName">*
          ????????
          <implementation.implementation-type?/>
          ????????
          <properties>?
          ????????????
          <v:property-name>property-value</v:property-name>+
          ????????
          </properties>
          ????????
          <references>?
          ????????????
          <v:reference-name>wire-target-URI</v:reference-name>+
          ????????
          </references>
          ????
          </component>

          ????<externalService?name="xs:NCName">*
          ????????
          <interface.interface-type?/>+
          ????????
          <binding.binding-type?uri="xs:anyURI"?/>*
          ????
          </externalService>

          ????<wire>*
          ????????
          <source.uri>wire-source-URI</source.uri>
          ????????
          <target.uri>wire-target-URI</target.uri>
          ????
          </wire>

          </module>

          < module /> 的name屬性表示module的名字,在一個SCA System中是唯一的。這個名字不能包含/或#字符。
          < module /> 包含0或n個 < entryPoint /> < component /> < externalService /> ?<wire />元素,這些元素的含義在之前的隨筆中 已經(jīng)說過。Component包含Module的業(yè)務(wù)邏輯,Wire描述Component之間的Service的連接,Entry Point定義Module提供的、可供外部訪問的public service,External Service表示Module對外部Service的依賴。

          Component

          Component 是Implementation的配置實例,它即提供 Service也消費Service。多個Component可以使用并配置同一個Implementation,只要每個Component都采用不同 的配置。Implementation通過component type來定義可由Component配置的aspect。SCA支持多種不同的實現(xiàn)技術(shù),如Java、BEPL、C++。SCA定義了一種可擴(kuò)展機(jī)制來 引入新類型的Implementation。目前的規(guī)范不指定必須被SCA runtime支持的實現(xiàn)技術(shù),供應(yīng)商可以選擇他們認(rèn)為重要的技術(shù)予以支持。我們來看一下Component的schema:
          <component?name="xs:NCName">*
          ???
          <implementation.implementation-type?/>
          ???
          <properties>?
          ???????
          <v:property-name>property-value</v:property-name>+
          ???
          </properties>
          ???
          <references>?
          ???????
          <v:reference-name>wire-target-URI</v:reference-name>+
          ???
          </references>
          </component>
          <component />的name屬性表示這個component的名字,它必須在當(dāng)前module中是唯一的。另外,當(dāng)前module中的entry point和external servic不可以和component重名。
          <component />必 須有一個implementation子元素,它指向component的具體實現(xiàn)。implementation元素的名字由兩部分組成: "implementation"+代表implementation-type的限定詞,例如:implementation.java表示是由 Java來實現(xiàn),implementation.bepl表示是由BPEL來實現(xiàn)。
          <implementation.java?class="services.myvalue.MyValueServiceImpl"/>
          <implementation.bpel?process="…"/>

          Component Type

          Component Type表示一個Implementation的可配置的東東,它由Implementation提供的Service、可設(shè)置的關(guān)聯(lián)到其他 Service的Reference和可設(shè)置的屬性組成。屬性和Reference將在使用這個Implementation的Component中具體 配置。
          確定一個Component Type需要兩個步驟:
          1. 從Implementation自身獲得信息(例如:從code annotation獲得信息)
          2. 從SCA component type文件獲得信息(XML配置文件)
          這是時下流行的做法,既可以從code annotation進(jìn)行配置,也可以從XML進(jìn)行配置,如果兩者同時使用,code annotation的優(yōu)先級高,但是兩者的配置要統(tǒng)一。
          SCA component type文件的擴(kuò)展名為".componentType",其中通過componentType元素來進(jìn)行配置,我們來看看它的schema:
          <?xml?version="1.0"?encoding="ASCII"?>
          <componentType?xmlns="http://www.osoa.org/xmlns/sca/0.9"?>
          ??? <service?name="xs:NCName">*
          ??????? <interface.interface-type/>
          ??? </service>
          ??? <reference?name="xs:NCName"?multiplicity="0..1?or?1..1?or?0..n?or?1..n"?>*
          ??????? <interface.interface-type/>
          ??? </reference>
          ??? <property?name="xs:NCName"?type="xs:QName"?many="xs:boolean"? default="xs:string"??required="xs:boolean"?/>*
          </componentType>
          <service />表示這個Component Type提供的Service,可以通過<interface.interface-type />設(shè)置其為remotable。<reference />表示這個Component Type依賴的其他Service,也可以通過<interface.interface-type />設(shè)置其為remotable,multiplicity屬性表示可以關(guān)聯(lián)到這個Reference的Wire的數(shù)量。<property />表示這個Component Type可配置的屬性。
          讓我們來看一個例子,Java文件MyValueServiceImpl是這個例子中的Implementation,其SCA component type如下:
          <?xml?version="1.0"?encoding="ASCII"?>
          <componentType?xmlns="http://www.osoa.org/xmlns/sca/0.9">
          ??? <service?name="MyValueService">
          ??????? <interface.java?interface="services.myvalue.MyValueService"/>
          ??? </service>
          ??? <reference?name="customerService">
          ??????? <interface.java?interface="services.customer.CustomerService"/>
          ??? </reference>
          ??? <reference?name="stockQuoteService">
          ??????? <interface.java?interface="services.stockquote.StockQuoteService"/>
          ??? </reference>
          ??? <property?name="currency"?type="xsd:string"?default="USD"/>
          </componentType>

          相應(yīng)的Java代碼如下:

          //?MyValueService?interface.
          package?services.myvalue;

          public?interface?MyValueService?{
          ????
          public?void?calculate();
          }

          //?MyValueServiceImpl?class
          package?services.myvalue;

          import?services.customer.CustomerService;
          import?services.stockquote.StockQuoteService;

          public?class?MyValueServiceImpl?implements?MyValueService?{

          ????
          //?Code?annotation.?和XML的功能相同,兩者取一個使用就夠了。
          ????@Property
          ????
          private?String?currency?=?"USD";

          ????@Reference
          ????
          private?CustomerService?customerService;

          ????@Reference
          ????
          private?StockQuoteService?stockQuoteService;

          ????
          public?void?calculate()?{
          ????????
          //?do?your?real?business?logic?here.
          ????}
          }

          Implementation

          Implementation 是業(yè)務(wù)邏輯的具體實現(xiàn),這些業(yè)務(wù)邏輯會提供或消費Service。SCA支持多種實現(xiàn)技術(shù),如Java、BPEL或C++。我們已經(jīng)知道, Service、Reference和Property是Implementation中關(guān)于配置的東東,他們組成Component Type。在運行時,Implementation Instance是Implementation的實例化,它提供的業(yè)務(wù)邏輯和Implementation中的相同,但Property和 Reference則取決于Component中的配置。下圖描述了Component Type、Component、Implementation和Implementation Instance之間的關(guān)系:
          SCA-relationship-between-implementation-and-implementation-instance.PNG

          Interface

          Interface 負(fù)責(zé)定義一個或多個business function。這些business function通過Service提供給外部,外部通過Reference使用它們。Service由自己實現(xiàn)的Interface定義。SCA支持如 下3種Interface:
          • Java interfaces
          • WSDL 1.1 portTypes
          • WSDL 2.0 interfaces
          我們一個一個來看:

          <interface.java?interface="NCName"?…?/>
          其中interface屬性為Java interface的全名(包括package)。例如:
          <interface.java?interface="services.stockquote.StockQuoteService" />

          <interface.wsdl?interface="xs:anyURI"?…?/>
          其中interface屬性為portType/interface的URI,其格式為<WSDL-namespace-URI>#wsdl.interface(<portType or Interface-name>)。例如:
          <interface.wsdl?interface="http://www.stockquote.org/StockQuoteService#wsdl.interface(StockQuote)"/>

          如果使用Java interface,Service方法的傳入?yún)?shù)和返回值可以使用Java class或Primitive type。最好使用SDO生成的Java class,因為它們和XML之間做了整合。(SDO也是IBM推出的一個SOA系列的標(biāo)準(zhǔn)。)
          如果使用WSDL,Service方法的傳入?yún)?shù)和返回值則使用XML schema描述。XML schema種描述的參數(shù)以SDO DataObject的形式暴露給開發(fā)者。

          一 個Component Implementation的Service是否是remotable的是由Service的Interface定義的。如果使用Java,為 Interface添加@Remotable annotation可以把Service聲明為remotable。WSDL定義的interface永遠(yuǎn)是remotable的。
          典型的remoteable interface是粗力度的,用于松耦合的交互。Remotable Service Interface不允許函數(shù)重載。無論是在 Module之外還是在Module內(nèi)的其他Component中使用
          remotable Service,數(shù)據(jù)交換都采用by-value語義。
          Remotable Serviced的Implementation可能會在Service調(diào)用過程中或調(diào)用之后改變傳入?yún)?shù),也可能在調(diào)用之后修改返回值。如果 remotable Service被locally或remotely調(diào)用,SCA container會保證傳入?yún)?shù)及返回值的改變對Service的調(diào)用者是不可見的(這就是by-value語義)。下面是一個remotable java interface的例子:
          package?services.hello;

          @Remotable
          //?@AllowsPassByReference
          public?interface?HelloService?{
          ????
          public?String?sayHello(String?message);
          }
          由External Service提供的Service永遠(yuǎn)是remotable的。可以使用@AllowsPassByReference annotation允許一個remotable Service在被同一Module中的其他Component調(diào)用時使用by-reference語義,這樣可以提高性能。

          由local Interface提供的Service只能在同一Module中使用,它們不能通過Entry Point發(fā)布到外部。如果不聲明@Remotable,Java interface默認(rèn)為local。典型的local Interface是細(xì)粒度的,用于緊耦合的交互。它允許方法重載,并采用by-reference語義。
          posted @ 2006-04-25 15:58 Allen Young 閱讀(853) | 評論 (0)編輯 收藏
          SCA Assembly Model涵蓋了兩種model:
          • 用來組裝緊耦合服務(wù)的model
          • 用來組裝松耦合面向服務(wù)系統(tǒng)的model

          SCA Assembly Model由一系列的artifact組成,這些artifact由XML文件中的element定義。下面先給出這些artifact的名詞:
          • Module
          • Service
          • Component
          • Entry Point
          • Reference
          • External Service
          • Wire
          • Implementation
          • SCA System
          • Subsystem
          • Module Component
          最基本的artifact是Module,它是SCA的部署單元,用來保存可以被 remote訪問的Service。一個Module包含一個或幾個Component,這些Component包含了這個Module所要提供的 business function。Component把這些function以Service的形式提供給外界,這些Service即可以被同一Model中的其他 Component使用,也可以通過Entry Point在Module之外使用。Component也可以依賴于其他Component提供的Service,這些依賴叫做Reference。 Reference即可以是對同一Module內(nèi)其他Component提供的Service的link,也可以是對Module外Service(其他 Module提供的Service)的link。連接到Module外部Service的Reference在其Module中被定義為External Service。Reference和Service之間的連接也包含在這個Module中,用Wire來表示。

          一個Component由一個配置好的Implementation組成,這個Implementation就是實現(xiàn)business function的那段程序。Component使用具體的值來配置Implementation中聲明的可配置的屬性,Component也可以把 Implementation中聲明的wiring of reference配置到具體的目標(biāo)Service上去。

          Module部署在SCA System中。一個SCA System往往表示一組相關(guān)Service的集合。為了方便建立和配置SCA System,Subsystem可以用來對Module進(jìn)行分組和配置。Subsystem包含Module Component(Module的配置好了的實例),和Module一樣,它也有Entry Point、External Service和Wire。

          下面附上兩張圖來展示這些artifact之間的關(guān)系。
          SCA-module-assembly-diagram.PNG
          SCA-system-assembly-diagram.PNG
          posted @ 2006-04-25 14:34 Allen Young 閱讀(615) | 評論 (1)編輯 收藏
          SOA and Web services 新手入門,轉(zhuǎn)自IBM DeveloperWorks,它的SOA and Web Service專區(qū)是學(xué)習(xí)SOA的很好的資源中心。本文章的內(nèi)容如下:

          1. 什么是面向服務(wù)的體系結(jié)構(gòu)(SOA)?
          2. 我可以用面向服務(wù)的體系結(jié)構(gòu)做什么?
          3. 構(gòu)成 SOA 的技術(shù)是什么?
          4. SOA 與其他技術(shù)的關(guān)系如何?
          5. 我可以如何構(gòu)建 SOA 系統(tǒng)?
          6. 我可以如何提高我的 SOA 技能?
          7. IBM 的什么工具和產(chǎn)品可用于 SOA?
          IBM肯定會為自己做廣告,呵呵,各位保持清醒就是了。
          posted @ 2006-04-25 11:09 Allen Young 閱讀(377) | 評論 (0)編輯 收藏
          Elune Team由Allen Young,atlanta,Helena和silver.sun組成,近期目標(biāo)為參加2006 IBM杯中國高校SOA應(yīng)用大賽,因此會在比賽期間在BlogJava SOA Team Blog進(jìn)行相關(guān)討論,內(nèi)容以SOA為主,會涉及參賽項目管理,團(tuán)隊文化等。
          posted @ 2006-04-25 10:23 Allen Young 閱讀(309) | 評論 (0)編輯 收藏
          歡迎各位對SOA感興趣的朋友加入討論BlogJava SOA Team Blog,下面是個人的幾點聲明,各位可以給我建議或補充。

          1. 隨筆要與Team Blog主題相關(guān),否則將刪除。
          2. 做一個Critical Thinker,對自己的言論負(fù)責(zé)。
          3. 歡迎各種觀點(我們需要不同的聲音),歡迎爭論,不歡迎爭吵。
          4. 隨筆請用Courier New字體,2號字,以便保持整體風(fēng)格一致。

          SOA是一種態(tài)度,而不是一種技術(shù)。
          posted @ 2006-04-25 10:17 Allen Young 閱讀(263) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 通化市| 河源市| 三台县| 曲麻莱县| 龙泉市| 汉阴县| 灵武市| 陆河县| 城口县| 白城市| 金华市| 新化县| 页游| 大关县| 东港市| 黄龙县| 密山市| 宕昌县| 衡东县| 太谷县| 靖西县| 西青区| 庐江县| 札达县| 科尔| 高阳县| 修武县| 新兴县| 彭水| 岢岚县| 榆树市| 灵丘县| 磐石市| 娄烦县| 苗栗县| 潼关县| 鲁山县| 宜兴市| 荥经县| 宣城市| 广宗县|