Brains2b.ORG

ResX 1.06

stable

component

ResX is a ResourceBundle implementation which makes use of a database connection.

Full description

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.

Files
namedatezipzip (source)tar.gztar.gz (source)
ResX 1.0622-11-2006ResX-1.06.zipResX-src-1.06.zipResX-1.06.tar.gzResX-src-1.06.tar.gz
ResX 0.1519-04-2004ResX-0.15.zipResX-0.15.tar.gz

Note: If you want to make a quick start download the .zip or .tar.gz file. It includes the compiled jar and possible dependencies. The sources contains the sources for this specific project and the compiled libraries listed as dependencies.

Dependencies

Using ResX

How to use

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")

As you can see getExtBundle() methods return a normal ResourceBundle which can be used as any other resource bundle

Reference implementation/examples

releases

ResX 1.06

  • Changes to Manifest to include version
  • Desynchronized the storage, using HashMap instead of Hashtable

ResX 0.15

  • Bug fixed in getKeys() which returned double keys from parent