KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > util > xmlreader > InitServerHooks


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
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     &lt;init-server-hooks&gt;
25         &lt;class-name&gt;package1.Class1&lt;/class-name&gt;
26         &lt;class-name&gt;package1.Class2&lt;/class-name&gt;
27     &lt;/init-server-hooks&gt;
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 JavaDoc 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 JavaDoc toXML(String JavaDoc pad) {
49         if(pad==null) pad="";
50         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
51         sb.append(pad+"<init-server-hooks>\n");
52         Iterator iterator = iterator();
53         while(iterator.hasNext()) {
54             String JavaDoc classname = (String JavaDoc) iterator.next();
55             sb.append(pad+"\t<class-name>"+classname+"</class-name>\n");
56         }
57         sb.append(pad+"</init-server-hooks>\n");
58         return sb.toString();
59     }
60 }
61
Popular Tags