Search code examples
javambeans

Custom MBean HTML pages


Im looking to customise the Agent View, Agent Administration and MBean View pages used in the management of MBeans, and would like to know if anyone has done this before or knows a tool to facilitate this.

So far, I've looked at simply extending the HTML generating classes (HTMLAdminPage, HTMLObjectPage and HTMLPage), however, this is proving difficult as they are private / protected and can't be extended.


Solution

  • For the MBean view, try XMBeans (MBeans defined by XML Files). All add an example.

    An excerpt from our SchedulerMBean XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mbean PUBLIC
       "-//JBoss//DTD JBOSS XMBEAN 1.2//EN"
       "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_2.dtd">
    
    <mbean>
     <description>Scheduler Management Interface</description>
     <class>ourpackage.SchedulerMBean</class>
    
     <operation>
      <description><![CDATA[starts the scheduler]]></description>
      <name>start</name>
      <return-type>void</return-type>
     </operation>
     <operation>
      <description>
      <![CDATA[(Re)initialises a scheduler. <br/>
      Deletes all jobs and loads the job defintion from the DB.]]>
      </description>
      <name>initScheduler</name>
      <parameter>
         <description>The scheduler's name</description>
         <name>Scheduler</name>
         <type>java.lang.String</type>
      </parameter>
      <return-type>void</return-type>
     </operation>
    </mbean>
    

    And our SchedulerMBean:

    @Service ( objectName = "OurApp:SchedulerMBean=SchedulerMBean", 
      xmbean="resource:path/to/SchedulerMBean.xml")
    public class SchedulerMBean {
       public void start() { ... }
       public void initScheduler(String schedulerName) { ... }
    }