RFR: 8013839: Enhance Logger API for handling of resource bundles
daniel.fuchs at oracle.com
Fri Sep 20 12:33:27 UTC 2013
Please find below a patch for:
8013839: Enhance Logger API for handling of resource bundles, and
4814565: (rb) add method to get basename from a ResourceBundle
1. It adds a ResourceBundle.getBaseBundleName() method,
2. It adds a Logger.setResourceBundle(ResourceBundle) method,
3. It adds a series of Logger.logrb(...) that take a ResourceBundle
object instead of a ResourceBundle name.
The previous versions of Logger.logrb(...) that took a
resource bundle name are therefore no longer needed,
they offer no added value above the new methods, and
are thus now deprecated.
Logger.getLogger(name, rbname) will continue to work as before,
and will also throw an exception if a RB with a different name
has been set before, either through setResourceBundle or
Logger.setResourceBundle works similarly to
Logger.getLogger(name, rbname) in the sense that it will not
allow to replace an existing bundle, unless both have the same
name. Like for Logger.getLogger(name, rbname) - it doesn't matter
by which method the previous bundle has been set.
This is mostly for consistency of the API - if thread A has
requested a logger with resource bundle name 'foo.Bundle'
and thread B attempts to set the resource bundle of that
logger to 'bar.Bundle' then thread B will get an IAE.
The resource bundle passed to Logger.setResourceBundle *must*
have a base name. Note that ResourceBundle objects will have
a base name by default if they have been loaded through
one of the ResourceBundle.getBundle(...) methods;
If ResourceBundle.getBaseBundleName() returns null an IAE
will be thrown.
Logger.setResourceBundle requires the "control" permission.
When a resource bundle is set with Logger.setResourceBundle,
then it's that resource bundle locale that will be used
when logging (and not the default locale).
I have written a set of unit tests which should cover all the points
More information about the core-libs-dev