I've used Spring before (and like it), but thought I'd take a look at Guice.
Is there a way to initialize something like maps or lists into beans using Guice?
For instance, I've done the following before in Spring to inject a list of items I want to process into some bean.
<property name="FilesToProcess">
<list>
<value>file1.xml</value>
<value>file2.xml</value>
</list>
</property>
How can I do this in Guice?
Guice2 has MultiBindings and MapBindings, which should work for you.
https://github.com/google/guice/wiki/Multibindings
Updated:
After looking at this again, it seems that you may be asking how you can inject runtime values into Guice, perhaps as arbitrary objects.
Guice is very focused around doing everything as typesafe code, so it doesn't lend itself naturally to this. What I've done to provide input to Guice is to create an XML schema and use jaxb to suck this in and inject the resulting objects.
There is a Names.bindProperties method for binding regular old properties into Guice constants.
There is also some level of integration with Spring, so you may want to look at this as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With