|
75 | 75 | (:use [clojure.walk :only [postwalk]])
|
76 | 76 | (:import [clojure.lang Associative]
|
77 | 77 | java.lang.management.ManagementFactory
|
78 |
| - [javax.management Attribute AttributeList DynamicMBean MBeanInfo |
79 |
| - ObjectName RuntimeMBeanException MBeanAttributeInfo MBeanServerConnection] |
| 78 | + [javax.management Attribute AttributeList DynamicMBean MBeanInfo MBeanServer |
| 79 | + ObjectName RuntimeMBeanException MBeanAttributeInfo MBeanOperationInfo |
| 80 | + MBeanParameterInfo MBeanServerConnection] |
80 | 81 | [javax.management.remote JMXConnectorFactory JMXServiceURL]))
|
81 | 82 |
|
| 83 | +(set! *warn-on-reflection* true) |
| 84 | + |
82 | 85 | (def ^{:dynamic true
|
83 | 86 | :doc "The connection to be used for JMX ops. Defaults to the local process."
|
84 |
| - :skip-wiki true} |
| 87 | + :skip-wiki true |
| 88 | + :tag MBeanServer} |
85 | 89 | *connection*
|
86 | 90 | (ManagementFactory/getPlatformMBeanServer))
|
87 | 91 |
|
|
200 | 204 | (binding [*connection* (.getMBeanServerConnection connector#)]
|
201 | 205 | ~@body))))
|
202 | 206 |
|
203 |
| -(defn ^{:skip-wiki true} mbean-info [n] |
| 207 | +(defn ^{:skip-wiki true} mbean-info |
| 208 | + ^MBeanInfo [n] |
204 | 209 | (.getMBeanInfo *connection* (as-object-name n)))
|
205 | 210 |
|
206 | 211 | (defn ^{:skip-wiki true} raw-read
|
|
210 | 215 | [n attrs]
|
211 | 216 | (if (sequential? attrs)
|
212 | 217 | (into {}
|
213 |
| - (map (fn [attr] [(keyword (.getName attr)) (.getValue attr)]) |
| 218 | + (map (fn [^Attribute attr] [(keyword (.getName attr)) (.getValue attr)]) |
214 | 219 | (.getAttributes *connection*
|
215 | 220 | (as-object-name n)
|
216 | 221 | (into-array (map name attrs)))))
|
|
241 | 246 |
|
242 | 247 | (defn ^{:skip-wiki true} attribute-info
|
243 | 248 | "Get the MBeanAttributeInfo for an attribute."
|
244 |
| - [object-name attr-name] |
| 249 | + ^MBeanAttributeInfo [object-name attr-name] |
245 | 250 | (first
|
246 |
| - (filter #(= (name attr-name) (.getName %)) |
| 251 | + (filter #(= (name attr-name) (.getName ^MBeanAttributeInfo %)) |
247 | 252 | (.getAttributes (mbean-info object-name)))))
|
248 | 253 |
|
249 | 254 | (defn readable?
|
|
258 | 263 |
|
259 | 264 | (defn- operation
|
260 | 265 | "The MBeanOperationInfo for operation op on mbean n. Used by invoke."
|
261 |
| - [n op] |
262 |
| - (first (filter #(= (-> % .getName keyword) op) (operations n)))) |
| 266 | + ^MBeanOperationInfo [n op] |
| 267 | + (first (filter (fn [^MBeanOperationInfo info] |
| 268 | + (= (-> info .getName keyword) op)) (operations n)))) |
263 | 269 |
|
264 | 270 | (defn- op-param-types
|
265 | 271 | "The parameter types (as class name strings) for operation op on n.
|
266 | 272 | Used for invoke."
|
267 | 273 | [n op]
|
268 |
| - (map #(-> % .getType) (.getSignature (operation n op)))) |
| 274 | + (map #(.getType ^MBeanParameterInfo %) |
| 275 | + (.getSignature (operation n op)))) |
269 | 276 |
|
270 | 277 | (defn register-mbean
|
271 | 278 | "Register an mbean with the current *connection*."
|
|
285 | 292 | (defn attribute-names
|
286 | 293 | "All attribute names available on an MBean."
|
287 | 294 | [n]
|
288 |
| - (doall (map #(-> % .getName keyword) |
| 295 | + (doall (map (fn [^MBeanAttributeInfo info] |
| 296 | + (-> info .getName keyword)) |
289 | 297 | (.getAttributes (mbean-info n)))))
|
290 | 298 |
|
291 | 299 | (defn operation-names
|
292 | 300 | "All operation names available on an MBean."
|
293 | 301 | [n]
|
294 |
| - (doall (map #(-> % .getName keyword) (operations n)))) |
| 302 | + (doall (map (fn [^MBeanOperationInfo info] |
| 303 | + (-> info .getName keyword)) (operations n)))) |
295 | 304 |
|
296 | 305 | (defn invoke-signature
|
297 | 306 | "Invoke an operation an an MBean. You must also supply
|
|
355 | 364 | (ref-set state-ref
|
356 | 365 | (merge @state-ref state-update))))))
|
357 | 366 | (setAttributes [_ attrs]
|
358 |
| - (let [attr-names (map (fn [attr] |
| 367 | + (let [attr-names (map (fn [^Attribute attr] |
359 | 368 | (.setAttribute _ attr)
|
360 | 369 | (.getName attr))
|
361 | 370 | attrs)]
|
|
0 commit comments