示例#1
0
  /**
   * Gets the stack trace elements.
   *
   * @param stackTrace The stack trace in composite data array
   * @return The stack trace elements
   */
  private StackTraceElement[] getStackTrace(CompositeData[] stackTrace) {
    List<StackTraceElement> list = new ArrayList<StackTraceElement>();
    for (CompositeData compositeData : stackTrace) {
      Object className = compositeData.get(CLASS_NAME);
      Object fileName = compositeData.get(FILE_NAME);
      Object lineNumber = compositeData.get(LINE_NUMBER);
      Object metohdName = compositeData.get(METHOD_NAME);
      Object nativeMethod = compositeData.get(NATIVE_METHOD);

      if ((className instanceof String)
          && (className instanceof String)
          && (fileName instanceof String)
          && (lineNumber instanceof Integer)
          && (metohdName instanceof String)
          && (nativeMethod instanceof Boolean)) {
        list.add(
            new StackTraceElement(
                (String) className,
                (String) metohdName,
                (String) fileName,
                (Boolean) nativeMethod ? -2 : (Integer) lineNumber));
      }
    }
    return list.toArray(new StackTraceElement[list.size()]);
  }
  /**
   * Adds the attribute to the given list.
   *
   * @param mBeanAttributes The attributes
   * @param root The root attribute
   * @param value The value
   */
  private void addAttributeRoots(
      List<AttributeNode> mBeanAttributes, AttributeNode root, Object value) {
    if (value instanceof CompositeData) {
      mBeanAttributes.add(root);
      CompositeData compositeData = (CompositeData) value;
      CompositeType type = compositeData.getCompositeType();
      for (String key : type.keySet()) {
        AttributeNode attribute = new AttributeNode(key, root);

        root.addChild(attribute);
        addAttributeItems(attribute, compositeData.get(key));
      }
    } else if (value instanceof TabularData) {
      mBeanAttributes.add(root);
      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]), root);

        root.addChild(attribute);
        addAttributeItems(attribute, tabularData.get(keys));
      }
    } else if (value instanceof Long || value instanceof Integer || value instanceof Double) {
      root.setValidLeaf(true);
      root.setRgb(getRGB(root.getQualifiedName()));
      mBeanAttributes.add(root);
    }
  }
  @Test
  public void testProperPropertyValueTypeExpressionConverter() throws Exception {
    ModelNode description = createDescription(ModelType.PROPERTY, ModelType.INT);
    TypeConverter converter =
        TypeConverters.createLegacyTypeConverters(true).getConverter(description);

    CompositeType type = assertCast(CompositeType.class, converter.getOpenType());
    Set<String> keys = type.keySet();
    Assert.assertEquals(2, keys.size());
    assertCompositeType(type, "name", String.class.getName(), "The property name");
    assertCompositeType(type, "value", Integer.class.getName(), "The property value");

    CompositeData data =
        assertCast(
            CompositeData.class,
            converter.fromModelNode(
                new ModelNode().setExpression("one", "${this.should.not.exist.!!!!!:1}")));
    Assert.assertEquals(type, data.getCompositeType());
    Assert.assertEquals("one", data.get("name"));
    Assert.assertEquals(1, data.get("value"));

    data =
        new CompositeDataSupport(
            type, new String[] {"name", "value"}, new Object[] {"two", Integer.valueOf(2)});
    ModelNode newNode = converter.toModelNode(data);
    Assert.assertEquals(ModelType.PROPERTY, newNode.getType());
    Assert.assertEquals(new ModelNode().set("two", 2), newNode);

    assertToArray(converter, data);
  }
  @Test
  public void testProperPropertyTypeConverter() throws Exception {
    ModelNode description = createDescription(ModelType.PROPERTY);
    TypeConverter converter =
        TypeConverters.createLegacyTypeConverters(true).getConverter(description);

    CompositeType type = assertCast(CompositeType.class, converter.getOpenType());
    Set<String> keys = type.keySet();
    Assert.assertEquals(2, keys.size());
    assertCompositeType(type, "name", String.class.getName(), "The property name");
    assertCompositeType(type, "value", String.class.getName(), "The property value");

    CompositeData data =
        assertCast(CompositeData.class, converter.fromModelNode(new ModelNode().set("one", "uno")));
    Assert.assertEquals(type, data.getCompositeType());
    Assert.assertEquals("one", data.get("name"));
    Assert.assertEquals("uno", data.get("value"));

    data =
        new CompositeDataSupport(type, new String[] {"name", "value"}, new String[] {"two", "dos"});
    ModelNode newNode = converter.toModelNode(data);
    Assert.assertEquals(ModelType.PROPERTY, newNode.getType());
    Assert.assertEquals(new ModelNode().set("two", "dos"), newNode);

    assertToArray(converter, data);
  }
  @Test
  public void testJsonObjectInComplexValue() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT);
    ModelNode complexValueType = new ModelNode();
    complexValueType.get("value", DESCRIPTION).set("A  value");
    complexValueType.get("value", TYPE).set(ModelType.OBJECT);
    description.get(VALUE_TYPE).set(complexValueType);

    TypeConverter converter = getConverter(description);

    CompositeType type = assertCast(CompositeType.class, converter.getOpenType());
    Set<String> keys = type.keySet();
    Assert.assertEquals(1, keys.size());

    Assert.assertEquals(SimpleType.STRING, type.getType("value"));

    ModelNode node = new ModelNode();
    node.get("value", "long").set(1L);
    node.get("value", "string").set("test");

    CompositeData data = assertCast(CompositeData.class, converter.fromModelNode(node));
    Assert.assertEquals(type, data.getCompositeType());
    Assert.assertEquals(
        ModelNode.fromJSONString(node.toJSONString(false)), converter.toModelNode(data));
  }
