KickJava   Java API By Example, From Geeks To Geeks.

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


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.quickserver.net.server.QuickServer;
18 import org.quickserver.net.qsadmin.QSAdminServer;
19
20 /**
21  * This class encapsulate the configuration of QSAdminServer.
22  * This class is used by
23  * {@link org.quickserver.net.server.QuickServer#configQuickServer}
24  * and {@link org.quickserver.net.server.QuickServer#initService} method to
25  * initialise QSAdminServer.
26  * @author Akshathkumar Shetty
27  * @since 1.2
28  */

29 public class QSAdminServerConfig extends BasicServerConfig {
30     
31     private String JavaDoc commandPlugin;
32     private String JavaDoc commandShellEnabled = "false";
33     private String JavaDoc commandShellPromptName = "QSAdmin";
34
35     public QSAdminServerConfig() {
36         setName("QSAdminServer v " + QSAdminServer.getVersion());
37         setPort(9877);
38         setBindAddr("127.0.0.1");
39         setClientCommandHandler("org.quickserver.net.qsadmin.CommandHandler");
40         setClientEventHandler("org.quickserver.net.qsadmin.CommandHandler");
41         setClientAuthenticationHandler("org.quickserver.net.qsadmin.Authenticator");
42         setClientData("org.quickserver.net.qsadmin.Data");
43         setMaxConnection(1);
44         getServerMode().setBlocking(false);
45     }
46     
47     
48     /**
49      * Set the CommandPlugin for QSAdminServer class which plugs in into
50      * CommandHandler of QsAdminServer,it will be null if not set.
51      * XML Tag: &lt;command-plugin&gt;&lt;/command-plugin&gt;
52      */

53     public void setCommandPlugin(String JavaDoc plugin) {
54         if(plugin!=null && plugin.equals("")==false)
55             commandPlugin = plugin;
56     }
57     /**
58      * Gets the CommandPlugin for QSAdminServer class which plugsin into
59      * CommandHandler of QsAdminServer,it will be null if not set.
60      */

61     public String JavaDoc getCommandPlugin() {
62         return commandPlugin;
63     }
64
65
66     /**
67      * Set the CommandShellEnable flag for QSAdminServer
68      * XML Tag: &lt;command-shell&gt;&lt;enable&gt;true&lt;/enable&gt;&lt;/command-shell&gt;
69      * Allowed values = <code>true</code> | <code>false</code>
70      * @since 1.3.2
71      */

72     public void setCommandShellEnable(String JavaDoc enable) {
73         if(enable!=null && enable.equals("")==false)
74             commandShellEnabled = enable;
75     }
76     /**
77      * Gets the CommandShellEnable flag for QSAdminServer
78      * @since 1.3.2
79      */

80     public String JavaDoc getCommandShellEnable() {
81         return commandShellEnabled;
82     }
83
84     /**
85      * Set the PromptName for QSAdminShell
86      * XML Tag: &lt;command-shell&gt;&lt;prompt-name&gt;true&lt;/prompt-name&gt;&lt;/command-shell&gt;
87      * Default values = <code>QSAdmin</code>
88      * @since 1.3.2
89      */

90     public void setCommandShellPromptName(String JavaDoc commandShellPromptName) {
91         if(commandShellPromptName!=null && commandShellPromptName.equals("")==false)
92             this.commandShellPromptName = commandShellPromptName;
93     }
94     /**
95      * Gets the PromptName for QSAdminShell
96      * @since 1.3.2
97      */

98     public String JavaDoc getCommandShellPromptName() {
99         return commandShellPromptName;
100     }
101
102
103     /**
104      * Returns XML config of this class.
105      * @since 1.3
106      */

107     public String JavaDoc toXML(String JavaDoc pad) {
108         if(pad==null) pad="";
109
110         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
111         sb.append(pad+"<qsadmin-server>\n");
112
113         if(getName()!=null)
114             sb.append(pad+"\t<name>"+getName()+"</name>\n");
115         if(getServerBanner()!=null)
116             sb.append(pad+"\t<server-banner>"+getServerBanner()+"</server-banner>\n");
117         sb.append(pad+"\t<port>"+getPort()+"</port>\n");
118         sb.append(pad+"\t<bind-address>"+getBindAddr()+"</bind-address>\n");
119
120         sb.append( getServerMode().toXML(pad+"\t") );
121
122         if(getClientEventHandler()!=null)
123             sb.append(pad+"\t<client-event-handler>"+getClientEventHandler()+"</client-event-handler>\n");
124         if(getClientCommandHandler()!=null)
125             sb.append(pad+"\t<client-command-handler>"+getClientCommandHandler()+"</client-command-handler>\n");
126         if(getClientObjectHandler()!=null)
127             sb.append(pad+"\t<client-object-handler>"+getClientObjectHandler()+"</client-object-handler>\n");
128         if(getClientBinaryHandler()!=null)
129             sb.append(pad+"\t<client-binary-handler>"+getClientBinaryHandler()+"</client-binary-handler>\n");
130         if(getClientWriteHandler()!=null)
131             sb.append(pad+"\t<client-write-handler>"+getClientWriteHandler()+"</client-write-handler>\n");
132         if(getClientAuthenticationHandler()!=null)
133             sb.append(pad+"\t<client-authentication-handler>"+getClientAuthenticationHandler()+"</client-authentication-handler>\n");
134         else if(getAuthenticator()!=null)
135             sb.append(pad+"\t<authenticator>"+getAuthenticator()+"</authenticator>\n");
136         if(getClientData()!=null)
137             sb.append(pad+"\t<client-data>"+getClientData()+"</client-data>\n");
138         if(getClientExtendedEventHandler()!=null)
139             sb.append(pad+"\t<client-extended-event-handler>"+getClientExtendedEventHandler()+"</client-extended-event-handler>\n");
140     
141         sb.append(pad+"\t<timeout>"+getTimeout()+"</timeout>\n");
142         if(getTimeoutMsg()!=null)
143             sb.append(pad+"\t<timeout-msg>"+getTimeoutMsg()+"</timeout-msg>\n");
144
145         sb.append(pad+"\t<max-auth-try>"+getMaxAuthTry()+"</max-auth-try>\n");
146         if(getMaxAuthTryMsg()!=null)
147             sb.append(pad+"\t<max-auth-try-msg>"+getMaxAuthTryMsg()+"</max-auth-try-msg>\n");
148         
149         sb.append(pad+"\t<max-connection>"+getMaxConnection()+"</max-connection>\n");
150         if(getMaxConnectionMsg()!=null)
151             sb.append(pad+"\t<max-connection-msg>"+getMaxConnectionMsg()+"</max-connection-msg>\n");
152         
153         /*
154         //Not used. Use main QS console logging
155         if(getConsoleLoggingLevel()!=null)
156             sb.append(pad+"\t<console-logging-level>"+getConsoleLoggingLevel()+"</console-logging-level>\n");
157         if(getConsoleLoggingFormatter()!=null)
158             sb.append(pad+"\t<console-logging-formatter>"+getConsoleLoggingFormatter()+"</consoleLoggingFormatter>\n");
159         */

160
161         sb.append(getObjectPoolConfig().toXML(pad+"\t"));
162
163         sb.append(pad+"\t<communication-logging>\n");
164         sb.append(pad+"\t\t<enable>"+getCommunicationLogging()+"</enable>\n");
165         sb.append(pad+"\t</communication-logging>\n");
166         
167         if(getCommandPlugin()!=null)
168             sb.append(pad+"\t<command-plugin>"+getCommandPlugin()+"</command-plugin>\n");
169         
170         sb.append(pad+"\t<command-shell>\n");
171         sb.append(pad+"\t\t<enable>"+getCommandShellEnable()+"</enable>\n");
172         sb.append(pad+"\t\t<prompt-name>"+getCommandShellPromptName()+"</prompt-name>\n");
173         sb.append(pad+"\t</command-shell>\n");
174     
175         if(getAccessConstraintConfig()!=null) {
176             sb.append(getAccessConstraintConfig().toXML(pad+"\t"));
177         }
178
179         if(getServerHooks()!=null) {
180             sb.append( getServerHooks().toXML(pad+"\t") );
181         }
182
183         sb.append( getSecure().toXML(pad+"\t") );
184         sb.append( getAdvancedSettings().toXML(pad+"\t") );
185
186         sb.append(pad+"</qsadmin-server>\n");
187         return sb.toString();
188     }
189
190     public String JavaDoc toString() {
191         return toXML(null);
192     }
193 }
194
Popular Tags