use of javax.management.MBeanAttributeInfo in project neo4j by neo4j.
the class JmxQueryProcedureTest method shouldHandleCompositeAttributes.
@Test
public void shouldHandleCompositeAttributes() throws Throwable {
// given
ObjectName beanName = new ObjectName("org.neo4j:chevyMakesTheTruck=bobMcCoshMakesTheDifference");
when(jmxServer.queryNames(new ObjectName("*:*"), null)).thenReturn(asSet(beanName));
when(jmxServer.getMBeanInfo(beanName)).thenReturn(new MBeanInfo("org.neo4j.SomeMBean", "This is a description", new MBeanAttributeInfo[] { new MBeanAttributeInfo("name", "differenceMaker", "Who makes the difference?", true, false, false) }, null, null, null));
when(jmxServer.getAttribute(beanName, "name")).thenReturn(new CompositeDataSupport(new CompositeType("myComposite", "Composite description", new String[] { "key1", "key2" }, new String[] { "Can't be empty", "Also can't be empty" }, new OpenType<?>[] { SimpleType.STRING, SimpleType.INTEGER }), map("key1", "Hello", "key2", 123)));
JmxQueryProcedure procedure = new JmxQueryProcedure(ProcedureSignature.procedureName("bob"), jmxServer);
// when
RawIterator<Object[], ProcedureException> result = procedure.apply(null, new Object[] { "*:*" });
// then
assertThat(asList(result), contains(equalTo(new Object[] { "org.neo4j:chevyMakesTheTruck=bobMcCoshMakesTheDifference", "This is a description", map(attributeName, map("description", "Who makes the difference?", "value", map("description", "Composite description", "properties", map("key1", "Hello", "key2", 123)))) })));
}
use of javax.management.MBeanAttributeInfo in project CloudStack-archive by CloudStack-extras.
the class PropertyMapDynamicBean method getMBeanInfo.
@Override
public synchronized MBeanInfo getMBeanInfo() {
SortedSet<String> names = new TreeSet<String>();
for (String name : _propMap.keySet()) names.add(name);
MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[names.size()];
Iterator<String> it = names.iterator();
for (int i = 0; i < attrs.length; i++) {
String name = it.next();
attrs[i] = new MBeanAttributeInfo(name, "java.lang.String", name, // isReadable
true, // isWritable
true, // isIs
false);
}
return new MBeanInfo(this.getClass().getName(), "Dynamic MBean", attrs, null, null, null);
}
use of javax.management.MBeanAttributeInfo in project spring-framework by spring-projects.
the class MBeanClientInterceptor method retrieveMBeanInfo.
/**
* Loads the management interface info for the configured MBean into the caches.
* This information is used by the proxy when determining whether an invocation matches
* a valid operation or attribute on the management interface of the managed resource.
*/
private void retrieveMBeanInfo() throws MBeanInfoRetrievalException {
try {
MBeanInfo info = this.serverToUse.getMBeanInfo(this.objectName);
MBeanAttributeInfo[] attributeInfo = info.getAttributes();
this.allowedAttributes = new HashMap<>(attributeInfo.length);
for (MBeanAttributeInfo infoEle : attributeInfo) {
this.allowedAttributes.put(infoEle.getName(), infoEle);
}
MBeanOperationInfo[] operationInfo = info.getOperations();
this.allowedOperations = new HashMap<>(operationInfo.length);
for (MBeanOperationInfo infoEle : operationInfo) {
Class<?>[] paramTypes = JmxUtils.parameterInfoToTypes(infoEle.getSignature(), this.beanClassLoader);
this.allowedOperations.put(new MethodCacheKey(infoEle.getName(), paramTypes), infoEle);
}
} catch (ClassNotFoundException ex) {
throw new MBeanInfoRetrievalException("Unable to locate class specified in method signature", ex);
} catch (IntrospectionException ex) {
throw new MBeanInfoRetrievalException("Unable to obtain MBean info for bean [" + this.objectName + "]", ex);
} catch (InstanceNotFoundException ex) {
// if we are this far this shouldn't happen, but...
throw new MBeanInfoRetrievalException("Unable to obtain MBean info for bean [" + this.objectName + "]: it is likely that this bean was unregistered during the proxy creation process", ex);
} catch (ReflectionException ex) {
throw new MBeanInfoRetrievalException("Unable to read MBean info for bean [ " + this.objectName + "]", ex);
} catch (IOException ex) {
throw new MBeanInfoRetrievalException("An IOException occurred when communicating with the " + "MBeanServer. It is likely that you are communicating with a remote MBeanServer. " + "Check the inner exception for exact details.", ex);
}
}
use of javax.management.MBeanAttributeInfo in project spring-framework by spring-projects.
the class MethodNameBasedMBeanInfoAssemblerMappedTests method testNickNameIsExposed.
@Test
public void testNickNameIsExposed() throws Exception {
ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
MBeanAttributeInfo attr = inf.getAttribute("NickName");
assertNickName(attr);
}
use of javax.management.MBeanAttributeInfo in project spring-framework by spring-projects.
the class MethodNameBasedMBeanInfoAssemblerMappedTests method testWithFallThrough.
@Test
public void testWithFallThrough() throws Exception {
MethodNameBasedMBeanInfoAssembler assembler = getWithMapping("foobar", "add,myOperation,getName,setName,getAge");
assembler.setManagedMethods("getNickName", "setNickName");
ModelMBeanInfo inf = assembler.getMBeanInfo(getBean(), getObjectName());
MBeanAttributeInfo attr = inf.getAttribute("NickName");
assertNickName(attr);
}
Aggregations