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