ResX 1.07
ResX is a ResourceBundle implementation which makes use of a database connection
This is by far the smallest component I made and does one simple thing: It overwrites java.util.ResourceBundle to get the internationalistation information from a datasource instead of a properties file or class. Having written java applications that extensively used a database, I did not find it very helpfull getting my resources from another source. It supprised me that there is hardly any performance loss noticable getting resources from the database
The implementation stays pretty close to the ResourceBundle implementation and will check first for
other types like java.util.ListResourceBundle and java.util.PropertyResourceBundle
before checking for the database. Unfortunatly the getBundle() methods in ResourceBundle are final and cannot be reimplemented.
Therefor new methods where implemented getExtBundle(String) and getExtBundle(String,Locale) to get the information from the database.
usage
The use of ResX is simple: create the LOCALIZED_RESOURCE table from the scripts directory (there is a script for oracle and an ANSI-script).
In your code add the appropriate JDBC connection information:
System.setProperty("sql.driver","oracle.jdbc.driver.OracleDriver"); System.setProperty("sql.url", "jdbc:oracle:thin:@server:1521:database"); System.setProperty("sql.user","SCOTT"); System.setProperty("sql.password","TIGER");
You can also use a properties-file called connection.properties in the directory you start your application from
which contains the properties as described above
You can now load the resource bundle by simply calling:
ResourceBundle rb = ExtResourceBundle.getExtBundle("bundleName")
The getExtBundle() methods return a normal ResourceBundle which can be used as any other resource bundle
language
java jdk 8+
references
- Examples for reimplementing ExtResourceBundle
- Track
- Babel
dependencies
- None
files
| Name | Version | Date | binary | tar | source |
|---|---|---|---|---|---|
| ResX | 1.07 | Feb 27, 2017 | ResX-1.07.zip | ResX-1.07.tar.gz | ResX-src-1.07.zip |
| ResX | 1.06 | Dec 2, 2018 | ResX-1.06.zip | ResX-1.06.tar.gz | ResX-src-1.06.zip |
| ResX | 0.15 | Dec 2, 2018 | ResX-0.15.zip | ResX-0.15.tar.gz | ResX-src-0.15.zip |
changelog
1.07
- Check if database connection is valid
1.06
- Changes to Manifest to include version
- Desynchronized the storage, using HashMap instead of Hashtable
0.15
- Bug fixed in getKeys() which returned double keys from parent