使用 Spring Framework 设计和开发 SCA 组件,第 1 部分: 三剑客:Spring、SCA 和 Apache Tuscany
2009-11-23 00:00:00 来源:WEB开发网在 calculator-context.xml(在 清单 3)中使用自定义名称空间元素声明 SCA 服务、引用和属性,如下所示。
清单 4. calculator-context.xml
<beans xmlns="http://www.springf
ramework.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.osoa.org/xmlns/sca/1.0/spring-sca.xsd"
> <sca:service
name="CalculatorService" type="calculator.CalculatorService" target="Calculator"/>
<bean id="Calculator" class="calculator.
CalculatorServiceImpl">
<property name=
"add" ref="addService"/>
<property name=
"subtract" ref="subtractService"/>
<property name=
"multiply" ref="multiplyService"/>
<property name=
"divide" ref=
"divideService"/>
</bean>
<sca:reference name=
"addService" type=
"calculator.AddService"/>
<sca:reference name=
"subtractService" type="calculator.SubtractService"/>
<sca:reference name=
"multiplyService" type="calculator.MultiplyService"/>
<sca:reference name=
"divideService" type=
"calculator.DivideService"/>
</beans>
更多精彩
赞助商链接