Search in sources :

Example 46 with TabularData

use of javax.management.openmbean.TabularData in project jdk8u_jdk by JetBrains.

the class TabularDataOrderTest method makeTable.

private static TabularData makeTable() throws OpenDataException {
    TabularData td = new TabularDataSupport(tt);
    for (Map.Entry<String, Integer> entry : stringToValue.entrySet()) {
        CompositeData cd = new CompositeDataSupport(ct, new String[] { "name", "int" }, new Object[] { entry.getKey(), entry.getValue() });
        td.put(cd);
    }
    return td;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TabularData(javax.management.openmbean.TabularData)

Example 47 with TabularData

use of javax.management.openmbean.TabularData in project jdk8u_jdk by JetBrains.

the class ValidateOpenTypes method checkMap.

private static void checkMap() throws Exception {
    // Add new system properties
    System.setProperty(KEY1, VALUE1);
    System.setProperty(KEY2, VALUE2);
    TabularData props1 = (TabularData) server.getAttribute(runtime, "SystemProperties");
    String value1 = getProperty(props1, KEY1);
    if (value1 == null || !value1.equals(VALUE1)) {
        throw new RuntimeException("TEST FAILED: " + KEY1 + " property found" + " with value = " + value1 + " but expected to be " + VALUE1);
    }
    String value2 = getProperty(props1, KEY2);
    if (value2 == null || !value2.equals(VALUE2)) {
        throw new RuntimeException("TEST FAILED: " + KEY2 + " property found" + " with value = " + value2 + " but expected to be " + VALUE2);
    }
    String value3 = getProperty(props1, KEY3);
    if (value3 != null) {
        throw new RuntimeException("TEST FAILED: " + KEY3 + " property found" + " but should not exist");
    }
}
Also used : TabularData(javax.management.openmbean.TabularData)

Example 48 with TabularData

use of javax.management.openmbean.TabularData in project tdi-studio-se by Talend.

the class AttributeParser method refreshTabularData.

/**
     * Refreshes the tabular data.
     * 
     * @param node
     *            The attribute node
     */
private void refreshTabularData(AttributeNode node) {
    List<AttributeNode> children = new ArrayList<AttributeNode>();
    TabularData tabularData = (TabularData) node.getValue();
    for (Object keyList : tabularData.keySet()) {
        @SuppressWarnings("unchecked") Object[] keys = ((List<Object>) keyList).toArray(new Object[0]);
        AttributeNode attribute = null;
        for (AttributeNode child : node.getChildren()) {
            if (child.getName().equals(String.valueOf(keys[0]))) {
                attribute = child;
                attribute.setValue(tabularData.get(keys));
                break;
            }
        }
        if (attribute == null) {
            attribute = new AttributeNode(String.valueOf(keys[0]), node, tabularData.get(keys));
        }
        children.add(attribute);
    }
    node.removeChildren();
    for (AttributeNode child : children) {
        node.addChild(child);
        refreshAttribute(child);
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TabularData(javax.management.openmbean.TabularData)

Example 49 with TabularData

use of javax.management.openmbean.TabularData in project tdi-studio-se by Talend.

the class DumpHprofAction method getInitialFileName.

/**
     * Gets the initial file name.
     * 
     * @param jvm The active JVM
     * @return The file name, or <tt>null</tt> if file name is specified
     * @throws JvmCoreException
     */
String getInitialFileName(IActiveJvm jvm) throws JvmCoreException {
    ObjectName objectName;
    try {
        objectName = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
    } catch (MalformedObjectNameException e) {
        throw new JvmCoreException(IStatus.ERROR, e.getMessage(), e);
    } catch (NullPointerException e) {
        throw new JvmCoreException(IStatus.ERROR, e.getMessage(), e);
    }
    //$NON-NLS-1$
    TabularData initialName = (TabularData) jvm.getMBeanServer().getAttribute(objectName, "SystemProperties");
    //$NON-NLS-1$
    CompositeData compisiteData = initialName.get(new Object[] { "user.home" });
    String home = compisiteData.values().toArray(new String[0])[1];
    StringBuffer initialFileName = new StringBuffer(home);
    initialFileName.append(File.separator).append(new Date().getTime()).append('.').append(SnapshotType.Hprof.getExtension());
    return initialFileName.toString();
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CompositeData(javax.management.openmbean.CompositeData) Date(java.util.Date) ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException) TabularData(javax.management.openmbean.TabularData)

Example 50 with TabularData

use of javax.management.openmbean.TabularData in project tdi-studio-se by Talend.

the class AttributeContentProvider method addAttributeItems.

/**
     * Adds the attribute to the given list.
     * 
     * @param parent The parent attribute
     * @param value The value
     */
private void addAttributeItems(AttributeNode parent, Object value) {
    if (value instanceof CompositeData) {
        CompositeData compositeData = (CompositeData) value;
        CompositeType type = compositeData.getCompositeType();
        for (String key : type.keySet()) {
            AttributeNode attribute = new AttributeNode(key, parent);
            parent.addChild(attribute);
            addAttributeItems(attribute, compositeData.get(key));
        }
    } else if (value instanceof TabularData) {
        TabularData tabularData = (TabularData) value;
        for (Object keyList : tabularData.keySet()) {
            @SuppressWarnings("unchecked") Object[] keys = ((List<Object>) keyList).toArray(new Object[0]);
            AttributeNode attribute = new AttributeNode(String.valueOf(keys[0]), parent);
            parent.addChild(attribute);
            addAttributeItems(attribute, tabularData.get(keys));
        }
    } else if (value instanceof Long || value instanceof Integer || value instanceof Double) {
        parent.setRgb(getRGB(parent.getQualifiedName()));
        parent.setValidLeaf(true);
    }
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

Aggregations

TabularData (javax.management.openmbean.TabularData)183 CompositeData (javax.management.openmbean.CompositeData)91 TabularDataSupport (javax.management.openmbean.TabularDataSupport)67 ObjectName (javax.management.ObjectName)54 MBeanServer (javax.management.MBeanServer)50 CompositeType (javax.management.openmbean.CompositeType)47 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)43 Test (org.junit.Test)38 Map (java.util.Map)28 ArrayList (java.util.ArrayList)23 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)21 HashMap (java.util.HashMap)20 TabularType (javax.management.openmbean.TabularType)17 Bundle (org.osgi.framework.Bundle)17 AbstractIntegrationTest (org.apache.aries.jmx.AbstractIntegrationTest)15 Collection (java.util.Collection)13 IOException (java.io.IOException)11 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)9 List (java.util.List)8 ServiceReference (org.osgi.framework.ServiceReference)8