KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.commons.digester.*;
18 import java.io.*;
19 import org.quickserver.util.*;
20 import java.util.logging.*;
21
22
23 /**
24  * This class reads the xml configuration and gives
25  * QSAdminPluginConfig object.
26  * @author Akshathkumar Shetty
27  * @since 1.3.2
28  */

29 public class PluginConfigReader {
30     private static Logger logger = Logger.getLogger(PluginConfigReader.class.getName());
31
32     public static QSAdminPluginConfig read(String JavaDoc fileName) throws Exception JavaDoc {
33         File input = new File(fileName);
34         return read(input);
35     }
36
37     /**
38      * Parses XML config of QSAdmin Plugin
39      */

40     public static QSAdminPluginConfig read(File input) throws Exception JavaDoc {
41         Digester digester = new Digester();
42         digester.setValidating(false);
43
44         String JavaDoc mainTag = "qsadmin-plugin";
45         
46         digester.addObjectCreate(mainTag, QSAdminPluginConfig.class);
47         digester.addBeanPropertySetter(mainTag+"/name", "name");
48         digester.addBeanPropertySetter(mainTag+"/desc", "desc");
49         digester.addBeanPropertySetter(mainTag+"/type", "type");
50         digester.addBeanPropertySetter(mainTag+"/main-class", "mainClass");
51         digester.addBeanPropertySetter(mainTag+"/active", "active");
52         
53
54         logger.fine("Loading Plugin config from xml file : " + input.getAbsolutePath());
55         QSAdminPluginConfig psc = (QSAdminPluginConfig) digester.parse(input);
56         return psc;
57     }
58 }
59
Popular Tags