List of usage examples for javax.management.openmbean OpenType getClassName
public String getClassName()
From source file:org.wso2.andes.management.ui.views.ViewUtility.java
/** * Populates the given composite with the CompositeData. Creates required widgets to hold the data types * @param toolkit// w w w.j a va 2s.c o m * @param parent * @param data CompositeData */ @SuppressWarnings("unchecked") private static void populateCompositeWithCompositeData(FormToolkit toolkit, Composite parent, CompositeData data) { Control[] oldControls = parent.getChildren(); for (int i = 0; i < oldControls.length; i++) { oldControls[i].dispose(); } Composite compositeHolder = toolkit.createComposite(parent, SWT.NONE); GridLayout layout = new GridLayout(4, false); layout.horizontalSpacing = 10; compositeHolder.setLayout(layout); compositeHolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // ItemNames in composite data List<String> itemNames = new ArrayList<String>(data.getCompositeType().keySet()); for (String itemName : itemNames) { OpenType itemType = data.getCompositeType().getType(itemName); Label keyLabel = toolkit.createLabel(compositeHolder, itemName, SWT.TRAIL); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1); layoutData.minimumWidth = 70; keyLabel.setLayoutData(layoutData); if (itemType.isArray()) { OpenType type = ((ArrayType) itemType).getElementOpenType(); // If Byte array and mimetype is text, convert to text string if (type.getClassName().equals(Byte.class.getName())) { String mimeType = null; String encoding = null; if (data.containsKey("MimeType")) { mimeType = (String) data.get("MimeType"); } if (data.containsKey("Encoding")) { encoding = (String) data.get("Encoding"); } if (encoding == null || encoding.length() == 0) { encoding = Charset.defaultCharset().name(); } if ("text/plain".equals(mimeType)) { convertByteArray(toolkit, compositeHolder, data, itemName, encoding); } else { handleBinaryMessageContent(toolkit, compositeHolder, data, itemName, encoding); } } // If array of any other supported type, show as a list of String array else if (SUPPORTED_ARRAY_DATATYPES.contains(type.getClassName())) { convertArrayItemForDisplay(compositeHolder, data, itemName); } else { setNotSupportedDataType(toolkit, compositeHolder); } } else if (itemType instanceof TabularType) { Composite composite = toolkit.createComposite(compositeHolder, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1)); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); createTabularDataHolder(toolkit, composite, (TabularDataSupport) data.get(itemName)); } else { Text valueText = toolkit.createText(compositeHolder, String.valueOf(data.get(itemName)), SWT.READ_ONLY | SWT.BORDER); valueText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1)); } } // layout the composite after creating new widgets. parent.layout(); }
From source file:org.jolokia.converter.object.ArrayTypeConverter.java
private Object[] createTargetArray(OpenType pElementType, int pLength) { if (pElementType instanceof SimpleType) { try {//www .ja va 2s.c o m SimpleType simpleType = (SimpleType) pElementType; Class elementClass = Class.forName(simpleType.getClassName()); return (Object[]) Array.newInstance(elementClass, pLength); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Can't find class " + pElementType.getClassName() + " for instantiating array: " + e.getMessage(), e); } } else if (pElementType instanceof CompositeType) { return new CompositeData[pLength]; } else { throw new UnsupportedOperationException("Unsupported array element type: " + pElementType); } }
From source file:com.appleframework.jmx.core.services.MBeanServiceImpl.java
/** * Expands a CompositeData object into individual attributes with the * naming convention://from w w w . j a v a 2s .c o m * <p> * attributeName.itemName * <p> * The items should conform to given "dataType" array. These individual * attributes are added to the <code>attributeList</code> * @param attributesList ObjectAttributeInfo instances are added to this * list */ private void handleCompositeData(ServerConnection connection, ObjectName objectName, ObjectAttributeInfo attrInfo, String[] dataTypes, List<ObjectAttributeInfo> attributesList) { CompositeType type = getCompositeType(connection, objectName, attrInfo); for (Iterator<?> it = type.keySet().iterator(); it.hasNext();) { String itemName = (String) it.next(); OpenType<?> itemType = type.getType(itemName); Class<?> itemTypeClass = getClass(itemType.getClassName(), this.getClass().getClassLoader()); for (int j = 0; j < dataTypes.length; j++) { Class<?> dataType = getClass(dataTypes[j], this.getClass().getClassLoader()); if (dataType.isAssignableFrom(itemTypeClass)) { attributesList .add(new ObjectAttributeInfo(attrInfo.getName() + COMPOSITE_ATTR_SEPARATOR + itemName, type.getDescription(itemName), itemType.getClassName(), false, true, false)); } } } }