Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IBM Worklight - How to change dynamically domain/hostname to which the adapter connects from the client at launch or runtime?

When configuring WL HTTP Adapters, the domain and port are part of the adapter configuration .xml file build and uploaded on the WL server. For our use case (especially beta testing and demos) the endpoint server url needs to be configurable for the end user. Example, same builds are tested by QA on test envs, while BA connects to demo. We have only one WL Server up and setting environment specific servers is not an option.

Is it possible to change domain/hostname dynamically at application launch or runtime ? Ideally it would be to get and use the domain/hostname value from a drop down or free input from the client and use it.

<connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>{hostname}</domain>
            <port>80</port>         
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="2" />
    </connectivity>
like image 523
DannySSS Avatar asked Mar 18 '23 20:03

DannySSS


1 Answers

Update: This answer is useful, so I leave it here for reference, but accept that it doesn't correctly answer this question!

There is a specific Worklight feature designed to address your scenario (for the Infocenter detail, see here).

You can do this by using a combination of worklight.properties and JNDI properties.

For example, let's say you had this setup in your adapter XML:

 <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>${my.adapter.protocol}</protocol>
            <domain>${my.adapter.domain}</domain>
            <port>${my.adapter.port}</port>         
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="2" />
 </connectivity>

You then define default values for these in your worklight.properties file (in the server/conf directory of your Worklight project, and "burnt in" to the .WAR file when you build it):

my.adapter.protocol=http
my.adapter.domain=some.host.com
my.adapter.port=80

You can then override these values in individual environments, by setting JNDI properties. For example, if you are using WebSphere Liberty, you might put this in your server.xml:

<jndiEntry jndiName="my.adapter.protocol" value="https"/>
<jndiEntry jndiName="my.adapter.domain" value="some.other.host.com"/>
<jndiEntry jndiName="my.adapter.port" value="8080"/>
like image 81
Andrew Ferrier Avatar answered May 16 '23 06:05

Andrew Ferrier