1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.servlet;
16  
17  import com.liferay.portal.kernel.deploy.hot.HotDeployEvent;
18  import com.liferay.portal.kernel.deploy.hot.HotDeployUtil;
19  
20  import javax.servlet.ServletContext;
21  import javax.servlet.ServletContextEvent;
22  import javax.servlet.ServletContextListener;
23  
24  /**
25   * <a href="WebContextListener.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class WebContextListener implements ServletContextListener {
30  
31      public void contextInitialized(ServletContextEvent event) {
32          ServletContext servletContext = event.getServletContext();
33  
34          Thread currentThread = Thread.currentThread();
35  
36          ClassLoader contextClassLoader = currentThread.getContextClassLoader();
37  
38          HotDeployUtil.fireDeployEvent(
39              new HotDeployEvent(servletContext, contextClassLoader));
40      }
41  
42      public void contextDestroyed(ServletContextEvent event) {
43          ServletContext servletContext = event.getServletContext();
44  
45          Thread currentThread = Thread.currentThread();
46  
47          ClassLoader contextClassLoader = currentThread.getContextClassLoader();
48  
49          HotDeployUtil.fireUndeployEvent(
50              new HotDeployEvent(servletContext, contextClassLoader));
51      }
52  
53  }