Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are a couple of ways to do what you're talking about, so I'll propose two types of solutions and I can give you more info about whichever fits your needs best.</p> <p>A relatively quick solution is to use a portal server like <a href="http://www.jboss.org/gatein" rel="nofollow">GateIn</a>. Your WARs could be displayed on the same page, but they'd be in seperate places and not integrated. You'd have to turn your WAR's into portlets and have an administrator add them to the portal's UI, but the portal would be able to scan and detect all available portlets.</p> <p>A more flexible solution would be to have one of your classes for each deployment implement a common MBean interface. Your dashboard could then use JMX, specifically <code>javax.management.MBeanServerConnection</code>'s <code>queryMBeans</code> method to obtain all MBeans (or a subset of MBeans belonging to a particular package, which you can specify as a query parameter). Then you can execute interface methods through <code>javax.management.MBeanServerConnection</code>'s <code>invoke</code> method. To obtain the MBeanServerConnection with JBoss, call <code>org.jboss.mx.util.MBeanServerLocator.locateJBoss()</code>.</p> <p>Some additional detail as requested (Note, the following is JBoss-specific):</p> <p>1) Turn your deployments into MBean's For each of your JAR files, add a <code>jboss-service.xml</code> and <code>*-xmbean.xml</code> file to the <code>META-INF</code> directory (where <code>*</code> is a name of your choosing). Follow <a href="http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch2.chapter.html#d0e5029" rel="nofollow">this example</a> for those files.</p> <p>Implement the MBean at whatever path you specified in the <code>jboss-service.xml</code> <code>mbean</code> element's <code>code</code> attribute (<code>org.jboss.chap2.xmbean.JNDIMap</code> in the example). Specify a consistent namespace and parameter for the <code>jboss-service.xml</code> <code>mbean</code> element's <code>name</code> attribute (<code>chap2.xmbean:service=</code> in the example). The operations and attributes you specify in the <code>*-xmbean.xml</code> file should map exacly to your interface.</p> <p>2) Create the dashboard and in one of it's classes poll the services (this code hasn't been tested, but should provide a good outline)</p> <pre><code>//Get the connection MBeanServerConnection connection = org.jboss.mx.util.MBeanServerLocator.locateJBoss(); //Query for MBeans in the chap2.xmbean namespace Set&lt;ObjectInstance&gt; mbeans = connection.queryMBeans(null, new ObjectName("chap2.xmbean:service=*")); //Loop over each MBean and invoke an interface method for (ObjectInstance mbean : mbeans) { //Invoking 'put' method from example. If this were an info method, this would return the result of the MBean operation connection .invoke(mbean.getObjectName(), "put", new Object[] {"TestKey", "TestValue"}, new String[] {Object.class.getName(), Object.class.getName()}); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload