Has anyone used ServiceLoader together with Guice?

前端 未结 3 1666
既然无缘
既然无缘 2021-01-31 11:41

I keep wanting to try this on a larger scale with our app + build system, but higher priorities keep pushing it to the back burner. It seems like a nice way to load Guice module

3条回答
  •  一向
    一向 (楼主)
    2021-01-31 11:55

    "because its impossible to bind the same interface twice."

    This is indeed wrong! With Guice's Multibinder there is a way to work with different implementations of the same interface, possibly bound in different modules.

    I came to a slightly different solution for the actual loading than Mark Renouf (his ModuleLoader looks indeed better), but my blog post may show a bit more about the environment where this approach is applicable (Plugins) and what the extension points look like:

    Guice 2.0 Multibinder + Java ServiceLoader = Plugin mechanism

提交回复
热议问题