示例#6
0
  /**
   * Gets the SWT resource elements.
   *
   * @param resourceComposites The resources in composite data array
   * @return The SWT resource elements
   */
  private Collection<ISWTResourceElement> getSWTResourceElements(
      CompositeData[] resourceComposites) {
    Map<String, ISWTResourceElement> newResourceElements =
        new HashMap<String, ISWTResourceElement>();
    for (CompositeData compositeData : resourceComposites) {
      Object name = compositeData.get(NAME);
      if (!(name instanceof String)) {
        continue;
      }

      ISWTResourceElement element = resourceElements.get(name);
      if (element == null) {
        Object stackTraceElements = compositeData.get(STACK_TRACE);
        if (!(stackTraceElements instanceof CompositeData[])) {
          continue;
        }
        element =
            new SWTResourceElement(
                (String) name, getStackTrace((CompositeData[]) stackTraceElements));
      }

      newResourceElements.put((String) name, element);
    }
    resourceElements = newResourceElements;
    return resourceElements.values();
  }
示例#7
0
 /**
  * Recursively extracts simple numeric values from composite data objects. The map {@code values}
  * will be populated with a path to the value as the key and the simple object as the value.
  */
 private void extractValues(String path, Map<String, Object> values, CompositeData obj) {
   for (String key : obj.getCompositeType().keySet()) {
     String newPath = (path == null) ? key : path + "." + key;
     Object value = obj.get(key);
     if (value instanceof CompositeData) {
       extractValues(newPath, values, (CompositeData) value);
     } else if (value != null) {
       values.put(newPath, value);
     }
   }
 }
