The Apache Jakarta Project Jakarta HiveMind Project
 
   

HiveMind Localization

Every HiveMind module may have its own set of messages. Messages are stored alongside the module deployment descriptor, as META-INF/hivemodule.properties (within the module's JAR).

Note
In actuality, the name of the properties file is created by stripping off the extension (".sdl" or ".xml") from the descriptor name and appending the localization code and ".properties". This is relevant only if you load your module deployment descriptors from a non-standard location, possibly via the <sub-module> element.

Services can gain access to localized messages, as an instance of Messages , which includes methods for accessing messages and formatting messages with arguments.

In a module descriptor, within the <contribution> and <invoke-factory> elements, you can reference a localized message in an attribute or element content simply by prefixing the message key with '%'. Examples:

  
contribution (configuration-id=...)
{
  some-item (message="%message.key") 
  { 
    "%other.message.key" 
  }
} 

The two keys (message.key and other.message.key ) are searched for in the contributing module's messages.

HiveMind gracefully recovers from undefined messages. If a message is not in the properties file, then HiveMind provides a substitute value by converting the key to upper-case and adding brackets, i.e. [MESSAGE.KEY]. This allows your application to continue running, but clearly identifies missing messages.

By adding additional files, message localization can be accomplished. For example, adding a second file, META-INF/hivemodule_fr.properties would provide French language localizations. Any common keys between the two files defer to the more specific file.

Setting the locale

When a Registry is created by the RegistryBuilder, a locale is specified. This is the locale for the Registry and, by extension, for all Modules in the registry. The locale may not be changed.