Hi,
Here are some modifications made to be able to dynamically specify mapping and formatter configuration files. The diff file is attached.
Modifications are the following :
* CSVParserFactory.java :
-> added a getSingleton() method that accepts mappping and formatter Readers as parameters.
-> added a loadMappings() method that accepts a mapping Reader as a parameter.
-> factorized code that was in the original loadMapping() method in a parseBeanMapping() method (to use it from the new loadMappings() method)
* CSVFormatterFactory.java :
-> added a getSingleton() method that accepts a formatter Reader as a parameter.
-> added a loadMappings() method that accepts a formatter Reader as a parameter.
-> moved the createCache() calls (that were originally into loadMappings() method) into getSingleton() methods in order to be able to call the original loadMappings() method from the new one (for factorization purpose)
* CSVFormatterConfigParser.java :
-> added a getAdditionalFormatMappings() method to be able to load the additional formatter configuration provided dynamically to CSVFormatterFactory
-> made Digester object a class member to be able to use it from different methods of the class
* CSVMappingParser.java :
-> added a getMappings() method that accepts a mapping Reader as a parameter
-> when embedded in a webapp deployed within a servlet container (and its classloader hierarchy hell), it was unable to find the net/sf/anupam/csv/mapping/csv-mapping-digester-rules.xml file in the class's classloader. therefore, I added a recursive classloader discovery until the good one is found.
Regards,
Benoit.
diff file for dyn selection of mapping and formatters conf files