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: * Engine definition element. This <code>RuleSet</code> does NOT include
025: * any rules for nested Host or DefaultContext elements, which should
026: * be added via instances of <code>HostRuleSet</code> or
027: * <code>ContextRuleSet</code>, respectively.</p>
028: *
029: * @author Craig R. McClanahan
030: * @version $Revision: 1.4 $ $Date: 2004/02/27 14:58:49 $
031: */
032:
033: public class EngineRuleSet 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 EngineRuleSet() {
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 EngineRuleSet(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 + "Engine",
083: "org.apache.catalina.core.StandardEngine", "className");
084: digester.addSetProperties(prefix + "Engine");
085: digester.addRule(prefix + "Engine", new LifecycleListenerRule(
086: "org.apache.catalina.startup.EngineConfig",
087: "engineConfigClass"));
088: digester.addSetNext(prefix + "Engine", "setContainer",
089: "org.apache.catalina.Container");
090:
091: digester.addObjectCreate(prefix + "Engine/Listener", null, // MUST be specified in the element
092: "className");
093: digester.addSetProperties(prefix + "Engine/Listener");
094: digester.addSetNext(prefix + "Engine/Listener",
095: "addLifecycleListener",
096: "org.apache.catalina.LifecycleListener");
097:
098: digester.addObjectCreate(prefix + "Engine/Logger", null, // MUST be specified in the element
099: "className");
100: digester.addSetProperties(prefix + "Engine/Logger");
101: digester.addSetNext(prefix + "Engine/Logger", "setLogger",
102: "org.apache.catalina.Logger");
103:
104: digester.addObjectCreate(prefix + "Engine/Realm", null, // MUST be specified in the element
105: "className");
106: digester.addSetProperties(prefix + "Engine/Realm");
107: digester.addSetNext(prefix + "Engine/Realm", "setRealm",
108: "org.apache.catalina.Realm");
109:
110: digester.addObjectCreate(prefix + "Engine/Valve", null, // MUST be specified in the element
111: "className");
112: digester.addSetProperties(prefix + "Engine/Valve");
113: digester.addSetNext(prefix + "Engine/Valve", "addValve",
114: "org.apache.catalina.Valve");
115:
116: }
117:
118: }
|