001: /* ====================================================================
002: * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
003: *
004: * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * 3. The end-user documentation included with the redistribution,
019: * if any, must include the following acknowledgment:
020: * "This product includes software developed by Jcorporate Ltd.
021: * (http://www.jcorporate.com/)."
022: * Alternately, this acknowledgment may appear in the software itself,
023: * if and wherever such third-party acknowledgments normally appear.
024: *
025: * 4. "Jcorporate" and product names such as "Expresso" must
026: * not be used to endorse or promote products derived from this
027: * software without prior written permission. For written permission,
028: * please contact info@jcorporate.com.
029: *
030: * 5. Products derived from this software may not be called "Expresso",
031: * or other Jcorporate product names; nor may "Expresso" or other
032: * Jcorporate product names appear in their name, without prior
033: * written permission of Jcorporate Ltd.
034: *
035: * 6. No product derived from this software may compete in the same
036: * market space, i.e. framework, without prior written permission
037: * of Jcorporate Ltd. For written permission, please contact
038: * partners@jcorporate.com.
039: *
040: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
041: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
042: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
043: * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
044: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
045: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
046: * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
047: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
048: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
049: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
050: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
051: * SUCH DAMAGE.
052: * ====================================================================
053: *
054: * This software consists of voluntary contributions made by many
055: * individuals on behalf of the Jcorporate Ltd. Contributions back
056: * to the project(s) are encouraged when you make modifications.
057: * Please send them to support@jcorporate.com. For more information
058: * on Jcorporate Ltd. and its products, please see
059: * <http://www.jcorporate.com/>.
060: *
061: * Portions of this software are based upon other open source
062: * products and are subject to their respective licenses.
063: */
064:
065: package com.jcorporate.expresso.core.db.config;
066:
067: import com.jcorporate.expresso.kernel.ComponentLifecycle;
068: import com.jcorporate.expresso.kernel.Configuration;
069: import com.jcorporate.expresso.kernel.exception.ConfigurationException;
070:
071: /**
072: * A Commons digester class for JDBC section of the standardmaessig
073: * Expresso Configuration XML file. This bean defines the conection characteristics
074: * to the database in this context
075: * <p/>
076: * <p>Documentation written by Yves Henri AMAIZO @ AmyCase.com, Sun Jul 29 00:55:00 GMT 2002</p>
077: * <p/>
078: * All the 'bean' methods here are directly mapped to the <jdbc> section
079: * int the expresso-config.xml file. It is recommend that you also look at the
080: * Expresso config DTD for a better understanding of the relation of these various
081: * parameteters.
082: *
083: * @author Yves Henri AMAIZO
084: * @since Expresso 5.1
085: */
086: public class JNDIConfig extends
087: com.jcorporate.expresso.kernel.EmbeddedComponent implements
088: java.io.Serializable, ComponentLifecycle {
089:
090: /**
091: * Default constructor
092: */
093: public JNDIConfig() {
094: }
095:
096: /**
097: * JNDI INITIAL CONTEXT FACTORY <com.sun.jndi.fscontext.RefFSContextFactory>
098: */
099: protected String initialContextFactory = "";
100:
101: /**
102: * JNDI provider URL <protocol>://<host>:<port>
103: */
104: protected String providerURL = "";
105:
106: /**
107: * JNDI SECURITY_PRINCIPAL Username
108: */
109: protected String securityPrincipal = "";
110:
111: /**
112: * JNDI SECURITY_CREDENTIALS Password
113: */
114: protected String securityCredentials = "";
115:
116: /**
117: * JNDI DNS_URL
118: */
119: protected String dnsURL = "";
120:
121: /**
122: * JNDI SECURITY_PROTOCOL
123: */
124: protected String securityProtocol = "";
125:
126: /**
127: * JNDI SECURITY_AUTHENTICATION "none", "simple", "strong"
128: */
129: protected String securityAuthentication = "";
130:
131: /**
132: * JNDI OBJECT_FACTORIES
133: */
134: protected String objectFactories = "";
135:
136: /**
137: * JNDI STATE_FACTORIES
138: */
139: protected String stateFactories = "";
140:
141: /**
142: * JNDI URL_PKG_PREFIXES
143: */
144: protected String urlPKGPrefixes = "";
145:
146: /**
147: * JNDI BATCHSIZE
148: */
149: protected String batchSize = "";
150:
151: /**
152: * JNDI AUTHORITATIVE
153: */
154: protected String authoritative = "";
155:
156: /**
157: * JNDI LANGUAGE
158: */
159: protected String language = "";
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 factory, String user, String pass,
170: String provider) {
171: initialContextFactory = factory;
172: securityPrincipal = user;
173: securityCredentials = pass;
174: providerURL = provider;
175: }/* ConfigJndi(String, String, String, String) */
176:
177: /**
178: * Gets the initialContextFactory
179: *
180: * @return Returns a String
181: */
182: public synchronized String 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(
192: String initialContextFactory) {
193: this .initialContextFactory = initialContextFactory;
194: }
195:
196: /**
197: * Gets the providerURL
198: *
199: * @return Returns a String
200: */
201: public synchronized String 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 providerURL) {
211: this .providerURL = providerURL;
212: }
213:
214: /**
215: * Gets the dnsURL
216: *
217: * @return Returns a String
218: */
219: public synchronized String getDnsURL() {
220: return dnsURL;
221: }
222:
223: /**
224: * Sets the dnsURL
225: *
226: * @param dnsURL The dnsURL to set
227: */
228: public synchronized void setDnsURL(String dnsURL) {
229: this .dnsURL = dnsURL;
230: }
231:
232: /**
233: * Gets the securityProtocol
234: *
235: * @return Returns a String
236: */
237: public String getSecurityProtocol() {
238: return securityProtocol;
239: }
240:
241: /**
242: * Sets the securityProtocol
243: *
244: * @param securityProtocol The securityProtocol to set
245: */
246: public void setSecurityProtocol(String securityProtocol) {
247: this .securityProtocol = securityProtocol;
248: }
249:
250: /**
251: * Gets the urlPKGPrefixes
252: *
253: * @return Returns a String
254: */
255: public String getUrlPKGPrefixes() {
256: return urlPKGPrefixes;
257: }
258:
259: /**
260: * Sets the urlPKGPrefixes
261: *
262: * @param urlPKGPrefixes The urlPKGPrefixes to set
263: */
264: public void setUrlPKGPrefixes(String urlPKGPrefixes) {
265: this .urlPKGPrefixes = urlPKGPrefixes;
266: }
267:
268: /**
269: * Gets the batchSize
270: *
271: * @return Returns a String
272: */
273: public synchronized String getBatchSize() {
274: return batchSize;
275: }
276:
277: /**
278: * Sets the batchSize
279: *
280: * @param batchSize The batchSize to set
281: */
282: public synchronized void setBatchSize(String batchSize) {
283: this .batchSize = batchSize;
284: }
285:
286: /**
287: * Gets the authoritative
288: *
289: * @return Returns a String
290: */
291: public synchronized String getAuthoritative() {
292: return authoritative;
293: }
294:
295: /**
296: * Sets the authoritative
297: *
298: * @param authoritative The authoritative to set
299: */
300: public synchronized void setAuthoritative(String authoritative) {
301: this .authoritative = authoritative;
302: }
303:
304: /**
305: * Gets the language
306: *
307: * @return Returns a String
308: */
309: public synchronized String getLanguage() {
310: return language;
311: }
312:
313: /**
314: * Sets the language
315: *
316: * @param language The language to set
317: */
318: public synchronized void setLanguage(String language) {
319: this .language = language;
320: }
321:
322: /**
323: * Gets the securityPrincipal
324: *
325: * @return Returns a String
326: */
327: public synchronized String getSecurityPrincipal() {
328: return securityPrincipal;
329: }
330:
331: /**
332: * Sets the securityPrincipal
333: *
334: * @param securityPrincipal The securityPrincipal to set
335: */
336: public synchronized void setSecurityPrincipal(
337: String securityPrincipal) {
338: this .securityPrincipal = securityPrincipal;
339: }
340:
341: /**
342: * Gets the securityCredentials
343: *
344: * @return Returns a String
345: */
346: public synchronized String getSecurityCredentials() {
347: return securityCredentials;
348: }
349:
350: /**
351: * Sets the securityCredentials
352: *
353: * @param securityCredentials The securityCredentials to set
354: */
355: public synchronized void setSecurityCredentials(
356: String securityCredentials) {
357: this .securityCredentials = securityCredentials;
358: }
359:
360: /**
361: * Gets the securityAuthentication
362: *
363: * @return Returns a String
364: */
365: public synchronized String getSecurityAuthentication() {
366: return securityAuthentication;
367: }
368:
369: /**
370: * Sets the securityAuthentication
371: *
372: * @param securityAuthentication The securityAuthentication to set
373: */
374: public synchronized void setSecurityAuthentication(
375: String securityAuthentication) {
376: this .securityAuthentication = securityAuthentication;
377: }
378:
379: /**
380: * Gets the objectFactories
381: *
382: * @return Returns a String
383: */
384: public synchronized String getObjectFactories() {
385: return objectFactories;
386: }
387:
388: /**
389: * Sets the objectFactories
390: *
391: * @param objectFactories The objectFactories to set
392: */
393: public synchronized void setObjectFactories(String objectFactories) {
394: this .objectFactories = objectFactories;
395: }
396:
397: /**
398: * Gets the stateFactories
399: *
400: * @return Returns a String
401: */
402: public synchronized String getStateFactories() {
403: return stateFactories;
404: }
405:
406: /**
407: * Sets the stateFactories
408: *
409: * @param stateFactories The stateFactories to set
410: */
411: public synchronized void setStateFactories(String stateFactories) {
412: this .stateFactories = stateFactories;
413: }
414:
415: /**
416: * Initial Creation initialization
417: */
418: public void initialize() {
419: }
420:
421: /**
422: * Configure lifecycle event. Loads all the configuration values
423: *
424: * @param newConfig the Kernel Configuration 'Bean'
425: * @throws ConfigurationException upon Configuration Error
426: */
427: public synchronized void configure(Configuration newConfig)
428: throws ConfigurationException {
429: authoritative = (String) newConfig.get("Authoritative");
430: batchSize = (String) newConfig.get("BatchSize");
431: dnsURL = (String) newConfig.get("DnsURL");
432: initialContextFactory = (String) newConfig
433: .get("InitialContextFactory");
434: language = (String) newConfig.get("Language");
435: objectFactories = (String) newConfig.get("ObjectFactories");
436: providerURL = (String) newConfig.get("ProviderURL");
437: securityAuthentication = (String) newConfig
438: .get("SecurityAuthentication");
439: securityCredentials = (String) newConfig
440: .get("SecurityCredentials");
441: securityPrincipal = (String) newConfig.get("SecurityPrincipal");
442: securityProtocol = (String) newConfig.get("SecurityProtocol");
443: stateFactories = (String) newConfig.get("StateFactories");
444: urlPKGPrefixes = (String) newConfig.get("urlPKGPrefixes");
445: }
446:
447: /**
448: * Reconfigure Lifecycle Event. Zeroes out all configuration values
449: * and reconfigures.
450: *
451: * @param newConfig The new configuration values
452: * @throws ConfigurationException upon error
453: */
454: public synchronized void reconfigure(Configuration newConfig)
455: throws ConfigurationException {
456: authoritative = null;
457: batchSize = null;
458: dnsURL = null;
459: initialContextFactory = null;
460: language = null;
461: objectFactories = null;
462: providerURL = null;
463: securityAuthentication = null;
464: securityCredentials = null;
465: securityPrincipal = null;
466: securityProtocol = null;
467: stateFactories = null;
468: urlPKGPrefixes = null;
469: configure(newConfig);
470: }
471:
472: /**
473: * Destroy Lifecycle Event
474: */
475: public synchronized void destroy() {
476: authoritative = null;
477: batchSize = null;
478: dnsURL = null;
479: initialContextFactory = null;
480: language = null;
481: objectFactories = null;
482: providerURL = null;
483: securityAuthentication = null;
484: securityCredentials = null;
485: securityPrincipal = null;
486: securityProtocol = null;
487: stateFactories = null;
488: urlPKGPrefixes = null;
489: }
490:
491: /**
492: * Because we look up our metadata in the parent component, we have to
493: * somehow know WHAT component's metadata is ours. Sub classes need to
494: * override this one-liner and return the name of the metadata we're
495: * looking for.
496: *
497: * @return java.lang.String
498: */
499: public String getMetadataName() {
500: return "JNDIConfig";
501: }
502:
503: }
|