JmxNotificationTestBean.java
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package fi.codecrew.moya.beans;
import java.io.IOException;
import javax.annotation.PostConstruct;
import javax.ejb.Local;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import javax.management.MBeanServerConnection;
import javax.management.Notification;
import javax.management.NotificationListener;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
@Startup
public class JmxNotificationTestBean implements NotificationListener {
@PostConstruct
public void startup() {
// JMXConnector jcf;
// try {
// jcf = JMXConnectorFactory.connect(new JMXServiceURL(null, null, 8686));
// MBeanServerConnection mbsc = jcf.getMBeanServerConnection();
// } catch (IOException e) {
// logger.warn("Error creating jmx connection", e);
// }
}
private static final Logger logger = LoggerFactory.getLogger(JmxNotificationTestBean.class);
@Override
public void handleNotification(Notification notification, Object handback) {
logger.info("Handling jmx Notification, src: {}, type {}, userdata: {}", new Object[] { notification.getSource(), notification.getType(), notification.getUserData() });
}
}