我想知道两个绑定后的范围有哪些:
bind(PermissionManager.class).in(Singleton.class);
和
bind(PermissionManager.class);
我已经阅读了 JavaDocs,它们如下。对于单身人士:
/**
* Apply this to implementation classes when you want only one instance
* (per {@link Injector}) to be reused for all injections for that binding.
*
* @author crazybob@google.com (Bob Lee)
*/
对于没有范围:
/**
* No scope; the same as not applying any scope at all. Each time the
* Injector obtains an instance of an object with "no scope", it injects this
* instance then immediately forgets it. When the next request for the same
* binding arrives it will need to obtain the instance over again.
*
* <p>This exists only in case a class has been annotated with a scope
* annotation such as {@link Singleton @Singleton}, and you need to override
* this to "no scope" in your binding.
*
* @since 2.0
*/
这实际上意味着什么?每个客户端或每个 JVM 是单例吗?没有范围,每个实例都不同吗?