Hi Anton,
Yes, you can inject dynamic lists into components using `injector#injectMembers()` - to do this you would install a WireModule around the application modules before creating the injector. You'd then need to share the same bean locator instance across any child/sibling injectors so components in them can be discovered.
Note this assumes that either the component being injected via `injector#injectMembers()` is mentioned in the application modules or the type of the dynamic list is bound somewhere using `requireBinding` so that the WireModule knows to register a binding for that particular dynamic list backed by the locator. This is because Guice doesn't let you create complex bindings on the fly (it only supports very simple just-in-time bindings.)
For example, assuming MyComponent exposes a setter to inject the dynamic list:
// where sharedBeanLocator is shared with other injectors using "bind(BeanLocator.class).toInstance(sharedBeanLocator);" in their configuration
MyComponent component = new MyComponentImpl();
Guice.createInjector(new WireModule(new AbstractModule() {
protected void configure() {
bind(MyComponent.class);
bind(BeanLocator.class).toProvider(() -> sharedBeanLocator);
// ^ provider so we can discover bindings in other injectors using this locator without publishing our bindings
}
})).injectMembers(component);
This is just a quick example - if you can provide more details about your use-case I can come up with more detailed suggestions.
--
Cheers, Stuart