Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/jcorporate/expresso/core/db/config/JNDIConfig.java


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, 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 initialContextFactory = "";
99  
100     /**
101      * JNDI provider URL <protocol>://<host>:<port>
102      */
103     protected String providerURL = "";
104 
105     /**
106      * JNDI SECURITY_PRINCIPAL Username
107      */
108     protected String securityPrincipal = "";
109 
110     /**
111      * JNDI SECURITY_CREDENTIALS Password
112      */
113     protected String securityCredentials = "";
114 
115     /**
116      * JNDI DNS_URL
117      */
118     protected String dnsURL = "";
119 
120     /**
121      * JNDI SECURITY_PROTOCOL
122      */
123     protected String securityProtocol = "";
124 
125     /**
126      * JNDI SECURITY_AUTHENTICATION   "none", "simple", "strong"
127      */
128     protected String securityAuthentication = "";
129 
130     /**
131      * JNDI OBJECT_FACTORIES
132      */
133     protected String objectFactories = "";
134 
135     /**
136      * JNDI STATE_FACTORIES
137      */
138     protected String stateFactories = "";
139 
140     /**
141      * JNDI URL_PKG_PREFIXES
142      */
143     protected String urlPKGPrefixes = "";
144 
145     /**
146      * JNDI BATCHSIZE
147      */
148     protected String batchSize = "";
149 
150     /**
151      * JNDI AUTHORITATIVE
152      */
153     protected String authoritative = "";
154 
155     /**
156      * JNDI LANGUAGE
157      */
158     protected String 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 factory, String user, String pass, String 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 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 initialContextFactory) {
192         this.initialContextFactory = initialContextFactory;
193     }
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     /**
216      * Gets the dnsURL
217      *
218      * @return Returns a String
219      */
220     public synchronized String 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 dnsURL) {
230         this.dnsURL = dnsURL;
231     }
232 
233 
234     /**
235      * Gets the securityProtocol
236      *
237      * @return Returns a String
238      */
239     public String 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 securityProtocol) {
249         this.securityProtocol = securityProtocol;
250     }
251 
252 
253     /**
254      * Gets the urlPKGPrefixes
255      *
256      * @return Returns a String
257      */
258     public String 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 urlPKGPrefixes) {
268         this.urlPKGPrefixes = urlPKGPrefixes;
269     }
270 
271 
272     /**
273      * Gets the batchSize
274      *
275      * @return Returns a String
276      */
277     public synchronized String 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 batchSize) {
287         this.batchSize = batchSize;
288     }
289 
290 
291     /**
292      * Gets the authoritative
293      *
294      * @return Returns a String
295      */
296     public synchronized String 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 authoritative) {
306         this.authoritative = authoritative;
307     }
308 
309 
310     /**
311      * Gets the language
312      *
313      * @return Returns a String
314      */
315     public synchronized String 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 language) {
325         this.language = language;
326     }
327 
328 
329     /**
330      * Gets the securityPrincipal
331      *
332      * @return Returns a String
333      */
334     public synchronized String 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 securityPrincipal) {
344         this.securityPrincipal = securityPrincipal;
345     }
346 
347 
348     /**
349      * Gets the securityCredentials
350      *
351      * @return Returns a String
352      */
353     public synchronized String 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 securityCredentials) {
363         this.securityCredentials = securityCredentials;
364     }
365 
366 
367     /**
368      * Gets the securityAuthentication
369      *
370      * @return Returns a String
371      */
372     public synchronized String 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 securityAuthentication) {
382         this.securityAuthentication = securityAuthentication;
383     }
384 
385 
386     /**
387      * Gets the objectFactories
388      *
389      * @return Returns a String
390      */
391     public synchronized String 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 objectFactories) {
401         this.objectFactories = objectFactories;
402     }
403 
404 
405     /**
406      * Gets the stateFactories
407      *
408      * @return Returns a String
409      */
410     public synchronized String 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 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) newConfig.get("Authoritative");
437         batchSize = (String) newConfig.get("BatchSize");
438         dnsURL = (String) newConfig.get("DnsURL");
439         initialContextFactory = (String) newConfig.get("InitialContextFactory");
440         language = (String) newConfig.get("Language");
441         objectFactories = (String) newConfig.get("ObjectFactories");
442         providerURL = (String) newConfig.get("ProviderURL");
443         securityAuthentication = (String) newConfig.get("SecurityAuthentication");
444         securityCredentials = (String) newConfig.get("SecurityCredentials");
445         securityPrincipal = (String) newConfig.get("SecurityPrincipal");
446         securityProtocol = (String) newConfig.get("SecurityProtocol");
447         stateFactories = (String) newConfig.get("StateFactories");
448         urlPKGPrefixes = (String) 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 getMetadataName() {
505         return "JNDIConfig";
506     }
507 
508 }