Discussion:
Constructor with a combination of parameters and guice injected fields
Itrat Jameel
2018-05-27 10:29:27 UTC
Permalink
Hi,

I have a normal constructor with fields used for creating the object of the
class, but I also need a fields injected regarding metrics, which I dont
want my caller to pass instead get directly passed by Guice.

MyClass(<User passed parameter>, <Guice injected parameter>)
{
}

Since if constructor injection is happening, then field injection is not
getting invoked.How can I achieve this?
--
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 google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/5a351d5a-83ad-45ba-bdfd-60a302fef9b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Stuart McCulloch
2018-05-27 10:33:12 UTC
Permalink
You're looking for https://github.com/google/guice/wiki/AssistedInject
Post by Itrat Jameel
Hi,
I have a normal constructor with fields used for creating the object of
the class, but I also need a fields injected regarding metrics, which I
dont want my caller to pass instead get directly passed by Guice.
MyClass(<User passed parameter>, <Guice injected parameter>)
{
}
Since if constructor injection is happening, then field injection is not
getting invoked.How can I achieve this?
--
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
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/5a351d5a-83ad-45ba-bdfd-60a302fef9b7%40googlegroups.com
<https://groups.google.com/d/msgid/google-guice/5a351d5a-83ad-45ba-bdfd-60a302fef9b7%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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 google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/CAMr6Z4%3DsFqJa-%3D-bzSvr%3Dhy_qhMNTeV0z%2BPh8t06KgZSQ4NgsA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...