IBM Worklight - 如何使用从外部文件获取的适配器域和端口属性? [英] IBM Worklight - How to use adapter domain and port properties taken from external file?

查看:140
本文介绍了IBM Worklight - 如何使用从外部文件获取的适配器域和端口属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络服务。它的域和端口可以更改。所以我想从文件或数据库中读取端口和域。当这些信息发生变化时,我会在数据库或文件中更新它们。

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.

适配器XML:

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

worklight.properties:

worklight.properties:

adp.hostname=localhost
adp.port=10080

这工作正常。但我想从文件或数据库中获取 adp.hostname adp.port

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

推荐答案

关于适配器需要记住的是实时 无法更改部署后在适配器XML中设置的属性。

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".

唯一可以做的事情就是决定什么将部署适配器之前的这些属性的值。例如,QA / TEST / UAT / PROD环境的一组不同属性......

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...

设置外部属性,启动Worklight 6.0及更高版本,您可以阅读本文档主题:使用JNDI环境条目在生产中配置IBM Worklight项目

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

特别针对其server.xml中的T​​omcat :

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. 您更改 app_context_path 到项目的上下文(项目名称)

  2. 为每个需要的属性添加 environment 子元素

  1. You change app_context_path to your project's context (project name)
  2. You add environment child elements for each property you need

重要的是要记住:这些属性也必须存在于 worklight.properties ;这些将是默认属性,如果使用上面的示例,它们将被覆盖,并且将使用环境属性。

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.

在上面的示例中,您可以看到它将替换默认属性 publicWorkLightPort

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

这篇关于IBM Worklight - 如何使用从外部文件获取的适配器域和端口属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