Search code examples
mx4j

how to bind mx4j to an ipaddress rather than localhost in jetty?


I am using mx4j in jetty to have a web console to my jmx bean. However, mx4j by default only bind to localhost. I don't know how to set to by to the ipaddres of my machine rather than localhost. Here is my code:

MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
MBeanContainer mBeanContainer=new MBeanContainer(mbeanServer);      
mBeanContainer.setManagementPort(1500);     
mBeanContainer.start();     
server.getContainer().addEventListener(mBeanContainer);  
// server is Jetty Server

Thanks


Solution

  • I found the answer. YOu need to setup HttpAdapter with XSTL translator like this

    HttpAdaptor adapter = new HttpAdaptor();
    ObjectName name = new ObjectName("Server:name=HttpAdaptor");
    mbeanServer.registerMBean(adapter, name);
    adapter.setPort(1500);
    adapter.setHost("MyIpAddress");
    adapter.setProcessor(new XSLTProcessor());
    adapter.start();