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