Permalink
Browse files

allow custom :jndi-path for JMX URLs

  • Loading branch information...
1 parent 6f2b1d7 commit 6cfd3b286680fd59021382fdc516be6be82a8834 @stuarthalloway stuarthalloway committed Feb 23, 2010
Showing with 10 additions and 5 deletions.
  1. +2 −2 src/main/clojure/clojure/contrib/jmx/data.clj
  2. +8 −3 src/test/clojure/clojure/contrib/test_jmx.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."
@@ -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)))
+ "long" (long 10)))

0 comments on commit 6cfd3b2

Please sign in to comment.