-
1. Re: accessing MBean from a web page
juhalindfors Jul 15, 2003 8:08 PM (in response to mrzeld)Check the source for the jmx-console in cvs (under varia), its a servlet accessing MBeans. If you need to access MBeans from a different process then lookup the RMIAdaptor from the JNDI and use its interface to interact with MBeans
-
2. Re: accessing MBean from a web page
mrzeld Jul 16, 2003 11:28 AM (in response to mrzeld)just FYI,
i just happen to have saved a PDF slide presentation from Sun on JMX. i was looking through it and found an example of what i needed. here is the code...
<%@ page import="javax.management.*,java.util.*" %>
...
//Step 1 - Get MBean server reference
ArrayList servers = MBeanServerFactory.findMBeanServer(null);
if (servers == null)
throw new Exception("No MBeanServer found.");
MBeanServer server = (MBeanServer)servers.get(0);
//Step 2 - Create object to identify MBean
ObjectName on = new ObjectName("com.jrw.jmx:service=TestJMX");
//Step 3 - Update MBean Value attribute
String newvalue = (String)request.getParameter("formValue");
if (newvalue != null && newvalue.length() > 0)
{
Attribute attribute = new Attribute("Value", newvalue);
server.setAttribute( on, attribute );
}
//Step 4 - Get latest Value attribute
String value = (String)server.getAttribute( on,"Value"); -
3. Re: accessing MBean from a web page
coldbeans Aug 12, 2003 8:05 AM (in response to mrzeld)See for example JMX taglib from Coldtags suite:
http://www.servletsuite.com/jsp.htm