rlm@10: (ns clojure.contrib.jmx.Bean rlm@10: (:gen-class rlm@10: :implements [javax.management.DynamicMBean] rlm@10: :init init rlm@10: :state state rlm@10: :constructors {[Object] []}) rlm@10: (:require [clojure.contrib.jmx :as jmx]) rlm@10: (:import [javax.management DynamicMBean MBeanInfo AttributeList])) rlm@10: rlm@10: (defn -init [derefable] rlm@10: [[] derefable]) rlm@10: rlm@10: ; TODO: rest of the arguments, as needed rlm@10: (defn generate-mbean-info [clj-bean] rlm@10: (MBeanInfo. (.. clj-bean getClass getName) ; class name rlm@10: "Clojure Dynamic MBean" ; description rlm@10: (jmx/map->attribute-infos @(.state clj-bean)) ; attributes rlm@10: nil ; constructors rlm@10: nil ; operations rlm@10: nil)) ; notifications rlm@10: rlm@10: (defn -getMBeanInfo rlm@10: [this] rlm@10: (generate-mbean-info this)) rlm@10: rlm@10: (defn -getAttribute rlm@10: [this attr] rlm@10: (@(.state this) (keyword attr))) rlm@10: rlm@10: (defn -getAttributes rlm@10: [this attrs] rlm@10: (let [result (AttributeList.)] rlm@10: (doseq [attr attrs] rlm@10: (.add result (.getAttribute this attr))) rlm@10: result))