I have a session scoped bean in my @Controller: it is called SessionPreferences and I hope its name will explain what it does 🙂
Almost any of my controllers make use of it, so I easily inject it in each controller via @Autowired.
I wanna go deeper so…. how can I avoid this duplication? Can I have a “father” controller in my application, in order to store all shared references to services, other beans and so on?
Maybe an abstract class that the controllers implement would be helpful?
If I’m understanding you, though, you want a class that you basically inject all of your services and daos into directly then the rest of those classes would inherit off of it?
This might cause issues with the way Spring sets up it’s proxies when classes reference the singletons you inject. Not 100% sure though, might want to avoid doing this.
Also, if you break one of your services, all of your controllers that inherit from that base class would be broken, don’t really recommend this. You’re coupling your controllers with too many facets of your application.