Friday, July 25, 2008

Overwriting Struts Resouce Bundle Handling

Care needs to be taken when we overwrite the struts resource bundle handling,especially while overwriting the get text method in struts

This is because , if the customised gettext copies this statment

ResourceBundle bundle = LocalizedTextUtil.findResourceBundle(bundleName, resourceLocale);

where bundlename is the bundle in which property is expected

and if the property does not exist in that bundle, Struts internally looks for the entire set of bundles and searches the key. This is not what is expected
and it consumes a lot of time for each literal check and chokes the server.

A quick fix to this would be to search for the expected bundle and then check if the key which is expected is present.This can be done by using bundle.containskey() and later if it exists then by using the above statement. This reduces a lot of time wasted checking for the entire set of bundle for each property.

No comments:

 
Free Domain Names @ .co.nr!