Most of that java code is just pasting together library function
calls. I'm not sure if there's any more elegant ways of doing that.
Your clojure code looks fine for the most part I think. It's mostly
just a question of style. The only thing that sticks out is the call
to (list). That's generally never needed in Clojure. You just use a
vector instead.

Here's how I would write your code. Nothing much has changed. Just
personal style:

(defn str-interpose [sep strings]
  (apply str (interpose sep strings)))

(defn acquire-address [vm]
  (.getProperty (.getAgentProperties vm)
    "com.sun.management.jmxremote.localConnectorAddress"))

(defn load-agent [vm]
  (.loadAgent vm
    (str-interpose File/separator
      [(.. vm getSystemProperties (getProperty "java.home")) "lib"
"management-agent.jar"])))

(defn obtain-local-connection [vmid]
  (let [vm (VirtualMachine/attach vmid)
        address (or (acquire-address vm)
                    (do (load-agent vm) (acquire-address vm)))]
    (.detach vm)
    address))

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to