⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snmp4jdemomib.java

📁 用snmp4j实现的agent,代码比较多,但是很值得一看,尤其是对于要用SNMP监控信息的编程者,可以仔细研究一下里面的代码.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public int isValueOK(SubRequest request) {      Variable newValue =        request.getVariableBinding().getVariable();      int valueOK = super.isValueOK(request);      if (valueOK != SnmpConstants.SNMP_ERROR_SUCCESS) {      	return valueOK;      }      OctetString os = (OctetString)newValue;      if (!(((os.length() >= 0) && (os.length() <= 255)))) {        valueOK = SnmpConstants.SNMP_ERROR_WRONG_LENGTH;      }     //--AgentGen BEGIN=snmp4jDemoScalar::isValueOK     //--AgentGen END      return valueOK;    }    public Variable getValue() {     //--AgentGen BEGIN=snmp4jDemoScalar::getValue     //--AgentGen END      return super.getValue();    }    public int setValue(Variable newValue) {     //--AgentGen BEGIN=snmp4jDemoScalar::setValue     //--AgentGen END      return super.setValue(newValue);    }     //--AgentGen BEGIN=snmp4jDemoScalar::_METHODS     //--AgentGen END  }  // Value Validators  /**   * The <code>Snmp4jDemoScalarValidator</code> implements the value   * validation for <code>Snmp4jDemoScalar</code>.   */  static class Snmp4jDemoScalarValidator implements MOValueValidationListener {    public void validate(MOValueValidationEvent validationEvent) {      Variable newValue = validationEvent.getNewValue();      OctetString os = (OctetString)newValue;      if (!(((os.length() >= 0) && (os.length() <= 255)))) {        validationEvent.setValidationStatus(SnmpConstants.SNMP_ERROR_WRONG_LENGTH);        return;      }     //--AgentGen BEGIN=snmp4jDemoScalar::validate     //--AgentGen END    }  }  /**   * The <code>Snmp4jDemoEntryCol1Validator</code> implements the value   * validation for <code>Snmp4jDemoEntryCol1</code>.   */  static class Snmp4jDemoEntryCol1Validator implements MOValueValidationListener {    public void validate(MOValueValidationEvent validationEvent) {      Variable newValue = validationEvent.getNewValue();     //--AgentGen BEGIN=snmp4jDemoEntryCol1::validate     //--AgentGen END    }  }  /**   * The <code>Snmp4jDemoEntryCol2Validator</code> implements the value   * validation for <code>Snmp4jDemoEntryCol2</code>.   */  static class Snmp4jDemoEntryCol2Validator implements MOValueValidationListener {    public void validate(MOValueValidationEvent validationEvent) {      Variable newValue = validationEvent.getNewValue();      OctetString os = (OctetString)newValue;      if (!(((os.length() >= 0) && (os.length() <= 128)))) {        validationEvent.setValidationStatus(SnmpConstants.SNMP_ERROR_WRONG_LENGTH);        return;      }     //--AgentGen BEGIN=snmp4jDemoEntryCol2::validate     //--AgentGen END    }  }  /**   * The <code>Snmp4jDemoEntryCol5Validator</code> implements the value   * validation for <code>Snmp4jDemoEntryCol5</code>.   */  static class Snmp4jDemoEntryCol5Validator implements MOValueValidationListener {    public void validate(MOValueValidationEvent validationEvent) {      Variable newValue = validationEvent.getNewValue();     //--AgentGen BEGIN=snmp4jDemoEntryCol5::validate     //--AgentGen END    }  }  /**   * The <code>Snmp4jDemoEntryCol6Validator</code> implements the value   * validation for <code>Snmp4jDemoEntryCol6</code>.   */  static class Snmp4jDemoEntryCol6Validator implements MOValueValidationListener {    public void validate(MOValueValidationEvent validationEvent) {      Variable newValue = validationEvent.getNewValue();     //--AgentGen BEGIN=snmp4jDemoEntryCol6::validate     //--AgentGen END    }  }  // Rows and Factories  public class Snmp4jDemoEntryRow extends DefaultMOMutableRow2PC {     //--AgentGen BEGIN=snmp4jDemoEntry::RowMembers     //--AgentGen END    public Snmp4jDemoEntryRow(OID index, Variable[] values) {      super(index, values);     //--AgentGen BEGIN=snmp4jDemoEntry::RowConstructor     //--AgentGen END    }    public Integer32 getSnmp4jDemoEntryCol1() {     //--AgentGen BEGIN=snmp4jDemoEntry::getSnmp4jDemoEntryCol1     //--AgentGen END      return (Integer32) super.getValue(idxSnmp4jDemoEntryCol1);    }    public void setSnmp4jDemoEntryCol1(Integer32 newValue) {     //--AgentGen BEGIN=snmp4jDemoEntry::setSnmp4jDemoEntryCol1     //--AgentGen END      super.setValue(idxSnmp4jDemoEntryCol1, newValue);    }    public OctetString getSnmp4jDemoEntryCol2() {     //--AgentGen BEGIN=snmp4jDemoEntry::getSnmp4jDemoEntryCol2     //--AgentGen END      return (OctetString) super.getValue(idxSnmp4jDemoEntryCol2);    }    public void setSnmp4jDemoEntryCol2(OctetString newValue) {     //--AgentGen BEGIN=snmp4jDemoEntry::setSnmp4jDemoEntryCol2     //--AgentGen END      super.setValue(idxSnmp4jDemoEntryCol2, newValue);    }    public Counter32 getSnmp4jDemoEntryCol3() {     //--AgentGen BEGIN=snmp4jDemoEntry::getSnmp4jDemoEntryCol3     //--AgentGen END      return (Counter32) super.getValue(idxSnmp4jDemoEntryCol3);    }    public void setSnmp4jDemoEntryCol3(Counter32 newValue) {     //--AgentGen BEGIN=snmp4jDemoEntry::setSnmp4jDemoEntryCol3     //--AgentGen END      super.setValue(idxSnmp4jDemoEntryCol3, newValue);    }    public TimeTicks getSnmp4jDemoEntryCol4() {     //--AgentGen BEGIN=snmp4jDemoEntry::getSnmp4jDemoEntryCol4     //--AgentGen END      return (TimeTicks) super.getValue(idxSnmp4jDemoEntryCol4);    }    public void setSnmp4jDemoEntryCol4(TimeTicks newValue) {     //--AgentGen BEGIN=snmp4jDemoEntry::setSnmp4jDemoEntryCol4     //--AgentGen END      super.setValue(idxSnmp4jDemoEntryCol4, newValue);    }    public Integer32 getSnmp4jDemoEntryCol5() {     //--AgentGen BEGIN=snmp4jDemoEntry::getSnmp4jDemoEntryCol5     //--AgentGen END      return (Integer32) super.getValue(idxSnmp4jDemoEntryCol5);    }    public void setSnmp4jDemoEntryCol5(Integer32 newValue) {     //--AgentGen BEGIN=snmp4jDemoEntry::setSnmp4jDemoEntryCol5     //--AgentGen END      super.setValue(idxSnmp4jDemoEntryCol5, newValue);    }    public Integer32 getSnmp4jDemoEntryCol6() {     //--AgentGen BEGIN=snmp4jDemoEntry::getSnmp4jDemoEntryCol6     //--AgentGen END      return (Integer32) super.getValue(idxSnmp4jDemoEntryCol6);    }    public void setSnmp4jDemoEntryCol6(Integer32 newValue) {     //--AgentGen BEGIN=snmp4jDemoEntry::setSnmp4jDemoEntryCol6     //--AgentGen END      super.setValue(idxSnmp4jDemoEntryCol6, newValue);    }    public Integer32 getSnmp4jDemoTableRowModification() {     //--AgentGen BEGIN=snmp4jDemoEntry::getSnmp4jDemoTableRowModification     //--AgentGen END      return (Integer32) super.getValue(idxSnmp4jDemoTableRowModification);    }    public void setSnmp4jDemoTableRowModification(Integer32 newValue) {     //--AgentGen BEGIN=snmp4jDemoEntry::setSnmp4jDemoTableRowModification     //--AgentGen END      super.setValue(idxSnmp4jDemoTableRowModification, newValue);    }    public Variable getValue(int column) {     //--AgentGen BEGIN=snmp4jDemoEntry::RowGetValue     //--AgentGen END      switch(column) {        case idxSnmp4jDemoEntryCol1:        	return getSnmp4jDemoEntryCol1();        case idxSnmp4jDemoEntryCol2:        	return getSnmp4jDemoEntryCol2();        case idxSnmp4jDemoEntryCol3:        	return getSnmp4jDemoEntryCol3();        case idxSnmp4jDemoEntryCol4:        	return getSnmp4jDemoEntryCol4();        case idxSnmp4jDemoEntryCol5:        	return getSnmp4jDemoEntryCol5();        case idxSnmp4jDemoEntryCol6:        	return getSnmp4jDemoEntryCol6();        case idxSnmp4jDemoTableRowModification:        	return getSnmp4jDemoTableRowModification();        default:          return super.getValue(column);      }    }    public void setValue(int column, Variable value) {     //--AgentGen BEGIN=snmp4jDemoEntry::RowSetValue     //--AgentGen END      switch(column) {        case idxSnmp4jDemoEntryCol1:        	setSnmp4jDemoEntryCol1((Integer32)value);        	break;        case idxSnmp4jDemoEntryCol2:        	setSnmp4jDemoEntryCol2((OctetString)value);        	break;        case idxSnmp4jDemoEntryCol3:        	setSnmp4jDemoEntryCol3((Counter32)value);        	break;        case idxSnmp4jDemoEntryCol4:        	setSnmp4jDemoEntryCol4((TimeTicks)value);        	break;        case idxSnmp4jDemoEntryCol5:        	setSnmp4jDemoEntryCol5((Integer32)value);        	break;        case idxSnmp4jDemoEntryCol6:        	setSnmp4jDemoEntryCol6((Integer32)value);        	break;        case idxSnmp4jDemoTableRowModification:        	setSnmp4jDemoTableRowModification((Integer32)value);        	break;        default:          super.setValue(column, value);      }    }     //--AgentGen BEGIN=snmp4jDemoEntry::Row     //--AgentGen END  }  class Snmp4jDemoEntryRowFactory        extends DefaultMOMutableRow2PCFactory  {    public synchronized MOTableRow createRow(OID index, Variable[] values)        throws UnsupportedOperationException    {      Snmp4jDemoEntryRow row =        new Snmp4jDemoEntryRow(index, values);     //--AgentGen BEGIN=snmp4jDemoEntry::createRow     //--AgentGen END      return row;    }    public synchronized void freeRow(MOTableRow row) {     //--AgentGen BEGIN=snmp4jDemoEntry::freeRow     //--AgentGen END    }     //--AgentGen BEGIN=snmp4jDemoEntry::RowFactory     //--AgentGen END  }//--AgentGen BEGIN=_METHODS//--AgentGen END  // Textual Definitions of MIB module Snmp4jDemoMib  protected void addTCsToFactory(MOFactory moFactory) {  }//--AgentGen BEGIN=_TC_CLASSES_IMPORTED_MODULES_BEGIN//--AgentGen END  // Textual Definitions of other MIB modules  protected void addImportedTCsToFactory(MOFactory moFactory) {  }//--AgentGen BEGIN=_TC_CLASSES_IMPORTED_MODULES_END//--AgentGen END//--AgentGen BEGIN=_CLASSES//--AgentGen END//--AgentGen BEGIN=_END//--AgentGen END}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -