I am writing a command line interface application that is connecting to an oracle database using MyBatis and injection done by Guice.
My question is with injection of nested classes. My class structure looks pretty much like this
MyInjector
Main
--Menu1
----Service1
----MenuA
------Service2
--------MenuAB
----------Service1
--Menu2
Now I need my user to type their login and password into the app (can't have it in a config file) so Main initializes the MyInjector, grabs the injector object from that, and uses that to inject and initialize Menu1. The problem is, once im in Menu1, it needs to go to MenuA and MenuA is going to need to inject services, and who knows how deep this will end up going.
Now, my first thought would be to make MyInjector a singleton class and just constantly get instances of it wherever needed and grab the injector field that was created by the Main class in the beginning, but im kinda curious as to if there's a better way.
Is there a more Guicey way to do this?