Search code examples
ibm-mobilefirstworklight-adaptersworklight-server

IBM Worklight - Accessing server properties in adapter JS?


I have to access few WL Server properties (from worklight.properties) in the Adapter JS file. I know we can access properties in the Adapter xml file but I have to access in the JS file.

{ WL.Server.configuration["local.IPAddress"] } 

Is this possible?


Solution

  • The answer is yes.

    For example, using a newly created adapter,

    1. I've added the following before the return in the getStories() function:

      WL.Logger.info("##################### Worklight protocal: " + WL.Server.configuration["publicWorkLightProtocol"]);
      
    2. In order to see this log line in the Worklight Development Server's console in Eclipse, go to and change:

      • Servers view > server.xml > Logging section > Console log level >> INFO

    3. Run As > Deploy Worklight Adapter
    4. Run As > Invoke Worklight Procedure