A SERVICE OF

logo

16 Chapter 4. WAF Component: Services
as reported by the user’s browser, and compares them to the list of languages and locales that
the system is configured to support.
For example, a user can configure the preferred first language to be German ("de") and the pre-
ferred second language to be British English ("en_GB"). If the system is configured to support
both of the languages, then the globalization service will choose "de" as the preferred locale.
If the system has been configured to support British English, but not German, then the glob-
alization service will choose "en_GB" as the preferred locale. If the system does not support
either of the configured languages, then the service falls back to a default locale which could be
"en_US" (US English).
Once the desired locale is configured, a supported character set must be selected. For example,
pages in German can be displayed using the ISO-8859-1
1
, UTF-8, or UTF-16 character sets.
The user may express a preference by configuring their browser. The user’s preference must
then be reconciled with the list of character sets that the system has been configured to support.
This example of locale and character set negotiation is simplified for this discussion, but it illustrates
the fact that correct negotiation is non-trivial. The globalization service relieves the developer of the
burden of negotiating the preferred locale and character set correctly.
TheWAFglobalization service provides aset ofhigh-level APIsbased onthe standard Java globaliza-
tion facilities that handle issues such as language negotiation and localization of static strings. These
APIs complement the basic globalization infrastructure provided by Java (i.e., ResourceBundles
and property files are still used in WAF) and are specifically designed for use by web applications
built with WAF.
4.5. Mail Service
The mail service acts as a Mail Transport Agent (MTA) for other WAF applications. It provides a
simple mechanism to send plain or rich text messages to any entity with a valid email address. This
service is nottypically accessed directly, but ratheris used asa building block forhigher-level services
such as notification. This service has no dependencies on WAF and exists primarily as a wrapper for
the more cumbersome JavaMail API.
When should you use the mail service directly? If you are writing an application that sends simple
plain-text alerts to users, and you do not require those alerts to be recorded in the database, then it
makes sense to use the mail service. Also, if you are dealing with raw email addresses rather than
WAF parties (users and groups), you probably want to use the mail service directly. Otherwise, you
should consider using the higher-level notification service (see Section 4.7 Notification Service).
4.6. Messaging Service
The WAF messaging service is intended to be used as a building block for messaging applications,
which are WAF applications that use messages to represent various types of communication between
users.
Messages can represent an email from one user to another, or a bulletin-board post, or a comment on
another object in the system. A message can store attachments such as images or other files which are
relevant to the message. Each attachment can be of any arbitrary MIME type.
The implementation follows the RFC822
2
standard, which has been deprecated by RFC2822
3
.
The Message class models a persistent text message with optional attachments:
1. http://www.htmlhelp.com/reference/charset/
2. http://www.rfc-editor.org/rfc/rfc822.txt
3. http://www.rfc-editor.org/rfc/rfc2822.txt