示例#8
0
 private static String getProperty(TabularData td, String propName) {
   CompositeData cd = td.get(new Object[] {propName});
   if (cd != null) {
     String key = (String) cd.get("key");
     if (!propName.equals(key)) {
       throw new RuntimeException(
           "TEST FAILED: " + key + " property found" + " but expected to be " + propName);
     }
     return (String) cd.get("value");
   }
   return null;
 }
 private String format(CompositeData compositeData) {
   StringBuffer stackTraceElement = new StringBuffer("    ");
   stackTraceElement.append((String) compositeData.get("className"));
   stackTraceElement.append('.');
   stackTraceElement.append(compositeData.get("methodName"));
   stackTraceElement.append('(');
   Boolean nativeMethod = (Boolean) compositeData.get("nativeMethod");
   if (!nativeMethod.booleanValue()) {
     stackTraceElement.append(compositeData.get("fileName"));
     stackTraceElement.append(':');
     stackTraceElement.append(compositeData.get("lineNumber"));
   } else {
     stackTraceElement.append("Native Method");
   }
   stackTraceElement.append(')');
   return stackTraceElement.toString();
 }
 /*     */ public static void validateCompositeData(CompositeData paramCompositeData) /*     */ {
   /* 122 */ if (paramCompositeData == null) {
     /* 123 */ throw new NullPointerException("Null CompositeData");
     /*     */ }
   /*     */
   /* 126 */ if (!isTypeMatched(vmOptionCompositeType, paramCompositeData.getCompositeType()))
     /* 127 */ throw new IllegalArgumentException("Unexpected composite type for VMOption");
   /*     */ }
  /**
   * Validate if the input CompositeData has the expected CompositeType (i.e. contain all attributes
   * with expected names and types).
   */
  public static void validateCompositeData(CompositeData cd) {
    if (cd == null) {
      throw new NullPointerException("Null CompositeData");
    }

    if (!isTypeMatched(stackTraceElementCompositeType, cd.getCompositeType())) {
      throw new IllegalArgumentException("Unexpected composite type for StackTraceElement");
    }
  }
  private Object unmarshall(Object value) {
    if (value instanceof ObjectName) {
      ObjectName name = (ObjectName) value;

      return new MBean(_server, name);
    } else if (value instanceof ObjectName[]) {
      ObjectName[] names = (ObjectName[]) value;

      MBean[] mbeans = new MBean[names.length];

      for (int i = 0; i < names.length; i++) mbeans[i] = new MBean(_server, names[i]);

      return mbeans;
    } else if (value instanceof CompositeData) {
      CompositeData compositeValue = (CompositeData) value;

      CompositeType type = compositeValue.getCompositeType();

      if (type != null) {
        String typeName = type.getTypeName();

        try {
          ClassLoader loader = Thread.currentThread().getContextClassLoader();

          Class typeClass = Class.forName(typeName, false, loader);

          Method from = typeClass.getMethod("from", new Class[] {CompositeData.class});

          if (from != null) return from.invoke(null, compositeValue);
        } catch (Exception e) {
          log.log(Level.FINER, e.toString(), e);
        }
      }

      return new CompositeDataBean(compositeValue);
    } else return value;
  }
示例#13
0
  public Object getValue(String serviceURL, String object, String attribute, String key)
      throws Exception {
    JMXConnector jmxc = null;
    try {
      // pega conector do pool
      jmxc = (JMXConnector) connectionPool.borrowObject(serviceURL);
      MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

      ObjectName name = new ObjectName(object);
      Object value = mbsc.getAttribute(name, attribute);
      if (value instanceof CompositeData) {
        if (key == null) {
          logger.warn(
              "Attribute {}:{} is CompositeData but resource did not define a 'compositeDataKey'",
              object,
              attribute);
          value = null;
        } else {
          CompositeData data = (CompositeData) value;
          value = data.get(key);
        }
      }
      return value;

    } catch (Exception e) {
      if (null != jmxc) {
        connectionPool.invalidateObject(serviceURL, jmxc);
        jmxc = null;
      }
      throw e;

    } finally {
      if (null != jmxc) {
        connectionPool.returnObject(serviceURL, jmxc);
      }
    }
  }
示例#14
0
  /**
   * 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);
    }

    TabularData initialName =
        (TabularData)
            jvm.getMBeanServer().getAttribute(objectName, "SystemProperties"); // $NON-NLS-1$
    CompositeData compisiteData = initialName.get(new Object[] {"user.home"}); // $NON-NLS-1$
    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();
  }
示例#15
0
 /**
  * Allows for reconstruction via CompositeData.
  *
  * @param cd composite data
  * @return Scope class instance
  */
 public static Scope from(CompositeData cd) {
   IScope parent = null;
   ScopeType type = ScopeType.UNDEFINED;
   String name = null;
   boolean persistent = false;
   if (cd.containsKey("parent")) {
     parent = (IScope) cd.get("parent");
   }
   if (cd.containsKey("type")) {
     type = (ScopeType) cd.get("type");
   }
   if (cd.containsKey("name")) {
     name = (String) cd.get("name");
   }
   if (cd.containsKey("persistent")) {
     persistent = (Boolean) cd.get("persistent");
   }
   return new Scope(new Builder(parent, type, name, persistent));
 }
