使用 Spring Framework 设计和开发 SCA 组件,第 2 部分: 使用 Apache Tuscany 的高级技巧
2010-02-25 00:00:00 来源:WEB开发网清单 6. CalculatorServiceImpl.java
@Service(CalculatorService.class)
public
class CalculatorServiceImpl implements CalculatorService {
// setter injection
public AddService addService;
// field injection
@Reference
public SubtractService subtractService;
// field injection (different reference and field name)
@Reference(name="multiplyService")
public MultiplyService multiply;
// setter injection (different reference and field name)
public DivideService divide;
// setter injection
public String message;
@Reference
public
void setAddService(AddService addService) {
this.addService = addService;
}
public AddService getAddService() {
return addService;
}
public
void setSubtractService(SubtractService subtractService) {
this.subtractService = subtractService;
}
public SubtractService getSubtractService() {
return subtractService;
}
@Reference(name="divideService")
public
void setDivideService(DivideService divide) {
this.divide = divide;
}
public DivideService getDivideService() {
return divide;
}
public
void setMultiplyService(MultiplyService multiply) {
this.multiply = multiply;
}
public MultiplyService getMultiplyService() {
return multiply;
}
@Property
public
void setMessage(String message) {
this.message = message;
}
…
}
更多精彩
赞助商链接