From 991945203adde3ecfb685e13d66cb3e4893868df Mon Sep 17 00:00:00 2001 From: Juan Hernandez Date: Mon, 17 Jun 2019 15:00:54 +0200 Subject: [PATCH] Optionally accept URI-path on the constructor --- .../java/org/newrelic/nrjmx/JMXFetcher.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/newrelic/nrjmx/JMXFetcher.java b/src/main/java/org/newrelic/nrjmx/JMXFetcher.java index f41cd100..e21f9bb5 100644 --- a/src/main/java/org/newrelic/nrjmx/JMXFetcher.java +++ b/src/main/java/org/newrelic/nrjmx/JMXFetcher.java @@ -39,6 +39,8 @@ * (usually stdout) */ public class JMXFetcher { + public static final String defaultURIPath = ""; + private static final Logger logger = Logger.getLogger("nrjmx"); private MBeanServerConnection connection; @@ -64,6 +66,24 @@ public ValueError(String message) { } } + /** + * Builds a new JMXFetcher + * @param hostname Hostname of the JMX endpoint + * @param port Port of the JMX endpoint + * @param username User name of the JMX endpoint, or an empty string if authentication is disabled + * @param password Password of the JMX endpoint, or an empty string if authentication is disabled + * @param keyStore Path of the client keystore file + * @param keyStorePassword Password of the keystore file + * @param trustStore Path of the client trust store file + * @param trustStorePassword Password of the trust store file + * @param isRemote true if the connection is remote. False otherwise. + */ + public JMXFetcher(String hostname, int port, String username, String password, String keyStore, + String keyStorePassword, String trustStore, String trustStorePassword, boolean isRemote) { + this(hostname, port, defaultURIPath, username, password, keyStore, + keyStorePassword, trustStore, trustStorePassword, isRemote); + } + /** * Builds a new JMXFetcher * @param hostname Hostname of the JMX endpoint @@ -82,9 +102,6 @@ public JMXFetcher(String hostname, int port, String uriPath, String username, St if (isRemote) { connectionString = String.format("service:jmx:remoting-jmx://%s:%s", hostname, port); } else { - if ("".equals(uriPath)) { - uriPath = "jmxrmi"; - } connectionString = String.format("service:jmx:rmi:///jndi/rmi://%s:%s/%s", hostname, port, uriPath); }