托斯卡尼 tuscany2续

本文介绍了SCA(Service Component Architecture)中服务组件的配置方式,重点讲解了引用属性(reference)的不同设置方法及其对服务植入的影响。文章还探讨了多个服务引用、不同multiplicity属性值的作用,并解释了如何在不同的SCA域中连接组件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

5、多个引用属性

   refrence标签的multiplicity属性,可以指定植入服务的数量。

multiplicity="1..1"-----------------------------引用总是被植入单独的服务

multiplicity="1..n"----------------------引用可以植入多个服务

multiplicity="0..1"------------------------引用可以不植入服务

multiplicity="0..n"----------------------引用可以植入多个服务,或者不植入服务

对于java技术,如果使用reference注解,那么可以选择required属性,如果是false,那么说明可以不用注入该引用到服务。

一个数组或者集合类型,说明这个引用时多个的

 

 

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://tuscanyscatours.com/"
name="carbookings1">
<component name="CarPartner">
<implementation.java
class="com.tuscanyscatours.usingsca.impl.CarPartnerImpl" />
<reference name="cars" target="JoesCars KensCars" />
Listing 2.5 Wiring references with different multiplicities
Figure 2.8 The cars reference
of CarPartner is wired to two car
vendor components: JoesCars and
KensCars. The other reference,
luxuryCars, is left unwired.
Connecting components using references and wires 55
</component>
<component name="JoesCars">
<implementation.java
class="com.tuscanyscatours.usingsca.impl.CarVendorImpl" />
</component>
<component name="KensCars">
<implementation.java
class="com.tuscanyscatours.usingsca.impl.CarVendorImpl" />
</component>

 

<reference name="cars">
<binding.ws uri="http://tuscanycars.com:8081/Cars" />
</reference>这个reference没有target属性,因为binding提供了引用的地址信息

<reference name="hotels" target="HotelPartner" />这个reference没有binding属性,所以他有一个默认的binging.sca,这个默认的binding用来连结sca服务

通过sca引用连结sca服务,而且必须在同一个sca域(SCAdomain)

6、SCA Domain(域)

    每个sca组件是域的一部分,在同一个域 的引用和服务可以通过植入互相连结,可以使用默认的binding,不同域的sca组件,必须使用可互操作的绑定实现引用(比如

  binding.ws).

 

<component name="HotelPartner">
<implementation.java class=
"com.tuscanyscatours.usingsca.impl.HotelPartnerImpl" />
<service name="Hotels">
<binding.ws uri=
"http://tuscanyscahotels.com:8083/Hotels" />
<binding.sca />
</service>
</component>
<component name="HotelOffers">
<implementation.java class=
"com.tuscanyscahotels.impl.HotelOffersImpl" />
<reference name="hotels"
target="HotelPartner/Hotels" />
</component>

同时指定bing.sca和binding.ws是很重要的,因为如果没有binding.sca,那么HotelOffers组件的引用是不能使用默认的binding.sca的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值