Hi, 

How is your UserDb class being injected?  Make sure it's not being 
injected before the PropertiesModule, which by default is injected via the 
web.xml.

If your class isn't being injected at all you can request a static 
injection in an existing guice module (or your own). 
requestStaticInjection(UserDb.class)

I also prefer method injection to field injection for setting values.  I'm 
not sure if one is preferred over the other in the broader community or 
not.

-Stanton



From:   Evgeny Bogdanov <[email protected]>
To:     [email protected], 
Date:   12/22/2011 06:30
Subject:        Guice problem in persistence



Hi

I have small problem, maybe somebody can point out where it is.

I have this line in shindig.properties: 
shindig.signing.global-callback-url=http://localhost:8080/gadgets/oauthcallback
I want to access it from my db class.

Properties file is read in PropertiesModule.java and Guice's Named 
annotation is created with
Names.bindProperties(this.binder(), getProperties());

Then I try to access it as following in my UserDb.java class
   @Transient
   @Inject @Named("shindig.signing.global-callback-url") String 
CALLBACK_URL;

For some reason, it is always null.
Could somebody explain why I can't do it? What is the workaround. I 
don't want to read properties file again,
since it's done in PropertiesModule.java already.

Any suggestions?

Best
Evgeny


Reply via email to