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: * Engine definition element. This <code>RuleSet</code> does NOT include
026: * any rules for nested Host or DefaultContext elements, which should
027: * be added via instances of <code>HostRuleSet</code> or
028: * <code>ContextRuleSet</code>, respectively.</p>
029: *
030: * @author Craig R. McClanahan
031: * @version $Revision: 520968 $ $Date: 2007-03-21 19:00:39 +0100 (mer., 21 mars 2007) $
032: */
033:
034: public class EngineRuleSet extends RuleSetBase {
035:
036: // ----------------------------------------------------- Instance Variables
037:
038: /**
039: * The matching pattern prefix to use for recognizing our elements.
040: */
041: protected String prefix = null;
042:
043: // ------------------------------------------------------------ Constructor
044:
045: /**
046: * Construct an instance of this <code>RuleSet</code> with the default
047: * matching pattern prefix.
048: */
049: public EngineRuleSet() {
050:
051: this ("");
052:
053: }
054:
055: /**
056: * Construct an instance of this <code>RuleSet</code> with the specified
057: * matching pattern prefix.
058: *
059: * @param prefix Prefix for matching pattern rules (including the
060: * trailing slash character)
061: */
062: public EngineRuleSet(String prefix) {
063:
064: super ();
065: this .namespaceURI = null;
066: this .prefix = prefix;
067:
068: }
069:
070: // --------------------------------------------------------- Public Methods
071:
072: /**
073: * <p>Add the set of Rule instances defined in this RuleSet to the
074: * specified <code>Digester</code> instance, associating them with
075: * our namespace URI (if any). This method should only be called
076: * by a Digester instance.</p>
077: *
078: * @param digester Digester instance to which the new Rule instances
079: * should be added.
080: */
081: public void addRuleInstances(Digester digester) {
082:
083: digester.addObjectCreate(prefix + "Engine",
084: "org.apache.catalina.core.StandardEngine", "className");
085: digester.addSetProperties(prefix + "Engine");
086: digester.addRule(prefix + "Engine", new LifecycleListenerRule(
087: "org.apache.catalina.startup.EngineConfig",
088: "engineConfigClass"));
089: digester.addSetNext(prefix + "Engine", "setContainer",
090: "org.apache.catalina.Container");
091:
092: //Cluster configuration start
093: digester.addObjectCreate(prefix + "Engine/Cluster", null, // MUST be specified in the element
094: "className");
095: digester.addSetProperties(prefix + "Engine/Cluster");
096: digester.addSetNext(prefix + "Engine/Cluster", "setCluster",
097: "org.apache.catalina.Cluster");
098: //Cluster configuration end
099:
100: digester.addObjectCreate(prefix + "Engine/Listener", null, // MUST be specified in the element
101: "className");
102: digester.addSetProperties(prefix + "Engine/Listener");
103: digester.addSetNext(prefix + "Engine/Listener",
104: "addLifecycleListener",
105: "org.apache.catalina.LifecycleListener");
106:
107: digester.addObjectCreate(prefix + "Engine/Realm", null, // MUST be specified in the element
108: "className");
109: digester.addSetProperties(prefix + "Engine/Realm");
110: digester.addSetNext(prefix + "Engine/Realm", "setRealm",
111: "org.apache.catalina.Realm");
112:
113: digester.addObjectCreate(prefix + "Engine/Valve", null, // MUST be specified in the element
114: "className");
115: digester.addSetProperties(prefix + "Engine/Valve");
116: digester.addSetNext(prefix + "Engine/Valve", "addValve",
117: "org.apache.catalina.Valve");
118:
119: }
120:
121: }
|