My app is using Spring/Hibernate and I am using the @SpringBean annotation
based dependency injection to tie in my services. During my development, I
found I needed access to one of the services at the session layer and found
a thread that discussed how to do that by calling out
"InjectorHolder.getInjector().inject(this);" in the init when constructing
the session.

Now I am wondering if it is more optimal to move all of my other service
lookup injectors to the session scope. To me, it seems that this would be
more optimal as the app would only need to inject the service once as
opposed to potentially many times if replicated within several components.
However, the trade-off may be holding service-level data at a session level,
thus sticking around for the life of the session. Is this a correct
analysis, or is it simply good practice to create injectors to services at
the session layer so that only one instance is ever created for a given
session?

Reply via email to