01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.catalina.startup;
19:
20: import org.xml.sax.Attributes;
21:
22: import org.apache.tomcat.util.IntrospectionUtils;
23: import org.apache.tomcat.util.digester.Rule;
24:
25: /**
26: * Rule that uses the introspection utils to set properties of a context
27: * (everything except "path").
28: *
29: * @author Remy Maucherat
30: */
31: public class SetContextPropertiesRule extends Rule {
32:
33: // ----------------------------------------------------------- Constructors
34:
35: // ----------------------------------------------------- Instance Variables
36:
37: // --------------------------------------------------------- Public Methods
38:
39: /**
40: * Handle the beginning of an XML element.
41: *
42: * @param attributes The attributes of this element
43: *
44: * @exception Exception if a processing error occurs
45: */
46: public void begin(String namespace, String nameX,
47: Attributes attributes) throws Exception {
48:
49: for (int i = 0; i < attributes.getLength(); i++) {
50: String name = attributes.getLocalName(i);
51: if ("".equals(name)) {
52: name = attributes.getQName(i);
53: }
54: if ("path".equals(name) || "docBase".equals(name)) {
55: continue;
56: }
57: String value = attributes.getValue(i);
58: IntrospectionUtils
59: .setProperty(digester.peek(), name, value);
60: }
61:
62: }
63:
64: }
|