![]() |
In the Enterprise JavaBeans environment, the Internationalization Service supplies a JNDI binding to an implementation of the UserInternationalization interface under the java:comp/websphere/UserInternationalization name. Applications requiring access to the service can perform a lookup on that JNDI name, as shown in the following code snippet:
import com.ibm.websphere.i18n.context.*; import javax.naming.*; public class MyApplication { ... //------------------------------------------------------------ // Resolve a reference to the UserInternationalization interface. //------------------------------------------------------------ InitialContext initCtx = null; UserInternationalization userI18n = null; try { initCtx = new InitialContext(); userI18n = (UserInternationalization)initCtx.lookup( "java:comp/websphere/UserInternationalization"); } catch (NamingException nnfe) { // UserInternationalization URL is unavailable. } catch (NamingException ne) { // InitialContext could not be instantiated. } ...
Once an application component resolves a reference to the UserInternationalization interface, it can use this reference to create references to the Internationalization and InvocationInternationalization interfaces, which afford access to both caller and invocation locales and time zone. See the following code snippet:
... //------------------------------------------------------------ // Resolve references to the Internationalization and // InvocationInternationalization interfaces. //------------------------------------------------------------ Internationalization callerI18n = null; InvocationInternationalization invocationI18n = null; try { callerI18n = userI18n.getCallerInternationalization(); invocationI18n = userI18n.getInvocationInternationalization(); } catch (IllegalStateException iae) { // An Internationalization interface(s) is unavailable. } ...
Related tasks... | |
Configuring the programming environment | |
Accessing caller locales and time zone | |
Accessing invocation locales and time zone | |
View PDF file... | |
To view a PDF file containing this article and related articles, click: | |
![]() | |