forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJMXTest.java
More file actions
32 lines (25 loc) · 1.03 KB
/
JMXTest.java
File metadata and controls
32 lines (25 loc) · 1.03 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
import java.lang.management.ManagementFactory;
import javax.management.ObjectName;
public class JMXTest {
public static interface FooMBean {
public String sometimesLiveMethod(String arg);
public String liveMethod2(String arg);
}
public static class FooIntermediate implements FooMBean {
// This method is dead, because it is overridden in FooImpl, which is the registered MBean.
public String sometimesLiveMethod(String arg) { return "foo"; }
// This method is live, because it is the most specific method for FooImpl
public String liveMethod2(String arg) { return "foo"; }
}
// MBean registered class
public static class FooImpl extends FooIntermediate {
// This method is live, because it is declared in FooMBean.
public String sometimesLiveMethod(String arg) { return "foo"; }
}
public static void register(Object o) throws Exception {
ManagementFactory.getPlatformMBeanServer().registerMBean(o, new ObjectName("foo"));
}
public static void main(String[] args) throws Exception {
register(new FooImpl());
}
}