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 JNDI Enterprise Naming
025: * Context resource declaration elements.</p>
026: *
027: * @author Craig R. McClanahan
028: * @author Remy Maucherat
029: * @version $Revision: 513349 $ $Date: 2007-03-01 15:33:06 +0100 (jeu., 01 mars 2007) $
030: */
031:
032: public class NamingRuleSet 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 NamingRuleSet() {
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 NamingRuleSet(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 + "Ejb",
082: "org.apache.catalina.deploy.ContextEjb");
083: digester.addRule(prefix + "Ejb", new SetAllPropertiesRule());
084: digester.addRule(prefix + "Ejb", new SetNextNamingRule(
085: "addEjb", "org.apache.catalina.deploy.ContextEjb"));
086:
087: digester.addObjectCreate(prefix + "Environment",
088: "org.apache.catalina.deploy.ContextEnvironment");
089: digester.addSetProperties(prefix + "Environment");
090: digester.addRule(prefix + "Environment", new SetNextNamingRule(
091: "addEnvironment",
092: "org.apache.catalina.deploy.ContextEnvironment"));
093:
094: digester.addObjectCreate(prefix + "LocalEjb",
095: "org.apache.catalina.deploy.ContextLocalEjb");
096: digester.addRule(prefix + "LocalEjb",
097: new SetAllPropertiesRule());
098: digester.addRule(prefix + "LocalEjb", new SetNextNamingRule(
099: "addLocalEjb",
100: "org.apache.catalina.deploy.ContextLocalEjb"));
101:
102: digester.addObjectCreate(prefix + "Resource",
103: "org.apache.catalina.deploy.ContextResource");
104: digester.addRule(prefix + "Resource",
105: new SetAllPropertiesRule());
106: digester.addRule(prefix + "Resource", new SetNextNamingRule(
107: "addResource",
108: "org.apache.catalina.deploy.ContextResource"));
109:
110: digester.addObjectCreate(prefix + "ResourceEnvRef",
111: "org.apache.catalina.deploy.ContextResourceEnvRef");
112: digester.addRule(prefix + "ResourceEnvRef",
113: new SetAllPropertiesRule());
114: digester
115: .addRule(
116: prefix + "ResourceEnvRef",
117: new SetNextNamingRule("addResourceEnvRef",
118: "org.apache.catalina.deploy.ContextResourceEnvRef"));
119:
120: digester.addObjectCreate(prefix + "ServiceRef",
121: "org.apache.catalina.deploy.Contextservice");
122: digester.addRule(prefix + "ServiceRef",
123: new SetAllPropertiesRule());
124: digester.addRule(prefix + "ServiceRef", new SetNextNamingRule(
125: "addService",
126: "org.apache.catalina.deploy.ContextService"));
127:
128: digester.addObjectCreate(prefix + "Transaction",
129: "org.apache.catalina.deploy.ContextTransaction");
130: digester.addRule(prefix + "Transaction",
131: new SetAllPropertiesRule());
132: digester.addRule(prefix + "Transaction", new SetNextNamingRule(
133: "setTransaction",
134: "org.apache.catalina.deploy.ContextTransaction"));
135:
136: }
137:
138: }
|