Monday, 12 August 2013

RoboGuice injection of POJOs into POJOs

RoboGuice injection of POJOs into POJOs

My Guice is a little rusty (been 3 years) so bear with me. I have a custom
API (@ContextSingleton) object that I need to @Inject into my various
classes. This works fine when the target class extends from RoboActivity
(or in my case, RoboSherlockActivity). However, when I want to inject it
into a POJO, the injection fails and I get a null object.
Am I missing anything here? I tried writing a custom Provider for the API
object (returning a new Api()), but the object creation graph isn't
complete as any @Inject members within the API object is still null.
Right now I'm working around this by passing in the API object into POJOs
instead of injecting it, but I'd like to eventually use @Inject for
consistency.

No comments:

Post a Comment