KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
18
19 /**
20  * This class encapsulate the basic configuration of QuickServer.
21  * @author Akshathkumar Shetty
22  * @since 1.2
23  * @see org.quickserver.util.xmlreader.QuickServerConfig
24  * @see org.quickserver.util.xmlreader.QSAdminServerConfig
25  */

26 public class BasicServerConfig implements java.io.Serializable JavaDoc {
27     
28     private String JavaDoc clientAuthenticationHandler; //v1.4.6
29
private String JavaDoc clientEventHandler; //v1.4.6
30
private String JavaDoc clientExtendedEventHandler; //v1.4.6
31
private String JavaDoc clientCommandHandler;
32     private String JavaDoc clientObjectHandler;
33     private String JavaDoc clientBinaryHandler;
34     private String JavaDoc clientData;
35     private String JavaDoc clientWriteHandler; //v1.4.5
36

37     private String JavaDoc serverBanner;
38     private String JavaDoc name = null;
39     private String JavaDoc maxConnectionMsg = "-ERR Server Busy. Max Connection Reached";
40     private String JavaDoc timeoutMsg = "-ERR Timeout";
41     private int maxAuthTry = 5;
42     private String JavaDoc maxAuthTryMsg = "-ERR Max Auth Try Reached";
43     private int port = 9876;
44     private String JavaDoc bindAddr;
45     private long maxConnection = -1;
46     private int timeout = 1 * 60 * 1000; //1 min. socket timeout
47

48     private String JavaDoc consoleLoggingLevel = "INFO";
49     private String JavaDoc consoleLoggingFormatter;
50
51     //for object pool
52
private ObjectPoolConfig objectPoolConfig = new ObjectPoolConfig();
53     private boolean communicationLogging = false;
54
55     //v1.3.3
56
private AccessConstraintConfig accessConstraintConfig;
57     private ServerHooks serverHooks;
58
59     //v1.4.0
60
private Secure secure = new Secure();
61     private ServerMode serverMode = new ServerMode();
62
63     //v1.4.5
64
private AdvancedSettings advancedSettings = new AdvancedSettings();
65
66     //v1.4.6
67
private DefaultDataMode defaultDataMode = new DefaultDataMode();
68
69     /**
70      * Returns the name of the QuickServer
71      * @see #setName
72      */

73     public String JavaDoc getName() {
74         return name;
75     }
76     /**
77      * Sets the name for the QuickServer.
78      * XML Tag: &lt;name&gt;&lt;/name&gt;
79      * @param name for the QuickServer
80      * @see #getName
81      */

82     public void setName(String JavaDoc name) {
83         if(name!=null && name.equals("")==false)
84             this.name = name;
85     }
86
87     /**
88      * Returns the Server Banner of the QuickServer
89      * @see #setServerBanner
90      */

91     public String JavaDoc getServerBanner() {
92         return serverBanner;
93     }
94     /**
95      * Sets the serverBanner for the QuickServer
96      * that will be displayed on the standard output [console]
97      * when server starts. &lt;br&gt;&nbsp;&lt;br&gt;
98      * To set welcome message to your client
99      * {@link org.quickserver.net.server.ClientEventHandler#gotConnected}
100      * XML Tag: &lt;server-banner&gt;&lt;/server-banner&gt;
101      * @param banner for the QuickServer
102      * @see #getServerBanner
103      */

104     public void setServerBanner(String JavaDoc banner) {
105         if(banner!=null && banner.equals("")==false)
106             serverBanner = banner;
107     }
108
109     /**
110      * Sets the port for the QuickServer to listen on.
111      * If not set, it will run on Port 9876<br/>
112      * XML Tag: &lt;port&gt;&lt;/port&gt;
113      * @param port to listen on.
114      * @see #getPort
115      */

116     public void setPort(int port) {
117         if(port>=0)
118             this.port = port;
119     }
120     /**
121      * Returns the port for the QuickServer
122      * @see #setPort
123      */

124     public int getPort() {
125         return port;
126     }
127
128     /**
129      * Sets the ClientCommandHandler class that interacts with
130      * client sockets.
131      * XML Tag: &lt;client-command-handler&gt;&lt;/client-command-handler&gt;
132      * @param handler the fully qualified name of the class that
133      * implements {@link org.quickserver.net.server.ClientCommandHandler}
134      * @see #getClientCommandHandler
135      */

136     public void setClientCommandHandler(String JavaDoc handler) {
137         if(handler!=null && handler.equals("")==false)
138             clientCommandHandler = handler;
139     }
140     /**
141      * Sets the ClientCommandHandler class that interacts with
142      * client sockets.
143      * @since 1.4.6
144      */

145     public void setClientCommandHandler(ClientCommandHandler handler) {
146         if(handler!=null)
147             clientCommandHandler = handler.getClass().getName();
148     }
149     /**
150      * Returns the ClientCommandHandler class that interacts with
151      * client sockets.
152      * @see #setClientCommandHandler
153      */

154     public String JavaDoc getClientCommandHandler() {
155         return clientCommandHandler;
156     }
157
158     /**
159      * Sets the ClientEventHandler class that gets notified of
160      * client events.
161      * XML Tag: &lt;client-event-handler&gt;&lt;/client-event-handler&gt;
162      * @param handler the fully qualified name of the class that
163      * implements {@link org.quickserver.net.server.ClientEventHandler}
164      * @see #getClientEventHandler
165      * @since 1.4.6
166      */

167     public void setClientEventHandler(String JavaDoc handler) {
168         if(handler!=null && handler.equals("")==false)
169             clientEventHandler = handler;
170     }
171     /**
172      * Sets the ClientEventHandler class that gets notified of
173      * client events.
174      * @since 1.4.6
175      */

176     public void setClientEventHandler(ClientEventHandler handler) {
177         if(handler!=null)
178             clientEventHandler = handler.getClass().getName();
179     }
180     /**
181      * Returns the ClientEventHandler class that gets notified of
182      * client events.
183      * @see #setClientEventHandler
184      * @since 1.4.6
185      */

186     public String JavaDoc getClientEventHandler() {
187         return clientEventHandler;
188     }
189
190     /**
191      * Sets the ClientExtendedEventHandler class that gets notified of
192      * client's extended events.
193      * XML Tag: &lt;client-extended-event-handler&gt;&lt;/client-extended-event-handler&gt;
194      * @param handler the fully qualified name of the class that
195      * implements {@link org.quickserver.net.server.ClientExtendedEventHandler}
196      * @see #getClientExtendedEventHandler
197      * @since 1.4.6
198      */

199     public void setClientExtendedEventHandler(String JavaDoc handler) {
200         if(handler!=null && handler.equals("")==false)
201             clientExtendedEventHandler = handler;
202     }
203     /**
204      * Sets the ClientExtendedEventHandler class that gets notified of
205      * client's extended events.
206      * @since 1.4.6
207      */

208     public void setClientExtendedEventHandler(ClientExtendedEventHandler handler) {
209         if(handler!=null)
210             clientExtendedEventHandler = handler.getClass().getName();
211     }
212     /**
213      * Returns the ClientExtendedEventHandler class that gets notified of
214      * client's extended events.
215      * @see #setClientExtendedEventHandler
216      * @since 1.4.6
217      */

218     public String JavaDoc getClientExtendedEventHandler() {
219         return clientExtendedEventHandler;
220     }
221
222     /**
223      * Sets the Authenticator class that handles the
224      * authentication of the client.
225      * XML Tag: &lt;authenticator&gt;&lt;/authenticator&gt;
226      * @param authenticator the fully qualified name of the class
227      * that implements {@link org.quickserver.net.server.Authenticator}.
228      * @see #getAuthenticator
229      * @since 1.3
230      */

231     public void setAuthenticator(String JavaDoc authenticator) {
232         if(authenticator!=null && authenticator.equals("")==false)
233             this.clientAuthenticationHandler = authenticator;
234     }
235     /**
236      * Sets the Authenticator class that handles the
237      * authentication of the client.
238      * @since 1.4.6
239      */

240     public void setAuthenticator(Authenticator authenticator) {
241         if(authenticator!=null)
242             this.clientAuthenticationHandler = authenticator.getClass().getName();
243     }
244     /**
245      * Returns the Authenticator class that handles the
246      * authentication of the client.
247      * @see #setAuthenticator
248      * @since 1.3
249      */

250     public String JavaDoc getAuthenticator() {
251         return clientAuthenticationHandler;
252     }
253
254     /**
255      * Sets the ClientAuthenticationHandler class that handles the
256      * authentication of the client.
257      * XML Tag: &lt;client-authentication-handler&gt;&lt;/client-authentication-handler&gt;
258      * @param clientAuthenticationHandler the fully qualified name of the class
259      * that implements {@link org.quickserver.net.server.ClientAuthenticationHandler}.
260      * @see #getClientAuthenticationHandler
261      * @since 1.4.6
262      */

263     public void setClientAuthenticationHandler(String JavaDoc clientAuthenticationHandler) {
264         if(clientAuthenticationHandler!=null && clientAuthenticationHandler.equals("")==false)
265             this.clientAuthenticationHandler = clientAuthenticationHandler;
266     }
267     /**
268      * Sets the ClientAuthenticationHandler class that handles the
269      * authentication of the client.
270      * @since 1.4.6
271      */

272     public void setClientAuthenticationHandler(ClientAuthenticationHandler clientAuthenticationHandler) {
273         if(clientAuthenticationHandler!=null)
274             this.clientAuthenticationHandler = clientAuthenticationHandler.getClass().getName();
275     }
276     /**
277      * Returns the ClientAuthenticationHandler class that handles the
278      * authentication of the client.
279      * @see #setClientAuthenticationHandler
280      * @since 1.4.6
281      */

282     public String JavaDoc getClientAuthenticationHandler() {
283         return clientAuthenticationHandler;
284     }
285
286     /**
287      * Sets the ClientData class that carries client data.
288      * XML Tag: &lt;client-data&gt;&lt;/client-data&gt;
289      * @param data the fully qualified name of the class that
290      * extends {@link org.quickserver.net.server.ClientData}.
291      * @see #getClientData
292      */

293     public void setClientData(String JavaDoc data) {
294         if(data!=null && data.equals("")==false)
295             this.clientData = data;
296     }
297     /**
298      * Sets the ClientData class that carries client data.
299      * @since 1.4.6
300      */

301     public void setClientData(ClientData data) {
302         if(data!=null)
303             this.clientData = data.getClass().getName();
304     }
305     /**
306      * Returns the ClientData class string that carries client data
307      * @return the fully qualified name of the class that
308      * implements {@link org.quickserver.net.server.ClientData}.
309      * @see #setClientData
310      */

311     public String JavaDoc getClientData() {
312         return clientData;
313     }
314
315     /**
316      * Sets the Client Socket timeout in milliseconds.
317      * XML Tag: &lt;timeout&gt;&lt;/timeout&gt;
318      * @param time client socket timeout in milliseconds.
319      * @see #getTimeout
320      */

321     public void setTimeout(int time) {
322         timeout = time;
323     }
324     /**
325      * Returns the Client Socket timeout in milliseconds.
326      * @see #setTimeout
327      */

328     public int getTimeout() {
329         return timeout;
330     }
331
332     /**
333      * Sets maximum allowed login attempts.
334      * XML Tag: &lt;max-auth-try&gt;&lt;/max-auth-try&gt;
335      */

336     public void setMaxAuthTry(int authTry) {
337         maxAuthTry = authTry;
338     }
339     /**
340      * Returns maximum allowed login attempts.
341      * Default is : 5
342      */

343     public int getMaxAuthTry() {
344         return maxAuthTry;
345     }
346
347     /**
348      * Sets message to be displayed when maximum allowed login
349      * attempts has reached.
350      * Default is : -ERR Max Auth Try Reached<br/>
351      * XML Tag: &lt;max-auth-try-msg&gt;&lt;/max-auth-try-msg&gt;
352      * @see #getMaxAuthTryMsg
353      */

354     public void setMaxAuthTryMsg(String JavaDoc msg) {
355         if(msg!=null && msg.equals("")==false)
356             maxAuthTryMsg = msg;
357     }
358     /**
359      * Returns message to be displayed when maximum allowed login
360      * attempts has reached.
361      * @see #getMaxAuthTryMsg
362      */

363     public String JavaDoc getMaxAuthTryMsg() {
364         return maxAuthTryMsg;
365     }
366
367     /**
368      * Sets timeout message.
369      * Default is : -ERR Timeout<br/>
370      * XML Tag: &lt;timeout-msg&gt;&lt;/timeout-msg&gt;
371      * @see #getTimeoutMsg
372      */

373     public void setTimeoutMsg(String JavaDoc msg) {
374         if(msg!=null && msg.equals("")==false)
375             timeoutMsg = msg;
376     }
377     /**
378      * Returns timeout message.
379      * @see #setTimeoutMsg
380      */

381     public String JavaDoc getTimeoutMsg() {
382         return timeoutMsg;
383     }
384
385     /**
386      * Sets the maximum number of client connection allowed..
387      * XML Tag: &lt;max-connection&gt;&lt;/max-connection&gt;
388      * @see #getMaxConnection
389      */

390     public void setMaxConnection(long maxConnection) {
391         this.maxConnection = maxConnection;
392     }
393     /**
394      * Returns the maximum number of client connection allowed.
395      * @see #setMaxConnection
396      */

397     public long getMaxConnection() {
398         return maxConnection;
399     }
400
401     /**
402      * Sets the message to be sent to any new client connected after
403      * maximum client connection has reached.
404      * Default is : <code>-ERR Server Busy. Max Connection Reached</code><br/>
405      * XML Tag: &lt;max-connection-msg&gt;&lt;/max-connection-msg&gt;
406      * @see #getMaxConnectionMsg
407      */

408     public void setMaxConnectionMsg(String JavaDoc maxConnectionMsg) {
409         if(maxConnectionMsg!=null && maxConnectionMsg.equals("")==false)
410             this.maxConnectionMsg = maxConnectionMsg;
411     }
412     /**
413      * Returns the message to be sent to any new client connected
414      * after maximum client connection has reached.
415      * @see #setMaxConnectionMsg
416      */

417     public String JavaDoc getMaxConnectionMsg() {
418         return maxConnectionMsg;
419     }
420
421     /**
422      * Sets the Ip address to bind to.
423      * @param bindAddr argument can be used on a multi-homed host for a
424      * QuickServer that will only accept connect requests to one
425      * of its addresses. If not set, it will default accepting
426      * connections on any/all local addresses.
427      * XML Tag: &lt;bind-address&gt;&lt;/bind-address&gt;
428      * @see #getBindAddr
429      */

430     public void setBindAddr(String JavaDoc bindAddr) {
431         if(bindAddr!=null && bindAddr.equals("")==false)
432             this.bindAddr = bindAddr;
433     }
434     /**
435      * Returns the Ip address binding to.
436      * @see #setBindAddr
437      */

438     public String JavaDoc getBindAddr() {
439         return bindAddr;
440     }
441
442     /**
443      * Sets the ClientObjectHandler class that interacts with
444      * client sockets.
445      * XML Tag: &lt;client-object-handler&gt;&lt;/client-object-handler&gt;
446      * @param handler object the fully qualified name of the class that
447      * implements {@link org.quickserver.net.server.ClientObjectHandler}
448      * @see #getClientObjectHandler
449      */

450     public void setClientObjectHandler(String JavaDoc handler) {
451         if(handler!=null && handler.equals("")==false)
452             clientObjectHandler = handler;
453     }
454     /**
455      * Sets the ClientObjectHandler class that interacts with
456      * client sockets.
457      * @since 1.4.6
458      */

459     public void setClientObjectHandler(ClientObjectHandler handler) {
460         if(handler!=null)
461             clientObjectHandler = handler.getClass().getName();
462     }
463     /**
464      * Returns the ClientObjectHandler class that interacts with
465      * client sockets.
466      * @see #setClientObjectHandler
467      */

468     public String JavaDoc getClientObjectHandler() {
469         return clientObjectHandler;
470     }
471
472     /**
473      * Sets the console log handler level.
474      * XML Tag: &lt;console-logging-level&gt;&lt;/console-logging-level&gt;
475      * @param level like INFO, FINE, CONFIG
476      */

477     public void setConsoleLoggingLevel(String JavaDoc level) {
478         if(level!=null && level.equals("")==false)
479             consoleLoggingLevel = level;
480     }
481     /**
482      * Returns the console log handler level.
483      */

484     public String JavaDoc getConsoleLoggingLevel() {
485         return consoleLoggingLevel;
486     }
487
488     /**
489      * Sets the console log handler formatter.
490      * XML Tag: &lt;console-logging-formatter&gt;&lt;/console-logging-formatter&gt;
491      * @param formatter fully qualified name of the class that
492      * implements {@link java.util.logging.Formatter}
493      */

494     public void setConsoleLoggingFormatter(String JavaDoc formatter) {
495         if(formatter!=null && formatter.equals("")==false)
496             consoleLoggingFormatter = formatter;
497     }
498     /**
499      * Returns the console log handler level.
500      */

501     public String JavaDoc getConsoleLoggingFormatter() {
502         return consoleLoggingFormatter;
503     }
504
505     /**
506      * Sets the ObjectPool Config object.
507      * XML Tag: &lt;object-pool&gt;&lt;/object-pool&gt;
508      */

509     public void setObjectPoolConfig(ObjectPoolConfig objectPoolConfig) {
510         if(objectPoolConfig!=null)
511             this.objectPoolConfig = objectPoolConfig;
512     }
513     /**
514      * Returns the ObjectPool Config object.
515      */

516     public ObjectPoolConfig getObjectPoolConfig() {
517         return objectPoolConfig;
518     }
519
520     /**
521      * Sets the communication logging flag.
522      * @see #getCommunicationLogging
523      * XML Tag: &lt;communication-logging&gt;&lt;enable&gt;true&lt;/enable&gt;&lt;/communication-logging&gt;
524      * Allowed values = <code>true</code> | <code>false</code>
525      * @since 1.3.2
526      */

527     public void setCommunicationLogging(boolean enable) {
528         this.communicationLogging = enable;
529     }
530     /**
531      * Returns the communication logging flag.
532      * @see #setCommunicationLogging
533      * @since 1.3.2
534      */

535     public boolean getCommunicationLogging() {
536         return communicationLogging;
537     }
538
539     /**
540      * Sets the Access constraints
541      * @since 1.3.3
542      */

543     public void setAccessConstraintConfig(
544         AccessConstraintConfig accessConstraintConfig) {
545         this.accessConstraintConfig = accessConstraintConfig;
546     }
547     /**
548      * Returns Access constraints if present else <code>null</code>.
549      * @since 1.3.3
550      */

551     public AccessConstraintConfig getAccessConstraintConfig() {
552         return accessConstraintConfig;
553     }
554
555     /**
556      * Sets the ServerHooks
557      * @since 1.3.3
558      */

559     public void setServerHooks(ServerHooks serverHooks) {
560         this.serverHooks = serverHooks;
561     }
562     /**
563      * Returns ServerHooks if present else <code>null</code>.
564      * @since 1.3.3
565      */

566     public ServerHooks getServerHooks() {
567         return serverHooks;
568     }
569
570     /**
571      * Sets the Secure setting for QuickServer
572      * @since 1.4.0
573      */

574     public void setSecure(Secure secure) {
575         this.secure = secure;
576     }
577     /**
578      * Returns Secure setting for QuickServer
579      * @since 1.4.0
580      */

581     public Secure getSecure() {
582         return secure;
583     }
584
585     /**
586      * Sets the ClientBinaryHandler class that interacts with
587      * client sockets.
588      * XML Tag: &lt;client-binary-handler&gt;&lt;/client-binary-handler&gt;
589      * @param handler the fully qualified name of the class that
590      * implements {@link org.quickserver.net.server.ClientBinaryHandler}
591      * @see #getClientBinaryHandler
592      */

593     public void setClientBinaryHandler(String JavaDoc handler) {
594         if(handler!=null && handler.equals("")==false)
595             clientBinaryHandler = handler;
596     }
597     /**
598      * Sets the ClientBinaryHandler class that interacts with
599      * client sockets.
600      * @since 1.4.6
601      */

602     public void setClientBinaryHandler(ClientBinaryHandler handler) {
603         if(handler!=null)
604             clientBinaryHandler = handler.getClass().getName();
605     }
606     /**
607      * Returns the ClientBinaryHandler class that interacts with
608      * client sockets.
609      * @see #setClientBinaryHandler
610      */

611     public String JavaDoc getClientBinaryHandler() {
612         return clientBinaryHandler;
613     }
614
615     /**
616      * Sets the ServerMode for the QuickServer.
617      * @param serverMode ServerMode object.
618      * @see #getServerMode
619      * @since 1.4.5
620      */

621     public void setServerMode(ServerMode serverMode) {
622         if(serverMode==null) serverMode = new ServerMode();
623         this.serverMode = serverMode;
624     }
625     /**
626      * Returns the ServerMode for the QuickServer.
627      * @see #setServerMode
628      * @since 1.4.5
629      */

630     public ServerMode getServerMode() {
631         return serverMode;
632     }
633
634     /**
635      * Sets the ClientWriteHandler class that interacts with
636      * client sockets.
637      * XML Tag: &lt;client-write-handler&gt;&lt;/client-write-handler&gt;
638      * @param handler the fully qualified name of the class that
639      * implements {@link org.quickserver.net.server.ClientWriteHandler}
640      * @see #getClientWriteHandler
641      * @since 1.4.5
642      */

643     public void setClientWriteHandler(String JavaDoc handler) {
644         if(handler!=null && handler.equals("")==false)
645             clientWriteHandler = handler;
646     }
647     /**
648      * Sets the ClientWriteHandler class that interacts with
649      * client sockets.
650      * @since 1.4.6
651      */

652     public void setClientWriteHandler(ClientWriteHandler handler) {
653         if(handler!=null)
654             clientWriteHandler = handler.getClass().getName();
655     }
656     /**
657      * Returns the ClientWriteHandler class that interacts with
658      * client sockets.
659      * @see #setClientWriteHandler
660      */

661     public String JavaDoc getClientWriteHandler() {
662         return clientWriteHandler;
663     }
664
665     /**
666      * Sets the AdvancedSettings for the QuickServer.
667      * @param advancedSettings AdvancedSettings object.
668      * @see #getAdvancedSettings
669      * @since 1.4.5
670      */

671     public void setAdvancedSettings(AdvancedSettings advancedSettings) {
672         this.advancedSettings = advancedSettings;
673     }
674     /**
675      * Returns the AdvancedSettings for the QuickServer.
676      * @see #setAdvancedSettings
677      * @since 1.4.5
678      */

679     public AdvancedSettings getAdvancedSettings() {
680         if(advancedSettings==null) advancedSettings = new AdvancedSettings();
681         return advancedSettings;
682     }
683
684     /**
685      * Sets the DefaultDataMode for the QuickServer.
686      * @param defaultDataMode DefaultDataMode object.
687      * @see #getDefaultDataMode
688      * @since 1.4.6
689      */

690     public void setDefaultDataMode(DefaultDataMode defaultDataMode) {
691         this.defaultDataMode = defaultDataMode;
692     }
693     /**
694      * Returns the DefaultDataMode for the QuickServer.
695      * @see #setDefaultDataMode
696      * @since 1.4.6
697      */

698     public DefaultDataMode getDefaultDataMode() {
699         if(defaultDataMode==null)
700             defaultDataMode = new DefaultDataMode();
701         return defaultDataMode;
702     }
703 }
704
Popular Tags