users@glassfish.java.net

Re: Accessing Glassfish configuration values from domain.xml

From: <forums_at_java.net>
Date: Tue, 6 Aug 2013 11:15:26 -0500 (CDT)

Having looked into the details of the response, I was lucky enough to find a
way of bypassing the REST interface and going direct to the
org.glassfish.embeddable.CommandRunner HK2 Service. To get hold of it I
needed to first get hold of the org.glassfish.hk2.api.ServiceLocator from the
OSGi Registry. I'm doing that part with blueprint. Then with the locator, I
can get the CommandRunner, and execute a get operation with any relevant
dotted property name (I used asadmin get * to find out the whole list) [code]
CommandRunner cr = locator.getService(CommandRunner.class, new
Annotation[0]); // get the https port final CommandResult response =
cr.run("get",
"configs.config.server-config.network-config.network-listeners.network-listener.http-listener-2.port");
ExitStatus outcome = null; if (response != null) { outcome =
response.getExitStatus(); } if (outcome == ExitStatus.SUCCESS) { // parse the
response output to get the actual value String[] lines =
response.getOutput().split("\\n"); String[] kvPair = lines[1].split("="); //
Obtain the value in the K=V pair return kvPair[1]; } [/code] I got the
formatting help from this link
https://github.com/arquillian/arquillian-container-glassfish/blob/master/glassfish-embedded-3.1/src/main/java/org/jboss/arquillian/container/glassfish/embedded_3_1/GlassFishContainer.java

--
[Message sent by forum member 'ejroberts']
View Post: http://forums.java.net/node/898130