Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

A New Strategy of Language Pack Management for Wireless Apps

By Huang Chang & Tong Chun Jie
2005-04-18


LPInvoker Bundle

To show how well the embodiment works, we will develop a testing bundle to simulate how a fictitious application bundle can benefit from the globalization support provided by the LPProxy. This bundle first gets the instance of LPProxyService by looking up the service registry of the Service Management Framework run time. Next, it identifies the LP bundle by specifying the base name and locale. Finally, the bundle reads the multilingual data from the LP bundle by calling the getString(String key) method. Listing 3 shows the source code of the start method.

Listing 3. The start method of LPInvoker Bundle

public void start(BundleContext context) throws Exception {

System.out.println("starting invoker...");
this.bc = context;
//Get LPProxyService from the run time
ServiceReference ref =
context.getServiceReference(LPProxyService.class.getName());
proxy = (LPProxyService)context.getService(ref);

//Initialize the LocaleData bundle by specifying the baseName and locale.
proxy.setBaseName("LP");
proxy.setLocale(new Locale("en", "US"));
//proxy.setLocale(new Locale("zh", "CN"));

//Invoke proxy.getString method to read from the localization package.
System.out.println("from invoker: "+proxy.getString("Hi") + ", ");
System.out.println(getBundleName());
}
Finally, we submit all these bundles to the Service Management Framework bundle server and elect to install the LPInvoker bundle. In the Service Management Framework run time console, we should see the output when the bundle starts and stops, as shown in Figure 4. We can try again by switching the locale to zh_CN in the start method, and the output changes accordingly, as shown in Figure 5.

Figure 4. The output from the console with locale en_US


Figure 5. The output from the console with locale zh_CN


Tutorial Pages:
» Use the Service Management Framework to Develop Globalized Wireless Apps
» Introduction
» PC Versus Mobile Devices
» OSGi Overview
» OSGi-based LP Loading Strategy
» Service Management Framework
» Design Model for an Exemplary Implementation
» Language Pack Bundle
» LPProxy Bundle
» LPInvoker Bundle
» In Summary
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» Secrets of the Wireless Elite: Alexei Polyakov
» Linux Wireless Networking
» Open Source Wireless Tools Emerge
» Getting Practical About Wireless Security, Part 1: Building a Wireless Sniffer with Perl
» Challenges and Opportunities in Mobile Games
» Running Linux on an iPAQ

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources