WEB开发网
开发学院软件开发Java 使用 Spring Framework 设计和开发 SCA 组件,第 ... 阅读

使用 Spring Framework 设计和开发 SCA 组件,第 2 部分: 使用 Apache Tuscany 的高级技巧

 2010-02-25 00:00:00 来源:WEB开发网   
核心提示: 清单 6. CalculatorServiceImpl.java@Service(CalculatorService.class)publicclassCalculatorServiceImplimplementsCalculatorService{//setterinjectionpublic

清单 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; 
  } 
   
  … 
} 

上一页  3 4 5 6 7 8 9  下一页

Tags:使用 Spring Framework

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接