<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -110,6 +110,10 @@ module JMX
     #
     # [:host]        the host of the MBean server (defaults to &quot;localhost&quot;)
     # [:port]        the port of the MBean server (defaults to 3000)
+    # [:url]         the url of the MBean server.
+    #                No default.
+    #                if the url is specified, the host &amp; port parameters are
+    #                not taken into account
     # [:username]    the name of the user (if the MBean server requires authentication).
     #                No default
     # [:password]    the password of the user (if the MBean server requires authentication).
@@ -125,7 +129,9 @@ module JMX
       password = args[:password]
       credentials = args[:credentials]
       
-      url = &quot;service:jmx:rmi:///jndi/rmi://#{host}:#{port}/jmxrmi&quot;
+      # host &amp; port are not taken into account if url is set (see issue #7)
+      standard_url = &quot;service:jmx:rmi:///jndi/rmi://#{host}:#{port}/jmxrmi&quot;
+      url = args[:url] || standard_url
       
       unless credentials
         if !username.nil? and username.length &gt; 0</diff>
      <filename>lib/jmx4r.rb</filename>
    </modified>
    <modified>
      <diff>@@ -39,4 +39,27 @@ class TestConnection &lt; Test::Unit::TestCase
       JConsole::stop 3001
     end
   end
+
+  def test_establish_connection_with_custom_url
+    begin
+      JConsole::start :port =&gt; 3001
+      url = &quot;service:jmx:rmi:///jndi/rmi://localhost:3001/jmxrmi&quot;
+      JMX::MBean.establish_connection :url =&gt; url
+    ensure
+      JConsole::stop 3001
+    end
+  end
+
+  def test_establish_connection_with_custom_url_overrides_host_and_port
+    begin
+      JConsole::start :port =&gt; 3001
+      good_url = &quot;service:jmx:rmi:///jndi/rmi://localhost:3001/jmxrmi&quot;
+      bad_port = 3000
+      # specifying a :url discards the :port &amp; :host parameters
+      JMX::MBean.establish_connection :port =&gt; bad_port, :url =&gt; good_url
+    ensure
+      JConsole::stop 3001
+    end
+  end
+
 end</diff>
      <filename>test/tc_connection.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3c77f7b265a08384e5e894bfe10a6b4d689001ca</id>
    </parent>
  </parents>
  <author>
    <name>Jeff Mesnil</name>
    <email>jmesnil@gmail.com</email>
  </author>
  <url>http://github.com/jmesnil/jmx4r/commit/07bc07affb65b83110ba27ebf13f3475e33855e4</url>
  <id>07bc07affb65b83110ba27ebf13f3475e33855e4</id>
  <committed-date>2008-04-12T11:51:30-07:00</committed-date>
  <authored-date>2008-04-12T11:51:30-07:00</authored-date>
  <message>fixed issue #7: Specify a URL when establishing a connection to the MBean server

added :url arg to JMX::MBean.establish_connection + tests</message>
  <tree>23391673fddbbd2684bd480a5781caeaf6385c45</tree>
  <committer>
    <name>Jeff Mesnil</name>
    <email>jmesnil@gmail.com</email>
  </committer>
</commit>
