aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/jmx/Bean.clj
blob: e04789c915a4f929efdc86fddc3703662da3333c (plain)
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
(in-ns 'clojure.contrib.jmx)
(import '[javax.management DynamicMBean MBeanInfo AttributeList])

; TODO: rest of the arguments, as needed
(defn generate-mbean-info [reference]
  (MBeanInfo. "clojure.contrib.jmx.Bean"                          ; class name
              "Clojure Dynamic MBean"                             ; description
              (map->attribute-infos @reference)                   ; attributes
              nil                                                 ; constructors
              nil                                                 ; operations
              nil))                                               ; notifications                                          

(deftype Bean [reference] [javax.management.DynamicMBean]
  (.getMBeanInfo
   []
   (generate-mbean-info reference))
  (.getAttribute
   [attr]
   (@reference (keyword attr)))
  (.getAttributes
   [attrs]
   (let [result (AttributeList.)]
     (doseq [attr attrs]
       (.add result (.getAttribute this attr)))
     result)))