IBM Worklight - How to use adapter domain and port properties taken from external file?

做~自己de王妃 提交于 2019-12-12 01:05:21

问题


I have a web service. Its domain and port can be changed. So I want to read port and domain from file or db. When this information change, I update them in db or file.

Adapter XML:

<domain>${adp.hostname}</domain>
<port>${adp.port}</port>

worklight.properties:

adp.hostname=localhost
adp.port=10080

This is working fine. But I'd like to take adp.hostname and adp.port from file or db.


回答1:


Something to remember about adapters is that you cannot change in real-time any of the properties set in the adapter XML once it is deployed.

Once the adapter is deployed, it is transformed into an object and is stored in memory. At this time, then, you can no longer interact with its "setup".

The only thing you can do, is to decide what will be the value of these properties before your deploy the adapter. For example, a different set of properties for QA/TEST/UAT/PROD environments...


To setup external properties, starting Worklight 6.0 and above, you can read this documentation topic: Configuring an IBM Worklight project in production by using JNDI environment entries

Specifically for Tomcat in its server.xml:

<Context docBase="app_context_path" path="/app_context_path">
  <Environment name="publicWorkLightPort" override="false" 
    type="java.lang.String" value="9080"/>
</Context>
  1. You change app_context_path to your project's context (project name)
  2. You add environment child elements for each property you need

Important to remember: these properties must also exist in worklight.properties; those will be the default properties, and if using the above example they will be over-written and the environment properties will be used instead.

In the example above you can see that it will replace the default property publicWorkLightPort.



来源:https://stackoverflow.com/questions/21158444/ibm-worklight-how-to-use-adapter-domain-and-port-properties-taken-from-externa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!