如何使用 Java 打印 Worklight 属性

How to print Worklight properties using Java

我们正在尝试使用服务器上的 Java 代码 运行 获取 Worklight 服务器内的所有属性。

Worklight 版本 6.2.0.1

基于以下 URL:

https://www-01.ibm.com/support/knowledgecenter/?lang=en#!/SSZH4A_6.2.0/com.ibm.worklight.apiref.doc/html/refjava-worklight-server/html/com/worklight/server/bundle/api/WorklightConfiguration.html

我正在尝试使用 getAllProperties() API。但是,我没有在代码中得到它:

我导入了java.util.Properties;

try{
     Properties p = new Properties();
     p.getAllProperties(); // This doesn't exist
     .
     .
}

我是不是做错了或遗漏了什么。?如何读取上述基于 IBM URL 的 Worklight 中的所有属性?

如果我正确地解决了你的问题,class WorklightConfiguration 提供了一个名为 getAllProperties() 的方法,returns 是 Properties 的一个实例。您没有在问题中提供任何代码,但此代码示例可能对您有所帮助(免责声明:我以前从未使用过 Worklight,因此可能需要进行一些调整,但您会明白的):

WorklightConfiguration config = WorklightConfiguration.getInstance ();
Properties properties = config.getAllProperties ();

for (String propertyName: properties.propertyNames ()) {
    String property = properties.getProperty (propertyName);
    // rest of implementation...
}