I try to avoid injecting the injector where at all possible. It's very
brittle, and moves errors even further into run-time. Not saying it is
never necessary, but I haven't encountered a case where I needed to do
it except to avoid a re-work of a design that needed the re-work anyway.
Christian.
On 13 Nov 2012, at 12:58, Alper Akture wrote:
Thanks, maybe injecting the injector will be good for now, I'll take a
look
at Christian's message too. I'm a big TestNG fan btw :)
On Monday, November 12, 2012 7:38:29 PM UTC-8, Cédric Beust ♔
wrote:
Two more thoughts:
- It's possible to inject the injector (I had to do this in at least
one place in our code base). Not as bad as referencing a static
injector,
but still not optimal. I think we should create the annotation
@Inception
for this kind of trick.
- In case you missed Christian's message a few days ago, consider
defining the factory interface in the same class that it
instantiates, in
the spirit of "keeping things together". This alleviates the hassle
of
having to update both your class and your factory signatures when you
add
@Assisted parameters.
--
Cédric
--
Cédric
On Mon, Nov 12, 2012 at 6:14 PM, Alper Akture
<[email protected]<javascript:>
wrote:
Thanks Cedric, I totally agree, I don't like using the injector
directly.
I wasn't aware of assisted injection, could be very useful. However,
for
many of my classes I have problems with, I give the framework the
class
name (in an init method that they call), and they do the
instantiation.
Something like this:
public void initHandlers() {
addEventHandler(SFSEventType.USER_LOGIN,
UserLoginEventHandler.class);
...
}
And I would need to inject stuff into the
UserLoginEventHandler.class. So
I don't think assisted inject can help here, can it?
--
You received this message because you are subscribed to the Google
Groups "google-guice" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-guice/-/IR_0JPK9gNwJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.