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 JNDI Enterprise Naming
024: * Context resource declaration elements.</p>
025: *
026: * @author Craig R. McClanahan
027: * @author Remy Maucherat
028: * @version $Revision: 1.3 $ $Date: 2004/02/27 14:58:49 $
029: */
030:
031: public class NamingRuleSet extends RuleSetBase {
032:
033: // ----------------------------------------------------- Instance Variables
034:
035: /**
036: * The matching pattern prefix to use for recognizing our elements.
037: */
038: protected String prefix = null;
039:
040: // ------------------------------------------------------------ Constructor
041:
042: /**
043: * Construct an instance of this <code>RuleSet</code> with the default
044: * matching pattern prefix.
045: */
046: public NamingRuleSet() {
047:
048: this ("");
049:
050: }
051:
052: /**
053: * Construct an instance of this <code>RuleSet</code> with the specified
054: * matching pattern prefix.
055: *
056: * @param prefix Prefix for matching pattern rules (including the
057: * trailing slash character)
058: */
059: public NamingRuleSet(String prefix) {
060:
061: super ();
062: this .namespaceURI = null;
063: this .prefix = prefix;
064:
065: }
066:
067: // --------------------------------------------------------- Public Methods
068:
069: /**
070: * <p>Add the set of Rule instances defined in this RuleSet to the
071: * specified <code>Digester</code> instance, associating them with
072: * our namespace URI (if any). This method should only be called
073: * by a Digester instance.</p>
074: *
075: * @param digester Digester instance to which the new Rule instances
076: * should be added.
077: */
078: public void addRuleInstances(Digester digester) {
079:
080: digester.addObjectCreate(prefix + "Ejb",
081: "org.apache.catalina.deploy.ContextEjb");
082: digester.addSetProperties(prefix + "Ejb");
083: digester.addSetNext(prefix + "Ejb", "addEjb",
084: "org.apache.catalina.deploy.ContextEjb");
085:
086: digester.addObjectCreate(prefix + "Environment",
087: "org.apache.catalina.deploy.ContextEnvironment");
088: digester.addSetProperties(prefix + "Environment");
089: digester.addSetNext(prefix + "Environment", "addEnvironment",
090: "org.apache.catalina.deploy.ContextEnvironment");
091:
092: digester.addObjectCreate(prefix + "LocalEjb",
093: "org.apache.catalina.deploy.ContextLocalEjb");
094: digester.addSetProperties(prefix + "LocalEjb");
095: digester.addSetNext(prefix + "LocalEjb", "addLocalEjb",
096: "org.apache.catalina.deploy.ContextLocalEjb");
097:
098: digester.addObjectCreate(prefix + "Resource",
099: "org.apache.catalina.deploy.ContextResource");
100: digester.addSetProperties(prefix + "Resource");
101: digester.addSetNext(prefix + "Resource", "addResource",
102: "org.apache.catalina.deploy.ContextResource");
103:
104: digester.addCallMethod(prefix + "ResourceEnvRef",
105: "addResourceEnvRef", 2);
106: digester.addCallParam(prefix + "ResourceEnvRef/name", 0);
107: digester.addCallParam(prefix + "ResourceEnvRef/type", 1);
108:
109: digester.addObjectCreate(prefix + "ResourceParams",
110: "org.apache.catalina.deploy.ResourceParams");
111: digester.addSetProperties(prefix + "ResourceParams");
112: digester.addSetNext(prefix + "ResourceParams",
113: "addResourceParams",
114: "org.apache.catalina.deploy.ResourceParams");
115:
116: digester.addCallMethod(prefix + "ResourceParams/parameter",
117: "addParameter", 2);
118: digester.addCallParam(prefix + "ResourceParams/parameter/name",
119: 0);
120: digester.addCallParam(
121: prefix + "ResourceParams/parameter/value", 1);
122:
123: }
124:
125: }
|