KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sape > carbon > core > config > format > jdom > JDOMPropertyConfiguration


1 /*
2  * The contents of this file are subject to the Sapient Public License
3  * Version 1.0 (the "License"); you may not use this file except in compliance
4  * with the License. You may obtain a copy of the License at
5  * http://carbon.sf.net/License.html.
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is The Carbon Component Framework.
12  *
13  * The Initial Developer of the Original Code is Sapient Corporation
14  *
15  * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
16  */

17
18 package org.sape.carbon.core.config.format.jdom;
19
20 import java.util.Date JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.StringTokenizer JavaDoc;
26
27 import org.sape.carbon.core.config.InvalidConfigurationException;
28 import org.sape.carbon.core.config.PropertyConfiguration;
29 import org.sape.carbon.core.config.type.ConfigurationTypeException;
30 import org.sape.carbon.core.config.type.ConfigurationTypeService;
31 import org.sape.carbon.core.config.type.ConfigurationTypeServiceFactory;
32 import org.sape.carbon.core.exception.InvalidParameterException;
33
34 import org.jdom.Document;
35 import org.jdom.Element;
36
37 /**
38  * <p>This is an implementation of the string based attribute lookup
39  * PropertyConfiguration.
40  * </p>
41  *
42  * Copyright 2001 Sapient
43  * @since carbon 1.0
44  * @author Greg Hinkle, February 2002
45  * @version $Revision: 1.20 $($Author: dvoet $ / $Date: 2003/05/05 21:21:17 $)
46  */

