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 package org.settings4j.helper.spring; 18 19 import org.springframework.web.context.ContextLoader; 20 import org.springframework.web.context.ContextLoaderListener; 21 22 /** 23 * {@link javax.servlet.ServletContextListener} to initialize the {@link Settings4jContextLoader}. 24 * <p> 25 * This Implementation replaces the {@link ContextLoaderListener} 26 * <p> 27 * <h3>Usage - Make SpringContext configurable</h3> <br /> 28 * Example Configuration could look like the following: 29 * 30 * <pre> 31 * web.xml 32 * -------------------------------------- 33 * <context-param> 34 * <param-name>settings4jContextConfigLocation</param-name> 35 * <param-value> 36 * ${com/myCompany/myApp/appContextSecurity}, 37 * /WEB-INF/applicationContext-otherBeans.xml 38 * </param-value> 39 * </context-param> 40 * 41 * <listener> 42 * <display-name></display-name> 43 * <listener-class>org.settings4j.helper.spring.Settings4jContextLoaderListener</listener-class> 44 * </listener> 45 * -------------------------------------- 46 * </pre> 47 * 48 * With this configuration you define with tehKey teh path to your Security configuration. 49 * <p> 50 * <h3>Server config Example</h3> <br /> 51 * Example Configuration in TOMCAT:<br /> 52 * Start tomcat with 53 * <code>-Dcom/myCompany/myApp/appContextSecurity=file:.../applicationContext-security-alwaysAdmin.xml</code><br /> 54 * Or configured a JNDI Value: 55 * 56 * <pre> 57 * TOMCAT context.xml 58 * -------------------------------------- 59 * <Environment name ="com/myCompany/myApp/appContextSecurity" 60 * value="/WEB-INF/applicationContext-security.xml" 61 * type="java.lang.String" /> 62 * 63 * -------------------------------------- 64 * </pre> 65 * <p> 66 * <h3>Default Values</h3> <br /> 67 * It is recommended to use this in combination with {@link org.settings4j.helper.web.DefaultPropertiesLoader}: 68 * 69 * <pre> 70 * web.xml 71 * -------------------------------------- 72 * <context-param> 73 * <param-name>settings4jDefaultProperties</param-name> 74 * <param-value> 75 * com/myCompany/myApp/appContextSecurity=/WEB-INF/applicationContext-security.xml 76 * </param-value> 77 * </context-param> 78 * 79 * <context-param> 80 * <param-name>settings4jContextConfigLocation</param-name> 81 * <param-value> 82 * ${com/myCompany/myApp/appContextSecurity}, 83 * /WEB-INF/applicationContext-otherBeans.xml 84 * </param-value> 85 * </context-param> 86 * 87 * <listener> 88 * <display-name></display-name> 89 * <listener-class>org.settings4j.helper.spring.Settings4jContextLoaderListener</listener-class> 90 * </listener> 91 * -------------------------------------- 92 * </pre> 93 * 94 * @author brabenetz 95 */ 96 public class Settings4jContextLoaderListener extends ContextLoaderListener { 97 98 /** {@inheritDoc} */ 99 @Override 100 protected ContextLoader createContextLoader() { 101 return new Settings4jContextLoader(); 102 } 103 104 }