Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When would one install a Guice module?

Tags:

java

guice

I'm referring to Binder.install() - when would one use that?

like image 686
ripper234 Avatar asked Dec 16 '22 14:12

ripper234


1 Answers

A couple examples:

  • Your module depends on bindings from another module and you don't expect the user of your module to provide those bindings (they're for some internal stuff, perhaps).
  • You'd prefer to group several modules in one rather than listing them all out in Guice.createInjector. For example, you might want to install several modules for services inside the ServletModule that defines the servlets/filters that use those services.
like image 55
ColinD Avatar answered Dec 26 '22 19:12

ColinD