<subsystem xmlns="urn:jboss:domain:undertow:3.1">
<!-- ... -->
<servlet-container name="default" default-session-timeout="30">
<!-- ... -->
</servlet-container>
<!-- ... -->
</subsystem>
I want to get value of default-session-timeout of above subsystem in java program. How to achieve that? I have searched around on internet but have not found any useful information.
You'll want to have a look at the ModelControllerClient
API.
Something like this would do the trick:
final ModelNode address = Operations.createAddress("subsystem", "undertow", "servlet-container", "default");
final ModelNode op = Operations.createReadAttributeOperation(address, "default-session-timeout");
try (ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9990)) {
final ModelNode result = client.execute(op);
if (!Operations.isSuccessfulOutcome(result)) {
throw new RuntimeException(Operations.getFailureDescription(result).asString());
}
System.out.println(Operations.readResult(result).asInt());
}
If you're using Maven the dependency would be something like:
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-controller-client</artifactId>
<version>${version.org.wildfly.core}</version>
</dependency>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.