Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation - Confusion with PrivateModule behavior #1206

Open
monday0rsunday opened this issue Sep 15, 2018 · 1 comment
Open

Documentation - Confusion with PrivateModule behavior #1206

monday0rsunday opened this issue Sep 15, 2018 · 1 comment

Comments

@monday0rsunday
Copy link

monday0rsunday commented Sep 15, 2018

Hello Guice,

Documentation of PrivateModule say that:

A module whose configuration information is hidden from its environment by default. Only bindings that are explicitly exposed will be available to other modules and to the users of the injector. This module may expose the bindings it creates and the bindings of the modules it installs

However I'm not sure what is hidden configuration information

As far as I know, the behavior of PrivateModule is that:

  • if a binding is not exposed, then you can not declare it(1)

(1) let to this confuse situation that you can not using combine/override with following modules:

  • a PrivateModule P which has non-exposed binding of class C
public class P extends PrivateModule {
void configure() {
  bind(C.class).toInstance(new C("Private C"));
}
}
  • a normal Module N which has also binding of class C
public class N extends AbstractModule {
void configure() {
  bind(C.class).toInstance(new C("Any C"));
}
}

The error is A binding to ... was already configured ...., which recognize configuration environment!

So do you think that PrivateModule documentation should be updated? And if it is possible, an example which describe why PrivateModule exists would be great.

Thank you in advance.

@lapkritinis
Copy link

Example why PrivateModule exists are here:
https://github.com/google/guice/wiki/GuicePersistMultiModules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants