1 22 package org.snmp4j.agent.mo.jmx; 23 24 import java.util.*; 25 26 import org.snmp4j.agent.mo.*; 27 import org.snmp4j.smi.*; 28 import org.snmp4j.PDU; 29 import javax.management.ObjectName ; 30 31 public abstract class AbstractJMXTableSupport implements JMXTableSupport { 32 33 protected Map<OID,JMXTableDetailSupport> columnValueMappings = 34 new HashMap<OID,JMXTableDetailSupport>(10); 35 36 public AbstractJMXTableSupport() { 37 } 38 39 public abstract OID getLastIndex(OID tableOID); 40 41 public int getRow(OID tableOID, MOTableRow row) { 42 Object rowKey = mapToRowId(tableOID, row.getIndex()); 43 if (rowKey != null) { 44 JMXTableDetailSupport detailSupport = getTableDetailSupport(tableOID); 45 if (detailSupport != null) { 46 ObjectName mBean = 47 detailSupport.getRowSupport().getRowMBean(tableOID, rowKey); 48 for (int i = 0; i < row.size(); i++) { 49 Variable v = row.getValue(i); 50 detailSupport.getColumnSupport().getColumnValue(mBean, i, v); 51 } 52 } 53 return PDU.noError; 54 } 55 return PDU.resourceUnavailable; 56 } 57 58 protected synchronized JMXTableDetailSupport getTableDetailSupport(OID tableOID) { 59 return columnValueMappings.get(tableOID); 60 } 61 62 public abstract int getRowCount(OID tableOID); 63 64 public abstract Iterator rowIdIterator(OID tableOID); 65 66 public abstract OID mapToIndex(OID tableOID, Object rowIdentifier); 67 68 public abstract Object mapToRowId(OID tableOID, OID rowIndex); 69 70 class JMXTableDetailSupport { 71 private JMXColumnSupport columnSupport; 72 private JMXRowSupport rowSupport; 73 74 public JMXTableDetailSupport(JMXRowSupport rowSupport, 75 JMXColumnSupport columnSupport) { 76 this.rowSupport = rowSupport; 77 this.columnSupport = columnSupport; 78 } 79 80 public JMXRowSupport getRowSupport() { 81 return rowSupport; 82 } 83 84 public JMXColumnSupport getColumnSupport() { 85 return columnSupport; 86 } 87 88 } 89 90 } 91 | Popular Tags |