So, I would personally recommend not doing that except at the edges of a
system that uses D-I and a system that doesn't. Generally speaking, I
would tend to suggest that if you need to inject a request-scoped object
into a singleton, then it isn't really a singleton, or the other isn't
really a request-scoped object, but probably you have parts of one or
the other that need to be factored out, and THAT is in one or the other
scope. Most scoping bugs of the sort you describe I find come from
improperly composing/decomposing your app. As much as possible,
incorporate clarity as to the lifetimes of your different components
into the constraints of your design, and remember that these
validities/lifetimes are concentric (singleton contains session contains
request, etc.)
That said, a few such cases are the result of integrating with legacy
systems, but even there, you should minimize the need for such hedges as
injecting Provider<T>. But if you need to, that's the place to do it.
Christian.
On 3 Sep 2013, at 17:22, [email protected] wrote:
I just realized that it may be wrong to always get two different
instances
of a dependency when calling two times its getter, when the dependency
has
no scope...
Anyway, I'll still interested by suggestions on how to minimize those
scope
bugs!
--
You received this message because you are subscribed to the Google
Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to
[email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.
Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency
Injection
email: [email protected] :::: mobile: +1 (646) 807-9839
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.