In the current implemenation of ResourceBundle, it requires the developer to explicitly define a hard-coded data path to the resource files. If ResourceBundle is able to help locate the resource files, if the developer does not state one explicitly, then this would add flexibility to the API.
For example,
/tmp
|
-- test
|
-- hello
|
--- MyData_ja.properties
Let's say that "/tmp" is in the classpath.
For the current implementation, it would require the following:
ResourceBundle rb = ResourceBundle.getBundle(test.hello.MyData, Locale.JAPAN);
Proposed RFE would have the API like this:
ResourceBundle rb = ResourceBundle.getBundle(MyData, Locale.JAPAN);
In other words, if the developer does not explicitly state an absolute location, ResourceBundle will:
1) Using the original search strategy, look for it in the current directory (in the case of this example).
2) Since it can't find it, it will now traverse subtrees in attempt to locate it using the classpath values as the base directory nodes.
I do see 2 problems with such an algorithm:
1) Performance - searching big subtrees can take a long time.
2) The assumption is that no 2 files under the search path(s) have the same name. If it is, then the first one encountered will be the one used which makes the algorithm a bit unpredictable for the developer.
However, there is a possible design to get around this problem which is to allow the developer to specify a base directory from which to start the recursive traversal. Again, using the above example, the developer is allowed to do something like this:
ResourceBundle rb = ResourceBundle.getBundle(test.MyData, Locale.JAPAN);
###@###.### 2002-11-21