SCA学习之2--SCA中使用SPRING笔记

     最近在看APACHE 的TUSCANY,其中的simple-bigbank-spring的例子,就是说如何在SCA中使用SPRING的。
首先看resources目录下bigbank.compsite文件

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
 xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
 targetNamespace="http://bigbank"
 xmlns:s="http://stockquote"
 name="BigBank">

    <component name="AccountServiceComponent">
        <implementation.spring location="Account-spring-context.xml"/>
        <reference name="stockQuoteService" target="StockQuoteServiceComponent"/>
    </component>

    <component name="StockQuoteServiceComponent">
        <implementation.composite name="s:StockQuote"/>
    </component>

</composite>
可以看到,在AccountServiceComponent这个组件中,其实现是直接用<implementation.spring location="Account-spring-context.xml"/>
指向了spring的配置文件。再看具体的这个SPRING配置文件
  

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:sca="http://www.springframework.org/schema/sca"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/sca http://www.springframework.org/schema/sca/spring-sca.xsd">

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

    <bean id="AccountServiceBean" class="bigbank.account.AccountServiceImpl">
        <property name="accountDataService" ref="AccountDataServiceBean"/>
        <property name="stockQuoteService" ref="stockQuoteService"/>
        <property name="currency" value="USD"/>
    </bean>

    <bean id="AccountDataServiceBean" class="bigbank.accountdata.AccountDataServiceImpl">
    </bean>

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

</beans>
由于是在SCA的容器内,所以这里要引用外部的服务的话,依然要用<sca:reference>来进行。

你可能感兴趣的:(apache,spring,bean,xml)