1 22 23 package org.snmp4j.agent.mo.jmx; 24 25 import org.snmp4j.agent.mo.jmx.types.TypedAttribute; 26 import org.snmp4j.smi.OID; 27 import org.snmp4j.smi.VariableBinding; 28 import javax.management.openmbean.CompositeDataSupport ; 29 import org.snmp4j.agent.mo.jmx.types.SMIVariant; 30 import org.snmp4j.smi.Variable; 31 32 39 public class MBeanNotificationObjectInfo { 40 41 private OID classID; 42 private Variable valueType; 43 private TypedAttribute attribute; 44 45 public MBeanNotificationObjectInfo(OID classID, 46 Variable valueType, 47 TypedAttribute attribute) { 48 this.classID = classID; 49 this.valueType = valueType; 50 this.attribute = attribute; 51 } 52 53 public VariableBinding getVariableBinding(Object mBeanNotifyUserObject, 54 OID index) { 55 Object value; 56 if (mBeanNotifyUserObject instanceof CompositeDataSupport ) { 57 CompositeDataSupport data = (CompositeDataSupport )mBeanNotifyUserObject; 58 value = data.get(attribute.getName()); 59 } 60 else { 61 value = mBeanNotifyUserObject; 62 } 63 Variable smiValue = (Variable) valueType.clone(); 64 SMIVariant smiVariant = new SMIVariant(smiValue); 65 value = attribute.transformFromNative(value, null); 66 smiVariant.setValue(value); 67 OID oid = new OID(classID); 68 if (index != null) { 69 oid.append(index); 70 } 71 return new VariableBinding(oid, smiValue); 72 } 73 74 } 75 | Popular Tags |