What about your use case prevents you from using a normal .to binding?

bind(SomeService.class).to(SomeService.class)

Nate


On Fri, Mar 7, 2014 at 4:13 PM, Mikkel Petersen <[email protected]> wrote:

> Hello all
>
> I have a slight problem with guice injection when using a method annotated
> with  @Provides
>
> example :
>
> @Provides
> public Service someService() {
>  return new SomeService()
> }
>
> I would like to get the current context injected in SomeService..I don't
> understand why Guice doesn't do that automatically, any particular reason
> for that ?
>
> I know I could do something like this (it works):
>
> @Provides
> public Service someService(@Inject Injector inj)  {
>   SomeService s =  new SomeService()
>   inj.injectMembers(s)
>   return s
> }
>
> But there must be a simpler way.
>
> Thanks
>
> Ps, another question, how to add syntax highlighting ?
>
>
>
>
>
>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-guice.
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/d/optout.

Reply via email to