|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The Internationalization interface provides methods to get Internationalization context elements within Enterprise JavaBean applications; it is one of three interfaces comprising the Internationalization context application programming interface (API).
For more information about the Internationalization context API, see interfaces:
To get Internationalization context elements, an application component first resolves a reference to the UserInternationalization interface, then uses it to get the appropriate Internationalization reference for reading caller or invocation context.
UserInternationalization userI18n = null; try { userI18n = initCtx.lookup("java:comp/websphere/UserInternationalization"); } catch (javax.naming.NamingException e) { // Cannot resolve UserInternationalization interface. } Internationalization callerI18n = null; Internationalization invocationI18n = null; try { callerI18n = userI18n.getCallerInternationalization(); invocationI18n = (Internationalization)userI18n.getInvocationInternationalization(); } catch (java.lang.IllegalStateException) { ...
Once you have obtained a reference to the Internationalization interface, use it throughout the component to get the locales and time zone associated with the current thread.
The Internationalization interface behaves slightly differently within the various application component types, depending on the applicable context management policy; however, all application components can read caller and invocation context elements using the Internationalization interface.java.util.Locale [] callerLocales = callerI18n.getLocales(); java.util.Locale [] invocationLocales = invocationI18n.getLocales(); java.util.Locale callerLocale = callerI18n.getLocale(); java.util.Locale invocationLocale = invocationI18n.getLocale(); java.util.SimpleTimeZone callerTimeZone = (java.util.SimpleTimeZone)callerI18n.getTimeZone(); java.util.SimpleTimeZone invocationTimeZone = (java.util.SimpleTimeZone)invocationI18n.getTimeZone(); ...
See interface UserInternationalization
for a brief description of the CSI and SSI context management policies.
Under CSI, client applications use Internationalization methods to get caller and invocation context elements. When obtaining an invocation context element, these same methods return the element most recently associated with the current thread using the InvocationInternationalization interface, or the default element whenever one is not yet associated. When obtaining a caller context element, Internationalization methods always return the default element of the process.
Under SSI, servlets and Enterprise JavaBeans (EJBs) run under the caller's Internationalization context. That is, caller and invocation context are the same; so, servlets and EJBs should use the Internationalization interface, only, for reading all types of context elements. In servlets, Internationalization methods return the list of locales propagated on the HTTP request, or the default locale of the server process if the HTTP request lacked locale information, and the default time zone of the server process. In EJBs, these methods return the caller's context elements propagated on business method requests, whenever they exist, or the default element of the process.
For complete details regarding the Internationalization Service, including context management policies, visit the IBM WebSphere Application Server InfoCenter and view the information that discusses the Internationalization Service topic within the Enterprise Services 4.0 documentation set.
Note: Although the Internationalization interface can currently be used within all application component methods, future context management policies may further restrict usage of the interface within EJB callback and servlet lifecycle methods.
Method Summary | |
java.util.Locale |
getLocale()
Get the first in the array of locales associated with the current thread. |
java.util.Locale[] |
getLocales()
Get the array of locales associated with the current thread. |
java.util.TimeZone |
getTimeZone()
Get the time zone associated with the current thread. |
Method Detail |
public java.util.Locale[] getLocales()
public java.util.Locale getLocale()
public java.util.TimeZone getTimeZone()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |