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