From 0ffeff4defd8e773cb63c00289857dc59abff45b Mon Sep 17 00:00:00 2001 From: Amila Senadheera Date: Fri, 21 Oct 2022 09:38:58 +0530 Subject: [PATCH] use string.format and comment corrected --- .../java/org/wso2/choreo/connect/enforcer/jmx/JMXAgent.java | 5 +++-- .../choreo/connect/enforcer/jmx/MBeanManagementFactory.java | 3 ++- .../wso2/choreo/connect/enforcer/jmx/MBeanRegistrator.java | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/JMXAgent.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/JMXAgent.java index aef2cbcf5b..6a2658437a 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/JMXAgent.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/JMXAgent.java @@ -48,8 +48,9 @@ public static void initJMXAgent() { LocateRegistry.createRegistry(Integer.parseInt(rmiRegistryPort)); - String jmxURL = "service:jmx:rmi://" + hostname + ":" + rmiServerPort - + "/jndi/rmi://" + hostname + ":" + rmiRegistryPort + "/jmxrmi"; + String jmxURL = String.format("service:jmx:rmi://%s:%s/jndi/rmi://%s:%s/jmxrmi", hostname, + rmiServerPort, + hostname, rmiRegistryPort); JMXServiceURL jmxServiceURL = new JMXServiceURL(jmxURL); jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(jmxServiceURL, null, diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/MBeanManagementFactory.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/MBeanManagementFactory.java index 43486650a0..c46b003351 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/MBeanManagementFactory.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/MBeanManagementFactory.java @@ -25,9 +25,10 @@ public class MBeanManagementFactory { /* - * @return A MBeanServer instance. * If one already exists, it will return that else it will create a new one and * return. + * + * @return A MBeanServer instance. */ public static MBeanServer getMBeanServer() { MBeanServer mBeanServer; diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/MBeanRegistrator.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/MBeanRegistrator.java index a829ac63c0..ad208ba274 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/MBeanRegistrator.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/jmx/MBeanRegistrator.java @@ -56,7 +56,7 @@ public static void registerMBean(Object mBeanInstance) throws RuntimeException { className = className.substring(className.lastIndexOf('.') + 1); } - String objectName = SERVER_PACKAGE + ":type=" + className; + String objectName = String.format("%s:type=%s", SERVER_PACKAGE, className); try { MBeanServer mBeanServer = MBeanManagementFactory.getMBeanServer(); Set set = mBeanServer.queryNames(new ObjectName(objectName), null);