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


Language Pack Bundle

The LP bundle contains the localization pack for a certain locale. Each LP bundle complies with the naming convention; that is, a complete bundle name must have an identical suffix and end with the corresponding locale (for example, LP_en_US, LP_zh_CN, LP_fr_RF, and so on). The language pack in the LP bundle can be presented as ListResourceBundle or PropertyResourceBundle, depending on different requirements. In our case, we'll choose the latter and use the bundle name as the property file name.

As you saw earlier, the LP bundle includes three classes along with the language pack file. The stub code here is necessary because the OGSi service platform uses different class loaders to load different bundles. Therefore, the language pack file packaged in the LP bundle cannot be accessed directly by the external classes from other bundles. The workaround is to add a segment of stub code to perform language pack file access and register the access operations as an OSGi service. Listing 1 shows the source code of LPServiceImpl.
Listing 1. The LPServiceImpl class

public class LPServiceImpl implements LPService{
private BundleContext bc;


public LPServiceImpl(BundleContext context) {
bc = context;
}

public String getString(String key) {
//Return the Bundle object for this context bundle.
Bundle bd = bc.getBundle();
//Get the LP name, which is the same as the Bundle name.
String bdName = (String) bd.getHeaders().get("Bundle-Name");

//Get the resource bundle and invoke its getBundle method.
ResourceBundle lpBD = ResourceBundle.getBundle(bdName);
return lpBD.getString(key);
}
}


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