示例#1
0
 public static <T> T getRemoteBean(
     Class<T> clazz, String mbeanName, IConfiguration config, boolean mxbean) {
   try {
     if (mxbean)
       return ManagementFactory.newPlatformMXBeanProxy(
           JMXNodeTool.instance(config).mbeanServerConn, mbeanName, clazz);
     else
       return JMX.newMBeanProxy(
           JMXNodeTool.instance(config).mbeanServerConn, new ObjectName(mbeanName), clazz);
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   return null;
 }
示例#2
0
  /**
   * This method will test if you can connect and query something before handing over the
   * connection, This is required for our retry logic.
   *
   * @return
   */
  private static boolean testConnection() {
    // connecting first time hence return false.
    if (tool == null) return false;

    try {
      tool.isInitialized();
    } catch (Throwable ex) {
      SystemUtils.closeQuietly(tool);
      return false;
    }
    return true;
  }