users@glassfish.java.net

Re: how to obtain instance name?

From: Trond Strømme <Trond.Stromme_at_Sun.COM>
Date: Fri, 18 Dec 2009 10:33:04 +0100

Hi Jose,
An easy way to do this is to look in the JMX substructure like this:

MBeanServer mServer = ManagementFactory.getPlatformMBeanServer();
//this should map to one unique mbean, but use queryMBeans if it doesn't
ObjectName on = new
ObjectName("com.sun.appserv:j2eeType=J2EEServer,category=runtime,*");

String name = (String) mServer.getAttribute(on, "name");

Please not that I've not run the code in an IDE, but it should work (i
might have some spelling errors, but....) or at least give you the
general idea of how to get it.

.trond

On 12/14/09 9:29 PM, glassfish_at_javadesktop.org wrote:
> Hi,
>
> I need to have in a cluster some instance specific configuration data. Is there any way I can obtain the glassfish instance name at runtime from a web application? Or to obtain access to an instance specific configuration file? Not a cluster level configuration, but an instance level configuration file accesible from my web application.
>
> Thanks a lot!
>
> José Gallegos A.
> [Message sent by forum member 'escudero4x4' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=376493
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>


-- 
Trond Strømme
Application Platform Ambassador
Sun Microsystems Nordic, Professional Services
+47 975 09 388
http://blog.sun.com/tronds