01: package org.apache.turbine.util;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
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 extends TurbineConfig {
53: /**
54: * Constructs a new TurbineXmlConfig.
55: *
56: * This is the general form of the constructor. You can provide
57: * a path to search for files, and a name-value map of init
58: * parameters.
59: *
60: * <p> For the list of recognized init parameters, see
61: * {@link org.apache.turbine.Turbine} class.
62: *
63: * @param path The web application root (i.e. the path for file lookup).
64: * @param attributes Servlet container (or emulator) attributes.
65: * @param initParams initialization parameters.
66: */
67: public TurbineXmlConfig(String path, Map attributes, Map initParams) {
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: this (path, new HashMap(0), initParams);
76: }
77:
78: /**
79: * Constructs a TurbineXmlConfig.
80: *
81: * This is a specialized constructor that allows to configure
82: * Turbine easiliy in the common setups.
83: *
84: * @param path The web application root (i.e. the path for file lookup).
85: * @param configuration the relative path to TurbineResources.xml file
86: */
87: public TurbineXmlConfig(String path, String config) {
88: this (path, new HashMap(1));
89: initParams.put(CONFIGURATION_PATH_KEY, config);
90: }
91: }
|