View Javadoc

    1   package org.apache.turbine.util;
    2
    3
    4   /*
    5    * Licensed to the Apache Software Foundation (ASF) under one
    6    * or more contributor license agreements.  See the NOTICE file
    7    * distributed with this work for additional information
    8    * regarding copyright ownership.  The ASF licenses this file
    9    * to you under the Apache License, Version 2.0 (the
    10   * "License"); you may not use this file except in compliance
    11   * with the License.  You may obtain a copy of the License at
    12   *
    13   *   http://www.apache.org/licenses/LICENSE-2.0
    14   *
    15   * Unless required by applicable law or agreed to in writing,
    16   * software distributed under the License is distributed on an
    17   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    18   * KIND, either express or implied.  See the License for the
    19   * specific language governing permissions and limitations
    20   * under the License.
    21   */
    22
    23  import java.util.HashMap;
    24  import java.util.Map;
    25
    26  /**
    27   * A class used for initialization of Turbine without a servlet container.
    28   * <p>
    29   * If you need to use Turbine outside of a servlet container, you can
    30   * use this class for initialization of the Turbine servlet.
    31   * <p>
    32   * <blockquote><code><pre>
    33   * TurbineXmlConfig config = new TurbineXmlConfig(".", "conf/TurbineResources.properties");
    34   * </pre></code></blockquote>
    35   * <p>
    36   * All paths referenced in TurbineResources.properties and the path to
    37   * the properties file itself (the second argument) will be resolved
    38   * relative to the directory given as the first argument of the constructor,
    39   * here - the directory where application was started. Don't worry about
    40   * discarding the references to objects created above. They are not needed,
    41   * once everything is initialized.
    42   * <p>
    43   * In order to initialize the Services Framework outside of the Turbine Servlet,
    44   * you need to call the <code>init()</code> method. By default, this will
    45   * initialize the Resource and Logging Services and any other services you
    46   * have defined in your TurbineResources.properties file.
    47   *
    48   * TODO Make this class enforce the lifecycle contracts
    49   *
    50   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
    51   * @version $Id: TurbineXmlConfig.java 1706239 2015-10-01 13:18:35Z tv $
    52   */
    53  public class TurbineXmlConfig
    54          extends TurbineConfig
    55  {
    56      /**
    57       * Constructs a new TurbineXmlConfig.
    58       *
    59       * This is the general form of the constructor. You can provide
    60       * a path to search for files, and a name-value map of init
    61       * parameters.
    62       *
    63       * <p> For the list of recognized init parameters, see
    64       * {@link org.apache.turbine.Turbine} class.
    65       *
    66       * @param path The web application root (i.e. the path for file lookup).
    67       * @param attributes Servlet container (or emulator) attributes.
    68       * @param initParams initialization parameters.
    69       */
    70      public TurbineXmlConfig(String path, Map<String, Object> attributes,
    71              Map<String, String> initParams)
    72      {
    73          super(path, attributes, initParams);
    74      }
    75
    76      /**
    77       * Constructs a new TurbineXmlConfig.
    78       *
    79       * This is the general form of the constructor. You can provide
    80       * a path to search for files, and a name-value map of init
    81       * parameters.
    82       *
    83       * <p> For the list of recognized init parameters, see
    84       * {@link org.apache.turbine.Turbine} class.
    85       *
    86       * @param path The web application root (i.e. the path for file lookup).
    87       * @param initParams initialization parameters.
    88       */
    89      public TurbineXmlConfig(String path, Map<String, String> initParams)
    90      {
    91          this(path, new HashMap<String, Object>(0), initParams);
    92      }
    93
    94      /**
    95       * Constructs a TurbineXmlConfig.
    96       *
    97       * This is a specialized constructor that allows to configure
    98       * Turbine easily in the common setups.
    99       *
    100      * @param path The web application root (i.e. the path for file lookup).
    101      * @param config the relative path to TurbineResources.xml file
    102      */
    103     public TurbineXmlConfig(String path, String config)
    104     {
    105         this(path, new HashMap<String, String>(1));
    106         initParams.put(CONFIGURATION_PATH_KEY, config);
    107     }
    108 }