use of javax.management.ObjectInstance in project cxf by apache.
the class ManagedRMManagerTest method testManagedRMManager.
@Test
public void testManagedRMManager() throws Exception {
final SpringBusFactory factory = new SpringBusFactory();
bus = factory.createBus("org/apache/cxf/ws/rm/managed-manager-bean.xml");
im = bus.getExtension(InstrumentationManager.class);
manager = bus.getExtension(RMManager.class);
endpoint = createTestEndpoint();
assertNotNull("Instrumentation Manager should not be null", im);
assertNotNull("RMManager should not be null", manager);
MBeanServer mbs = im.getMBeanServer();
assertNotNull("MBeanServer should be available.", mbs);
ObjectName managerName = RMUtils.getManagedObjectName(manager);
Set<ObjectInstance> mbset = mbs.queryMBeans(managerName, null);
assertEquals("ManagedRMManager should be found", 1, mbset.size());
Object o;
o = mbs.getAttribute(managerName, "UsingStore");
assertTrue(o instanceof Boolean);
assertFalse("Store attribute is false", (Boolean) o);
o = mbs.invoke(managerName, "getEndpointIdentifiers", null, null);
assertTrue(o instanceof String[]);
assertEquals("No Endpoint", 0, ((String[]) o).length);
RMEndpoint rme = createTestRMEndpoint();
ObjectName endpointName = RMUtils.getManagedObjectName(rme);
mbset = mbs.queryMBeans(endpointName, null);
assertEquals("ManagedRMEndpoint should be found", 1, mbset.size());
o = mbs.invoke(managerName, "getEndpointIdentifiers", null, null);
assertEquals("One Endpoint", 1, ((String[]) o).length);
assertEquals("Endpoint identifier must match", RMUtils.getEndpointIdentifier(endpoint, bus), ((String[]) o)[0]);
// test some endpoint methods
o = mbs.getAttribute(endpointName, "Address");
assertTrue(o instanceof String);
assertEquals("Endpoint address must match", TEST_URI, o);
o = mbs.getAttribute(endpointName, "LastApplicationMessage");
assertNull(o);
o = mbs.getAttribute(endpointName, "LastControlMessage");
assertNull(o);
o = mbs.invoke(endpointName, "getDestinationSequenceIds", null, null);
assertTrue(o instanceof String[]);
assertEquals("No sequence", 0, ((String[]) o).length);
o = mbs.invoke(endpointName, "getDestinationSequences", null, null);
assertTrue(o instanceof CompositeData[]);
assertEquals("No sequence", 0, ((CompositeData[]) o).length);
o = mbs.invoke(endpointName, "getSourceSequenceIds", new Object[] { true }, new String[] { "boolean" });
assertTrue(o instanceof String[]);
assertEquals("No sequence", 0, ((String[]) o).length);
o = mbs.invoke(endpointName, "getSourceSequences", new Object[] { true }, new String[] { "boolean" });
assertTrue(o instanceof CompositeData[]);
assertEquals("No sequence", 0, ((CompositeData[]) o).length);
o = mbs.invoke(endpointName, "getDeferredAcknowledgementTotalCount", null, null);
assertTrue(o instanceof Integer);
assertEquals("No deferred acks", 0, o);
o = mbs.invoke(endpointName, "getQueuedMessageTotalCount", new Object[] { true }, new String[] { "boolean" });
assertTrue(o instanceof Integer);
assertEquals("No queued messages", 0, o);
}
use of javax.management.ObjectInstance in project karaf by apache.
the class EventAdminMBeanServerWrapper method getObjectInstance.
@Override
public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException {
Throwable error = null;
ObjectInstance result = null;
try {
return result = delegate.getObjectInstance(name);
} catch (Throwable e) {
error = e;
throw e;
} finally {
log(GET_OBJECT_INSTANCE, GET_OBJECT_INSTANCE_SIG, result, error, name);
}
}
use of javax.management.ObjectInstance in project neo4j-documentation by neo4j.
the class JmxBeanDocumenter method asDetails.
private void asDetails(ObjectName objectName, String name, PrintStream out) throws IntrospectionException, InstanceNotFoundException, ReflectionException {
Set<ObjectInstance> mBeans = mBeanServer.queryMBeans(objectName, null);
if (mBeans.size() != 1) {
throw new IllegalStateException(String.format("Unexpected size [%s] of query result for [%s].", mBeans.size(), objectName));
}
ObjectInstance bean = mBeans.iterator().next();
MBeanInfo info = mBeanServer.getMBeanInfo(objectName);
String description = info.getDescription().replace('\n', ' ');
String id = getId(name);
String name0 = objectName.getKeyProperty("name0");
if (name0 != null) {
name += "/" + name0;
}
List<MBeanAttributeInfo> attributes = Arrays.asList(info.getAttributes());
if (name.equalsIgnoreCase("Configuration")) {
attributes = attributes.stream().filter(it -> !it.getName().startsWith("unsupported")).collect(Collectors.toList());
}
out.printf("[[%s]]%n", id);
if (attributes.size() > 0) {
out.printf(".MBean %s (%s) Attributes%n", name, bean.getClassName());
attributesTable(description, out, attributes, false);
attributesTable(description, out, attributes, true);
out.println();
}
List<MBeanOperationInfo> operations = Arrays.asList(info.getOperations());
if (operations.size() > 0) {
out.printf(".MBean %s (%s) Operations%n", name, bean.getClassName());
operationsTable(out, operations, false);
operationsTable(out, operations, true);
out.println();
}
}
use of javax.management.ObjectInstance in project jersey by jersey.
the class MBeansTest method checkResourceMBean.
private void checkResourceMBean(String name) throws MalformedObjectNameException {
final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
final ObjectName objectName = new ObjectName("org.glassfish.jersey:type=myApplication,subType=Uris,resource=\"" + name + "\"");
ObjectInstance mbean = null;
try {
mbean = mBeanServer.getObjectInstance(objectName);
} catch (InstanceNotFoundException e) {
Assert.fail("Resource MBean name '" + name + "' not found.");
}
assertNotNull(mbean);
}
use of javax.management.ObjectInstance in project metrics by dropwizard.
the class JmxAttributeGaugeTest method registerMBean.
private static void registerMBean(ObjectName objectName) throws JMException {
ObjectInstance objectInstance = mBeanServer.registerMBean(new JmxTest(), objectName);
registeredMBeans.add(objectInstance.getObjectName());
}
Aggregations