📄 snmp4jlogmib.java
字号:
snmp4jLogLoggerToHandlerEntryModel = new DefaultMOMutableTableModel();
snmp4jLogLoggerToHandlerEntryModel.setRowFactory(new Snmp4jLogLoggerToHandlerEntryRowFactory());
snmp4jLogLoggerToHandlerEntry =
moFactory.createTable(oidSnmp4jLogLoggerToHandlerEntry,
snmp4jLogLoggerToHandlerEntryIndex,
snmp4jLogLoggerToHandlerEntryColumns,
snmp4jLogLoggerToHandlerEntryModel);
}
public MOTable getSnmp4jLogHandlerEntry() {
return snmp4jLogHandlerEntry;
}
private void createSnmp4jLogHandlerEntry() {
MOColumn[] snmp4jLogHandlerEntryColumns = new MOColumn[3];
snmp4jLogHandlerEntryColumns[idxSnmp4jLogHandlerType] =
new MOMutableColumn(colSnmp4jLogHandlerType,
SMIConstants.SYNTAX_OBJECT_IDENTIFIER,
MOAccessImpl.ACCESS_READ_CREATE,
new OID("1.3.6.1.4.1.4976.10.1.1.1.1.2.5.1.2.1"),
true);
((MOMutableColumn)snmp4jLogHandlerEntryColumns[idxSnmp4jLogHandlerType]).
addMOValueValidationListener(new Snmp4jLogHandlerTypeValidator());
snmp4jLogHandlerEntryColumns[idxSnmp4jLogHandlerStorageType] =
new StorageType(colSnmp4jLogHandlerStorageType,
MOAccessImpl.ACCESS_READ_CREATE,
null,
true);
snmp4jLogHandlerEntryColumns[idxSnmp4jLogHandlerRowStatus] =
new RowStatus(colSnmp4jLogHandlerRowStatus);
snmp4jLogHandlerEntryModel = new DefaultMOMutableTableModel();
snmp4jLogHandlerEntryModel.setRowFactory(new Snmp4jLogHandlerEntryRowFactory());
snmp4jLogHandlerEntry =
moFactory.createTable(oidSnmp4jLogHandlerEntry,
snmp4jLogHandlerEntryIndex,
snmp4jLogHandlerEntryColumns,
snmp4jLogHandlerEntryModel);
}
public MOTable getSnmp4jLogFileHandlerEntry() {
return snmp4jLogFileHandlerEntry;
}
private void createSnmp4jLogFileHandlerEntry() {
MOColumn[] snmp4jLogFileHandlerEntryColumns = new MOColumn[4];
snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerPath] =
new MOMutableColumn(colSnmp4jLogFileHandlerPath,
SMIConstants.SYNTAX_OCTET_STRING,
MOAccessImpl.ACCESS_READ_CREATE,
new OctetString(new byte[] { (byte)115,(byte)110,(byte)109,(byte)112,(byte)52,(byte)106,(byte)46,(byte)108,(byte)111,(byte)103 }),
true);
((MOMutableColumn)snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerPath]).
addMOValueValidationListener(new Snmp4jLogFileHandlerPathValidator());
snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerAppend] =
new MOMutableColumn(colSnmp4jLogFileHandlerAppend,
SMIConstants.SYNTAX_INTEGER,
MOAccessImpl.ACCESS_READ_CREATE,
new Integer32(1),
true);
((MOMutableColumn)snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerAppend]).
addMOValueValidationListener(new Snmp4jLogFileHandlerAppendValidator());
snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerBufferedIO] =
new MOMutableColumn(colSnmp4jLogFileHandlerBufferedIO,
SMIConstants.SYNTAX_INTEGER,
MOAccessImpl.ACCESS_READ_CREATE,
new Integer32(1),
true);
((MOMutableColumn)snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerBufferedIO]).
addMOValueValidationListener(new Snmp4jLogFileHandlerBufferedIOValidator());
snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerBufferSize] =
new MOMutableColumn(colSnmp4jLogFileHandlerBufferSize,
SMIConstants.SYNTAX_GAUGE32,
MOAccessImpl.ACCESS_READ_CREATE,
new UnsignedInteger32(16535),
true);
((MOMutableColumn)snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerBufferSize]).
addMOValueValidationListener(new Snmp4jLogFileHandlerBufferSizeValidator());
snmp4jLogFileHandlerEntryModel = new DefaultMOMutableTableModel();
snmp4jLogFileHandlerEntryModel.setRowFactory(new Snmp4jLogFileHandlerEntryRowFactory());
snmp4jLogFileHandlerEntry =
moFactory.createTable(oidSnmp4jLogFileHandlerEntry,
snmp4jLogFileHandlerEntryIndex,
snmp4jLogFileHandlerEntryColumns,
snmp4jLogFileHandlerEntryModel);
}
public MOTable getSnmp4jLogConsoleHandlerEntry() {
return snmp4jLogConsoleHandlerEntry;
}
private void createSnmp4jLogConsoleHandlerEntry() {
MOColumn[] snmp4jLogConsoleHandlerEntryColumns = new MOColumn[1];
snmp4jLogConsoleHandlerEntryColumns[idxSnmp4jLogConsoleHandlerTarget] =
new Enumerated(colSnmp4jLogConsoleHandlerTarget,
MOAccessImpl.ACCESS_READ_CREATE,
new Integer32(1),
true,
new int[] { Snmp4jLogConsoleHandlerTargetEnum.systemOut,
Snmp4jLogConsoleHandlerTargetEnum.systemErr });
((MOMutableColumn)snmp4jLogConsoleHandlerEntryColumns[idxSnmp4jLogConsoleHandlerTarget]).
addMOValueValidationListener(new Snmp4jLogConsoleHandlerTargetValidator());
snmp4jLogConsoleHandlerEntryModel = new DefaultMOMutableTableModel();
snmp4jLogConsoleHandlerEntryModel.setRowFactory(new Snmp4jLogConsoleHandlerEntryRowFactory());
snmp4jLogConsoleHandlerEntry =
moFactory.createTable(oidSnmp4jLogConsoleHandlerEntry,
snmp4jLogConsoleHandlerEntryIndex,
snmp4jLogConsoleHandlerEntryColumns,
snmp4jLogConsoleHandlerEntryModel);
}
public void registerMOs(MOServer server, OctetString context)
throws DuplicateRegistrationException
{
// Scalar Objects
server.register(this.snmp4jLogSysDescr, context);
server.register(this.snmp4jLogFactory, context);
server.register(this.snmp4jLogRootLevel, context);
server.register(this.snmp4jLogLoggerEntry, context);
/**@todo implement other tables
server.register(this.snmp4jLogLoggerToHandlerEntry, context);
server.register(this.snmp4jLogHandlerEntry, context);
server.register(this.snmp4jLogFileHandlerEntry, context);
server.register(this.snmp4jLogConsoleHandlerEntry, context);
*/
//--AgentGen BEGIN=_registerMOs
server.addLookupListener(this, this.snmp4jLogSysDescr);
server.addLookupListener(this, this.snmp4jLogLoggerEntry);
//--AgentGen END
}
public void unregisterMOs(MOServer server, OctetString context) {
// Scalar Objects
server.unregister(this.snmp4jLogSysDescr, context);
server.unregister(this.snmp4jLogFactory, context);
server.unregister(this.snmp4jLogRootLevel, context);
server.unregister(this.snmp4jLogLoggerEntry, context);
server.unregister(this.snmp4jLogLoggerToHandlerEntry, context);
server.unregister(this.snmp4jLogHandlerEntry, context);
server.unregister(this.snmp4jLogFileHandlerEntry, context);
server.unregister(this.snmp4jLogConsoleHandlerEntry, context);
//--AgentGen BEGIN=_unregisterMOs
server.removeLookupListener(this, this.snmp4jLogSysDescr);
server.removeLookupListener(this, this.snmp4jLogLoggerEntry);
//--AgentGen END
}
// Notifications
// Scalars
class Snmp4jLogRootLevel extends MOScalar {
Snmp4jLogRootLevel(OID oid, MOAccess access) {
super(oid, access, new Integer32());
}
public void commit(SubRequest request) {
//--AgentGen BEGIN=snmp4jLogRootLevel::commit
Variable vb = request.getVariableBinding().getVariable();
int v = ((Integer32)vb).getValue();
LogAdapter logAdapter = LogFactory.getLogFactory().getRootLogger();
logAdapter.setLogLevel(new LogLevel(v));
//--AgentGen END
super.commit(request);
}
}
// Value Validators
/**
* The <code>Snmp4jLogRootLevelValidator</code> implements the value
* validation for <code>Snmp4jLogRootLevel</code>.
*/
static class Snmp4jLogLevelValidator implements MOValueValidationListener {
public void validate(MOValueValidationEvent validationEvent) {
Variable newValue = validationEvent.getNewValue();
//--AgentGen BEGIN=snmp4jLogRootLevel::validate
int v = ((Integer32)newValue ).getValue();
if ((v < 1) || (v > 8)) {
validationEvent.setValidationStatus(SnmpConstants.SNMP_ERROR_WRONG_VALUE);
}
//--AgentGen END
}
}
/**
* The <code>Snmp4jLogHandlerTypeValidator</code> implements the value
* validation for <code>Snmp4jLogHandlerType</code>.
*/
static class Snmp4jLogHandlerTypeValidator implements MOValueValidationListener {
public void validate(MOValueValidationEvent validationEvent) {
Variable newValue = validationEvent.getNewValue();
//--AgentGen BEGIN=snmp4jLogHandlerType::validate
//--AgentGen END
}
}
/**
* The <code>Snmp4jLogFileHandlerPathValidator</code> implements the value
* validation for <code>Snmp4jLogFileHandlerPath</code>.
*/
static class Snmp4jLogFileHandlerPathValidator implements MOValueValidationListener {
public void validate(MOValueValidationEvent validationEvent) {
Variable newValue = validationEvent.getNewValue();
OctetString os = (OctetString)newValue;
if (!(((os.length() >= 1) && (os.length() <= 512)))) {
validationEvent.setValidationStatus(SnmpConstants.SNMP_ERROR_WRONG_LENGTH);
return;
}
//--AgentGen BEGIN=snmp4jLogFileHandlerPath::validate
//--AgentGen END
}
}
/**
* The <code>Snmp4jLogFileHandlerAppendValidator</code> implements the value
* validation for <code>Snmp4jLogFileHandlerAppend</code>.
*/
static class Snmp4jLogFileHandlerAppendValidator implements MOValueValidationListener {
public void validate(MOValueValidationEvent validationEvent) {
Variable newValue = validationEvent.getNewValue();
//--AgentGen BEGIN=snmp4jLogFileHandlerAppend::validate
//--AgentGen END
}
}
/**
* The <code>Snmp4jLogFileHandlerBufferedIOValidator</code> implements the value
* validation for <code>Snmp4jLogFileHandlerBufferedIO</code>.
*/
static class Snmp4jLogFileHandlerBufferedIOValidator implements MOValueValidationListener {
public void validate(MOValueValidationEvent validationEvent) {
Variable newValue = validationEvent.getNewValue();
//--AgentGen BEGIN=snmp4jLogFileHandlerBufferedIO::validate
//--AgentGen END
}
}
/**
* The <code>Snmp4jLogFileHandlerBufferSizeValidator</code> implements the value
* validation for <code>Snmp4jLogFileHandlerBufferSize</code>.
*/
static class Snmp4jLogFileHandlerBufferSizeValidator implements MOValueValidationListener {
public void validate(MOValueValidationEvent validationEvent) {
Variable newValue = validationEvent.getNewValue();
//--AgentGen BEGIN=snmp4jLogFileHandlerBufferSize::validate
//--AgentGen END
}
}
/**
* The <code>Snmp4jLogConsoleHandlerTargetValidator</code> implements the value
* validation for <code>Snmp4jLogConsoleHandlerTarget</code>.
*/
static class Snmp4jLogConsoleHandlerTargetValidator implements MOValueValidationListener {
public void validate(MOValueValidationEvent validationEvent) {
Variable newValue = validationEvent.getNewValue();
//--AgentGen BEGIN=snmp4jLogConsoleHandlerTarget::validate
//--AgentGen END
}
}
public static final class Snmp4jLogLoggerToHandlerThresholdEnum {
/* -- no level has been specified */
public static final int notSpecified = 0;
public static final int off = 1;
public static final int all = 2;
public static final int trace = 3;
public static final int debug = 4;
public static final int info = 5;
public static final int warn = 6;
public static final int error = 7;
public static final int fatal = 8;
}
public static final class Snmp4jLogFileHandlerAppendEnum {
public static final int _true = 1;
public static final int _false = 2;
}
public static final class Snmp4jLogFileHandlerBufferedIOEnum {
public static final int _true = 1;
public static final int _false = 2;
}
public static final class Snmp4jLogConsoleHandlerTargetEnum {
public static final int systemOut = 1;
public static final int systemErr = 2;
}
// Rows and Factories
class Snmp4jLogLoggerEntryRowFactory
extends DefaultMOMutableRow2PCFactory
{
public Snmp4jLogLoggerEntryRowFactory() {}
public MOTableRow createRow(OID index, Variable[] values)
throws UnsupportedOperationException
{
// Snmp4jLogLoggerEntryRow row = new Snmp4jLogLoggerEntryRow(index, values);
//--AgentGen BEGIN=snmp4jLogLoggerEntry::createRow
int i = nextLoggerIndex++;
Snmp4jLogLoggerEntryRow row =
new Snmp4jLogLoggerRow(index, values, i, null);
row.setSnmp4jLogLoggerIndex(new Integer32(i));
loggerNames2Index.put(new OctetString(index.toByteArray()).toString(),
new Integer(i));
//--AgentGen END
return row;
}
public void freeRow(MOTableRow row) {
//--AgentGen BEGIN=snmp4jLogLoggerEntry::freeRow
//--AgentGen END
}
}
class Snmp4jLogLoggerEntryRow extends DefaultMOMutableRow2PC {
public Snmp4jLogLoggerEntryRow(OID index, Variable[] values) {
super(index, values);
}
public Integer32 getSnmp4jLogLoggerIndex() {
return (Integer32) getValue(idxSnmp4jLogLoggerIndex);
}
public void setSnmp4jLogLoggerIndex(Integer32 newValue) {
setValue(idxSnmp4jLogLoggerIndex, newValue);
}
public Integer32 getSnmp4jLogLoggerLevel() {
return (Integer32) getValue(idxSnmp4jLogLoggerLevel);
}
public void setSnmp4jLogLoggerLevel(Integer32 newValue) {
setValue(idxSnmp4jLogLoggerLevel, newValue);
}
public Integer32 getSnmp4jLogLoggerEffectiveLevel() {
return (Integer32) getValue(idxSnmp4jLogLoggerEffectiveLevel);
}
public void setSnmp4jLogLoggerEffectiveLevel(Integer32 newValue) {
setValue(idxSnmp4jLogLoggerEffectiveLevel, newValue);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -