geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "gianny DAMOUR" <>
Subject Re: [i18n] Hardcoded message strings
Date Mon, 25 Aug 2003 15:50:28 GMT
>I also followed up a post on this to suggest that instead of package names, 
>what about organising them by module name instead. Would this be better?
Perhaps that to structure the messages via module is better.

>Can you explain what you mean a bit more by these points, and provide 
>examples of what you're thinking? It's obviously late in the day (and I'm 
>not allowed coffee at the moment) so I can't understand what you mean ...

Quick overview of what I try to suggest:

1. A set of resource bundles defining the messages of specific services, 
e.g.;; et cetera.

2. A set of type-safe enumerations, one for each resource bundle, which maps 
the keys of its related resource bundle to an element of the type-safe 

e.g. defines the following messages:
00001=Authentication failed ${0} ${1}.
00002=Authentication failed#2.

One defines the following class:
public final class JavaMailMessage {
  private JavaMailMessage(int anErrorCode) {}
  public JavaMailMessage FAILED = new JavaMailMessage(00001);
  public JavaMailMessage FAILED_2 = new JavaMailMessage(00002);

3. A i18n exception specific to JavaMail.
public I18NJavaMaiExceptionl extends I18NException {
  public I18NJavaMailException(JavaMailMessage anException, Object[] 
aListOfParameters) {};

4. An exception formatter specific to JavaMail.
public I18NJavaMailExceptionFormatter extends I18NExceptionFormatter {
  private I18NJavaMailExceptionFormatter SINGLETON = new 
  public I18NJavaMailExceptionFormatter getInstance() {};
  public String format(I18NJavaMaiException) {};

5. In the code, one uses this:
throw new I18NJavaMailException(JavaMailMessage.FAILED, new Object[] 
{"value1", "value2"});

6. A last resort handling mechanism:
public String handle(I18NException anException) {
  return I18NException.format(anException);


MSN Messenger 6  : dialoguez en son et en image 
avec vos amis.

View raw message