Hi jan, On Oct 8, 2009, at 6:47 AM, Jan Kriesten wrote:
This is an interesting approach. From what I remember from guice, you can use it to overcome the problem of having to start all your object by injection (classes that initiated by "new" can not use the injector anymore). But does it preserve the ability to know at startup if all your injections are resolved?Hi Haim,Yes, I remember seeing that. How would you add it to wicket? by adding ServiceInjector trait to the Application class or using the wicket- guice way (addComponentInstantiationListener(new GuiceComponentInjector(this));)?the Injector is just a trait, so anywhere it's needed, I just add it to the corresponding class - whether it's a Wicket component or not doesn't matter. Soyou have class MyWebPage extends WebPage with Injector { @Inject val domainRepo: DomainRepo = domainRepo } class DomainRepo extends Repo with Injector { @Inject val customerRepo: CustomerRep = customerRepo } This is a general approach, so no need to add a intantiation listener.
BTW, to test it I need to supply a custom Module since I can not invoke the class without injection. am I right?
One more question about injections in wicket. How can I handle the session object. Do I have to use the getSession method, or can I inject the session object as well?One more question though, In the example you're only using constructorinjection. Any reason not to use field injection?Actually, I use field injection most of the time, see above. Best regards, --- Jan.
Thanks for your help -- Haim
PGP.sig
Description: This is a digitally signed message part