Guice injection on nested classes of CLI App -


i writing command line interface application connecting oracle database using mybatis , injection done guice.

my question injection of nested classes. class structure looks pretty this

myinjector main --menu1 ----service1 ----menua ------service2 --------menuab ----------service1 --menu2 

now need user type login , password app (can't have in config file) main initializes myinjector, grabs injector object that, , uses inject , initialize menu1. problem is, once im in menu1, needs go menua , menua going need inject services, , knows how deep end going.

now, first thought make myinjector singleton class , instances of wherever needed , grab injector field created main class in beginning, im kinda curious if there's better way.

is there more guicey way this?

maybe need @assistedinject? pass arguments factory method , instance of top level object it. other appropriately annotated fields injected automatically.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -