Craig and Jason,
A while back I wrote a pretty basic interface that represented
a generalized localized resource class. This is very similar
to the MessageResources class in Struts, it just adds two
lifecycle methods and getData() methods that return an
InputStream or a String, depending on what the developer
wants to use. It also optionally adds a timezone argument
in case the implementation wants to use it.
The Resource.java file is attached to this email.
My idea of this whole thing is that per-app you have a
ResourceManager, started up when the app is started, that
manages the different resource implementations by name/class/whatever
from a configuration file and is resposible for the resources
lifecycle. When you want to retrieve data, you would ask the
ResourceManager for a Resource implementation (by a logical name
specified in a config file), and then call on methods against
the Resource interface to retrieve data. I haven't written
a ResourceManager as of yet, but it would be relatively trivial.
The method I'm talking about would look something like this:
class ResourceManager {
public Resource getResourceByName(String name);
}
And usage would go something like this:
{
ResourceManager manager = ...;
Locale userLocale = ...;
{
String data;
Resource dbResource = manager.getResourceByName("DBRESOURCE");
data = dbResource.getData("some.key", userLocale, null);
}
}
I also wrote an implementation of the Resource interface to retrieve
locale specific files as content, but it's *very* untested
and there's no real reason to attach it right now.
As for the desired scope of this, I'd like to see this project
to include Resource implementations for at least databases, filesystems,
and java's native ResourceBundles, and whatever else anyone can come up
with.
You can count me in for making whatever is necessary for this
thing to take off, and I'm totally open to any ideas if
you guys go for this.
-Mike
[I18N] Resources (was RE: Struts Message Resources)
SCHACHTER,MICHAEL (HP-NewJersey,ex2) Fri, 25 May 2001 14:29:22 -0700
Resource.java