Brains2b.ORG

ResX 0.15

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
namedatejar-binaryzip (complete)tar.gz (complete)
ResX 0.1519-04-2004ResX-0.15.jarResX-0.15.zipResX-0.15.tar.gz

Note: If you want to make a quick start download the .zip or .tar.gz file. Next to the sources it also includes a compiled jar and possible dependencies. The jar-binary file listed above does not contain possible dependencies for this component or application and you are required to download them yourself.

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 there 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 0.15

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