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