aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2009-11-13 15:21:56 -0500
committerStuart Halloway <stu@thinkrelevance.com>2009-11-13 15:21:56 -0500
commit4ed00f581fd203c5b5870842427a78bcc3dfffe8 (patch)
tree7e66d2a08ba0d372c9b780e5b45ca6bc21a1a91c
parent0b211b7e4c1b148d46acabc67e6bcb21791935b0 (diff)
converting jmx bean to use AOT deftype
-rw-r--r--build.xml2
-rw-r--r--src/clojure/contrib/jmx.clj3
-rw-r--r--src/clojure/contrib/jmx/Bean.clj45
3 files changed, 22 insertions, 28 deletions
diff --git a/build.xml b/build.xml
index 91eb0825..a5a78176 100644
--- a/build.xml
+++ b/build.xml
@@ -87,7 +87,7 @@
<arg value="clojure.contrib.pprint.PrettyWriter"/>
<arg value="clojure.contrib.fnmap.PersistentFnMap"/>
<arg value="clojure.contrib.condition.Condition"/>
- <arg value="clojure.contrib.jmx.Bean"/>
+ <arg value="clojure.contrib.jmx"/>
</java>
</target>
diff --git a/src/clojure/contrib/jmx.clj b/src/clojure/contrib/jmx.clj
index dd6d7588..8fa293ce 100644
--- a/src/clojure/contrib/jmx.clj
+++ b/src/clojure/contrib/jmx.clj
@@ -86,6 +86,7 @@
(load "jmx/data")
(load "jmx/client")
(load "jmx/server")
+(load "jmx/Bean")
(defn mbean-names
"Finds all MBeans matching a name on the current *connection*."
@@ -119,3 +120,5 @@
(into {} (map (fn [attr-name] [(keyword attr-name) (read-supported n attr-name)])
(attribute-names n))))
+
+
diff --git a/src/clojure/contrib/jmx/Bean.clj b/src/clojure/contrib/jmx/Bean.clj
index cae67d21..e04789c9 100644
--- a/src/clojure/contrib/jmx/Bean.clj
+++ b/src/clojure/contrib/jmx/Bean.clj
@@ -1,35 +1,26 @@
-(ns clojure.contrib.jmx.Bean
- (:gen-class
- :implements [javax.management.DynamicMBean]
- :init init
- :state state
- :constructors {[Object] []})
- (:require [clojure.contrib.jmx :as jmx])
- (:import [javax.management DynamicMBean MBeanInfo AttributeList]))
-
-(defn -init [derefable]
- [[] derefable])
+(in-ns 'clojure.contrib.jmx)
+(import '[javax.management DynamicMBean MBeanInfo AttributeList])
; TODO: rest of the arguments, as needed
-(defn generate-mbean-info [clj-bean]
- (MBeanInfo. (.. clj-bean getClass getName) ; class name
+(defn generate-mbean-info [reference]
+ (MBeanInfo. "clojure.contrib.jmx.Bean" ; class name
"Clojure Dynamic MBean" ; description
- (jmx/map->attribute-infos @(.state clj-bean)) ; attributes
+ (map->attribute-infos @reference) ; attributes
nil ; constructors
nil ; operations
nil)) ; notifications
-(defn -getMBeanInfo
- [this]
- (generate-mbean-info this))
-
-(defn -getAttribute
- [this attr]
- (@(.state this) (keyword attr)))
+(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)))
-(defn -getAttributes
- [this attrs]
- (let [result (AttributeList.)]
- (doseq [attr attrs]
- (.add result (.getAttribute this attr)))
- result)) \ No newline at end of file