1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.hivemind.management.mbeans; |
16 |
| |
17 |
| import javax.management.Attribute; |
18 |
| import javax.management.AttributeList; |
19 |
| import javax.management.AttributeNotFoundException; |
20 |
| import javax.management.DynamicMBean; |
21 |
| import javax.management.InvalidAttributeValueException; |
22 |
| import javax.management.MBeanAttributeInfo; |
23 |
| import javax.management.MBeanConstructorInfo; |
24 |
| import javax.management.MBeanException; |
25 |
| import javax.management.MBeanInfo; |
26 |
| import javax.management.MBeanNotificationInfo; |
27 |
| import javax.management.MBeanOperationInfo; |
28 |
| import javax.management.ReflectionException; |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| public abstract class AbstractDynamicMBean implements DynamicMBean |
38 |
| { |
39 |
| |
40 |
| private MBeanInfo _mBeanInfo; |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
4
| public MBeanInfo getMBeanInfo()
|
46 |
| { |
47 |
4
| if (_mBeanInfo == null)
|
48 |
2
| setMBeanInfo(createMBeanInfo());
|
49 |
4
| return _mBeanInfo;
|
50 |
| } |
51 |
| |
52 |
| |
53 |
| |
54 |
| |
55 |
| |
56 |
| |
57 |
| |
58 |
2
| protected void setMBeanInfo(MBeanInfo info)
|
59 |
| { |
60 |
2
| _mBeanInfo = info;
|
61 |
| } |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
2
| private MBeanInfo createMBeanInfo()
|
69 |
| { |
70 |
2
| MBeanAttributeInfo attrs[] = createMBeanAttributeInfo();
|
71 |
2
| MBeanConstructorInfo ctors[] = createMBeanConstructorInfo();
|
72 |
2
| MBeanOperationInfo opers[] = createMBeanOperationInfo();
|
73 |
2
| MBeanNotificationInfo notifs[] = createMBeanNotificationInfo();
|
74 |
2
| String className = getMBeanClassName();
|
75 |
2
| String description = getMBeanDescription();
|
76 |
2
| return new MBeanInfo(className, description, attrs, ctors, opers, notifs);
|
77 |
| } |
78 |
| |
79 |
| |
80 |
| |
81 |
| |
82 |
0
| protected MBeanAttributeInfo[] createMBeanAttributeInfo()
|
83 |
| { |
84 |
0
| return null;
|
85 |
| } |
86 |
| |
87 |
| |
88 |
| |
89 |
| |
90 |
1
| protected MBeanConstructorInfo[] createMBeanConstructorInfo()
|
91 |
| { |
92 |
1
| return null;
|
93 |
| } |
94 |
| |
95 |
| |
96 |
| |
97 |
| |
98 |
| |
99 |
1
| protected MBeanOperationInfo[] createMBeanOperationInfo()
|
100 |
| { |
101 |
1
| return null;
|
102 |
| } |
103 |
| |
104 |
| |
105 |
| |
106 |
| |
107 |
| |
108 |
1
| protected MBeanNotificationInfo[] createMBeanNotificationInfo()
|
109 |
| { |
110 |
1
| return null;
|
111 |
| } |
112 |
| |
113 |
2
| protected String getMBeanClassName()
|
114 |
| { |
115 |
2
| return getClass().getName();
|
116 |
| } |
117 |
| |
118 |
| |
119 |
| |
120 |
| |
121 |
2
| protected String getMBeanDescription()
|
122 |
| { |
123 |
2
| return null;
|
124 |
| } |
125 |
| |
126 |
| |
127 |
| |
128 |
| |
129 |
0
| public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException,
|
130 |
| ReflectionException |
131 |
| { |
132 |
0
| return null;
|
133 |
| } |
134 |
| |
135 |
| |
136 |
| |
137 |
| |
138 |
0
| public void setAttribute(Attribute attribute) throws AttributeNotFoundException,
|
139 |
| InvalidAttributeValueException, MBeanException, ReflectionException |
140 |
| { |
141 |
| } |
142 |
| |
143 |
| |
144 |
| |
145 |
| |
146 |
| |
147 |
| |
148 |
1
| public AttributeList getAttributes(String[] attributes)
|
149 |
| { |
150 |
1
| AttributeList list = new AttributeList();
|
151 |
1
| if (attributes != null)
|
152 |
| { |
153 |
1
| for (int i = 0; i < attributes.length; i++)
|
154 |
| { |
155 |
2
| String attribute = attributes[i];
|
156 |
2
| try
|
157 |
| { |
158 |
2
| Object result = getAttribute(attribute);
|
159 |
2
| list.add(new Attribute(attribute, result));
|
160 |
| } |
161 |
| catch (AttributeNotFoundException ignored) |
162 |
| { |
163 |
| } |
164 |
| catch (MBeanException ignored) |
165 |
| { |
166 |
| } |
167 |
| catch (ReflectionException ignored) |
168 |
| { |
169 |
| } |
170 |
| } |
171 |
| |
172 |
| } |
173 |
1
| return list;
|
174 |
| } |
175 |
| |
176 |
| |
177 |
| |
178 |
| |
179 |
1
| public AttributeList setAttributes(AttributeList attributes)
|
180 |
| { |
181 |
1
| AttributeList list = new AttributeList();
|
182 |
| |
183 |
1
| if (attributes != null)
|
184 |
| { |
185 |
1
| for (int i = 0; i < attributes.size(); ++i)
|
186 |
| { |
187 |
2
| Attribute attribute = (Attribute) attributes.get(i);
|
188 |
2
| try
|
189 |
| { |
190 |
2
| setAttribute(attribute);
|
191 |
0
| list.add(attribute);
|
192 |
| } |
193 |
| catch (AttributeNotFoundException ignored) |
194 |
| { |
195 |
| } |
196 |
| catch (InvalidAttributeValueException ignored) |
197 |
| { |
198 |
| } |
199 |
| catch (MBeanException ignored) |
200 |
| { |
201 |
| } |
202 |
| catch (ReflectionException ignored) |
203 |
| { |
204 |
| } |
205 |
| } |
206 |
| } |
207 |
| |
208 |
1
| return list;
|
209 |
| } |
210 |
| |
211 |
| |
212 |
| |
213 |
| |
214 |
| |
215 |
0
| public Object invoke(String method, Object[] arguments, String[] params) throws MBeanException,
|
216 |
| ReflectionException |
217 |
| { |
218 |
0
| return null;
|
219 |
| } |
220 |
| |
221 |
| } |