Hello Erik,

here is an example that runs on JBoss 2.4.x


package monitor;

import org.jboss.util.ServiceMBeanSupport;

public class JBossMonitor extends ServiceMBeanSupport
implements JBossMonitorMBean, Runnable {

Thread monitor = null;
int interval = 3000;

public JBossMonitor() {}

public String getName() {
return "Monitor:name=JBossMonitor";
}

protected void startService() throws Exception {
// Create a new thread with this monitor
// Set it as a daemon
// start the thread
}

protected void stopService() {
monitor.interrupt();
}

// IMPLEMENT THE GETTERS AND SETTERS FROM THE INTERFACE DEFINITION

public void run() {

boolean running = true;
while (running) {
try {

// put the thread to sleep for the interval specified
// System.out the memory usage
// System.out the thread usage
}
catch (InterruptedException e) {
running = false;
}
}
}

private String getMem() {
return "Total Mem: " + Runtime.getRuntime().totalMemory() + " " +
"Free Mem: " + Runtime.getRuntime().freeMemory(); }

private String getThreads() {
ThreadGroup root = null;
root = Thread.currentThread().getThreadGroup();
while (root.getParent() != null)
root = root.getParent();
return "Thread Count: " + root.activeCount();
}

}


package monitor;

import org.jboss.util.ServiceMBean;

public interface JBossMonitorMBean extends ServiceMBean {

void setInterval(int interval);
int getInterval();

}

Kazandjian Erik wrote:

Hi,
I'm trying to implment a simple model MBean with one attribute and one getter for that attribute. Everything seems to compile but when I look in the agent the MBean is registered but a detail view always gives a class not found exception (in the browser) of the class that is my managed resource. Does anyone know where I can find a simple working example of a Model MBean for JBoss 2.4.x
Thanks
Erik

/Erik Kazandjian - Software Engineer/
/Siemens Atea IC D AS B5/
/++32 14 252962/
/e-mail : [EMAIL PROTECTED]/

--
----------------------------------------------------------------------
ir. Werner Ramaekers
Enterprise Java Solutions Architect - Shift@
Sun Certified Java Programmer - BeJUG steering commitee member

"May the source be with you."

Read my Blog at http://www.werner.be
----------------------------------------------------------------------




-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to