public Set<ObjectInstance> findMBeans(final ObjectName objectName) { return invokeWithReconnect(new Callable<Set<ObjectInstance>>() { @Override public Set<ObjectInstance> call() throws Exception { return getConnectionOrFail().queryMBeans(objectName, null); }}); }
public void addNotificationListener(final ObjectName objectName, final NotificationListener listener, final NotificationFilter filter) { invokeWithReconnect(new Callable<Void>() { @Override public Void call() throws Exception { getConnectionOrFail().addNotificationListener(objectName, listener, filter, null); return null; }}); }
public void removeNotificationListener(final ObjectName objectName, final NotificationListener listener, final NotificationFilter filter) { if (isConnected()) invokeWithReconnect(new Callable<Void>() { @Override public Void call() throws Exception { getConnectionOrFail().removeNotificationListener(objectName, listener, filter, null); return null; }}); }
public void setAttribute(ObjectName objectName, final String attribute, final Object val) { final ObjectName realObjectName = toLiteralObjectName(objectName); if (realObjectName != null) { invokeWithReconnect(new Callable<Void>() { @Override public Void call() throws Exception { getConnectionOrFail().setAttribute(realObjectName, new javax.management.Attribute(attribute, val)); return null; }}); if (LOG.isTraceEnabled()) LOG.trace("From {}, for jmx attribute {}.{}, set value {}", new Object[] {url, objectName.getCanonicalName(), attribute, val}); } else { if (LOG.isDebugEnabled()) LOG.debug("From {}, cannot set attribute {}.{}, because mbean not found", new Object[] {url, objectName.getCanonicalName(), attribute}); } }
/** * Returns a specific attribute for a JMX {@link ObjectName}. */ public Object getAttribute(ObjectName objectName, final String attribute) { final ObjectName realObjectName = toLiteralObjectName(objectName); if (realObjectName != null) { Object result = invokeWithReconnect(new Callable<Object>() { @Override public Object call() throws Exception { return getConnectionOrFail().getAttribute(realObjectName, attribute); }}); if (LOG.isTraceEnabled()) LOG.trace("From {}, for jmx attribute {}.{}, got value {}", new Object[] {url, objectName.getCanonicalName(), attribute, result}); return result; } else { return null; } }
/** * Executes an operation on a JMX {@link ObjectName}. */ public Object operation(ObjectName objectName, final String method, final Object... arguments) { final ObjectName realObjectName = toLiteralObjectName(objectName); final String[] signature = new String[arguments.length]; for (int i = 0; i < arguments.length; i++) { Class<?> clazz = arguments[i].getClass(); signature[i] = (CLASSES.containsKey(clazz.getSimpleName()) ? CLASSES.get(clazz.getSimpleName()) : clazz.getName()); } Object result = invokeWithReconnect(new Callable<Object>() { @Override public Object call() throws Exception { return getConnectionOrFail().invoke(realObjectName, method, arguments, signature); }}); if (LOG.isTraceEnabled()) LOG.trace("From {}, for jmx operation {}.{}({}), got value {}", new Object[] {url, realObjectName.getCanonicalName(), method, Arrays.asList(arguments), result}); return result; }