Before you begin
An application component must first resolve a reference to the CallerInternationalization object and then bind it to the Internationalization interface.
Why and when to perform this task
Every remote invocation of an application component has an associated caller internationalization context associated with the thread running that invocation. Caller context is propagated by the internationalization service and middleware to the target of a request, such as an EJB business method or servlet service method. Perform the following task to access elements of the Caller internationalization context.
This
task also applies to Web service client programs and stateless session beans
enabled for Web services.
Steps for this task
java.util.Locale [] myLocales = null; try { myLocales = callerI18n.getLocales(); } catch (IllegalStateException ise) { // The Caller context is unavailable; // is the service started and enabled? } ...
The Internationalization interface contains the following methods to get caller internationalization context elements:
The Internationalization interface allows read-only access to internationalization context within application components. Methods of the Internationalization interface are available to all EJB application components and are used in the same manner for each, but the method semantics vary according to the component's type. For instance, when obtaining caller locale within an EJB client application, the interface returns the default locale of the host JVM; in contrast, when obtaining caller context within a servlet service method (for example, doPost() or doGet() methods), the interface returns the first locale (accept-language) propagated within the corresponding HTML request. See Internationalization context for a discussion of how the service propagates internationalization context throughout an application.
DateFormat df = DateFormat.getDateInstance(myLocale); String localizedDate = df.getDateInstance().format(aDateInstance); ...