On Thursday, April 25, 2013 8:04:49 AM UTC+2, mmonti wrote:
Hi guys,
>
> I really appreciate your replies. I took a look at both solutions Tim's
> micro-fwk and magic-config, but unfortunately I couldn't make it work, and
> also I am not sure if what i need. To be honest I think that I am pretty
> lost since I tried different ways to do it without success. Ill try to
> describe what "I think" my problem is and let me know if I am wrong.
>
> The thing is, I need to bind a constant to a String value:
> *bindConstant().annotatedWith(Db4Objects.class).to(
> <value-taken-from-properties> ).*
> That value should be passed to the module by the constructor or injected.
> BTW, I am using Names.bindProperties(...) to bind my config.properties
> files.
>
> So, my persistence module looks like:
>
> public class PersistenceModule extends AbstractModule {
>
> @Inject @Named("config.db4o.database")
> private String database;
>
> @Override
> protected void configure() {
>
> install(PersistenceService.usingDb4o().across(UnitOfWork.REQUEST).buildModule());
> bindConstant().annotatedWith(Db4Objects.class).to(database);
> }
> }
>
I wonder if you couldn't use:
bind(String.class).annotatedWith(Db4Objects.class).to(Key.get(String.class,
Names.named("config.db4o.database")));
In other words: you're not binding a constant value, as you're trying to
bind to another key.
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.