Adapter Development Kit 9.12 | webMethods Adapter Development Kit Documentation | webMethods Adapter Development Kit Installation and User’s Documentation | Alternative Approaches to Metadata | Using Resource Bundles with Resource Domain Values
 
Using Resource Bundles with Resource Domain Values
A resource bundle contains all display strings and messages used by the adapter at runtime and at design time. A resource bundle is:
*Specific to a particular locale.
*Enables you to internationalize an adapter quickly, without having to change the code in the adapter.
For more information, see Creating Resource Bundles Class With Example .
Adapters can explicitly use a resource bundle to localize other data known at development time. For example, you can localize data such as resource domain values. For more information about resource domain values, see Populating Resource Domains with Values. In those cases, the strategy for key composition is left to your discretion.
Important:
When a localized value needs to be understood in the other parts of the code, a translation is performed. For example, a list of known record status values as shown: (if this.getStatus() != "active")
For example, suppose an adapter service includes a metadata parameter called status, which can be set to a value of active or inactive. These values must be localized so that active or inactive appear in the language of the current user. If the runtime locale is different from the locale in design-time client, then the adapter needs to know the language that is used when the value of status was set. You must use the following:
if (this.getStatus() != inLanguageOfDesignTimeClient("active"))
instead of the following:
if (this.getStatus() != "active")
The localization becomes more complicated if the adapter service node is managed (edited) in more than one locale. If a resource domain lookup depends on a value that is localized, and that value was set by a client in a different locale than the current client, then use the following:
if (this.getStatus() != inLanguageUsedWhenValueWasSet("active"))
To support this functionality, the ADK inserts a special designTimeLocale metadata property, in each adapter service node and notification node.
*Value of designTimeLocale is set when the node is created.
*Adapter users update the value in the node when they click the icon on the Designer toolbar which reloads values from the adapter. The icon appears when users view an adapter service or notification node.
*An adapter that uses the designTimeLocale property can then present resource domain values in the appropriate client locale when the node is created, and understand the value at runtime regardless of what locale Integration Server may use.
*For example, if a Japanese client wants to edit a node that was configured by an English client, then
*The initial presentation in the Adapter Service Editor or Adapter Notification Editor reflects the English values currently stored in the node.
*When the Japanese client clicks the icon, Integration Server changes the designTimeLocale to Japanese, and performs all resource domain lookups using the new locale.
*From the adapter user's perspective, all localized values change from English to Japanese.
*This example assumes that the adapter includes both an English and a Japanese resource bundle.
To support localized resource domain values, perform the following:
*Include the ADKGLOBAL.DESIGN_LOCALE_PROPERTY property name in the resource domain dependency list of any parameter that uses a resource domain with localized resource domain values.
*Include ADKGLOBAL.DESIGN_LOCALE_PROPERTY property name for all the parameters where the lookup depends on a parameter containing localized values.
For example:
d.setResourceDomain( "status", "statusLookup", new
String[]{ADKGLOBAL.DESIGN_LOCALE_PROPERTY} );
d.setResourceDomain( "statusDescription","statusDescriptionLookup", new
String[]
{ "status",ADKGLOBAL.DESIGN_LOCALE_PROPERTY } );
You must present the designTimeLocale as a string (derived from Locale.toString) so that the value is available as a resource domain value. To convert this string to a Locale object, use AdapterUtil.parseLocaleString method.
Within the implementation of the statusLookup, the adapter uses the designTimeLocale value provided to create a list of localized string values:
if (resourceDomainName.equals("statusLookup"))
{
AdapterResourceBundleManager ar =
MyAdapter.getInstance().getAdapterResourceBundleManager();
Locale lookupLocale = AdapterUtil.parseLocaleString(values[0][0]);
for (int i =0; i< statusNames.length;i++)
{
try {
displayNames[i] =
ar.getStringResource(statusNames[i], lookupLocale);
}
catch(Throwable t)
{
displayNames[i] = statusNames[i];
}
}
ResourceDomainValues rdv = new
ResourceDomainValues(resourceDomainName,displayNames);
rdv.setComplete(true); // allow user edit
return new ResourceDomainValues[] {rdv};
}
At runtime, the adapter uses the getDesignTimeLocale method to retrieve the locale, and to interpret the value of localized parameters. For example:
Locale lookupLocale =
AdapterUtil.parseLocaleString(this.getDesignTimeLocale());
AdapterResourceBundleManager ar =
MyAdapter.getInstance().getAdapterResourceBundleManager();
if (this.getStatus.equals(ar.getStringResource("active",lookupLocale)))
{
...
For more information, see the Javadoc for the following:
*com.wm.adk.ADKGLOBALS.DESIGN_TIME_LOCALE_PROPERTY
*com.wm.adk.cci.interaction.WmAdapterService.getDesignTimeLocale
*com.wm.adk.notification.WmNotification.getDesignTimeLocale
*com.wm.adk.util.AdapterUtil.parseLocaleString