Olá
Aí vai o código copiado do livro:
package book.jmx.examples;
import javax.management.*;
import javax.management.timer.*;
import java.util.Date;
import java.util.List;
public class TimerAgent {
private MBeanServer server = null;
private ObjectName timer = null;
private ObjectName receiver = null;
public void run() {
// Find an agent from this JVM. Null argument will
// return a list of all MBeanServer instances.
List list = MBeanServerFactory.findMBeanServer(null);
server = (MBeanServer)list.iterator().next();
try {
// register the timer and receiver mbeans
timer = new ObjectName("service:name=timer");
receiver = new ObjectName("example:name=listener," +
"source=timer");
server.registerMBean(new Timer(), timer);
server.registerMBean(new TimerReceiver(), receiver);
// start the timer service
server.invoke(timer, "start", null, null);
// add scheduled notification to five seconds
// past the registration
Date date = new Date(System.currentTimeMillis() +
Timer.ONE_SECOND * 5);
Integer id = (Integer)server.invoke(
timer, // MBean
"addNotification", // operation
new Object[] { // arguments:
"timer.notification", // type
"Scheduled notification.", // message
null, // user data
date
},
new String[] { // signature
String.class.getName(),
String.class.getName(),
Object.class.getName(),
Date.class.getName()
}
);
// add listener to the timer
NotificationFilter filter = new TimerFilter(id);
server.addNotificationListener(
timer, receiver, filter, null);
}
catch (JMException e) {
e.printStackTrace();
}
}
//
// Notification filter implementation.
//
class TimerFilter implements NotificationFilter {
private Integer id = null;
TimerFilter(Integer id) {
this.id = id;
}
public boolean isNotificationEnabled(Notification n) {
if (n.getType().equals("timer.notification")) {
TimerNotification notif = (TimerNotification)n;
if (notif.getNotificationID().equals(id))
return true;
}
return false;
}
}
//
// Main method for the client. This will instantiate
// an agent in the JVM.
//
public static void main(String[] args) {
MBeanServer server =
MBeanServerFactory.createMBeanServer();
new TimerAgent().run();
}
}
package book.jmx.examples;
import javax.management.*;
import javax.management.timer.*;
public class TimerReceiver implements TimerReceiverMBean, NotificationListener {
public void handleNotification(Notification n, Object handback) {
System.out.println(n.getMessage());
}
}
package book.jmx.examples;
import javax.management.*;
import javax.management.timer.*;
public interface TimerReceiverMBean {
}
javac -d . -classpath jmx-1_0_1-ri_bin\jmx\lib\jmxri.jar TimerAgent.java TimerReceiver.javaTimerReceiverBean.java
java -classpath .;jmx-1_0_1-ri_bin\jmx\lib\jmxri.jar book.jmx.examples.TimerAgent
jmxri é a implementação de referência da Sun. Substitua pelo JBossMX MBean server.
http://www.jboss.org/index.html?module=html&op=userdisplay&id=developers/projects/jboss/jbossmx
http://sourceforge.net/project/showfiles.php?group_id=22866
http://sourceforge.net/project/shownotes.php?release_id=133660
Desculpe-me se não cheguei a captar seu problema.
[]s
Luca