KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > core > db > config > JNDIConfig


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by Jcorporate Ltd.
21  * (http://www.jcorporate.com/)."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. "Jcorporate" and product names such as "Expresso" must
26  * not be used to endorse or promote products derived from this
27  * software without prior written permission. For written permission,
28  * please contact info@jcorporate.com.
29  *
30  * 5. Products derived from this software may not be called "Expresso",
31  * or other Jcorporate product names; nor may "Expresso" or other
32  * Jcorporate product names appear in their name, without prior
33  * written permission of Jcorporate Ltd.
34  *
35  * 6. No product derived from this software may compete in the same
36  * market space, i.e. framework, without prior written permission
37  * of Jcorporate Ltd. For written permission, please contact
38  * partners@jcorporate.com.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This software consists of voluntary contributions made by many
55  * individuals on behalf of the Jcorporate Ltd. Contributions back
56  * to the project(s) are encouraged when you make modifications.
57  * Please send them to support@jcorporate.com. For more information
58  * on Jcorporate Ltd. and its products, please see
59  * <http://www.jcorporate.com/>.
60  *
61  * Portions of this software are based upon other open source
62  * products and are subject to their respective licenses.
63  */

64
65 package com.jcorporate.expresso.core.db.config;
66
67 import com.jcorporate.expresso.kernel.ComponentLifecycle;
68 import com.jcorporate.expresso.kernel.Configuration;
69 import com.jcorporate.expresso.kernel.exception.ConfigurationException;
70
71 /**
72  * A Commons digester class for JDBC section of the standardmaessig
73  * Expresso Configuration XML file. This bean defines the conection characteristics
74  * to the database in this context
75  * <p/>
76  * <p>Documentation written by Yves Henri AMAIZO @ AmyCase.com, Sun Jul 29 00:55:00 GMT 2002</p>
77  * <p/>
78  * All the 'bean' methods here are directly mapped to the &lt;jdbc&gt; section
79  * int the expresso-config.xml file. It is recommend that you also look at the
80  * Expresso config DTD for a better understanding of the relation of these various
81  * parameteters.
82  *
83  * @author Yves Henri AMAIZO
84  * @since Expresso 5.1
85  */

86 public class JNDIConfig extends com.jcorporate.expresso.kernel.EmbeddedComponent
87         implements java.io.Serializable JavaDoc, ComponentLifecycle {
88
89     /**
90      * Default constructor
91      */

92     public JNDIConfig() {
93     }
94
95     /**
96      * JNDI INITIAL CONTEXT FACTORY <com.sun.jndi.fscontext.RefFSContextFactory>
97      */

98     protected String JavaDoc initialContextFactory = "";
99
100     /**
101      * JNDI provider URL <protocol>://<host>:<port>
102      */

103     protected String JavaDoc providerURL = "";
104
105     /**
106      * JNDI SECURITY_PRINCIPAL Username
107      */

108     protected String JavaDoc securityPrincipal = "";
109
110     /**
111      * JNDI SECURITY_CREDENTIALS Password
112      */

113     protected String JavaDoc securityCredentials = "";
114
115     /**
116      * JNDI DNS_URL
117      */

118     protected String JavaDoc dnsURL = "";
119
120     /**
121      * JNDI SECURITY_PROTOCOL
122      */

123     protected String JavaDoc securityProtocol = "";
124
125     /**
126      * JNDI SECURITY_AUTHENTICATION "none", "simple", "strong"
127      */

128     protected String JavaDoc securityAuthentication = "";
129
130     /**
131      * JNDI OBJECT_FACTORIES
132      */

133     protected String JavaDoc objectFactories = "";
134
135     /**
136      * JNDI STATE_FACTORIES
137      */

138     protected String JavaDoc stateFactories = "";
139
140     /**
141      * JNDI URL_PKG_PREFIXES
142      */

143     protected String JavaDoc urlPKGPrefixes = "";
144
145     /**
146      * JNDI BATCHSIZE
147      */

148     protected String JavaDoc batchSize = "";
149
150     /**
151      * JNDI AUTHORITATIVE
152      */

153     protected String JavaDoc authoritative = "";
154
155     /**
156      * JNDI LANGUAGE
157      */

158     protected String JavaDoc language = "";
159
160
161     /**
162      * Default commons constructor
163      *
164      * @param factory JNDIFactory name
165      * @param user User Name
166      * @param pass Password
167      * @param provider The DataSource Provider
168      */

169     public JNDIConfig(String JavaDoc factory, String JavaDoc user, String JavaDoc pass, String JavaDoc provider) {
170         initialContextFactory = factory;
171         securityPrincipal = user;
172         securityCredentials = pass;
173         providerURL = provider;
174     }/* ConfigJndi(String, String, String, String) */
175
176
177     /**
178      * Gets the initialContextFactory
179      *
180      * @return Returns a String
181      */

182     public synchronized String JavaDoc getInitialContextFactory() {
183         return initialContextFactory;
184     }
185
186     /**
187      * Sets the initialContextFactory
188      *
189      * @param initialContextFactory The initialContextFactory to set
190      */

191     public synchronized void setInitialContextFactory(String JavaDoc initialContextFactory) {
192         this.initialContextFactory = initialContextFactory;
193     }
194
195
196     /**
197      * Gets the providerURL
198      *
199      * @return Returns a String
200      */

201     public synchronized String JavaDoc getProviderURL() {
202         return providerURL;
203     }
204
205     /**
206      * Sets the providerURL
207      *
208      * @param providerURL The providerURL to set
209      */

210     public synchronized void setProviderURL(String JavaDoc providerURL) {
211         this.providerURL = providerURL;
212     }
213
214
215     /**
216      * Gets the dnsURL
217      *
218      * @return Returns a String
219      */

220     public synchronized String JavaDoc getDnsURL() {
221         return dnsURL;
222     }
223
224     /**
225      * Sets the dnsURL
226      *
227      * @param dnsURL The dnsURL to set
228      */

229     public synchronized void setDnsURL(String JavaDoc dnsURL) {
230         this.dnsURL = dnsURL;
231     }
232
233
234     /**
235      * Gets the securityProtocol
236      *
237      * @return Returns a String
238      */

239     public String JavaDoc getSecurityProtocol() {
240         return securityProtocol;
241     }
242
243     /**
244      * Sets the securityProtocol
245      *
246      * @param securityProtocol The securityProtocol to set
247      */

248     public void setSecurityProtocol(String JavaDoc securityProtocol) {
249         this.securityProtocol = securityProtocol;
250     }
251
252
253     /**
254      * Gets the urlPKGPrefixes
255      *
256      * @return Returns a String
257      */

258     public String JavaDoc getUrlPKGPrefixes() {
259         return urlPKGPrefixes;
260     }
261
262     /**
263      * Sets the urlPKGPrefixes
264      *
265      * @param urlPKGPrefixes The urlPKGPrefixes to set
266      */

267     public void setUrlPKGPrefixes(String JavaDoc urlPKGPrefixes) {
268         this.urlPKGPrefixes = urlPKGPrefixes;
269     }
270
271
272     /**
273      * Gets the batchSize
274      *
275      * @return Returns a String
276      */

277     public synchronized String JavaDoc getBatchSize() {
278         return batchSize;
279     }
280
281     /**
282      * Sets the batchSize
283      *
284      * @param batchSize The batchSize to set
285      */

286     public synchronized void setBatchSize(String JavaDoc batchSize) {
287         this.batchSize = batchSize;
288     }
289
290
291     /**
292      * Gets the authoritative
293      *
294      * @return Returns a String
295      */

296     public synchronized String JavaDoc getAuthoritative() {
297         return authoritative;
298     }
299
300     /**
301      * Sets the authoritative
302      *
303      * @param authoritative The authoritative to set
304      */

305     public synchronized void setAuthoritative(String JavaDoc authoritative) {
306         this.authoritative = authoritative;
307     }
308
309
310     /**
311      * Gets the language
312      *
313      * @return Returns a String
314      */

315     public synchronized String JavaDoc getLanguage() {
316         return language;
317     }
318
319     /**
320      * Sets the language
321      *
322      * @param language The language to set
323      */

324     public synchronized void setLanguage(String JavaDoc language) {
325         this.language = language;
326     }
327
328
329     /**
330      * Gets the securityPrincipal
331      *
332      * @return Returns a String
333      */

334     public synchronized String JavaDoc getSecurityPrincipal() {
335         return securityPrincipal;
336     }
337
338     /**
339      * Sets the securityPrincipal
340      *
341      * @param securityPrincipal The securityPrincipal to set
342      */

343     public synchronized void setSecurityPrincipal(String JavaDoc securityPrincipal) {
344         this.securityPrincipal = securityPrincipal;
345     }
346
347
348     /**
349      * Gets the securityCredentials
350      *
351      * @return Returns a String
352      */

353     public synchronized String JavaDoc getSecurityCredentials() {
354         return securityCredentials;
355     }
356
357     /**
358      * Sets the securityCredentials
359      *
360      * @param securityCredentials The securityCredentials to set
361      */

362     public synchronized void setSecurityCredentials(String JavaDoc securityCredentials) {
363         this.securityCredentials = securityCredentials;
364     }
365
366
367     /**
368      * Gets the securityAuthentication
369      *
370      * @return Returns a String
371      */

372     public synchronized String JavaDoc getSecurityAuthentication() {
373         return securityAuthentication;
374     }
375
376     /**
377      * Sets the securityAuthentication
378      *
379      * @param securityAuthentication The securityAuthentication to set
380      */

381     public synchronized void setSecurityAuthentication(String JavaDoc securityAuthentication) {
382         this.securityAuthentication = securityAuthentication;
383     }
384
385
386     /**
387      * Gets the objectFactories
388      *
389      * @return Returns a String
390      */

391     public synchronized String JavaDoc getObjectFactories() {
392         return objectFactories;
393     }
394
395     /**
396      * Sets the objectFactories
397      *
398      * @param objectFactories The objectFactories to set
399      */

400     public synchronized void setObjectFactories(String JavaDoc objectFactories) {
401         this.objectFactories = objectFactories;
402     }
403
404
405     /**
406      * Gets the stateFactories
407      *
408      * @return Returns a String
409      */

410     public synchronized String JavaDoc getStateFactories() {
411         return stateFactories;
412     }
413
414     /**
415      * Sets the stateFactories
416      *
417      * @param stateFactories The stateFactories to set
418      */

419     public synchronized void setStateFactories(String JavaDoc stateFactories) {
420         this.stateFactories = stateFactories;
421     }
422
423     /**
424      * Initial Creation initialization
425      */

426     public void initialize() {
427     }
428
429     /**
430      * Configure lifecycle event. Loads all the configuration values
431      *
432      * @param newConfig the Kernel Configuration 'Bean'
433      * @throws ConfigurationException upon Configuration Error
434      */

435     public synchronized void configure(Configuration newConfig) throws ConfigurationException {
436         authoritative = (String JavaDoc) newConfig.get("Authoritative");
437         batchSize = (String JavaDoc) newConfig.get("BatchSize");
438         dnsURL = (String JavaDoc) newConfig.get("DnsURL");
439         initialContextFactory = (String JavaDoc) newConfig.get("InitialContextFactory");
440         language = (String JavaDoc) newConfig.get("Language");
441         objectFactories = (String JavaDoc) newConfig.get("ObjectFactories");
442         providerURL = (String JavaDoc) newConfig.get("ProviderURL");
443         securityAuthentication = (String JavaDoc) newConfig.get("SecurityAuthentication");
444         securityCredentials = (String JavaDoc) newConfig.get("SecurityCredentials");
445         securityPrincipal = (String JavaDoc) newConfig.get("SecurityPrincipal");
446         securityProtocol = (String JavaDoc) newConfig.get("SecurityProtocol");
447         stateFactories = (String JavaDoc) newConfig.get("StateFactories");
448         urlPKGPrefixes = (String JavaDoc) newConfig.get("urlPKGPrefixes");
449     }
450
451     /**
452      * Reconfigure Lifecycle Event. Zeroes out all configuration values
453      * and reconfigures.
454      *
455      * @param newConfig The new configuration values
456      * @throws ConfigurationException upon error
457      */

458     public synchronized void reconfigure(Configuration newConfig) throws ConfigurationException {
459         authoritative = null;
460         batchSize = null;
461         dnsURL = null;
462         initialContextFactory = null;
463         language = null;
464         objectFactories = null;
465         providerURL = null;
466         securityAuthentication = null;
467         securityCredentials = null;
468         securityPrincipal = null;
469         securityProtocol = null;
470         stateFactories = null;
471         urlPKGPrefixes = null;
472         configure(newConfig);
473     }
474
475
476     /**
477      * Destroy Lifecycle Event
478      */

479     public synchronized void destroy() {
480         authoritative = null;
481         batchSize = null;
482         dnsURL = null;
483         initialContextFactory = null;
484         language = null;
485         objectFactories = null;
486         providerURL = null;
487         securityAuthentication = null;
488         securityCredentials = null;
489         securityPrincipal = null;
490         securityProtocol = null;
491         stateFactories = null;
492         urlPKGPrefixes = null;
493     }
494
495
496     /**
497      * Because we look up our metadata in the parent component, we have to
498      * somehow know WHAT component's metadata is ours. Sub classes need to
499      * override this one-liner and return the name of the metadata we're
500      * looking for.
501      *
502      * @return java.lang.String
503      */

504     public String JavaDoc getMetadataName() {
505         return "JNDIConfig";
506     }
507
508 }
Popular Tags