jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: ResourceBundles and JSP tags
Date Mon, 22 Jan 2001 17:54:49 GMT
Scott Stirling wrote:

> I started the process of putting all Gnat Taglib exception and message
> strings in ListResourceBundles this weekend.  I have some ideas and
> questions pertaining to their use in taglibs.
> 1. ListResourceBundles are unsynchronized.  Seems like there's a good chance
> of contention for objects in them, especially if there are several of the
> same tags on a page with several pages executing simultaneously.  Should the
> general rule be that we synchronize access to ListResourceBundles?  Will
> that make deadlock more or less likely?  Anyone have much experience with
> ResourceBundles in a very multi-threaded environment?

If the ListResourceBundle instance is not modified after it is created, why
would access need to be synchronized?  In the same way that you can do read-only
accesses to a HashMap without synchronizing, operations that are non-destructive
should not cause problems here.

> 2. The general issue of l10n in JSP tag libs: what do you think?  I think
> it's a good thing to do, by at least using ResourceBundles for exception and
> message strings.  The taglib users can take care of localizing the Strings
> to different languages, but it would be nice if we already wrote the tags
> with that in mind.

Struts <http://jakarta.apache.org/struts> includes extensive support for this in
its tag library ... you're welcome to use 'em :-).

I also wanted to warn you about a gotcha we ran into with Struts -- the
ResourceBundle family of classes in the JDK does *not* implement Serializable.
This issue came up because we store the message bundles as servlet context
attributes (to make them easily accessible to custom tag libraries), and some
application servers impose the requirement that servlet context attributes must
be Serializable.

Our workaround was to implement a variation on ResourceBundle that also allows
you to look up messages by message key *and* Locale -- it manages the separate
property resource files (or whatever) underneath transparently.

> 3. Related issue: should we draw up a document of coding and tag design
> guidelines?  Joe Ottinger began this discussion a few weeks ago, but we
> never solidified anything.  The Avalon project has a pretty sane set of
> guidelines we could adopt as a basis.  And we could add tag library specific
> ones to it.  I'd post the URL to it, but the java.apache.org and jakarta
> sites are temporarily down, it seems.

Sounds like an interesting approach.

> Scott Stirling
> Allaire Corporation
> http://www.allaire.com/developer/jrunreferencedesk/


View raw message