Mercurial > lasercutter
view src/clojure/contrib/jmx/Bean.clj @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
line wrap: on
line source
1 (ns clojure.contrib.jmx.Bean2 (:gen-class3 :implements [javax.management.DynamicMBean]4 :init init5 :state state6 :constructors {[Object] []})7 (:require [clojure.contrib.jmx :as jmx])8 (:import [javax.management DynamicMBean MBeanInfo AttributeList]))10 (defn -init [derefable]11 [[] derefable])13 ; TODO: rest of the arguments, as needed14 (defn generate-mbean-info [clj-bean]15 (MBeanInfo. (.. clj-bean getClass getName) ; class name16 "Clojure Dynamic MBean" ; description17 (jmx/map->attribute-infos @(.state clj-bean)) ; attributes18 nil ; constructors19 nil ; operations20 nil)) ; notifications22 (defn -getMBeanInfo23 [this]24 (generate-mbean-info this))26 (defn -getAttribute27 [this attr]28 (@(.state this) (keyword attr)))30 (defn -getAttributes31 [this attrs]32 (let [result (AttributeList.)]33 (doseq [attr attrs]34 (.add result (.getAttribute this attr)))35 result))