這是本文件的舊版!


Guice

Notes

  • @ImplementedBy 等效於Module中做Bind to的動作。如果有多個implementation,宣告的就是預設值。
  • @Provider 等效於Module中設定Provider的動作。
  • 用Provider的目的是為了針對同一種interface可能會有不同type的instance,如果將不同type判斷寫在Module邏輯中是不好的。可以把它當simple factory用。
  • 一個APP只會有一個類別會與Injector溝通,APP不會直接與Injector溝通,而是透過此類別與Injector溝通。(把Guice當Service Locator)

Resource

Refactoring