[英]How to read attributes using XML apache commons configuration
I am using Apache Commons Configuration for reading configuration in xml file - standalone-full-ha.xml
in Wildfly 8
application server. 我正在使用Apache Commons Configuration读取xml文件中的配置
Wildfly 8
应用程序服务器中的standalone-full-ha.xml
。
<?xml version="1.0" ?>
<server xmlns="urn:jboss:domain:2.2">
...
...
<profile>
...
...
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jta="true" jndi-name="java:/TestDB" pool-name="TestDB" enabled="true" use-java-context="true" spy="false" use-ccm="true">
<connection-url>jdbc:sybase:Tds:ip:port/db-name</connection-url>
...
...
</subsystem>
</profile>
</server>
How to read jndi name java:/TestDB
and connection url jdbc:sybase:Tds:ip:port/db-name
from the above xml. 如何从上述xml中读取jndi名称
java:/TestDB
和连接URL jdbc:sybase:Tds:ip:port/db-name
。
I tried the below but no result is obtained. 我尝试了以下方法,但未获得结果。
XMLConfiguration conf = new XMLConfiguration();
((XMLConfiguration) conf).setDelimiterParsingDisabled(true);
((XMLConfiguration) conf).load("xml file location");
String url = conf.getString("server/profile/subsystem[xmlns= 'urn:jboss:domain:datasources:2.0']/datasources/datasource/connection-url");
String jndiName = conf.getString("server/profile/subsystem[xmlns= 'urn:jboss:domain:datasources:2.0']/datasources/datasource[jndi-name]");
Can anyone please suggest about how to read jndi name and connection url from the xml using XML apache commons configuration. 任何人都可以建议如何使用XML apache commons配置从xml读取jndi名称和连接URL。 Thanks.
谢谢。
WildFly has a Management API WildFly具有管理API
( https://docs.jboss.org/author/display/WFLY8/Management+API+reference ) ( https://docs.jboss.org/author/display/WFLY8/Management+API+reference )
I would suggest using that API in order to Access the WildFly Configuration instead of parsing it 'manually' 我建议使用该API来访问WildFly配置,而不是“手动”解析它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.