示例#16
0
文件: Client.java 项目: Juliens/red5
 /**
  * Allows for reconstruction via CompositeData.
  *
  * @param cd composite data
  * @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;
 }
  @Test
  public void testComplexValue() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT);
    ModelNode complexValueType = new ModelNode();
    complexValueType.get("int-value", DESCRIPTION).set("An int value");
    complexValueType.get("int-value", TYPE).set(ModelType.INT);
    complexValueType.get("bigint-value", DESCRIPTION).set("A biginteger value");
    complexValueType.get("bigint-value", TYPE).set(ModelType.BIG_INTEGER);
    complexValueType.get("bigdecimal-value", DESCRIPTION).set("A bigdecimal value");
    complexValueType.get("bigdecimal-value", TYPE).set(ModelType.BIG_DECIMAL);
    complexValueType.get("boolean-value", DESCRIPTION).set("A boolean value");
    complexValueType.get("boolean-value", TYPE).set(ModelType.BOOLEAN);
    complexValueType.get("bytes-value", DESCRIPTION).set("A bytes value");
    complexValueType.get("bytes-value", TYPE).set(ModelType.BYTES);
    complexValueType.get("double-value", DESCRIPTION).set("A double value");
    complexValueType.get("double-value", TYPE).set(ModelType.DOUBLE);
    complexValueType.get("string-value", DESCRIPTION).set("A string value");
    complexValueType.get("string-value", TYPE).set(ModelType.STRING);
    complexValueType.get("long-value", DESCRIPTION).set("A long value");
    complexValueType.get("long-value", TYPE).set(ModelType.LONG);
    complexValueType.get("type-value", DESCRIPTION).set("A type value");
    complexValueType.get("type-value", TYPE).set(ModelType.TYPE);
    complexValueType.get("list-int-value", DESCRIPTION).set("An int list value");
    complexValueType.get("list-int-value", TYPE).set(ModelType.LIST);
    complexValueType.get("list-int-value", VALUE_TYPE).set(ModelType.INT);
    complexValueType.get("map-int-value", DESCRIPTION).set("An int map value");
    complexValueType.get("map-int-value", TYPE).set(ModelType.OBJECT);
    complexValueType.get("map-int-value", VALUE_TYPE).set(ModelType.INT);
    description.get(VALUE_TYPE).set(complexValueType);

    TypeConverter converter = getConverter(description);

    CompositeType type = assertCast(CompositeType.class, converter.getOpenType());
    Set<String> keys = type.keySet();
    Assert.assertEquals(11, keys.size());
    assertCompositeType(type, "int-value", Integer.class.getName(), "An int value");
    assertCompositeType(type, "bigint-value", BigInteger.class.getName(), "A biginteger value");
    assertCompositeType(type, "bigdecimal-value", BigDecimal.class.getName(), "A bigdecimal value");
    assertCompositeType(type, "boolean-value", Boolean.class.getName(), "A boolean value");
    assertCompositeType(type, "bytes-value", byte[].class.getName(), "A bytes value");
    assertCompositeType(type, "double-value", Double.class.getName(), "A double value");
    assertCompositeType(type, "string-value", String.class.getName(), "A string value");
    assertCompositeType(type, "long-value", Long.class.getName(), "A long value");
    assertCompositeType(type, "type-value", String.class.getName(), "A type value");
    assertCompositeType(type, "list-int-value", Integer[].class.getName(), "An int list value");
    assertMapType(
        assertCast(
            TabularType.class,
            assertCompositeType(
                type, "map-int-value", TabularType.class.getName(), "An int map value", false)),
        SimpleType.STRING,
        SimpleType.INTEGER);

    ModelNode node = new ModelNode();
    node.get("int-value").set(1);
    node.get("bigint-value").set(BigInteger.valueOf(2));
    node.get("bigdecimal-value").set(BigDecimal.valueOf(3));
    node.get("boolean-value").set(Boolean.TRUE);
    node.get("bytes-value").set(new byte[] {4, 5});
    node.get("double-value").set(Double.valueOf(6));
    node.get("string-value").set("Seven");
    node.get("long-value").set(Long.valueOf(8));
    node.get("type-value").set(ModelType.INT);
    node.get("list-int-value").add(9);
    node.get("list-int-value").add(10);
    node.get("map-int-value", "one").set(11);
    node.get("map-int-value", "two").set(12);

    CompositeData data = assertCast(CompositeData.class, converter.fromModelNode(node));
    Assert.assertEquals(type, data.getCompositeType());
    Assert.assertEquals(node, converter.toModelNode(data));

    // Another test testing missing data in fromModelNode();
    node = new ModelNode();
    node.get("int-value").set(1);
    data = assertCast(CompositeData.class, converter.fromModelNode(node));
    Assert.assertEquals(node, converter.toModelNode(data));

    // And another test testing missing data in fromModelNode();
    node = new ModelNode();
    node.get("boolean-value").set(true);
    data = assertCast(CompositeData.class, converter.fromModelNode(node));
    Assert.assertEquals(node, converter.toModelNode(data));
  }
示例#18
0
 /**
  * create result as property with name from property prefix When result is an array and
  * isSeparateArrayResults is true, resultproperty used as prefix (<code>
  * resultproperty.0-array.length</code> and store the result array length at <code>
  * resultproperty.length</code>. Other option is that you delimit your result with a delimiter
  * (java.util.StringTokenizer is used).
  *
  * @param propertyPrefix
  * @param result
  */
 protected void createProperty(String propertyPrefix, Object result) {
   if (propertyPrefix == null) propertyPrefix = "";
   if (result instanceof CompositeDataSupport) {
     CompositeDataSupport data = (CompositeDataSupport) result;
     CompositeType compositeType = data.getCompositeType();
     Set<String> keys = compositeType.keySet();
     for (Iterator<String> iter = keys.iterator(); iter.hasNext(); ) {
       String key = iter.next();
       Object value = data.get(key);
       OpenType<?> type = compositeType.getType(key);
       if (type instanceof SimpleType<?>) {
         setProperty(propertyPrefix + "." + key, value);
       } else {
         createProperty(propertyPrefix + "." + key, value);
       }
     }
   } else if (result instanceof TabularDataSupport) {
     TabularDataSupport data = (TabularDataSupport) result;
     for (Iterator<Object> iter = data.keySet().iterator(); iter.hasNext(); ) {
       Object key = iter.next();
       for (Iterator<?> iter1 = ((List<?>) key).iterator(); iter1.hasNext(); ) {
         Object key1 = iter1.next();
         CompositeData valuedata = data.get(new Object[] {key1});
         Object value = valuedata.get("value");
         OpenType<?> type = valuedata.getCompositeType().getType("value");
         if (type instanceof SimpleType<?>) {
           setProperty(propertyPrefix + "." + key1, value);
         } else {
           createProperty(propertyPrefix + "." + key1, value);
         }
       }
     }
   } else if (result.getClass().isArray()) {
     if (isSeparatearrayresults()) {
       int size = 0;
       for (int i = 0; i < Array.getLength(result); i++) {
         if (setProperty(propertyPrefix + "." + size, Array.get(result, i))) {
           size++;
         }
       }
       if (size > 0) {
         setProperty(propertyPrefix + ".Length", Integer.toString(size));
       }
     }
   } else {
     String delim = getDelimiter();
     if (delim != null) {
       StringTokenizer tokenizer = new StringTokenizer(result.toString(), delim);
       int size = 0;
       for (; tokenizer.hasMoreTokens(); ) {
         String token = tokenizer.nextToken();
         if (setProperty(propertyPrefix + "." + size, token)) {
           size++;
         }
       }
       if (size > 0) setProperty(propertyPrefix + ".Length", Integer.toString(size));
     } else {
       setProperty(propertyPrefix, result.toString());
     }
   }
 }
