Using the Spring framework bundled with WebLogic 12 the programming of JMX MBeans becomes as easy as writing a simple POJO within a web application. After coding the MBean as a POJO all that is left to do is creating the Spring configuration file and editing the web.xml deployment decriptor:
– Firstly you have to add the Spring <listener> to the web.xml deployment descriptor with the web.xml to get Spring started.
– Secondly create the applicationContext.xml for Spring in the WEB-INF subdirectory. Declare the Spring bean and let Spring export it to the platform MBean server.
– Thirdly deploy the web application and test it with JConsole, WLST or j4psh.
For your convinience I already built an example. You can download the deployable SimpleJMX.war file or the complete NetBeans project.
You can see the application in action, including the involved files and the deployment in the following screencast:
How to access custom MBeans from WLST is shown in the second part:
The third part is showing how to retrieve MBean attributes from a JSP: