????Guice????Google???Bob lee?????????????????java IoC?????????????????
????????????spring??100????
????????????(????????????????????Guice???????)?????????annotation????????????????????顣
???????????????????????????
????Guice??spring??????????Guice??????????????????????????????????OSGI??????spring????????????????
????????
?????????????IOC???????????????????????????????????????Guice?????????????????????Σ??????????????@Inject???磺
???????
public class OrderServiceImpl implements OrderService {
private ItemService itemService;
private PriceService priceService;
@Inject
public OrderServiceImpl(ItemService itemService?? PriceService priceService) {
this.itemService = itemService;
this.priceService = priceService;
}
...
}
???????
public class OrderServiceImpl implements OrderService {
private ItemService itemService;
private PriceService priceService;
@Inject
public void init(ItemService itemService?? PriceService priceService) {
this.itemService = itemService;
this.priceService = priceService;
}
...
}
????(setter)???
public class OrderServiceImpl implements OrderService {
private ItemService itemService;
private PriceService priceService;
@Inject
public void setItemService(ItemService itemService) {
this.itemService = itemService;
}
@Inject
public void setPriceService(PriceService priceService) {
this.priceService = priceService;
}
...
}