KickJava   Java API By Example, From Geeks To Geeks.

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


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 Server Hooks. These are event listeners to
21  * the QuickServer.
22  * The example xml is <pre>
23     ....
24     &lt;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;/server-hooks&gt;
28     ....
29  </pre>
30  * @see org.quickserver.net.ServerHook
31  * @see org.quickserver.util.xmlreader.InitServerHooks
32  * @author Akshathkumar Shetty
33  * @since 1.3.3
34  */

35 public class ServerHooks extends ArrayList {
36     
37     /**
38      * Addes the class to server hooks
39      */

40     public void addClassName(String JavaDoc className) {
41         if(className!=null && className.trim().length()!=0) {
42             add(className.trim());
43         }
44     }
45
46     /**
47      * Returns XML config of this class.
48      */

49     public String JavaDoc toXML(String JavaDoc pad) {
50         if(pad==null) pad="";
51         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
52         sb.append(pad+"<server-hooks>\n");
53         Iterator iterator = iterator();
54         while(iterator.hasNext()) {
55             String JavaDoc classname = (String JavaDoc) iterator.next();
56             sb.append(pad+"\t<class-name>"+classname+"</class-name>\n");
57         }
58         sb.append(pad+"</server-hooks>\n");
59         return sb.toString();
60     }
61 }
62
Popular Tags