01: /*
02: * This file is part of the QuickServer library
03: * Copyright (C) 2003-2005 QuickServer.org
04: *
05: * Use, modification, copying and distribution of this software is subject to
06: * the terms and conditions of the GNU Lesser General Public License.
07: * You should have received a copy of the GNU LGP License along with this
08: * library; if not, you can download a copy from <http://www.quickserver.org/>.
09: *
10: * For questions, suggestions, bug-reports, enhancement-requests etc.
11: * visit http://www.quickserver.org
12: *
13: */
14:
15: package org.quickserver.util.xmlreader;
16:
17: import java.util.*;
18:
19: /**
20: * This class encapsulate the init Server Hooks. Called just after server
21: * loads the xml configuration file. Can be using to set up loggers.
22: * The example xml is <pre>
23: ....
24: <init-server-hooks>
25: <class-name>package1.Class1</class-name>
26: <class-name>package1.Class2</class-name>
27: </init-server-hooks>
28: ....
29: </pre>
30: * @see org.quickserver.net.InitServerHook
31: * @see org.quickserver.util.xmlreader.ServerHooks
32: * @author Akshathkumar Shetty
33: * @since 1.4
34: */
35: public class InitServerHooks extends ArrayList {
36: /**
37: * Addes the class to init server hooks.
38: */
39: public void addClassName(String className) {
40: if (className != null && className.trim().length() != 0) {
41: add(className.trim());
42: }
43: }
44:
45: /**
46: * Returns XML config of this class.
47: */
48: public String toXML(String pad) {
49: if (pad == null)
50: pad = "";
51: StringBuffer sb = new StringBuffer();
52: sb.append(pad + "<init-server-hooks>\n");
53: Iterator iterator = iterator();
54: while (iterator.hasNext()) {
55: String classname = (String) iterator.next();
56: sb.append(pad + "\t<class-name>" + classname
57: + "</class-name>\n");
58: }
59: sb.append(pad + "</init-server-hooks>\n");
60: return sb.toString();
61: }
62: }
|