On Jan 27, 11:48 am, "Kitching, Simon" <[email protected]> wrote: > I'd like to use AssistedInject with classes whose names are only known > at runtime [note: I'm using Guice3.0rc1].
[snip] > == Guice 3.0-style attempt > > I can't see how to "dynamically" create factories at all with Guice3.0; > the "FactoryProvider2" class is package-scoped. Using a Module isn't > possible, as the classes are being created after Guice initialisation is > complete. Sigh. I figured out a solution soon after sending this mail :-(. Using Injector i2 = injector.createChildInjector(new MyFactoryModule(jobClass)); i2.getInstance(JobFactory.class).newInstance(manualParam); works fairly well. In other words, a Module *is* used to create the necessary binding, as per normal docs, and each new generated factory resides in a separate child injector so the repeated binding of the same factory interface to multiple concrete created types doesn't conflict. Sounds entirely reasonable. If anyone has an alternative solution, I'd be happy to hear it - but this one works ok for me. Cheers, Simon -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
