Proposal for Resources Package

(0) Rationale

Many Java applications must support internationalization (i18n) of message strings presented as part of the user interface, or in messages written to log files. The standard Java APIs offer the java.util.ResourceBundle family of classes to support this requirement; however, these classes have the following limitations that reduce their usefulness:

  • The classes assume that all messages should be presented based on a single Locale, while many applications require support for different Locales for each current application user.
  • The ResourceBundle implementation classes do not implement the java.io.Serializable interface, which is required in some operational environments.

The classes in the proposed Resources package offer solutions to these two problems, and provide a framework for providing customized MessageResources implementations that can access resource strings from any desired static or dynamically updated collection.

(1) Scope of the Package

The proposal defines a miniature resources framework consisting of two abstract classes:

  • MessageResources - Base class for a collection of message strings, keyed by a combination of a java.util.Locale and a message key.
  • MessageResourcesFactory - Factory class to configure and instantiate an appropriate MessageResources instance.

An initial (and default) implementation accesses the required message strings from Properties files accessed via Class.getResource(). These files are named with a base name, plus extensions identifying the Locale of the contained message strings, in a manner identical to the java.util.PropertyResourceBundle class of the standard APIs.

(1.5) Interaction With Other Packages

Resource relies on the standard JDK 1.2 (or later) APIs, plus the Collections package from Apache Commons.

No external configuration files are utilized.

(2) Initial Source of the Package

The four original Java classes (MessageResources, MessageResourcesFactory, PropertyMessageResources, and PropertyMessageResourcesFactory) are an integral part of the Struts Framework. However, they have no dependencies on other aspects of Struts. Once accepted and released as a Apache Commons component, Struts will be modified to use the Commons version of these classes, and its internal versions will be deprecated.

The proposed package name for the new component is org.apache.commons.resources.

(3) Required Jakarta-Commons Resources

  • CVS Repository - New directory resources in the jakarta-commons CVS repository. All initial committers are already committers on jakarta-commons, so no additional user setups are required.
  • Mailing List - Discussions will take place on the general jakarta-commons@jakarta.apache.org mailing list. To help list subscribers identify messages of interest, it is suggested that the message subject of messages about this component be prefixed with [Resources].
  • Bugzilla - New component "Resources" under the "Commons" product category, with appropriate version identifiers as needed.
  • Jyve FAQ - New category "commons-resources" (when available).

(4) Initial Committers

The initial committers on the Resources component shall be Craig McClanahan, Michael Schachter, Jason van Zyl, and Daniel Rall.