+

Search Tips | Advanced Search

For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


Configure adapters

Learn how we can override properties during run time, without having to redeploy adapters.

Starting with V8.0.0 of MobileFirst Server, administrators can use the MobileFirst Operations Console to modify the behavior of an adapter that has been deployed. After configuration has been modified, the changes take effect in the server immediately, without the need to redeploy the adapter, or restart the server. For more information, see Configure adapter properties with MobileFirst Operations Console in this page.

There are two levels of properties that can be modified on-the-fly:

Parent topic: Develop the server side of a MobileFirst application


Create user-defined adapter properties

We use a property element for each user-defined property we want to add. For more information on the property element, see property element of the JavaScript adapter XML file, or property element of the Java™ adapter XML file.


Procedure

  1. Open the adapter-descriptor (adapter.xml) file for our adapter in an editor.
  2. For each new property, add a property element to the file, as follows:

      <property name="unique-name" 
          description="value" 
          defaultValue="value" 
          type="value"
      />

    Note: If the adapter.xml file of a JavaScript adapter contains procedure elements, the property elements must always appear below them.

  3. Save the adapter.xml file.
  4. To apply your changes and make your custom properties available in the MobileFirst Server, build your adapter and deploy it to an instance of the server.


Results

After you successfully deploy an adapter with custom properties to the server, you make the value of the properties available to the adapter code with a call to the appropriate API:

See Using user-defined property values in adapter code in this page.


Configure adapter properties with MobileFirst Operations Console

Both the built-in connection policy properties as well as the user-defined properties can be overridden in the MobileFirst Operations Console.


Example

Assume that you have deployed a JavaScript adapter JavaSQL to MobileFirst Server. Assume that the adapter.xml descriptor file contains three user-defined properties, as follows:

We can view the configuration settings by clicking the Configurations tab under mfp Runtime > adapter_name. The predefined connection policy parameters are displayed under Connectivity. Beneath them, under Parameters, are the user-defined properties settings. In this example, Database URL, Database username, and Database password.

Figure 1. User-defined adapter properties in the MobileFirst Operations Console

This figure shows how user-defined properties are shown in the Console.

Administrators can modify the values that are shown and save. The changes take effect immediately, without redeploying the adapter.


Sharing adapter configurations

Customized adapter properties appear in the modified adapter configuration file in the Configuration files tab of MobileFirst Operations Console. Use the configpull and configpush goals to share the custom configuration. See Maven adapter plug-in.


Using user-defined property values in adapter code

There are both Java and JavaScript server-side APIs that enable you to retrieve properties defined in the adapter.xml file or in MobileFirst Operations Console.