|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package org.jconfig.jmx; |
|
8 |
| |
|
9 |
| import javax.management.MBeanRegistration; |
|
10 |
| import javax.management.MBeanServer; |
|
11 |
| import javax.management.ObjectName; |
|
12 |
| |
|
13 |
| import org.jconfig.Configuration; |
|
14 |
| import org.jconfig.ConfigurationManager; |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| public class DynamicConfiguration implements DynamicConfigurationMBean, MBeanRegistration { |
|
20 |
| |
|
21 |
| private MBeanServer mBeanServer; |
|
22 |
| private String name; |
|
23 |
| private ObjectName objectName; |
|
24 |
| |
|
25 |
0
| public DynamicConfiguration() {
|
|
26 |
| } |
|
27 |
| |
|
28 |
0
| public String getName() {
|
|
29 |
0
| return name;
|
|
30 |
| } |
|
31 |
| |
|
32 |
0
| public void setName(String name) {
|
|
33 |
0
| this.name = name;
|
|
34 |
0
| Configuration config = ConfigurationManager.getConfiguration(name);
|
|
35 |
0
| loadConfiguration(name);
|
|
36 |
| } |
|
37 |
| |
|
38 |
0
| public void postDeregister() {
|
|
39 |
| } |
|
40 |
| |
|
41 |
0
| public void postRegister(Boolean booleanParam) {
|
|
42 |
| } |
|
43 |
| |
|
44 |
0
| public void preDeregister() throws java.lang.Exception {
|
|
45 |
| } |
|
46 |
| |
|
47 |
0
| public ObjectName preRegister(MBeanServer mBeanServer, ObjectName objectName) throws java.lang.Exception {
|
|
48 |
0
| this.mBeanServer = mBeanServer;
|
|
49 |
0
| this.objectName = objectName;
|
|
50 |
0
| return objectName;
|
|
51 |
| } |
|
52 |
| |
|
53 |
0
| public ObjectName loadConfiguration(String name) {
|
|
54 |
| |
|
55 |
0
| System.out.println("loadConfiguration called:"+name);
|
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
0
| return registerConfigurationMBean(name);
|
|
67 |
| } |
|
68 |
| |
|
69 |
0
| ObjectName registerConfigurationMBean(String name) {
|
|
70 |
| |
|
71 |
0
| ObjectName configurationObjectName = null;
|
|
72 |
0
| try {
|
|
73 |
0
| configurationObjectName =
|
|
74 |
| new ObjectName(objectName.getDomain(), "configuration", name); |
|
75 |
0
| ConfigurationDynamicMBean configurationMBean =
|
|
76 |
| new ConfigurationDynamicMBean(configurationObjectName, name); |
|
77 |
0
| mBeanServer.registerMBean(configurationMBean, configurationObjectName);
|
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| } catch (Exception e) { |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
0
| e.printStackTrace();
|
|
97 |
| } |
|
98 |
0
| return objectName;
|
|
99 |
| } |
|
100 |
| |
|
101 |
| } |