Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.3.4
-
None
-
None
Description
I'm attaching a patch that enables wicket-jmx-panel to work with a MBeanServerConnection (super interface of MBeanServer). This is necessary to display interact with JMX beans. The patch also enables the user to select the MBeanServer to use, which isn't possible so far.
To illustrate the usage of my patched code, here is a simple example:
public class Admin extends WebPage {
@SpringBean
private MBeanServerConnection jmxClient;
public Admin() {
add(new JmxPanel("jmx", JmxPanelRenderer.Tree, new JmxMBeanServerWrapper() {
@Override protected Object load()
}));
}
}
The jmxClient bean is configured via Spring, in my case with JavaConfig:
public @Bean MBeanServerConnectionFactoryBean jmxClient() throws MalformedURLException {
MBeanServerConnectionFactoryBean factory = new MBeanServerConnectionFactoryBean();
factory.setConnectOnStartup(false);
factory.setServiceUrl("service:jmx:rmi://localhost/jndi/rmi://localhost:1099/server");
return factory;
}
To enable the rmi jmx connector on the server:
public @Bean RmiRegistryFactoryBean rmiRegistry() throws Exception {
return new RmiRegistryFactoryBean();
}
public @Bean(dependsOn="rmiRegistry") ConnectorServerFactoryBean jmxServer() throws MalformedObjectNameException {
ConnectorServerFactoryBean factory = new ConnectorServerFactoryBean();
factory.setObjectName("connector:name=rmi");
factory.setServiceUrl("service:jmx:rmi://localhost/jndi/rmi://localhost:1099/tomfyweb");
return factory;
}
Replacing RMI with a different connector/protocol is quite easy this way.