Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/main/clojure/clojure/java/jmx.clj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@
(into {} (zipmap (keys m) (map objects->data (vals m)))))

Object
(objects->data [obj] obj))
(objects->data [obj] obj)

javax.management.Attribute
(objects->data [attr] (.getValue attr)))

(def ^{:private true} guess-attribute-map
{"java.lang.Integer" "int"
Expand Down Expand Up @@ -315,7 +318,7 @@
nil ; operations
nil))
(getAttribute [_ attr]
(@state-ref (keyword attr)))
(Attribute. attr (@state-ref (keyword attr))))
(getAttributes [_ attrs]
(let [result (AttributeList.)]
(doseq [attr attrs]
Expand Down
10 changes: 6 additions & 4 deletions src/test/clojure/clojure/java/test_jmx.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

(ns clojure.java.test-jmx
(:import javax.management.openmbean.CompositeDataSupport
[javax.management MBeanAttributeInfo AttributeList]
[javax.management MBeanAttributeInfo Attribute AttributeList]
[java.util.logging LogManager Logger])
(:use clojure.test)
(:require [clojure.java [jmx :as jmx]]))
Expand Down Expand Up @@ -169,8 +169,9 @@
(let [state (reftype {:a 1 :b 2})
bean (jmx/create-bean state)]
(testing (str "accessing values from a " (class state))
(are [result expr] (= result expr)
1 (.getAttribute bean "a"))))))
(are [result expr] (= result expr)
"a" (.getName (.getAttribute bean "a"))
1 (.getValue (.getAttribute bean "a")))))))

(deftest test-bean-info
(let [state (ref {:a 1 :b 2})
Expand All @@ -185,7 +186,8 @@
atts (.getAttributes bean (into-array ["r" "d"]))]
(are [x y] (= x y)
AttributeList (class atts)
[5 4] (seq atts))))
["r" "d"] (map (memfn getName) (seq atts))
[5 4] (map (memfn getValue) (seq atts)))))

(def primitive-int? (< (.compareTo (clojure-version) "1.3.0") 0))

Expand Down