I'm not positive, but it's unlikely that it would work because TypeListener.hear sets Guice up for how to perform injections. It wouldn't make sense to inject things prior to knowing how to inject them. You may be able to workaround it by constructing your TypeListener with a provider of what you want. Something like: 'myTypeListener = new MyTypeListener(binder().getProvider(Foo.class));'.
sam On Mon, Nov 1, 2010 at 8:57 AM, Simone Tripodi <[email protected]>wrote: > Hi all guys, > does the TypeListener support request injection before the hear() > method is executed? I mean, in Guice 2.0 the following code doesn't > work, any chance to making this working with next release? Thanks in > advance! > > class MyTypeListener implements TypeListener { > @Inject Service service; > > public void setService(Service service) { > this.service = service; > } > > public <T> void hear(TypeLiteral<T> typeLiteral, TypeEncounter<T> > typeEncounter) { > // something magic that requires this.service > } > } > > @Override > protected void configure() { > MyTypeListener myTypeListener = new TypeListener(); > binder().requestInjection(myTypeListener); > bindListener(Matchers.any(), myTypeListener); > } > > http://people.apache.org/~simonetripodi/<http://people.apache.org/%7Esimonetripodi/> > http://www.99soft.org/ > > -- > 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]<google-guice%[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.
