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="ThemeContextListener.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Ivica Cardic
28   * @author Brian Wing Shun Chan
29   */
30  public class ThemeContextListener implements ServletContextListener {
31  
32      public void contextInitialized(ServletContextEvent event) {
33          ServletContext servletContext = event.getServletContext();
34  
35          Thread currentThread = Thread.currentThread();
36  
37          ClassLoader contextClassLoader = currentThread.getContextClassLoader();
38  
39          HotDeployUtil.fireDeployEvent(
40              new HotDeployEvent(servletContext, contextClassLoader));
41      }
42  
43      public void contextDestroyed(ServletContextEvent event) {
44          ServletContext servletContext = event.getServletContext();
45  
46          Thread currentThread = Thread.currentThread();
47  
48          ClassLoader contextClassLoader = currentThread.getContextClassLoader();
49  
50          HotDeployUtil.fireUndeployEvent(
51              new HotDeployEvent(servletContext, contextClassLoader));
52      }
53  
54  }