public Iterable<Result> fetchResults(MBeanServerConnection mbeanServer, ObjectName queryName) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException { ObjectInstance oi = mbeanServer.getObjectInstance(queryName); List<String> attributes; if (attr.isEmpty()) { attributes = new ArrayList<>(); MBeanInfo info = mbeanServer.getMBeanInfo(queryName); for (MBeanAttributeInfo attrInfo : info.getAttributes()) { attributes.add(attrInfo.getName()); } } else { attributes = attr; } try { if (!attributes.isEmpty()) { logger.debug("Executing queryName [{}] from query [{}]", queryName.getCanonicalName(), this); AttributeList al = mbeanServer.getAttributes(queryName, attributes.toArray(new String[attributes.size()])); return new JmxResultProcessor(this, oi, al.asList(), oi.getClassName(), queryName.getDomain()).getResults(); } } catch (UnmarshalException ue) { if ((ue.getCause() != null) && (ue.getCause() instanceof ClassNotFoundException)) { logger.debug("Bad unmarshall, continuing. This is probably ok and due to something like this: " + "http://ehcache.org/xref/net/sf/ehcache/distribution/RMICacheManagerPeerListener.html#52", ue.getMessage()); } else { throw ue; } } return ImmutableList.of(); }
/** * Checks whether an MBean implements notification support classes or not * * @return if this MBean can be a notification broadcaster */ public boolean hasNotificationSupport(ObjectName objectName) { try { if (!isRegistered(objectName)) { return false; } ObjectInstance instance = mbeanServer.getObjectInstance(objectName); String className = instance.getClassName(); Class cls = ClassLoadUtil.classFromName(className); Type[] intfTyps = cls.getGenericInterfaces(); for (Type intfTyp1 : intfTyps) { Class intfTyp = (Class) intfTyp1; if (intfTyp.equals(NotificationEmitter.class)) { return true; } } Class superClassType = (Class) cls.getGenericSuperclass(); if (superClassType != null && superClassType.equals(NotificationBroadcasterSupport.class)) { return true; } } catch (InstanceNotFoundException | ClassNotFoundException e) { throw new ManagementException(e); } return false; }
while (iterator.hasNext()) { ObjectInstance instance = iterator.next(); System.out.println("Class Name: " + instance.getClassName()); System.out.println("Object Name: " + instance.getObjectName());
while (iterator.hasNext()) { ObjectInstance instance = iterator.next(); LOG.warn("Class Name: " + instance.getClassName()); LOG.warn("Object Name: " + instance.getObjectName());
try { instance = mbeanServer.getObjectInstance(objectName); String className = instance.getClassName(); Class cls = ClassLoadUtil.classFromName(className); Type[] intfTyps = cls.getGenericInterfaces();
try { instance = mbeanServer.getObjectInstance(objectName); String className = instance.getClassName(); Class cls = ClassLoadUtil.classFromName(className); Type[] intfTyps = cls.getGenericInterfaces();
protected boolean filterMBeans(ObjectInstance obj) { String className = obj.getClassName(); return className.equals(QueueView.class.getName()) || className.equals(TopicView.class.getName()); }
public static void unregisterMXBean(ObjectInstance bean) { logger.info("Unregistering {} with JMX", bean.getClassName()); try { if (ManagementFactory.getPlatformMBeanServer().isRegistered(bean.getObjectName())) { ManagementFactory.getPlatformMBeanServer().unregisterMBean(bean.getObjectName()); } } catch (Exception e) { logger.warn("Unable to unregister mbean {}: {}", bean.getClassName(), e); } }
protected boolean filterMBeans(ObjectInstance obj) { String className = obj.getClassName(); return className.equals(QueueView.class.getName()) || className.equals(TopicView.class.getName()); }
protected boolean filterMBeans(ObjectInstance obj) { String className = obj.getClassName(); return className.equals(QueueView.class.getName()) || className.equals(TopicView.class.getName()); }
/** * Constructs a <code>ObjectInstance</code> instance based upon a * <code>javax.management.ObjectInstance</code> instance. * * @param objectInstance The JMX <code>ObjectInstance</code> instance to base this instance on. */ public ObjectInstance(javax.management.ObjectInstance objectInstance) { objectName = new ObjectName(objectInstance.getObjectName()); className = objectInstance.getClassName(); }
/** * Constructs a <code>ObjectInstance</code> instance based upon a * <code>javax.management.ObjectInstance</code> instance. * * @param objectInstance The JMX <code>ObjectInstance</code> instance to base this instance on. */ public ObjectInstance(javax.management.ObjectInstance objectInstance) { objectName = new ObjectName(objectInstance.getObjectName()); className = objectInstance.getClassName(); }
/** * Checks, is mbean required to be registered as producer * @param mBean mbean to check requirements * @return true - mbean need to be registered * false - no */ private static boolean isMBeanRequired(final ObjectInstance mBean) { final String domain = mBean.getObjectName().getDomain(); final String className = mBean.getClassName(); return !domain.startsWith("moskito.") // we have to skip all the moskito internal MBeans && conf.isMBeanRequired(domain, className); }
/** * Constructs a <code>ObjectInstance</code> instance based upon a * <code>javax.management.ObjectInstance</code> instance. * * @param objectInstance The JMX <code>ObjectInstance</code> instance to base this instance on. */ public ObjectInstance(javax.management.ObjectInstance objectInstance) { objectName = new ObjectName(objectInstance.getObjectName()); className = objectInstance.getClassName(); }
public UPNPMBeanDevice buildUPNPMBean( MBeanServer server, ObjectInstance objectInstance, MBeanInfo info ) throws IOException { String descr = info.getDescription(); if ( descr == null ) descr = "No MBean description available"; String beanName = objectInstance.getObjectName().getKeyProperty( "name" ); if ( beanName == null ) beanName = "No MBean name available"; UPNPMBeanDevice dv = new UPNPMBeanDevice( domain, objectInstance.getClassName(), 1, vendor, descr, beanName, objectInstance.getObjectName().toString() ); dv.addService( info, objectInstance.getObjectName(), server, Integer.toString( info.getClassName().hashCode() ), info.getClassName(), 1 ); return dv; }
@Override public void exec(CLIContext ctx, String[] args) throws Exception { final ObjectName on = new ObjectName("Q2:type=qbean,service=*"); MBeanServer server = ctx.getCLI().getQ2().getMBeanServer(); Set<ObjectInstance> b = server.queryMBeans(on, null); Iterator<ObjectInstance> it = b.iterator(); while (it.hasNext()) { ObjectInstance instance = it.next(); int status = (Integer) server.getAttribute(instance.getObjectName(), "State"); if (status == QBean.STARTED) { ctx.println(instance.getObjectName().getKeyProperty("service") + "\t\t" + instance.getClassName()); } } }
public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException { ObjectInstance oi = registry.getObjectInstance(name); checkMBeanPermission(oi.getClassName(), null, name, "getObjectInstance"); return oi; }
public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException { ObjectInstance oi = registry.getObjectInstance(name); checkMBeanPermission(oi.getClassName(), null, name, "getObjectInstance"); return oi; }
public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException { ObjectInstance instance = (ObjectInstance)value; context.startElement(name, attributes); context.serialize(OBJECTNAME_QNAME, null, instance.getObjectName()); context.serialize(CLASS_NAME_QNAME, null, instance.getClassName()); context.endElement(); }
private void testStatisticsMBeanRegistered(String suffix) throws Exception { String objectName = JMXRegistrar.buildMBeanName( StatisticsInfoMBean.STATISTICS_MBEAN_OBJECT_NAME, suffix ); ObjectName statisticsBeanObjectName = new ObjectName( objectName ); ObjectInstance mBean = null; try { mBean = mbeanServer.getObjectInstance( statisticsBeanObjectName ); } catch (InstanceNotFoundException e) { fail( "The mbean " + statisticsBeanObjectName.getCanonicalName() + " should be registered with the MBean server " ); } assertEquals( JMXRegistrar.StatisticsInfo.class.getName(), mBean.getClassName() ); }