View Javadoc
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   * &lt;context-param&gt;
33   *     &lt;param-name&gt;settings4jDefaultProperties&lt;/param-name&gt;
34   *     &lt;param-value&gt;
35   *         com/myCompany/myApp/log4j.configuration=com/myCompany/myApp/log4j.xml
36   *     &lt;/param-value&gt;
37   * &lt;/context-param&gt;
38   * 
39   * &lt;listener&gt;
40   *     &lt;display-name&gt;&lt;/display-name&gt;
41   *     &lt;listener-class&gt;org.settings4j.helper.web.DefaultPropertiesLoaderListener&lt;/listener-class&gt;
42   * &lt;/listener&gt;
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  }