尽展体育的魅力,创造历史辉煌!2008让我们为奥运加油,为中国加油!
 
 奥运金牌榜
  
  高级搜索
  首页   技术论坛   博客   产品中心   资源中心   银弹在线   商城  





SCA与Spring框架    
#1楼
给作者发送短消息 给作者发送短消息 实名会员 
查看用户其他信息
总分 126 分
财富 547 goCom币
威望 53
排名 :(
段位 新手必读
简介

       Spring框架普遍用于构建Java应用。它的目标是要减少编程环境的复杂度,与SCA有许多相同的设计原则。特别地,Spring提供了依赖注入机制的运行时容器,以便应用组件能避免直接对中间件API的编码。这也是SCA众多关键原则之一。

       SCA和Spring是天然的合作者。Spring在SCA中可以做为一种组件实现技术来使用。Spring框架能用于创建服务组件,并通过其依赖注入特性来连线构件中的服务组件。SCA既可通过将Spring bean作为SCA的组件服务来公布给其他SCA组件或远程客户来访问的方式,也可以通过为连线到服务的服务引用提供Spring bean的方式,来扩展Spring组件的功能。开发者和装配者可以衡量两种技术在他们应用中的力度。

       SCA是实现、框架和语言无关的服务构件和编程技术,SCA可以增加有用的功能到使用Spring实现的应用中。比如

u       支持远程组件

u       支持使用多协议的通讯

u       支持从各种编程语言实现的组件装配成应用

u       支持异步编程模式

u       支持组件以及组件与组件之间的灵活策略应用

       SCA和Spring的集成使得Spring在用Java构建SCA组件非常自然。

Spring组件实现规范概述

       SCA spring组件实现规范指定了Spring框架在SCA中如何做为组件实现技术使用。

       在粗粒度级别上,提供了在SCA中支持Spring框架。在SCA中可以使用已存在的Spring application context作为组件实现。支持Spring集成的SCA运行时环境支持在SCA装配中使用application context。对于这么一个组件,有可能不需要引入SCA metadata到Spring的配置中就可以连线(wire)Spring服务和引用。Spring上下文需要知道非常少的关于SCA环境的信息。指出了SCA元数据和Spring context的交互的两点是服务和引用。任意的策略强制性,如安全特性是由SCA运行时在调用Spring application context时,在最终信息达到目标spring bean之前提供的。在由application context向外调用时,SCA提供的引用可以提供策略强制性。

       也可以在Spring配置中作为bean指定与SCA相关的元数据。Spring组件实现规范指定如下来完成以上工作:

u       Spring bean作为组件服务,对SCA有效。

u       Spring bean描述SCA属性。

u       Spring bean描述SCA 引用。

       三个元素:sca:service,sca:reference和sca:property,用于在Spring application context配置中来各自地标识SCA服务,SCA引用或SCA属性。

       使用Spring来实现BigBank案例

       在这节中,我们将看到Spring application context是如何被用于实现BigBank应用变种的。BigBank应用在SCA 0.9规范的白皮书中公布过。Bigbank.account构件装配图如下所示:


       bigbank.account构件由AccountService和AccountDataService两个组件构成。它还将AccountService服务暴露在构件外部,同时依赖于构件外部的StockQuoteService引用。AccountService组件有两个依赖。第一个是外部的引用,第二个是对由AccountDataService组件提供的服务的连接。AccountService组件和AccountDataService组件都用Spring application context实现。在这种情况下,AccountDataService组件使用已存在的Spring bean AccountDataService实现,如下所示:

<beans>

    <bean id="AccountDataService" class="bigbank.account.AccountDataService"/>

</beans>

       正如它展示的,在application context中没有SCA元数据。

       AccountService组件使用SCA感知的Spring application context实现,如下所示:

<beans>

    <bean id="X">

        <property name="aPropertyName" ref="Y"/>

    </bean>

    <bean id="Y">

        <property name="SQRef" ref="StockQuoteService"/>

        <property name="ADRef" ref="AccountDataService"/>

    </bean>

    <sca:service name="AccountService" type="bigbank.account.AccountService" target="X"/>

    <sca:reference name="StockQuoteService" type="bigbank.account.StockQuoteService"/>

    <sca:referencename="AccountDataService" type="bigbank.account.AccountDataService"/>

<beans>

       该组件使用了两个Spring bean X和Y来实现。application context包含了SCA服务和引用的显式声明。AccountService是导出的服务,还有了两个引用:StockQuoteService和AccountDataService。AccountDataService引用是该application context外部的一个引用,由SCA连线到前面讲到的AccountDataservice组件所导出的服务。StockQuoteService引用也是该application context外部的一个引用,并由SCA运行时外部的StockQuote Web service提供。

       使用Spring组件实现技术的SCA装配SCDL文件和相应的图以及Spring application context如下所示:


                 targetNamespace="http://bigbank.com"

                 name="bigbank.account">

 

       <service name="AccountService" promote="AccountServiceComponent">

              <interface.java inter/>

              <binding.ws port="... #wsdl.endpoint(AccountService/AccountServiceSOAP)"/>

       </service>

 

       <component name="AccountServiceComponent">

              <implementation.spring location="..." />

              <reference name="AccountDataService" target="AccountDataServiceComponent"/>

              <reference name="StockQuoteService" target="StockQuoteService"/>

       </component>

 

       <component name="AccountDataServiceComponent">

              <implementation.spring location="..."/>

       </component>

 

       <reference name="StockQuoteService"

                promote="AccountServiceComponent">

              <interface.java inter/>

              <binding.ws port="...#wsdl.endpoint(StockQuoteService/StockQuoteServiceSOAP)"/>

       </reference>

 

</composite>

       总结

       SCA和Spring框架作为基于面向服务架构的业务解决方案方面,为构建Java组件形成了很好的合作关系。两个模型的体系联盟一气,并且SCA为使用Spring 框架的Java实现的组件提供更广泛的装配支持。

       参考资料




 

Re: SCA与Spring框架    
#2楼
给作者发送短消息 给作者发送短消息  
查看用户其他信息
初级会员
 

Re: SCA与Spring框架    
#3楼
给作者发送短消息 给作者发送短消息 实名会员 
查看用户其他信息
初级会员
 

Re: SCA与Spring框架    
#4楼
给作者发送短消息 给作者发送短消息  
查看用户其他信息
总分 12 分
财富 2 goCom币
威望 1
排名 :(
段位 新手必读
 




发表回复
账号用户名   密码   登录
内容:url email imgsrc image code quote
范例 Example
bold italic underline linethrough   


 [更多...]