1 22 23 package org.snmp4j.agent.mo.jmx; 24 25 import java.io.IOException ; 26 import javax.management.*; 27 import org.snmp4j.agent.mo.jmx.types.*; 28 29 36 public class MBeanAttributeMOTableInfo extends MBeanMOInfo { 37 38 private MBeanAttributeKeyProvider keyProvider; 39 private String [] indexAttributes; 40 private TypedAttribute[] columns; 41 private JMXIndexSupport indexSupport; 42 43 59 public MBeanAttributeMOTableInfo(ObjectName name, 60 MBeanAttributeKeyProvider keyProvider, 61 TypedAttribute[] columns, 62 String [] keyAttributes, 63 JMXIndexSupport indexSupport) { 64 super(name); 65 this.keyProvider = keyProvider; 66 this.indexAttributes = keyAttributes; 67 this.columns = columns; 68 this.indexSupport = indexSupport; 69 } 70 71 public String [] getIndexAttributes() { 72 return indexAttributes; 73 } 74 75 public TypedAttribute[] getColumns() { 76 return columns; 77 } 78 79 public MBeanAttributeKeyProvider getKeyProvider() { 80 return keyProvider; 81 } 82 83 public JMXIndexSupport getIndexSupport() { 84 return indexSupport; 85 } 86 87 public Object getKey(MBeanServerConnection server, ObjectName row) throws 88 IOException , ReflectionException, InstanceNotFoundException { 89 Object [] key = new Object [indexAttributes.length]; 90 AttributeList keyObjects = server.getAttributes(row, indexAttributes); 91 for (int i=0; i<keyObjects.size(); i++) { 92 key[i] = ((Attribute)keyObjects.get(i)).getValue(); 93 } 94 if (key.length == 1) { 95 return key[0]; 96 } 97 return key; 98 } 99 } 100 | Popular Tags |