47 public class JDOMPropertyConfiguration implements PropertyConfiguration {
48     /** Name delimiter: space */
49     private static final String JavaDoc NAME_DELIMITER = ".";
50
51     /** Comma delimiter: , */
52     private static final String JavaDoc COMMA_DELIMITER = ",";
53
54     /** Whitespace output delimiter. Space.*/
55     private static final String JavaDoc WHITE_SPACE_OUTPUT_DELIMITER = " ";
56
57     /** Deletermins for whitespace input. Includes space, tab and newlline. */
58     private static final String JavaDoc WHITE_SPACE_INPUT_DELIMITERS = " \t\n";
59
60     /** Name of the configuration. */
61     private String JavaDoc name;
62
63     /** The JDOM document that holds the root element. */
64     private Document document;
65
66     /** Holds the root element of the JDOM document.*/
67     private Element rootElement;
68
69     /** Holds a reference to the configuration this extends. */
70     private PropertyConfiguration extendedConfig = null;
71
72     /** Holds a reference to the type config service. */
73     private ConfigurationTypeService typeService =
74         ConfigurationTypeServiceFactory.getInstance();
75
76     /** cache of text values contained in document keyed by property name */
77     private Map JavaDoc propertyCache = new HashMap JavaDoc();
78
79     /**
80      * True if this object may be altered, false if it should throw exceptions
81      * when attempts are made to alter it.
82      */

83     private boolean writable = true;
84
85     /**
86      * Constructs a JDOMConfigurationProxy for the specified
87      * class type. This class only supports subclasses of the
88      * {@link org.sape.carbon.core.config.Configuration} object.
89      * The supplied document is used as the backing store for
90      * this configuration object's data.
91      * @param document The JDOM Document object representing a configurations
92      * data
93      */

94     public JDOMPropertyConfiguration(Document document) {
95         this.document = document;
96         this.rootElement = document.getRootElement();
97     }
98
99     /**
100      * Creates a new empty configruation that extends nothing.
101      */

102     public JDOMPropertyConfiguration() {
103         this.rootElement = new Element("Configuration");
104         this.rootElement.setAttribute(
105             "ConfigurationInterface", PropertyConfiguration.class.getName());
106
107         this.document = new Document(this.rootElement);
108     }
109
110     /**
111      * Constructs a new configruation that extends another configuration.
112      *
113      * @param document configuration document
114      * @param extendedConfig the configuration being extended.
115      */

116     public JDOMPropertyConfiguration(
117         Document document,
118         PropertyConfiguration extendedConfig) {
119
120         this.document = document;
121         this.rootElement = document.getRootElement();
122         this.extendedConfig = extendedConfig;
123     }
124
125     /**
126      * Constructs a new blank configruation that extends another configuration.
127      *
128      * @param extendedConfig the configuration being extended.
129      */

130     public JDOMPropertyConfiguration(PropertyConfiguration extendedConfig) {
131
132         this.rootElement = new Element("Configuration");
133         this.rootElement.setAttribute(
134             "ConfigurationInterface", PropertyConfiguration.class.getName());
135
136         this.document = new Document(this.rootElement);
137         this.extendedConfig = extendedConfig;
138     }
139
140     /**
141      * Returns the interface of the configuration.
142      *
143      * @return PropertyConfiguration.class
144      */

145     public Class JavaDoc getConfigurationInterface() {
146         return PropertyConfiguration.class;
147     }
148
149     /**
150      * Gets the document containing the root element.
151      *
152      * @return the document
153      */

154     public Document getDataStructure() {
155         return this.document;
156     }
157
158     /**
159      * Gets the root element of the configuration.
160      *
161      * @return root element of the configuration
162      */

163     public Element getRootElement() {
164         return this.rootElement;
165     }
166
167     /**
168      * @see PropertyConfiguration#getConfigurationName
169      */

170     public String JavaDoc getConfigurationName() {
171         return this.name;
172     }
173
174     /**
175      * @see PropertyConfiguration#setConfigurationName
176      */

177     public void setConfigurationName(String JavaDoc name) {
178         this.name = name;
179     }
180
181     /**
182      * @see PropertyConfiguration#clone
183      */

184     public Object JavaDoc clone() {
185         Document doc = (Document) this.document.clone();
186         JDOMPropertyConfiguration config = new JDOMPropertyConfiguration(
187             doc,
188             this.extendedConfig);
189
190         config.setConfigurationName(this.getConfigurationName());
191         return config;
192     }
193
194     /**
195      * @see PropertyConfiguration#getBooleanProperty
196      */

197     public boolean getBooleanProperty(String JavaDoc propertyName) {
198         Boolean JavaDoc value =
199             (Boolean JavaDoc) getProperty(propertyName, null, boolean.class);
200
201         if (value == null) {
202             throw new InvalidConfigurationException(
203                 this.getClass(),
204                 getConfigurationName(),
205                 propertyName,
206                 "Value did not exist and no default was specified");
207         }
208
209         return value.booleanValue();
210     }
211
212     /**
213      * @see PropertyConfiguration#getBooleanProperty
214      */

215     public boolean getBooleanProperty(
216         String JavaDoc propertyName,
217         boolean defaultValue) {
218
219         Boolean JavaDoc value =
220             (Boolean JavaDoc) getProperty(propertyName,
221                 new Boolean JavaDoc(defaultValue),
222                 boolean.class);
223         return value.booleanValue();
224     }
225
226     /**
227      * @see PropertyConfiguration#getByteProperty
228      */

229     public byte getByteProperty(String JavaDoc propertyName) {
230         Byte JavaDoc value = (Byte JavaDoc) getProperty(propertyName, null, byte.class);
231
232         if (value == null) {
233             throw new InvalidConfigurationException(
234                 this.getClass(),
235                 getConfigurationName(),
236                 propertyName,
237                 "Value did not exist and no default was specified");
238         }
239
240         return value.byteValue();
241     }
242
243     /**
244      * @see PropertyConfiguration#getByteProperty
245      */

246     public byte getByteProperty(String JavaDoc propertyName, byte defaultValue) {
247         Byte JavaDoc value =
248             (Byte JavaDoc) getProperty(propertyName,
249                 new Byte JavaDoc(defaultValue),
250                 byte.class);
251         return value.byteValue();
252     }
253
254     /**
255      * @see PropertyConfiguration#getCSVProperty
256      */

257     public String JavaDoc[] getCSVProperty(String JavaDoc propertyName) {
258         return delimitedStringToArray(
259             getProperty(propertyName),
260             COMMA_DELIMITER);
261     }
262
263     /**
264      * @see PropertyConfiguration#getShortProperty
265      */

266     public short getShortProperty(String JavaDoc propertyName) {
267         Short JavaDoc value = (Short JavaDoc) getProperty(propertyName, null, short.class);
268
269         if (value == null) {
270             throw new InvalidConfigurationException(
271                 this.getClass(),
272                 getConfigurationName(),
273                 propertyName,
274                 "Value did not exist and no default was specified");
275         }
276
277         return value.shortValue();
278     }
279
280     /**
281      * @see PropertyConfiguration#getShortProperty
282      */

283     public short getShortProperty(String JavaDoc propertyName, short defaultValue) {
284         Short JavaDoc value =
285             (Short JavaDoc) getProperty(propertyName,
286                 new Short JavaDoc(defaultValue),
287                 short.class);
288         return value.shortValue();
289     }
290
291     /**
292      * @see PropertyConfiguration#getDoubleProperty
293      */

294     public double getDoubleProperty(String JavaDoc propertyName) {
295         Double JavaDoc value = (Double JavaDoc) getProperty(propertyName, null, double.class);
296
297         if (value == null) {
298             throw new InvalidConfigurationException(
299                 this.getClass(),
300                 getConfigurationName(),
301                 propertyName,
302                 "Value did not exist and no default was specified");
303         }
304
305         return value.doubleValue();
306     }
307
308     /**
309      * @see PropertyConfiguration#getDoubleProperty
310      */

311     public double getDoubleProperty(String JavaDoc propertyName, double defaultValue) {
312         Double JavaDoc value =
313             (Double JavaDoc) getProperty(propertyName,
314                 new Double JavaDoc(defaultValue),
315                 double.class);
316         return value.doubleValue();
317     }
318
319     /**
320      * @see PropertyConfiguration#getFloatProperty
321      */

322     public float getFloatProperty(String JavaDoc propertyName) {
323         Float JavaDoc value = (Float JavaDoc) getProperty(propertyName, null, float.class);
324
325         if (value == null) {
326             throw new InvalidConfigurationException(
327                 this.getClass(),
328                 getConfigurationName(),
329                 propertyName,
330                 "Value did not exist and no default was specified");
331         }
332
333         return value.floatValue();
334     }
335
336     /**
337      * @see PropertyConfiguration#getFloatProperty
338      */

339     public float getFloatProperty(String JavaDoc propertyName, float defaultValue) {
340         Float JavaDoc value =
341             (Float JavaDoc) getProperty(propertyName,
342                 new Float JavaDoc(defaultValue),
343                 boolean.class);
344         return value.floatValue();
345     }
346
347     /**
348      * @see PropertyConfiguration#getIntProperty
349      */

350     public int getIntProperty(String JavaDoc propertyName) {
351         Integer JavaDoc value = (Integer JavaDoc) getProperty(propertyName, null, int.class);
352
353         if (value == null) {
354             throw new InvalidConfigurationException(
355                 this.getClass(),
356                 getConfigurationName(),
357                 propertyName,
358                 "Value did not exist and no default was specified");
359         }
360
361         return value.intValue();
362     }
363
364     /**
365      * @see PropertyConfiguration#getIntProperty
366      */

367     public int getIntProperty(String JavaDoc propertyName, int defaultValue) {
368         Integer JavaDoc value =
369             (Integer JavaDoc) getProperty(propertyName,
370                 new Integer JavaDoc(defaultValue),
371                 int.class);
372         return value.intValue();
373     }
374
375     /**
376      * @see PropertyConfiguration#getLongProperty
377      */

378     public long getLongProperty(String JavaDoc propertyName) {
379         Long JavaDoc value = (Long JavaDoc) getProperty(propertyName, null, long.class);
380
381         if (value == null) {
382             throw new InvalidConfigurationException(
383                 this.getClass(),
384                 getConfigurationName(),
385                 propertyName,
386                 "Value did not exist and no default was specified");
387         }
388
389         return value.longValue();
390     }
391
392     /**
393      * @see PropertyConfiguration#getLongProperty
394      */

395     public long getLongProperty(String JavaDoc propertyName, long defaultValue) {
396         Long JavaDoc value =
397             (Long JavaDoc) getProperty(propertyName,
398                 new Long JavaDoc(defaultValue),
399                 long.class);
400         return value.longValue();
401     }
402
403     /**
404      * @see PropertyConfiguration#getProperty
405      */

406     public String JavaDoc getProperty(String JavaDoc propertyName) {
407         String JavaDoc value = (String JavaDoc) getProperty(propertyName, null, String JavaDoc.class);
408
409         if (value == null) {
410             throw new InvalidConfigurationException(
411                 this.getClass(),
412                 getConfigurationName(),
413                 propertyName,
414                 "Value did not exist and no default was specified");
415         }
416
417         return value;
418     }
419
420     /**
421      * @see PropertyConfiguration#getProperty
422      */

423     public String JavaDoc getProperty(String JavaDoc propertyName, String JavaDoc defaultValue) {
424         String JavaDoc value =
425             (String JavaDoc) getProperty(propertyName, defaultValue, String JavaDoc.class);
426         return value;
427     }
428
429     /**
430      * @see PropertyConfiguration#getWSVProperty
431      */

432     public String JavaDoc[] getWSVProperty(String JavaDoc propertyName) {
433         return delimitedStringToArray(
434             getProperty(propertyName),
435             WHITE_SPACE_INPUT_DELIMITERS);
436     }
437
438     /**
439      * @see PropertyConfiguration#getClassProperty
440      */

441     public Class JavaDoc getClassProperty(String JavaDoc propertyName) {
442         Class JavaDoc value = (Class JavaDoc) getProperty(propertyName, null, Class JavaDoc.class);
443
444         if (value == null) {
445             throw new InvalidConfigurationException(
446                 this.getClass(),
447                 getConfigurationName(),
448                 propertyName,
449                 "Value did not exist and no default was specified");
450         }
451
452         return value;
453     }
454
455     /**
456      * @see PropertyConfiguration#getClassProperty
457      */

458     public Class JavaDoc getClassProperty(String JavaDoc propertyName, Class JavaDoc defaultValue) {
459         Class JavaDoc value =
460             (Class JavaDoc) getProperty(propertyName, defaultValue, boolean.class);
461         return value;
462     }
463
464     /**
465      * @see PropertyConfiguration#getDateProperty
466      */

467     public Date JavaDoc getDateProperty(String JavaDoc propertyName, Date JavaDoc defaultValue) {
468         Date JavaDoc value = (Date JavaDoc) getProperty(propertyName, defaultValue, Date JavaDoc.class);
469         return value;
470     }
471
472     /**
473      * @see PropertyConfiguration#getDateProperty
474      */

475     public Date JavaDoc getDateProperty(String JavaDoc propertyName) {
476         Date JavaDoc value = (Date JavaDoc) getProperty(propertyName, null, Date JavaDoc.class);
477
478         if (value == null) {
479             throw new InvalidConfigurationException(
480                 this.getClass(),
481                 getConfigurationName(),
482                 propertyName,
483                 "Value did not exist and no default was specified");
484         }
485
486         return value;
487     }
488
489     /**
490      * @see PropertyConfiguration#setBooleanProperty
491      */

492     public void setBooleanProperty(String JavaDoc propertyName, boolean value) {
493         setProperty(
494             propertyName,
495             this.typeService.toString(boolean.class, new Boolean JavaDoc(value)));
496     }
497
498     /**
499      * @see PropertyConfiguration#setByteProperty
500      */

501     public void setByteProperty(String JavaDoc propertyName, byte value) {
502         setProperty(
503             propertyName,
504             this.typeService.toString(byte.class, new Byte JavaDoc(value)));
505     }
506
507     /**
508      * @see PropertyConfiguration#setClassProperty
509      */

510     public void setClassProperty(String JavaDoc propertyName, Class JavaDoc value) {
511         setProperty(
512             propertyName,
513             this.typeService.toString(Class JavaDoc.class, value));
514     }
515
516     /**
517      * @see PropertyConfiguration#setCSVProperty
518      */

519     public void setCSVProperty(String JavaDoc propertyName, String JavaDoc[] values) {
520         setProperty(
521             propertyName,
522             arrayToDelimitedString(values, COMMA_DELIMITER));
523     }
524
525     /**
526      * @see PropertyConfiguration#setDateProperty
527      */

528     public void setDateProperty(String JavaDoc propertyName, Date JavaDoc value) {
529         setProperty(
530             propertyName,
531             this.typeService.toString(Date JavaDoc.class, value));
532     }
533
534     /**
535      * @see PropertyConfiguration#setDoubleProperty
536      */

537     public void setDoubleProperty(String JavaDoc propertyName, double value) {
538         setProperty(
539             propertyName,
540             this.typeService.toString(double.class, new Double JavaDoc(value)));
541     }
542
543     /**
544      * @see PropertyConfiguration#setFloatProperty
545      */

546     public void setFloatProperty(String JavaDoc propertyName, float value) {
547         setProperty(
548             propertyName,
549             this.typeService.toString(float.class, new Float JavaDoc(value)));
550     }
551
552     /**
553      * @see PropertyConfiguration#setIntProperty
554      */

555     public void setIntProperty(String JavaDoc propertyName, int value) {
556         setProperty(
557             propertyName,
558             this.typeService.toString(int.class, new Integer JavaDoc(value)));
559     }
560
561     /**
562      * @see PropertyConfiguration#setLongProperty
563      */

564     public void setLongProperty(String JavaDoc propertyName, long value) {
565         setProperty(
566             propertyName,
567             this.typeService.toString(long.class, new Long JavaDoc(value)));
568     }
569
570
571     /**
572      * @see PropertyConfiguration#setProperty
573      */

574      public void setProperty(String JavaDoc propertyName, String JavaDoc value) {
575         // Only allow if document is writable
576
if (!this.isConfigurationWritable()) {
577             throw new java.lang.UnsupportedOperationException JavaDoc(
578                 this.getClass().getName()
579                 + "Configuration Document is read-only, write not supported.");
580         }
581
582         if (propertyName == null || propertyName.equals("")) {
583             throw new InvalidParameterException(
584                 this.getClass(),
585                 "propertyName cannot be null or empty");
586         }
587
588         // clear the cached value
589
this.propertyCache.remove(propertyName);
590
591         StringTokenizer JavaDoc names = new StringTokenizer JavaDoc(
592             propertyName,
593             NAME_DELIMITER);
594         Element currentElement = this.rootElement;
595
596         while (names.hasMoreTokens()) {
597             String JavaDoc childName = names.nextToken();
598             Element childElement = currentElement.getChild(childName);
599
600             if (childElement == null) {
601                 // the child does not exists so create it
602
childElement = new Element(childName);
603                 currentElement.addContent(childElement);
604             }
605
606             currentElement = childElement;
607         }
608
609         currentElement.setText(value);
610     }
611
612     /**
613      * @see PropertyConfiguration#setShortProperty
614      */

615     public void setShortProperty(String JavaDoc propertyName, short value) {
616         setProperty(
617             propertyName,
618             this.typeService.toString(short.class, new Short JavaDoc(value)));
619     }
620
621     /**
622      * @see PropertyConfiguration#setWSVProperty
623      */

624     public void setWSVProperty(String JavaDoc propertyName, String JavaDoc[] values) {
625         setProperty(
626             propertyName,
627             arrayToDelimitedString(values, WHITE_SPACE_OUTPUT_DELIMITER));
628     }
629
630     /**
631      * Centralized method for property lookup. This method will first lookup
632      * the text for the property in the propertyCache. If the text is not there
633      * it is retrieved from the document and cached. The text value is then
634      * converted to the appropriate type by the typeService. If the propertyText
635      * did not exist in the document, the defaultValue is returned.
636      *
637      * @param propertyName the name of the property to retreive a value for
638      * @param defaultValue the default value that will be returned if no value
639      * can be found
640      * @param type type of object to format the property text into and return
641      * @return Object
642      */

643     private Object JavaDoc getProperty(
644         String JavaDoc propertyName,
645         Object JavaDoc defaultValue,
646         Class JavaDoc type) {
647
648         // get propertyText from the cache
649
String JavaDoc propertyText = (String JavaDoc) this.propertyCache.get(propertyName);
650
651         if (propertyText == null) {
652             // propertyText was not cached, get it from the document
653
StringTokenizer JavaDoc nameChain =
654                 new StringTokenizer JavaDoc(propertyName, NAME_DELIMITER);
655
656             Element element = this.rootElement;
657             while (nameChain.hasMoreTokens() && element != null) {
658
659                 element = element.getChild(nameChain.nextToken());
660
661             }
662             if (element != null) {
663                 // propertyText exists in the document
664
propertyText = element.getText();
665                 this.propertyCache.put(propertyName, propertyText);
666             } else if (this.extendedConfig != null) {
667                 // we are extending another PropertyConfiguration,
668
// get the propertyText from there
669

670                 // don't cache the following result, it is cached elsewhere and
671
// adding it could corrupt this cache in multi-threaded access
672
propertyText =
673                     this.extendedConfig.getProperty(propertyName, null);
674             }
675
676         }
677
678         Object JavaDoc property;
679         if (propertyText != null) {
680             // we have a propertyText, format it
681
try {
682                 property = this.typeService.toObject(type, propertyText);
683             } catch (ConfigurationTypeException cte) {
684                 throw new InvalidConfigurationException(
685                     this.getClass(),
686                     getConfigurationName(),
687                     propertyName,
688                     "Value could not be formatted to class ["
689                         + type.getName()
690                         + "]: value ["
691                         + propertyText
692                         + "]",
693                     cte);
694             }
695         } else {
696             // no propertyText, return the default
697
property = defaultValue;
698         }
699
700         return property;
701     }
702
703     /**
704      * Converts a String with values delimted by delimiters to an array of
705      * Strings. If there nare no values in delimitedValues, a 0 length array
706      * is returned.
707      *
708      * @param delimitedValues string to convert to string array
709      * @param delimiters delimiters to use in string conversion
710      * @return String[] the resulted array
711      */

712     private String JavaDoc[] delimitedStringToArray(
713         String JavaDoc delimitedValues,
714         String JavaDoc delimiters) {
715
716         StringTokenizer JavaDoc values = new StringTokenizer JavaDoc(
717             delimitedValues,
718             delimiters);
719         String JavaDoc[] valueArray = new String JavaDoc[values.countTokens()];
720         for (int i = 0; values.hasMoreTokens(); i++) {
721             valueArray[i] = values.nextToken();
722         }
723         return valueArray;
724     }
725
726     /**
727      * Serializes an array of Strings into a single String with values delimited
728      * by delimiter
729      *
730      * @param values the array of values to delimit
731      * @param delimiter the delimiter to place between the values
732      * @return String the result string of the delimited values
733      */

734     private String JavaDoc arrayToDelimitedString(String JavaDoc[] values, String JavaDoc delimiter) {
735         if (values.length > 0) {
736             StringBuffer JavaDoc delimitedString = new StringBuffer JavaDoc(values[0]);
737             for (int i = 1; i < values.length; i++) {
738                 delimitedString.append(delimiter);
739                 delimitedString.append(values[i]);
740             }
741             return delimitedString.toString();
742         } else {
743             return null;
744         }
745     }
746
747         /**
748      * Is this configuration document writable or is it read-only. Shared cache
749      * instances of configuration objects should either be synchronized or
750      * marked not writable. When a configuration object is not writable, it
751      * should throw an exception if an attempt is made to modify it.
752      *
753      * @return true if this cofiguration object may be altered.
754      * @since carbon 1.1
755      */

756     public boolean isConfigurationWritable() {
757         return this.writable;
758     }
759
760     /**
761      * Sets whether this configuration may be altered.
762      * @since carbon 1.1
763      */

764     public void setConfigurationReadOnly() {
765         this.writable = false;
766         preloadProperyCache(this.rootElement, null);
767
768 // // this object should be prepared for multithreaded reads,
769
// // the attributeCache needs to by synced to ensure that concurrent
770
// // reads to not corrupt the Map
771
// this.propertyCache =
772
// Collections.synchronizedMap(this.propertyCache);
773
}
774
775     /**
776      * Loads up the property cache with all the values.
777      *
778      * @param parentElement the parent element.
779      * @param parentElementName the name of the parent element.
780      */

781     private void preloadProperyCache(
782             Element parentElement, String JavaDoc parentElementName) {
783
784         String JavaDoc namePrefix;
785         if (parentElementName == null) {
786             namePrefix = "";
787         } else {
788             // cache the value
789

790             // doesn't matter what the type is, it will be cached as a
791
// String no matter what
792
Object JavaDoc value =
793                 getProperty(parentElementName, null, String JavaDoc.class);
794
795 // test logging commented out because it was too verbose (bug 434)
796
// TODO: add white box testing to test caching functionality
797
// if (Logger.getLogger().isLogging(source, SeverityEnum.TRACE)) {
798
//
799
// Logger.getLogger().log(
800
// source,
801
// SeverityEnum.TRACE,
802
// "Preloaded attribute ["
803
// + parentElement.getName()
804
// + "] with value ["
805
// + value
806
// + "] of configuration ["
807
// + getConfigurationName()
808
// + "]");
809
// }
810

811             namePrefix =
812                 parentElementName + JDOMPropertyConfiguration.NAME_DELIMITER;
813         }
814
815         // recursively load children
816
List JavaDoc children = parentElement.getChildren();
817         Iterator JavaDoc childIterator = children.iterator();
818
819         while (childIterator.hasNext()) {
820             Element element = (Element) childIterator.next();
821             preloadProperyCache(element, namePrefix + element.getName());
822         }
823     }
824 }
Popular Tags