Hi Mauro, I've been meaning to write about this very topic for a while and your email finally pushed me over the edge:
http://www.refresh.io/2013/04/flexible-configuration-with-guice/ This describes a simple, statically-typed (no @Named cop out!) way of injecting individual configuration parameters using Guice. For example: public class A { @Inject @Prop(Property.HOST) private String host; @Inject @Prop(Property.PORT) private Integer port; } It seems to match closely what you are looking for, let me know what you think! -- Cédric -- Cédric On Sun, Apr 21, 2013 at 11:47 PM, mmonti <[email protected]> wrote: > Hi guys, > > Quick question from a newbie using Guice.. :) > I have the following module that I am using to persist my objects with > db4o: > > public class PersistenceModule extends AbstractModule { > private static final Logger logger = > LoggerFactory.getLogger(DefaultBootstrapModule.class); > private static final String BOOKINGS_DATA = "./target/bookings.data"; > @Override > protected void configure() { > > install(PersistenceService.usingDb4o().across(UnitOfWork.TRANSACTION).buildModule()); > bindConstant().annotatedWith(Db4Objects.class).to(BOOKINGS_DATA); > } > } > > Is there any way to "provide" to this module the database name, for > example injecting the value into the module? What is the correct > approach/pattern for this case? > The idea is to take this configuration parameter from a properties file. I > have already an object that provides me these values from the property, but > i cant find the way to inject it to this module. I dont know if its > possible but i assume that is a pretty common use case, so i would like to > know what is the best way to do it. > > Thanks! > > > > > -- > 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. > > > -- 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.
