List of usage examples for javax.management.openmbean OpenDataException toString
public String toString()
From source file:org.eclipse.gyrex.monitoring.internal.mbeans.MetricSetMBean.java
private void initialize() { final List<OpenMBeanAttributeInfoSupport> attributes = new ArrayList<OpenMBeanAttributeInfoSupport>(); final OpenMBeanConstructorInfoSupport[] constructors = new OpenMBeanConstructorInfoSupport[0]; final List<OpenMBeanOperationInfoSupport> operations = new ArrayList<OpenMBeanOperationInfoSupport>(1); final MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[0]; // common attribute attributes// www .ja v a 2 s .co m .add(new OpenMBeanAttributeInfoSupport(ID, "MetricSet Id", SimpleType.STRING, true, false, false)); attributes.add(new OpenMBeanAttributeInfoSupport(DESCRIPTION, "MetricSet Description", SimpleType.STRING, true, false, false)); // service property attributes try { final String[] propertyTypeNames = new String[] { "key", "value" }; propertyType = new CompositeType("property", "A property with name and value.", propertyTypeNames, new String[] { "Name", "Value" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING }); propertyTableType = new TabularType(PROPERTIES, "A lst of properties.", propertyType, new String[] { "key" }); attributes.add(new OpenMBeanAttributeInfoSupport(PROPERTIES, "MetricSet Properties", propertyTableType, true, false, false)); // pre-build service properties properties = new TabularDataSupport(propertyTableType); final String[] propertyKeys = reference.getPropertyKeys(); for (final String serviceProperty : propertyKeys) { if (serviceProperty.startsWith("gyrex.") || serviceProperty.equals(Constants.SERVICE_DESCRIPTION) || serviceProperty.equals(Constants.SERVICE_VENDOR)) { final Object value = reference.getProperty(serviceProperty); if (value == null) { continue; } if (isConvertibleToString(value.getClass())) { final Object[] values = { serviceProperty, String.valueOf(value) }; properties.put(new CompositeDataSupport(propertyType, propertyTypeNames, values)); } } } } catch (final OpenDataException e) { attributes.add(new OpenMBeanAttributeInfoSupport("propertiesError", "Exception occured while determining properties. " + e.toString(), SimpleType.STRING, true, false, false)); } // metrics final List<BaseMetric> metrics = metricSet.getMetrics(); metricTypesByAttributeName = new HashMap<String, CompositeType>(metrics.size()); metricByAttributeName = new HashMap<String, BaseMetric>(metrics.size()); for (final BaseMetric metric : metrics) { final String attributeName = StringUtils.removeStart(metric.getId(), metricSet.getId() + "."); try { final CompositeType type = getType(metric); if (type != null) { metricTypesByAttributeName.put(attributeName, type); metricByAttributeName.put(attributeName, metric); attributes.add(new OpenMBeanAttributeInfoSupport(attributeName, metric.getId(), type, true, false, false)); } } catch (final OpenDataException e) { attributes.add(new OpenMBeanAttributeInfoSupport(attributeName + "Error", "Exception occured while determining properties. " + e.toString(), SimpleType.STRING, true, false, false)); } } // reset operation for metric operations.add(new OpenMBeanOperationInfoSupport(RESET_STATS, "reset the metric statistics", null, SimpleType.VOID, MBeanOperationInfo.ACTION)); // build the info beanInfo = new OpenMBeanInfoSupport(this.getClass().getName(), metricSet.getDescription(), attributes.toArray(new OpenMBeanAttributeInfoSupport[attributes.size()]), constructors, operations.toArray(new OpenMBeanOperationInfoSupport[operations.size()]), notifications); }