aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2010-02-23 09:57:41 -0500
committerStuart Halloway <stu@thinkrelevance.com>2010-02-23 09:57:41 -0500
commit6cfd3b286680fd59021382fdc516be6be82a8834 (patch)
tree01449eef94a6c687d707cee4634c99d416c23654
parent6f2b1d73b50b7b9f0d753aa0f5fd343b67f75bf6 (diff)
allow custom :jndi-path for JMX URLs
-rw-r--r--src/main/clojure/clojure/contrib/jmx/data.clj4
-rw-r--r--src/test/clojure/clojure/contrib/test_jmx.clj11
2 files changed, 10 insertions, 5 deletions
diff --git a/src/main/clojure/clojure/contrib/jmx/data.clj b/src/main/clojure/clojure/contrib/jmx/data.clj
index 3a4c5275..8a914270 100644
--- a/src/main/clojure/clojure/contrib/jmx/data.clj
+++ b/src/main/clojure/clojure/contrib/jmx/data.clj
@@ -20,8 +20,8 @@
"Build a JMX URL from options."
([] (jmx-url {}))
([overrides]
- (let [opts (merge {:host "localhost", :port "3000"} overrides)]
- (format "service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi" (opts :host) (opts :port)))))
+ (let [opts (merge {:host "localhost", :port "3000", :jndi-path "jmxrmi"} overrides)]
+ (format "service:jmx:rmi:///jndi/rmi://%s:%s/%s" (opts :host) (opts :port) (opts :jndi-path)))))
(defmulti as-object-name
"Interpret an object as a JMX ObjectName."
diff --git a/src/test/clojure/clojure/contrib/test_jmx.clj b/src/test/clojure/clojure/contrib/test_jmx.clj
index d54a477b..24d6b975 100644
--- a/src/test/clojure/clojure/contrib/test_jmx.clj
+++ b/src/test/clojure/clojure/contrib/test_jmx.clj
@@ -117,9 +117,14 @@
(deftest test-jmx-url
(testing "creates default url"
- (is (= "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi" (jmx/jmx-url))))
+ (is (= "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi"
+ (jmx/jmx-url))))
(testing "creates custom url"
- (is (= "service:jmx:rmi:///jndi/rmi://example.com:4000/jmxrmi" (jmx/jmx-url {:host "example.com" :port 4000})))))
+ (is (= "service:jmx:rmi:///jndi/rmi://example.com:4000/jmxrmi"
+ (jmx/jmx-url {:host "example.com" :port 4000}))))
+ (testing "creates custom jndi path"
+ (is (= "service:jmx:rmi:///jndi/rmi://example.com:4000/jmxconnector"
+ (jmx/jmx-url {:host "example.com" :port 4000 :jndi-path "jmxconnector"})))))
;; ----------------------------------------------------------------------
;; tests for clojure.contrib.jmx.Bean.
@@ -163,4 +168,4 @@
"int" 10
"boolean" false
"java.lang.String" "foo"
- "long" (long 10))) \ No newline at end of file
+ "long" (long 10)))