Just thought I'd check in and see if you had any comments on this. I think supporting requestStaticInjection for typelisteners would be a natural extension to the typelistener functionality, and not having it means you can't use custom injection annotations when trying to support legacy singletons.
I'd like to be able to support this for users of my libraries. Is there another mechanism I can plug into in order to work around this limitation? Cheers, Mike On Nov 13, 4:26 pm, Michael Burton <[email protected]> wrote: > > Looks like a bug in our documentation. As they were designed, > > TypeListeners aren't appropriate for static injection. They are > > intended to expose facilities for per-instance callbacks > > (InjectionListener) and per-instance injections (MembersInjector), > > neither of which is appropriate for static injection. > > > What did you have in mind? > > Ah, that would explain it then. It's certainly unexpected that they wouldn't > work for static injection -- is that a technical limitation? > > I've created my own custom injection annotations (@InjectResource) which I > use to inject Android resources into objects. I wasn't able to use the > standard @Inject annotation because android resources are identified with an > int identifier, and there's no way to pass the value of an annotation to a > provider in guice 2.0, at least. > > Here's an example: > > @InjectResource(R.id.network_error_msg) protected String networkErrorMsg; > > Like any other injected objects, these are usually done as non-static > members, but occasionally when dealing with legacy code it is necessary to > inject these values into static fields. So I tried injecting them statically > into a legacy singleton I had, and you know the rest. > > From some conversations on the group it seems like TypeListeners are the > preferred mechanism to define custom injection mechanisms like the one I > mention above. As such, it seems like it would be useful for them to also > support static injection. > > Does that sound reasonable? > > Cheers, > Mike -- 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=.
