List of usage examples for javax.management.openmbean CompositeData get
public Object get(String key);
From source file:com.zenoss.jmx.ValueExtractor.java
private static Object getData(CompositeData cData, String key) { _logger.debug("composite data is: " + cData); _logger.debug("getting '" + key + "' from composite data"); Object result = cData.get(key); _logger.debug("value from composite data is " + result); return result; }
From source file:org.red5.server.Client.java
/** * Allows for reconstruction via CompositeData. * * @param cd composite data//from w w w. j av a 2 s . c o m * @return Client class instance */ public static Client from(CompositeData cd) { Client instance = null; if (cd.containsKey("id")) { String id = (String) cd.get("id"); instance = new Client(id, null); instance.setCreationTime((Long) cd.get("creationTime")); instance.setAttribute(PERMISSIONS, cd.get(PERMISSIONS)); } if (cd.containsKey("attributes")) { AttributeStore attrs = (AttributeStore) cd.get("attributes"); instance.setAttributes(attrs); } return instance; }
From source file:com.proofpoint.jmx.JmxHttpModule.java
private static Map<String, Object> toMap(CompositeData data) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); // never trust JMX to do the right thing Set<String> keySet = data.getCompositeType().keySet(); if (keySet != null) { for (String key : keySet) { if (key != null) { Object value = data.get(key); if (value != null) { builder.put(key, value); }/*from ww w.ja v a2 s . c o m*/ } } } return builder.build(); }
From source file:org.red5.server.Context.java
/** * Allows for reconstruction via CompositeData. * //ww w . j a v a 2 s .c om * @param cd composite data * @return Context class instance */ public static Context from(CompositeData cd) { Context instance = new Context(); if (cd.containsKey("context") && cd.containsKey("contextPath")) { Object context = cd.get("context"); Object contextPath = cd.get("contextPath"); if (context != null && contextPath != null) { instance = new Context((ApplicationContext) context, (String) contextPath); } } return instance; }
From source file:org.apache.hadoop.hbase.util.JSONBean.java
private static void writeObject(final JsonGenerator jg, final boolean description, Object value) throws IOException { if (value == null) { jg.writeNull();/* w w w. ja v a 2 s . c o m*/ } else { Class<?> c = value.getClass(); if (c.isArray()) { jg.writeStartArray(); int len = Array.getLength(value); for (int j = 0; j < len; j++) { Object item = Array.get(value, j); writeObject(jg, description, item); } jg.writeEndArray(); } else if (value instanceof Number) { Number n = (Number) value; jg.writeNumber(n.toString()); } else if (value instanceof Boolean) { Boolean b = (Boolean) value; jg.writeBoolean(b); } else if (value instanceof CompositeData) { CompositeData cds = (CompositeData) value; CompositeType comp = cds.getCompositeType(); Set<String> keys = comp.keySet(); jg.writeStartObject(); for (String key : keys) { writeAttribute(jg, key, null, cds.get(key)); } jg.writeEndObject(); } else if (value instanceof TabularData) { TabularData tds = (TabularData) value; jg.writeStartArray(); for (Object entry : tds.values()) { writeObject(jg, description, entry); } jg.writeEndArray(); } else { jg.writeString(value.toString()); } } }
From source file:de.jgoldhammer.alfresco.jscript.jmx.JmxDumpUtil.java
/** * Dumps the details of a single CompositeData object. * // w w w. jav a2 s .c om * @param composite * the composite object * @param out * PrintWriter to write the output to * @param nestLevel * the nesting level * @throws IOException * Signals that an I/O exception has occurred. */ @SuppressWarnings("unchecked") public static void printCompositeInfo(CompositeData composite, PrintWriter out, int nestLevel) throws IOException { Map<String, Object> attributes = new TreeMap<String, Object>(); for (String key : (Set<String>) composite.getCompositeType().keySet()) { Object value; try { value = composite.get(key); } catch (Exception e) { value = JmxDumpUtil.UNREADABLE_VALUE; } attributes.put(key, value); } tabulate(JmxDumpUtil.NAME_HEADER, JmxDumpUtil.VALUE_HEADER, attributes, out, nestLevel); }
From source file:org.wso2.andes.management.ui.views.ViewUtility.java
/** * Creates a List widget for displaying array of strings * @param compositeHolder/*from ww w . j a va 2 s. c o m*/ * @param data - containing the array item value * @param itemName - item name */ private static void convertArrayItemForDisplay(Composite compositeHolder, CompositeData data, String itemName) { Object[] arrayItems = (Object[]) data.get(itemName); String[] items = new String[arrayItems.length]; for (int i = 0; i < arrayItems.length; i++) { items[i] = String.valueOf(arrayItems[i]); } org.eclipse.swt.widgets.List list = new org.eclipse.swt.widgets.List(compositeHolder, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); list.setItems(items); //list.setBackground(compositeHolder.getBackground()); list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); }
From source file:org.wso2.andes.management.ui.views.ViewUtility.java
private static void convertByteArray(FormToolkit toolkit, Composite compositeHolder, CompositeData data, String itemName, String encoding) { Byte[] arrayItems = (Byte[]) data.get(itemName); byte[] byteArray = new byte[arrayItems.length]; for (int i = 0; i < arrayItems.length; i++) { byteArray[i] = arrayItems[i];//from w ww .ja v a2 s.c o m } try { String textMessage = new String(byteArray, encoding); Text valueText = toolkit.createText(compositeHolder, textMessage, SWT.READ_ONLY | SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); gridData.heightHint = 300; valueText.setLayoutData(gridData); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.jkoolcloud.tnt4j.streams.custom.kafka.interceptors.reporters.metrics.MetricsReporter.java
protected static PropertySnapshot processAttrValue(PropertySnapshot snapshot, PropertyNameBuilder propName, Object value) {/*from ww w.j ava2 s.c om*/ if (value instanceof CompositeData) { CompositeData cdata = (CompositeData) value; Set<String> keys = cdata.getCompositeType().keySet(); boolean isKVSet = keys.contains("key") && keys.contains("value"); // NON-NLS for (String key : keys) { Object cVal = cdata.get(key); if (isKVSet && "key".equals(key)) { // NON-NLS propName.append(Utils.toString(cVal)); } else if (isKVSet && "value".equals(key)) { // NON-NLS processAttrValue(snapshot, propName, cVal); } else { processAttrValue(snapshot, propName.append(key), cVal); } } propName.popLevel(); } else if (value instanceof TabularData) { TabularData tData = (TabularData) value; Collection<?> values = tData.values(); int row = 0; for (Object tVal : values) { processAttrValue(snapshot, tVal instanceof CompositeData ? propName : propName.append(padNumber(++row)), tVal); } propName.popLevel(); } else { snapshot.add(propName.propString(), value); } return snapshot; }
From source file:org.osgi.jmx.codec.OSGiAuthorization.java
public OSGiAuthorization(CompositeData data) { if (data != null) { this.name = (String) data.get(UserManagerMBean.USER_NAME); this.roles = (String[]) data.get(UserManagerMBean.ROLE_NAMES); }//from w w w . ja va 2 s . c o m }