001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.startup;
019:
020: import org.apache.tomcat.util.digester.Digester;
021: import org.apache.tomcat.util.digester.RuleSetBase;
022:
023: /**
024: * <p><strong>RuleSet</strong> for processing the contents of a
025: * Host definition element. This <code>RuleSet</code> does NOT include
026: * any rules for nested Context or DefaultContext elements, which should
027: * be added via instances of <code>ContextRuleSet</code>.</p>
028: *
029: * @author Craig R. McClanahan
030: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
031: */
032:
033: public class HostRuleSet extends RuleSetBase {
034:
035: // ----------------------------------------------------- Instance Variables
036:
037: /**
038: * The matching pattern prefix to use for recognizing our elements.
039: */
040: protected String prefix = null;
041:
042: // ------------------------------------------------------------ Constructor
043:
044: /**
045: * Construct an instance of this <code>RuleSet</code> with the default
046: * matching pattern prefix.
047: */
048: public HostRuleSet() {
049:
050: this ("");
051:
052: }
053:
054: /**
055: * Construct an instance of this <code>RuleSet</code> with the specified
056: * matching pattern prefix.
057: *
058: * @param prefix Prefix for matching pattern rules (including the
059: * trailing slash character)
060: */
061: public HostRuleSet(String prefix) {
062:
063: super ();
064: this .namespaceURI = null;
065: this .prefix = prefix;
066:
067: }
068:
069: // --------------------------------------------------------- Public Methods
070:
071: /**
072: * <p>Add the set of Rule instances defined in this RuleSet to the
073: * specified <code>Digester</code> instance, associating them with
074: * our namespace URI (if any). This method should only be called
075: * by a Digester instance.</p>
076: *
077: * @param digester Digester instance to which the new Rule instances
078: * should be added.
079: */
080: public void addRuleInstances(Digester digester) {
081:
082: digester.addObjectCreate(prefix + "Host",
083: "org.apache.catalina.core.StandardHost", "className");
084: digester.addSetProperties(prefix + "Host");
085: digester.addRule(prefix + "Host",
086: new CopyParentClassLoaderRule());
087: digester.addRule(prefix + "Host", new LifecycleListenerRule(
088: "org.apache.catalina.startup.HostConfig",
089: "hostConfigClass"));
090: digester.addSetNext(prefix + "Host", "addChild",
091: "org.apache.catalina.Container");
092:
093: digester.addCallMethod(prefix + "Host/Alias", "addAlias", 0);
094:
095: //Cluster configuration start
096: digester.addObjectCreate(prefix + "Host/Cluster", null, // MUST be specified in the element
097: "className");
098: digester.addSetProperties(prefix + "Host/Cluster");
099: digester.addSetNext(prefix + "Host/Cluster", "setCluster",
100: "org.apache.catalina.Cluster");
101: //Cluster configuration end
102:
103: digester.addObjectCreate(prefix + "Host/Listener", null, // MUST be specified in the element
104: "className");
105: digester.addSetProperties(prefix + "Host/Listener");
106: digester.addSetNext(prefix + "Host/Listener",
107: "addLifecycleListener",
108: "org.apache.catalina.LifecycleListener");
109:
110: digester.addObjectCreate(prefix + "Host/Realm", null, // MUST be specified in the element
111: "className");
112: digester.addSetProperties(prefix + "Host/Realm");
113: digester.addSetNext(prefix + "Host/Realm", "setRealm",
114: "org.apache.catalina.Realm");
115:
116: digester.addObjectCreate(prefix + "Host/Valve", null, // MUST be specified in the element
117: "className");
118: digester.addSetProperties(prefix + "Host/Valve");
119: digester.addSetNext(prefix + "Host/Valve", "addValve",
120: "org.apache.catalina.Valve");
121:
122: }
123:
124: }
|