|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The UserInternationalization interface provides methods to get references necessary for managing different types of Internationalization context within Enterprise JavaBeans 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:
The Internationalization service defines two types of context:
Caller context is the locale and time zone information that propagates from calling application components on remote business method requests. It is readable within all application components, but cannot be set using the API.
Invocation context is the locale and time zone information that propagates to target application components on remote business methods. It is the context under which component or business methods execute. Invocation context is readable and writable within application components according to the applicable context management policies of the Internationalization service (see below).
To access Internationalization context elements of either type, an application component first resolves a reference to the UserInternationalization interface by performing a JNDI lookup on the initial context for URL java:comp/websphere/UserInternationalization.
UserInternationalization userI18n = null; try { userI18n = initCtx.lookup("java:comp/websphere/UserInternationalization"); } catch (javax.naming.NamingException e) { ...
Next, use the get methods of UserInternationalization to
obtain references to the Internationalization
or InvocationInternationalization
interfaces, which provide methods to access caller or invocation context
elements, respectively. For example, the following code snippet gets the
caller locale and time zone associated with the current thread.
Locale callerLocale = null; SimpleTimeZone callerTimeZone = null; try { callerLocale = userI18n.getCallerInternationalization().getLocale(); callerTimeZone = (SimpleTimeZone)userI18n.getInvocationInternationalization().getTimeZone(); } catch (java.lang.IllegalStateException) { ...
And the following snippet sets the invocation locale and time zone associated with the current thread.
try { userI18n.getInvocationInternationalization().setLocale(new Locale("en", "US")); userI18n.getInvocationInternationalization().setTimeZone("CST"); } catch (java.lang.IllegalStateException) { ...
Internationalization context management polices specify API access restrictions, how invocation context will propagate on business method requests, and the context under which target requests will execute. There are two context management policies corresponding to whether an application component is contained on the client-side or the server-side.
Client-side Internationalization (CSI) applies to components deployed within J2EE client containers, only. Under CSI, client applications may get and set invocation context elements. Context elements set using the API persist until either set again or the application exits.
Server-side Internationalization (SSI) applies to components deployed within J2EE server-side containers. Under SSI, servlets and EJBs always run under the caller's context; that is, their invocation context is that of the caller. Servlets and EJBs may not set invocation context. All components can access caller context using the Internationalization interface, regardless of the applicable context management policy.
For further details about accessing caller and invocation contexts
under these context management policies, refer to interfaces
Internationalization
and
InvocationInternationalization
.
For a complete description of the Internationalization Service, 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.
Method Summary | |
Internationalization |
getCallerInternationalization()
Get a reference to the Internationalization interface that allows read-only access to caller Internationalization context elements. |
InvocationInternationalization |
getInvocationInternationalization()
Get a reference to the InvocationInternationalization interface that allows read-write access to invocation Internationalization context elements. |
Method Detail |
public Internationalization getCallerInternationalization()
java.lang.IllegalStateException
- Whenever the
service is disabled.Internationalization
public InvocationInternationalization getInvocationInternationalization()
java.lang.IllegalStateException
- Whenever the
service is disabled.InvocationInternationalization
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |