WebApplicationInitializer provides a way to programmatically represent a good portion of a standard web.xml file - the servlets, filters, listeners.
However I have
In web.xml
3
-->
Listener Class
public class ProductBidRollBackListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
HttpSession session=httpSessionEvent.getSession();
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
ProductService productService=(ProductService) context.getBean("productServiceImpl");
Cart cart=(Cart)session.getAttribute("cart");
if (cart!=null && cart.getCartItems()!=null && cart.getCartItems().size()>0){
for (int i=0; i