can i configure HttpSession in spring bean xml configuration file ? i have to create HttpSession fectory so i can use this all session objects to every where.
is there any way to put object under HttpSession with xml configuration file ??
can i configure HttpSession in spring bean xml configuration file ? i have to create HttpSession fectory so i can use this all session objects to every where.
is there any way to put object under HttpSession with xml configuration file ??
You could write a DelegatingHttpSessionListenerProxy
in similary way that the framework DelegatingFilterProxy
.
For example (very simple and not tested)
public class DelegatingHttpSessionListenerProxy implements HttpSessionListener {
private HttpSessionListener delegate;
private WebApplicationContext wac;
@Override
public void sessionCreated(HttpSessionEvent event) {
if (wac == null) {
wac = findWebApplicationContext(event);
}
if (wac != null) {
delegate = wac.getBean(HttpSessionListener.class);
delegate.sessionCreated(event);
}
}
@Override
public void sessionDestroyed(HttpSessionEvent event) {
if (wac == null) {
wac = findWebApplicationContext(event);
}
if (wac != null) {
delegate = wac.getBean(HttpSessionListener.class);
delegate.sessionDestroyed(event);
}
}
protected WebApplicationContext findWebApplicationContext(HttpSessionEvent event) {
return WebApplicationContextUtils.getWebApplicationContext(event.getSession().getServletContext());
}
Then, register the proxy in web.xml and manage your real implementation in the application context.