托斯卡尼 tuscany2续

来源:互联网 发布:义乌市盛灿网络 编辑:程序博客网 时间:2024/06/05 09:00

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的