private MBeanServerConnection getConnection() { MBeanServerConnection connection = this.connection; if (connection == null) { try { final Map<String, Object> env = new HashMap<>(); if (Authentication.username != null && !Authentication.username.isEmpty()) { // Only set this is there is a username as it disabled local authentication. env.put(CallbackHandler.class.getName(), Authentication.getCallbackHandler()); } if (config.getAuthenticationConfig() != null) { env.put("wildfly.config.url", config.getAuthenticationConfig()); } final JMXServiceURL serviceURL = getRemoteJMXURL(); final JMXConnector connector = this.connector = JMXConnectorFactory.connect(serviceURL, env); connection = this.connection = new MBeanConnectionProxy(connector.getMBeanServerConnection()); } catch (IOException e) { throw new RuntimeException(e); } } return connection; }
@Override public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException, IOException { try { return connection.getAttribute(name, attribute); } catch (IOException e) { checkConnection(); return connection.getAttribute(name, attribute); } }
private boolean checkConnection() { try { this.connection.getDefaultDomain(); return true; } catch (IOException ioe) { logger.debug("JMX connection error.", ioe); } this.connection = reconnect(); return false; }
private MBeanServerConnection getConnection() { MBeanServerConnection connection = this.connection; if (connection == null) { try { final Map<String, Object> env = new HashMap<>(); if (Authentication.username != null && !Authentication.username.isEmpty()) { // Only set this is there is a username as it disabled local authentication. env.put(CallbackHandler.class.getName(), Authentication.getCallbackHandler()); } if (config.getAuthenticationConfig() != null) { env.put("wildfly.config.url", config.getAuthenticationConfig()); } final JMXServiceURL serviceURL = getRemoteJMXURL(); final JMXConnector connector = this.connector = JMXConnectorFactory.connect(serviceURL, env); connection = this.connection = new MBeanConnectionProxy(connector.getMBeanServerConnection()); } catch (IOException e) { throw new RuntimeException(e); } } return connection; }
private MBeanServerConnection getConnection() { if (connection == null) { try { final HashMap<String, Object> env = new HashMap<String, Object>(); if (Authentication.username != null && Authentication.username.length() > 0) { // Only set this is there is a username as it disabled local authentication. env.put(CallbackHandler.class.getName(), Authentication.getCallbackHandler()); } connector = JMXConnectorFactory.connect(getRemoteJMXURL(), env); connection = new MBeanConnectionProxy(connector.getMBeanServerConnection()); } catch (IOException e) { throw new RuntimeException(e); } } return connection; }
@Override public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException { try { connection.removeNotificationListener(name, listener, filter, handback); } catch (IOException e) { if (!checkConnection()) { connection.removeNotificationListener(name, listener, filter, handback); } else { throw e; } } }
@Override public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException { try { connection.removeNotificationListener(name, listener, filter, handback); } catch (IOException e) { if (!checkConnection()) { connection.removeNotificationListener(name, listener, filter, handback); } else { throw e; } } }
@Override public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException { try { connection.removeNotificationListener(name, listener, filter, handback); } catch (IOException e) { if (!checkConnection()) { connection.removeNotificationListener(name, listener, filter, handback); } else { throw e; } } }
@Override public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException { try { connection.removeNotificationListener(name, listener); } catch (IOException e) { if (!checkConnection()) { connection.removeNotificationListener(name, listener); } else { throw e; } } }
@Override public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException { try { connection.removeNotificationListener(name, listener, filter, handback); } catch (IOException e) { if (!checkConnection()) { connection.removeNotificationListener(name, listener, filter, handback); } else { throw e; } } }
@Override public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException { try { connection.removeNotificationListener(name, listener, filter, handback); } catch (IOException e) { if (!checkConnection()) { connection.removeNotificationListener(name, listener, filter, handback); } else { throw e; } } }
@Override public void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException { try { connection.removeNotificationListener(name, listener); } catch (IOException e) { if (!checkConnection()) { connection.removeNotificationListener(name, listener); } else { throw e; } } }
@Override public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException { try { connection.addNotificationListener(name, listener, filter, handback); } catch (IOException e) { if (!checkConnection()) { connection.addNotificationListener(name, listener, filter, handback); } else { throw e; } } }
@Override public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException { try { connection.addNotificationListener(name, listener, filter, handback); } catch (IOException e) { if (!checkConnection()) { connection.addNotificationListener(name, listener, filter, handback); } else { throw e; } } }
@Override public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException { try { connection.removeNotificationListener(name, listener); } catch (IOException e) { if (!checkConnection()) { connection.removeNotificationListener(name, listener); } else { throw e; } } }
@Override public void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException { try { connection.removeNotificationListener(name, listener); } catch (IOException e) { if (!checkConnection()) { connection.removeNotificationListener(name, listener); } else { throw e; } } }
@Override public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException { try { connection.addNotificationListener(name, listener, filter, handback); } catch (IOException e) { if (!checkConnection()) { connection.addNotificationListener(name, listener, filter, handback); } else { throw e; } } }
@Override public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException { try { connection.addNotificationListener(name, listener, filter, handback); } catch (IOException e) { if (!checkConnection()) { connection.addNotificationListener(name, listener, filter, handback); } else { throw e; } } }
@Override public boolean isRegistered(ObjectName name) throws IOException { try { return connection.isRegistered(name); } catch (IOException e) { checkConnection(); return connection.isRegistered(name); } }
@Override public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException, IOException { checkConnection(); connection.unregisterMBean(name); }