java - How to get DI working with Guice and Webapps? -


how di work in webapp? far i've done following:

1) annotate setter method @inject

2) extend abstractmodule binds interface class implementation class attribute setter annotated in step 1

3) extend guicecontextservletlistener , overrode getinjector returns guice.createinjector(new extendedabstractmodule())

4) registered extended guicecontextservletlistener in web.xml listener

i've verified extended guicecontextservletlistener.getinjector() method called when webapp started. attribute setter annotated not being injected , remains null.

i went ahead , created servletmodule serves servlet instantiates object @inject setter. after instantiating object injector servletcontext , call injectmembers method passing instantiated object.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -