%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.util.TurbineXmlConfig |
|
|
1 | package org.apache.turbine.util; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
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 | 4 | super(path, attributes, initParams); |
69 | 4 | } |
70 | ||
71 | /** |
|
72 | * @see #TurbineXmlConfig(String path, Map attributes, Map initParams) |
|
73 | */ |
|
74 | public TurbineXmlConfig(String path, Map initParams) |
|
75 | { |
|
76 | 4 | this(path, new HashMap(0), initParams); |
77 | 4 | } |
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 | 4 | this(path, new HashMap(1)); |
91 | 4 | initParams.put(CONFIGURATION_PATH_KEY, config); |
92 | 4 | } |
93 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |