Hi, I'm new to Guice and lack experience in using it the suggested
(intended) way. I already figured out most of what I need to use Guice
in a relatively simple application and like it very much but one thing
is missing: injecting static dependencies.

I need this in classes that contain only static methods (a utility
class). For the sake of an example, think of a logger that should be
injected and be usable by the static methods. Let's say it looks like
this:

public class Utils {

  @Inject private static Logger log;

  public static void logFoo( Foo bar )
  {
    log.info( bar.toString() );
  }

}

How do I inject the Logger correctly? My current approach is to use
"requestStaticInjection( Utils.class )" in my Guice module but,
according to the docs, this is discouraged. What other options do I
have?

Thanks for your help!

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to google-gu...@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to