示例#19
0
  /**
   * {@inheritDoc}
   *
   * <p>Perform data collection.
   */
  @Override
  public CollectionSet collect(CollectionAgent agent, EventProxy eproxy, Map<String, Object> map) {
    InetAddress ipaddr = agent.getAddress();
    JMXNodeInfo nodeInfo = agent.getAttribute(NODE_INFO_KEY);
    Map<String, BeanInfo> mbeans = nodeInfo.getMBeans();
    String collDir = serviceName;

    boolean useMbeanForRrds = ParameterMap.getKeyedBoolean(map, "use-mbean-name-for-rrds", false);
    String port = ParameterMap.getKeyedString(map, "port", null);
    String friendlyName = ParameterMap.getKeyedString(map, "friendly-name", port);
    if (useFriendlyName) {
      collDir = friendlyName;
    }

    JMXCollectionSet collectionSet = new JMXCollectionSet(agent, collDir);
    collectionSet.setCollectionTimestamp(new Date());
    JMXCollectionResource collectionResource = collectionSet.getResource();

    ConnectionWrapper connection = null;

    LogUtils.debugf(
        this, "collecting %s on node ID %d", InetAddressUtils.str(ipaddr), nodeInfo.getNodeId());

    try {
      connection = getMBeanServerConnection(map, ipaddr);

      if (connection == null) {
        return collectionSet;
      }

      MBeanServerConnection mbeanServer = connection.getMBeanServer();

      int retry = ParameterMap.getKeyedInteger(map, "retry", 3);
      for (int attempts = 0; attempts <= retry; attempts++) {
        try {
          /*
           * Iterate over the mbeans, for each object name perform a
           * getAttributes, the update the RRD.
           */

          for (Iterator<BeanInfo> iter = mbeans.values().iterator(); iter.hasNext(); ) {
            BeanInfo beanInfo = iter.next();
            String mbeanName = beanInfo.getMbeanName();
            String objectName = beanInfo.getObjectName();
            String excludeList = beanInfo.getExcludes();
            // All JMX collected values are per node
            String obj = useMbeanForRrds ? mbeanName : objectName;
            AttributeGroupType attribGroupType = new AttributeGroupType(fixGroupName(obj), "all");

            List<String> attribNames = beanInfo.getAttributeNames();
            List<String> compAttribNames = beanInfo.getCompositeAttributeNames();

            for (String compAttribName : compAttribNames) {
              if (attribNames.contains(compAttribName)) {
                attribNames.remove(compAttribName);
                String[] ac = compAttribName.split("\\|", -1);
                String attrName = ac[0];
                if (!attribNames.contains(attrName)) {
                  attribNames.add(attrName);
                }
              }
            }
            // log.debug(" JMXCollector: processed the following attributes: " +
            // attribNames.toString());
            // log.debug(" JMXCollector: processed the following Composite Attributes: " +
            // compAttribNames.toString());

            String[] attrNames = attribNames.toArray(new String[attribNames.size()]);

            if (objectName.indexOf("*") == -1) {
              LogUtils.debugf(
                  this,
                  "%s Collector - getAttributes: %s, # attributes: %d, # composite attribute members: %d",
                  serviceName,
                  objectName,
                  attrNames.length,
                  compAttribNames.size());
              try {
                ObjectName oName = new ObjectName(objectName);
                if (mbeanServer.isRegistered(oName)) {
                  AttributeList attrList = mbeanServer.getAttributes(oName, attrNames);
                  Map<String, JMXDataSource> dsMap = nodeInfo.getDsMap();
                  for (Object attribute : attrList) {
                    List<String> compositeMemberKeys = new ArrayList<String>();
                    Boolean isComposite = false;
                    Attribute attrib = (Attribute) attribute;
                    for (String compAttrName : compAttribNames) {
                      String[] attribKeys = compAttrName.split("\\|", -1);
                      if (attrib.getName().equals(attribKeys[0])) {
                        compositeMemberKeys.add(attribKeys[1]);
                        isComposite = true;
                      }
                    }
                    if (isComposite) {
                      try {
                        CompositeData cd = (CompositeData) attrib.getValue();
                        for (String key : compositeMemberKeys) {
                          /*
                          value = cd.get(key);

                          log.debug(" JMXCollector - got CompositeData: " +
                                    objectName + "|" + attrib.getName() + "|" + key + " |-> " + cd.get(key).toString());
                          */
                          JMXDataSource ds =
                              dsMap.get(objectName + "|" + attrib.getName() + "|" + key);
                          JMXCollectionAttributeType attribType =
                              new JMXCollectionAttributeType(ds, null, null, attribGroupType);
                          collectionResource.setAttributeValue(attribType, cd.get(key).toString());
                        }
                      } catch (final ClassCastException cce) {
                        LogUtils.debugf(
                            this,
                            cce,
                            "%s Collection - getAttributes (try CompositeData) - ERROR: Failed to cast attribute value to type CompositeData!",
                            serviceName);
                      }
                    } else {
                      // this is a normal attribute, so fallback to default handler
                      JMXDataSource ds = dsMap.get(objectName + "|" + attrib.getName());
                      JMXCollectionAttributeType attribType =
                          new JMXCollectionAttributeType(ds, null, null, attribGroupType);
                      collectionResource.setAttributeValue(
                          attribType, attrib.getValue().toString());
                    }
                  }
                }
              } catch (final InstanceNotFoundException e) {
                LogUtils.errorf(this, e, "Unable to retrieve attributes from %s", objectName);
              }
            } else {
              /*
               * This section is for ObjectNames that use the
               * '*' wildcard
               */
              Set<ObjectName> mbeanSet = getObjectNames(mbeanServer, objectName);
              for (Iterator<ObjectName> objectNameIter = mbeanSet.iterator();
                  objectNameIter.hasNext(); ) {
                ObjectName oName = objectNameIter.next();
                LogUtils.debugf(
                    this,
                    "%s Collector - getAttributesWC: %s, # attributes: %d, alias: %s",
                    serviceName,
                    oName,
                    attrNames.length,
                    beanInfo.getKeyAlias());

                try {
                  if (excludeList == null) {
                    // the exclude list doesn't apply
                    if (mbeanServer.isRegistered(oName)) {
                      AttributeList attrList = mbeanServer.getAttributes(oName, attrNames);
                      Map<String, JMXDataSource> dsMap = nodeInfo.getDsMap();

                      for (Object attribute : attrList) {
                        Attribute attrib = (Attribute) attribute;
                        JMXDataSource ds = dsMap.get(objectName + "|" + attrib.getName());
                        JMXCollectionAttributeType attribType =
                            new JMXCollectionAttributeType(
                                ds,
                                oName.getKeyProperty(beanInfo.getKeyField()),
                                beanInfo.getKeyAlias(),
                                attribGroupType);

                        collectionResource.setAttributeValue(
                            attribType, attrib.getValue().toString());
                      }
                    }
                  } else {
                    /*
                     * filter out calls if the key field
                     * matches an entry in the exclude
                     * list
                     */
                    String keyName = oName.getKeyProperty(beanInfo.getKeyField());
                    boolean found = false;
                    StringTokenizer st = new StringTokenizer(excludeList, ",");
                    while (st.hasMoreTokens()) {
                      if (keyName.equals(st.nextToken())) {
                        found = true;
                        break;
                      }
                    }
                    if (!found) {
                      if (mbeanServer.isRegistered(oName)) {
                        AttributeList attrList = mbeanServer.getAttributes(oName, attrNames);
                        Map<String, JMXDataSource> dsMap = nodeInfo.getDsMap();

                        for (Object attribute : attrList) {
                          Attribute attrib = (Attribute) attribute;
                          JMXDataSource ds = dsMap.get(objectName + "|" + attrib.getName());
                          JMXCollectionAttributeType attribType =
                              new JMXCollectionAttributeType(
                                  ds,
                                  oName.getKeyProperty(beanInfo.getKeyField()),
                                  beanInfo.getKeyAlias(),
                                  attribGroupType);

                          collectionResource.setAttributeValue(
                              attribType, attrib.getValue().toString());
                        }
                      }
                    }
                  }
                } catch (final InstanceNotFoundException e) {
                  LogUtils.errorf(this, e, "Error retrieving attributes for %s", oName);
                }
              }
            }
          }
          break;
        } catch (final Exception e) {
          LogUtils.debugf(
              this,
              e,
              "%s Collector.collect: IOException while collecting address: %s",
              serviceName,
              agent.getAddress());
        }
      }
    } catch (final Exception e) {
      LogUtils.errorf(this, e, "Error getting MBeanServer");
    } finally {
      if (connection != null) {
        connection.close();
      }
    }

    collectionSet.setStatus(ServiceCollector.COLLECTION_SUCCEEDED);
    return collectionSet;
  }
 public String toString() {
   return _data.getCompositeType().toString();
 }
 public Set getKeys() {
   return _data.getCompositeType().keySet();
 }
 /** Returns an attribute. */
 public Object __getField(String attrName) {
   return _data.get(attrName);
 }
 public Builder add(String name, CompositeData data) throws OpenDataException {
   if (data != null) return add(name, data.getCompositeType(), data);
   return add(name, SimpleType.VOID, null);
 }