KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > startup > HostRuleSet


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina.startup;
20
21
22 import org.apache.tomcat.util.digester.Digester;
23 import org.apache.tomcat.util.digester.RuleSetBase;
24
25
26 /**
27  * <p><strong>RuleSet</strong> for processing the contents of a
28  * Host definition element. This <code>RuleSet</code> does NOT include
29  * any rules for nested Context or DefaultContext elements, which should
30  * be added via instances of <code>ContextRuleSet</code>.</p>
31  *
32  * @author Craig R. McClanahan
33  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
34  */

35
36 public class HostRuleSet extends RuleSetBase {
37
38
39     // ----------------------------------------------------- Instance Variables
40

41
42     /**
43      * The matching pattern prefix to use for recognizing our elements.
44      */

45     protected String JavaDoc prefix = null;
46
47
48     // ------------------------------------------------------------ Constructor
49

50
51     /**
52      * Construct an instance of this <code>RuleSet</code> with the default
53      * matching pattern prefix.
54      */

55     public HostRuleSet() {
56
57         this("");
58
59     }
60
61
62     /**
63      * Construct an instance of this <code>RuleSet</code> with the specified
64      * matching pattern prefix.
65      *
66      * @param prefix Prefix for matching pattern rules (including the
67      * trailing slash character)
68      */

69     public HostRuleSet(String JavaDoc prefix) {
70
71         super();
72         this.namespaceURI = null;
73         this.prefix = prefix;
74
75     }
76
77
78     // --------------------------------------------------------- Public Methods
79

80
81     /**
82      * <p>Add the set of Rule instances defined in this RuleSet to the
83      * specified <code>Digester</code> instance, associating them with
84      * our namespace URI (if any). This method should only be called
85      * by a Digester instance.</p>
86      *
87      * @param digester Digester instance to which the new Rule instances
88      * should be added.
89      */

90     public void addRuleInstances(Digester digester) {
91
92         digester.addObjectCreate(prefix + "Host",
93                                  "org.apache.catalina.core.StandardHost",
94                                  "className");
95         digester.addSetProperties(prefix + "Host");
96         digester.addRule(prefix + "Host",
97                          new CopyParentClassLoaderRule());
98         digester.addRule(prefix + "Host",
99                          new LifecycleListenerRule
100                          ("org.apache.catalina.startup.HostConfig",
101                           "hostConfigClass"));
102         digester.addSetNext(prefix + "Host",
103                             "addChild",
104                             "org.apache.catalina.Container");
105
106         digester.addCallMethod(prefix + "Host/Alias",
107                                "addAlias", 0);
108
109         //Cluster configuration start
110
digester.addObjectCreate(prefix + "Host/Cluster",
111                                  null, // MUST be specified in the element
112
"className");
113         digester.addSetProperties(prefix + "Host/Cluster");
114         digester.addSetNext(prefix + "Host/Cluster",
115                             "setCluster",
116                             "org.apache.catalina.Cluster");
117         //Cluster configuration end
118

119         digester.addObjectCreate(prefix + "Host/Listener",
120                                  null, // MUST be specified in the element
121
"className");
122         digester.addSetProperties(prefix + "Host/Listener");
123         digester.addSetNext(prefix + "Host/Listener",
124                             "addLifecycleListener",
125                             "org.apache.catalina.LifecycleListener");
126
127         digester.addObjectCreate(prefix + "Host/Realm",
128                                  null, // MUST be specified in the element
129
"className");
130         digester.addSetProperties(prefix + "Host/Realm");
131         digester.addSetNext(prefix + "Host/Realm",
132                             "setRealm",
133                             "org.apache.catalina.Realm");
134
135         digester.addObjectCreate(prefix + "Host/Valve",
136                                  null, // MUST be specified in the element
137
"className");
138         digester.addSetProperties(prefix + "Host/Valve");
139         digester.addSetNext(prefix + "Host/Valve",
140                             "addValve",
141                             "org.apache.catalina.Valve");
142
143     }
144
145
146 }
147
Popular Tags