1 /* *************************************************************************** 2 * Copyright (c) 2008 Brabenetz Harald, Austria. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 *****************************************************************************/ 17 18 package org.settings4j.helper.web; 19 20 import javax.servlet.ServletContextEvent; 21 import javax.servlet.ServletContextListener; 22 23 24 /** 25 * {@link javax.servlet.ServletContextListener} to initialize the {@link DefaultPropertiesLoader}. 26 * <p> 27 * Example Configuration could look like the following: 28 * 29 * <pre> 30 * web.xml 31 * -------------------------------------- 32 * <context-param> 33 * <param-name>settings4jDefaultProperties</param-name> 34 * <param-value> 35 * com/myCompany/myApp/log4j.configuration=com/myCompany/myApp/log4j.xml 36 * </param-value> 37 * </context-param> 38 * 39 * <listener> 40 * <display-name></display-name> 41 * <listener-class>org.settings4j.helper.web.DefaultPropertiesLoaderListener</listener-class> 42 * </listener> 43 * -------------------------------------- 44 * </pre> 45 * 46 * @author brabenetz 47 */ 48 public class DefaultPropertiesLoaderListener implements ServletContextListener { 49 50 /** {@inheritDoc} */ 51 public void contextInitialized(final ServletContextEvent event) { 52 new DefaultPropertiesLoader().initDefaultProperties(event.getServletContext()); 53 } 54 55 56 /** {@inheritDoc} */ 57 public void contextDestroyed(final ServletContextEvent event) { 58 // do nothing 59 } 60 61 }