You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

此文来自Tuscany 邮件列表<tuscany-user@ws.apache.org>,由Raymond Feng 所写。原文为英文,此处根据自己的理解翻译为中文,不正之处,请修改
1) target 属性
a)一个SCA中的service可表示一个业务功能,该功能由component提供。比如,一个书店提供卖书的服务。
b)一个SCA中的reference表示某个component所需要使用的业务功能。比如,书店需要用到购物车和目录。
reference的属性target 指向该reference所需的service。如下:
BookStore component有一个reference

<component name="BookStoreComponent">
<reference name="catalog" target="CatalogComponent/Catalog"/>
</component>

<component name="CatalogComponent">
<service name=Catalog></service>...
</component>

target属性的意思是,CatalogComponent 的Catalog Service是catalog reference的提供者。
如果我们将CatalogComponent改名为NewCatalogComponent,那么相应的target改为:NewCatalogComponent/Catalog.

2) promote属性
在SCA中,可以采用<implementation.composite>来在一个composite中使用另一个compoiste。比如,Catalog service本身可以以composite的形式部署,
在Catalog composite中,可以用

In SCA, a pre-assembled composite can be reused as a building block for
compositions. It's achieved by <implementation.composite>. For example, the
Catalog service itself can be developed as a SCA composite. Inside the
Catalog composite, there could be a few java components.

<component name="CatalogComponent>
<implementation.composite composite="ns1:CatalogComposite"/>
...
</component>

Now the question is what services/references in the CatalogComposite will be
made public for CatalogComponent. Service/Reference promotion is introduced
for this purpose.

For example,

<composite name="CatalogComposite">
<service name="Catalog"
promote="InternalCatalogComponent/InternalCatalog">
...
</service>

<reference name="parnterCatalog"
promote="InternalCatalogComponent/partnerCatalog">
...
</reference>

<component name="InternalCatalogComponent>
...
</component>
</composite>

The @promote for the <service> says if CatalogComposite is used as a
component for assembly, there is a service named Catalog that makes the
InternalCatalogComponent's InternalCatalog service public. As a result, the
CatalogComponent has a public Catalog service that can be wired to.

The @promote for the <reference> says if CatalogComposite is used as a
component for assembly, there is a reference named partnerCatalog that makes
the InternalCatalogComponent's partnerCatalog reference public. As a result,
the CatalogComponent has a public partnerCatalog reference and a service
provider can be defined for this reference.

  • No labels