Hy guys I have code below that works fine:
try {
jmxUrl = new JMXServiceURL(jmxGlassFishConnectorString);
jmxEnv.put(JMXConnector.CREDENTIALS, credentials);
connector =
JMXConnectorFactory.connect(jmxUrl, jmxEnv);
mbsc = connector.getMBeanServerConnection();
ObjectName name = new ObjectName("user:impl-class-name=class,name=class,server=server");
ParametrizacaoAmbienteMBean mbean = JMX.newMBeanProxy(mbsc, name, ParametrizacaoAmbienteMBean.class);
System.out.println(mbean.getAmbiente());
} catch (MalformedObjectNameException ex) {
Logger.getLogger(TesteJMX.class.getName()).log(Level.SEVERE, null, ex);
} catch (NullPointerException ex) {
Logger.getLogger(TesteJMX.class.getName()).log(Level.SEVERE, null, ex);
}
My problem is about these parameters:
final int port = 8686; // standard GlassFish JMX port.
final String host = "localhost";
final String jmxGlassFishConnectorString =
"service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi";
I think its not very good making hard coded port and host because it can change between diferent enviroments, so how can i get connection to jmx using @Resource annotation to expose some method to web client?
thanks
[Message sent by forum member 'josecarlosbarros' (josecarlos.barros_at_gmail.com)]
http://forums.java.net/jive/thread.jspa?messageID=381671