loobiecore
Oct 6th, 2005, 05:10 AM
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 :
public void sessionDidActivate(HttpSessionEvent event) {
mySingleton = event.getSession().getServletContext().getAttribut e("mySingleton");
}
I'm not satisfied with this solution because I have to store mySingleton in the ServletContext.
any idea about a cleaner solution that enables a direct access to the WebApplicationContext ?
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 :
public void sessionDidActivate(HttpSessionEvent event) {
mySingleton = event.getSession().getServletContext().getAttribut e("mySingleton");
}
I'm not satisfied with this solution because I have to store mySingleton in the ServletContext.
any idea about a cleaner solution that enables a direct access to the WebApplicationContext ?