1 package org.apache.turbine.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.HashMap;
23 import java.util.Map;
24
25 /***
26 * A class used for initialization of Turbine without a servlet container.
27 * <p>
28 * If you need to use Turbine outside of a servlet container, you can
29 * use this class for initialization of the Turbine servlet.
30 * <p>
31 * <blockquote><code><pre>
32 * TurbineXmlConfig config = new TurbineXmlConfig(".", "conf/TurbineResources.properties");
33 * </pre></code></blockquote>
34 * <p>
35 * All paths referenced in TurbineResources.properties and the path to
36 * the properties file itself (the second argument) will be resolved
37 * relative to the directory given as the first argument of the constructor,
38 * here - the directory where application was started. Don't worry about
39 * discarding the references to objects created above. They are not needed,
40 * once everything is initialized.
41 * <p>
42 * In order to initialize the Services Framework outside of the Turbine Servlet,
43 * you need to call the <code>init()</code> method. By default, this will
44 * initialize the Resource and Logging Services and any other services you
45 * have defined in your TurbineResources.properties file.
46 *
47 * @todo Make this class enforce the lifecycle contracts
48 *
49 * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
50 * @version $Id: TurbineXmlConfig.java 534527 2007-05-02 16:10:59Z tv $
51 */
52 public class TurbineXmlConfig
53 extends TurbineConfig
54 {
55 /***
56 * Constructs a new TurbineXmlConfig.
57 *
58 * This is the general form of the constructor. You can provide
59 * a path to search for files, and a name-value map of init
60 * parameters.
61 *
62 * <p> For the list of recognized init parameters, see
63 * {@link org.apache.turbine.Turbine} class.
64 *
65 * @param path The web application root (i.e. the path for file lookup).
66 * @param attributes Servlet container (or emulator) attributes.
67 * @param initParams initialization parameters.
68 */
69 public TurbineXmlConfig(String path, Map attributes, Map initParams)
70 {
71 super(path, attributes, initParams);
72 }
73
74 /***
75 * @see #TurbineXmlConfig(String path, Map attributes, Map initParams)
76 */
77 public TurbineXmlConfig(String path, Map initParams)
78 {
79 this(path, new HashMap(0), initParams);
80 }
81
82 /***
83 * Constructs a TurbineXmlConfig.
84 *
85 * This is a specialized constructor that allows to configure
86 * Turbine easiliy in the common setups.
87 *
88 * @param path The web application root (i.e. the path for file lookup).
89 * @param configuration the relative path to TurbineResources.xml file
90 */
91 public TurbineXmlConfig(String path, String config)
92 {
93 this(path, new HashMap(1));
94 initParams.put(CONFIGURATION_PATH_KEY, config);
95 }
96 }