users@glassfish.java.net

Re: Accessing Glassfish configuration values from domain.xml

From: <forums_at_java.net>
Date: Tue, 6 Aug 2013 12:06:40 -0500 (CDT)

Bear in mind that this approach relies on numerous unpublished, internal, and
undocumented techniques that are not guaranteed to work in the future. It's
also fairly heavyweight to create a new CommandRunner, submit a command to
it, have it parse and process the command, etc. Another possibility would be
to build your code as an OSGi module that depends on the config API module in
GlassFish. Your module would then be able to use @Inject one or more
configuration items of interest, from which it could either directly get the
values you need or navigate from those to the values you need. For example,
@Inject private Domain domain gives the code access to the top-level element,
from which it can navigate anywhere it needs to. Now, having said that, the
config API is itself not an officially supported interface any more than
CommandRunner, but realistically it's probably less likely to change (since
it directly reflects the structure of domain.xml). And this approach will be
much more efficient. If you're going to use one unpublished interface or
another you might as well consider the faster one! - Tim

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