KickJava   Java API By Example, From Geeks To Geeks.

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


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

29 public class QuickServerConfig extends BasicServerConfig {
30     
31     private QSAdminServerConfig qSAdminServerConfig;
32     private DBObjectPoolConfig dDObjectPoolConfig;
33     private ApplicationConfiguration applicationConfiguration;
34     private InitServerHooks initServerHooks;
35
36     private String JavaDoc securityManagerClass = null;
37     private String JavaDoc configFile = null;
38     private String JavaDoc applicationJarPath = null;
39
40     public QuickServerConfig() {
41         setName("QuickServer v"+QuickServer.getVersion());
42     }
43     
44     /**
45      * Sets the QSAdminServer configuration.
46      * XML Tag: &lt;qsadmin-server&gt;&lt;/qsadmin-server&gt;
47      */

48     public void setQSAdminServerConfig(QSAdminServerConfig config) {
49         qSAdminServerConfig = config;
50     }
51     /**
52      * Returns QSAdminServer configuration.
53      */

54     public QSAdminServerConfig getQSAdminServerConfig() {
55         return qSAdminServerConfig;
56     }
57
58     /**
59      * Sets the DBObjectPoolConfig
60      * XML Tag: &lt;object-pool&gt;&lt;/object-pool&gt;
61      * @since 1.3
62      */

63     public void setDBObjectPoolConfig(DBObjectPoolConfig dDObjectPoolConfig) {
64         this.dDObjectPoolConfig = dDObjectPoolConfig;
65     }
66     /**
67      * Returns DBObjectPoolConfig
68      * @since 1.3
69      */

70     public DBObjectPoolConfig getDBObjectPoolConfig() {
71         return dDObjectPoolConfig;
72     }
73
74     /**
75      * Sets the Application Configuration. This can be used by application to
76      * store its configuration information.
77      * XML Tag: &lt;application-configuration&gt;&lt;/application-configuration&gt;
78      * @since 1.3.2
79      */

80     public void setApplicationConfiguration(
81             ApplicationConfiguration applicationConfiguration) {
82         this.applicationConfiguration = applicationConfiguration;
83     }
84     /**
85      * Returns ApplicationConfiguration
86      * @since 1.3.2
87      */

88     public ApplicationConfiguration getApplicationConfiguration() {
89         return applicationConfiguration;
90     }
91
92
93     /**
94      * Sets the SecurityManager class
95      * XML Tag: &lt;security-manager-class&gt;&lt;/security-manager-class&gt;
96      * @param securityManagerClass className the fully qualified name of the
97      * class that extends {@link java.lang.SecurityManager}.
98      * @see #getSecurityManagerClass
99      * @since 1.3.3
100      */

101     public void setSecurityManagerClass(String JavaDoc securityManagerClass) {
102         if(securityManagerClass!=null)
103             this.securityManagerClass = securityManagerClass;
104     }
105     /**
106      * Returns the SecurityManager class
107      * @see #setSecurityManagerClass
108      * @since 1.3.3
109      */

110     public String JavaDoc getSecurityManagerClass() {
111         return securityManagerClass;
112     }
113
114     /**
115      * Sets the file path of the file that loaded the config from.
116      * @since 1.3.3
117      */

118     protected void setConfigFile(String JavaDoc fileName) {
119         configFile = fileName;
120     }
121
122     /**
123      * Returns the file path of the file that loaded the configuration file.
124      * @since 1.3.3
125      */

126     public String JavaDoc getConfigFile() {
127         return configFile;
128     }
129
130
131     /**
132      * Sets the applications jar/s path. This can be either absolute or
133      * relative(to config file) path to the jar file or the directory containing the jars
134      * needed by the application.
135      * @see #getApplicationJarPath
136      * @since 1.3.3
137      */

138     public void setApplicationJarPath(String JavaDoc applicationJarPath) {
139         this.applicationJarPath = applicationJarPath;
140     }
141
142     /**
143      * Returns the applications jar/s path. This can be either absolute or
144      * relative(to config file) path to the jar file or the directory containing the jars
145      * needed by the application.
146      * @see #setApplicationJarPath
147      * @since 1.3.3
148      */

149     public String JavaDoc getApplicationJarPath() {
150         return applicationJarPath;
151     }
152
153
154     /**
155      * Sets the InitServerHooks.
156      * @see #getInitServerHooks
157      * @since 1.4
158      */

159     public void setInitServerHooks(InitServerHooks initServerHooks) {
160         this.initServerHooks = initServerHooks;
161     }
162
163     /**
164      * Returns the InitServerHooks.
165      * @see #setInitServerHooks
166      * @since 1.4
167      */

168     public InitServerHooks getInitServerHooks() {
169         return initServerHooks;
170     }
171
172     /**
173      * Returns XML config of this class.
174      * @since 1.3
175      */

176     public String JavaDoc toXML(String JavaDoc pad) {
177         if(pad==null) pad="";
178         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
179         sb.append(pad+"<quickserver>\n");
180
181         if(getName()!=null)
182             sb.append(pad+"\t<name>"+getName()+"</name>\n");
183         if(getServerBanner()!=null)
184             sb.append(pad+"\t<server-banner>"+getServerBanner()+"</server-banner>\n");
185         sb.append(pad+"\t<port>"+getPort()+"</port>\n");
186         if(getBindAddr()!=null)
187             sb.append(pad+"\t<bind-address>"+getBindAddr()+"</bind-address>\n");
188
189         sb.append( getServerMode().toXML(pad+"\t") );
190
191         if(getClientEventHandler()!=null)
192             sb.append(pad+"\t<client-event-handler>"+getClientEventHandler()+"</client-event-handler>\n");
193         if(getClientCommandHandler()!=null)
194             sb.append(pad+"\t<client-command-handler>"+getClientCommandHandler()+"</client-command-handler>\n");
195         if(getClientObjectHandler()!=null)
196             sb.append(pad+"\t<client-object-handler>"+getClientObjectHandler()+"</client-object-handler>\n");
197         if(getClientBinaryHandler()!=null)
198             sb.append(pad+"\t<client-binary-handler>"+getClientBinaryHandler()+"</client-binary-handler>\n");
199         if(getClientWriteHandler()!=null)
200             sb.append(pad+"\t<client-write-handler>"+getClientWriteHandler()+"</client-write-handler>\n");
201         if(getClientAuthenticationHandler()!=null)
202             sb.append(pad+"\t<client-authentication-handler>"+getClientAuthenticationHandler()+"</client-authentication-handler>\n");
203         else if(getAuthenticator()!=null)
204             sb.append(pad+"\t<authenticator>"+getAuthenticator()+"</authenticator>\n");
205         if(getClientData()!=null)
206             sb.append(pad+"\t<client-data>"+getClientData()+"</client-data>\n");
207         if(getClientExtendedEventHandler()!=null)
208             sb.append(pad+"\t<client-extended-event-handler>"+getClientExtendedEventHandler()+"</client-extended-event-handler>\n");
209     
210         sb.append( getDefaultDataMode().toXML(pad+"\t") );
211
212         sb.append(pad+"\t<timeout>"+getTimeout()+"</timeout>\n");
213         if(getTimeoutMsg()!=null)
214             sb.append(pad+"\t<timeout-msg>"+getTimeoutMsg()+"</timeout-msg>\n");
215
216         sb.append(pad+"\t<max-auth-try>"+getMaxAuthTry()+"</max-auth-try>\n");
217         if(getMaxAuthTryMsg()!=null)
218             sb.append(pad+"\t<max-auth-try-msg>"+getMaxAuthTryMsg()+"</max-auth-try-msg>\n");
219         
220         sb.append(pad+"\t<max-connection>"+getMaxConnection()+"</max-connection>\n");
221         if(getMaxConnectionMsg()!=null)
222             sb.append(pad+"\t<max-connection-msg>"+getMaxConnectionMsg()+"</max-connection-msg>\n");
223         
224         
225         if(getConsoleLoggingLevel()!=null)
226             sb.append(pad+"\t<console-logging-level>"+getConsoleLoggingLevel()+"</console-logging-level>\n");
227         if(getConsoleLoggingFormatter()!=null)
228             sb.append(pad+"\t<console-logging-formatter>"+getConsoleLoggingFormatter()+"</console-logging-formatter>\n");
229         
230         sb.append(getObjectPoolConfig().toXML(pad+"\t"));
231
232         sb.append(pad+"\t<communication-logging>\n");
233         sb.append(pad+"\t\t<enable>"+getCommunicationLogging()+"</enable>\n");
234         sb.append(pad+"\t</communication-logging>\n");
235
236         if(getDBObjectPoolConfig()!=null) {
237             sb.append( getDBObjectPoolConfig().toXML(pad+"\t") );
238         }
239
240         if(getSecurityManagerClass()!=null) {
241             sb.append(pad+"\t<security-manager-class>"+getSecurityManagerClass()+"</security-manager-class>\n");
242         }
243
244         if(getAccessConstraintConfig()!=null) {
245             sb.append(getAccessConstraintConfig().toXML(pad+"\t"));
246         }
247
248         if(getQSAdminServerConfig()!=null)
249             sb.append( getQSAdminServerConfig().toXML(pad+"\t") );
250
251
252         if(getApplicationConfiguration()!=null) {
253             sb.append( getApplicationConfiguration().toXML(pad+"\t") );
254         }
255
256         if(getApplicationJarPath()!=null) {
257             sb.append(pad+"\t<application-jar-path>"+
258                 getApplicationJarPath()+
259                 "</application-jar-path>\n");
260         }
261
262         if(getServerHooks()!=null) {
263             sb.append( getServerHooks().toXML(pad+"\t") );
264         }
265
266         if(getInitServerHooks()!=null) {
267             sb.append( getInitServerHooks().toXML(pad+"\t") );
268         }
269
270         sb.append( getSecure().toXML(pad+"\t") );
271         sb.append( getAdvancedSettings().toXML(pad+"\t") );
272
273         sb.append(pad+"</quickserver>\n");
274         return sb.toString();
275     }
276
277     public String JavaDoc toString() {
278         return toXML(null);
279     }
280 }
281
Popular Tags