Internationalization context API: Programming reference
Application components programmatically manage internationalization context
through the UserInternationalization, Internationalization, and InvocationInternationalization
interfaces in the com.ibm.websphere.i18n.context package. The following code
example introduces the internationalization context API:
public interface UserInternationalization {
public Internationalization getCallerInternationalization();
public InvocationInternationalization
getInvocationInternationalization();
}
public interface Internationalization {
public java.util.Locale[] getLocales();
public java.util.Locale getLocale();
public java.util.TimeZone getTimeZone();
}
public interface InvocationInternationalization
extends Internationalization {
public void setLocales(java.util.Locale[] locales);
public void setLocale(java.util.Locale jmLocale);
public void setTimeZone(java.util.TimeZonetimeZone);
public void setTimeZone(String timeZoneId);
}
UserInternationalization interface
The UserInternationalization
interface provides factory methods for obtaining references to the CallerInternationalization
and InvocationInternationalization context objects. Use these references to
access elements of the caller and invocation contexts correlated to the current
thread.
Methods of the UserInternationalization interface:
- Internationalization getCallerInternationalization()
- Returns a reference implementing the Internationalization interface that
allows access to elements of the caller internationalization context correlated
to the current thread. If the service is disabled, this method throws an IllegalStateException.
- InvocationInternationalization getInvocationInternationalization()
- Returns a reference implementing the InvocationInternationalization interface.
If the service is disabled, this method throws an IllegalStateException.
Internationalization interface
The Internationalization
interface declares methods affording read-only access to internationalization
context. Given a caller or invocation internationalization context object
created with the UserInternationalization interface, bind the object to the
Internationalization interface in order to get elements of that context type.
Observe that caller internationalization context can be accessed only through
this interface.
Methods of the Internationalization interface:
- Locale[] getLocales()
- Returns the chain of locales within the internationalization context (object)
bound to the interface, provided the chain is not null; otherwise this method
returns a chain of length(1) containing the default locale of the JVM.
- Locale getLocale()
- Returns the first in the chain of locales within the internationalization
context (object) bound to the interface, provided the chain is not null; otherwise
this method returns the default locale of the JVM.
- TimeZone getTimeZone()
- Returns the caller time zone (that is, the SimpleTimeZone) associated
with the current thread, provided the time zone is non-null; otherwise this
method returns the process time zone.
InvocationInternationalization interface
The InvocationInternationalization
interface declares methods affording read and write access to InvocationInternationalization
context. Given an invocation internationalization context object created with
the UserInternationalization interface, bind the object to the InvocationInternationalization
interface in order to get and set elements of the invocation context.
Note: According to the container-managed internationalization (CMI)
policy, all set methods, setXxx(), throw an IllegalStateException when called
within a CMI servlet or enterprise bean.
Methods of the InvocationInternationalization
interface:
- void setLocales(java.util.Locale[] locales)
- Sets the chain of locales to the supplied chain, locales, within
the invocation internationalization context. The supplied chain can be null
or have length(>= 0). When the supplied chain is null or has length(0), the
service sets the chain of invocation locales to an array of length(1) containing
the default locale of the JVM. Null entries can exist within the supplied
locale list, for which the service substitutes the default locale of the JVM
on remote invocations.
- void setLocale(java.util.Locale locale)
- Sets the chain of locales within the invocation internationalization context
to an array of length(1) containing the supplied locale, locale. The
supplied locale can be null, in which case the service instead sets the chain
to an array of length(1) containing the default locale of the JVM.
- void setTimeZone(java.util.TimeZone timeZone)
- Sets the time zone within the invocation internationalization context
to the supplied time zone, time zone. If the supplied time zone is
not an exact instance of java.util.SimpleTimeZone or is null, the service
instead sets the invocation time zone to the default time zone of the JVM.
- void setTimeZone(String timeZoneId)
- Sets the time zone within the invocation internationalization context
to the java.util.SimpleTimeZone having the supplied ID, timeZoneId.
If the supplied time zone ID is null or invalid (that is, it does not appear
in the list of IDs returned by the java.util.TimeZone.getAvailableIds() method)
the service sets the invocation time zone to the simple time zone having an
ID of GMT, an offset of 00:00, and otherwise invalid fields.

Internationalization context
Internationalization context: Propagation and scope
Internationalization context: Management policies

Using the internationalization context API

Example: Internationalization context in an EJB client program
Example: Internationalization context in a servlet
Example: Internationalization context in a session bean
Searchable topic ID:
rin_i18napi
Last updated: Jun 21, 2007 8:07:48 PM CDT
WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/i18n/ref/rin_i18napi.html