Hi,
I've got a bean "mybean" that is stored in a HttpSession and that should be ApplicationContext aware to access a singleton "mySingleton".
My question regards what happens if my http session is passivated.
If I implement the ApplicationContextAware interface, i guess I will have no valid reference on the WebApplicationContext any more when the bean will be activated, since the WebApplicationContext is not serializable
I've implemented HttpSessionActivationListener for "mybean" like this :
I'm not satisfied with this solution because I have to store mySingleton in the ServletContext.Code:public void sessionDidActivate(HttpSessionEvent event) { mySingleton = event.getSession().getServletContext().getAttribute("mySingleton"); }
any idea about a "more Spring"solution that enables a direct access to the WebApplicationContext ?


Reply With Quote