0001: /*_############################################################################
0002: _##
0003: _## SNMP4J-Agent - Snmp4jLogMib.java
0004: _##
0005: _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
0006: _##
0007: _## Licensed under the Apache License, Version 2.0 (the "License");
0008: _## you may not use this file except in compliance with the License.
0009: _## You may obtain a copy of the License at
0010: _##
0011: _## http://www.apache.org/licenses/LICENSE-2.0
0012: _##
0013: _## Unless required by applicable law or agreed to in writing, software
0014: _## distributed under the License is distributed on an "AS IS" BASIS,
0015: _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016: _## See the License for the specific language governing permissions and
0017: _## limitations under the License.
0018: _##
0019: _##########################################################################*/
0020:
0021: package org.snmp4j.agent.mo.snmp4j;
0022:
0023: //--AgentGen BEGIN=_BEGIN
0024: //--AgentGen END
0025:
0026: import org.snmp4j.smi.*;
0027: import org.snmp4j.mp.SnmpConstants;
0028: import org.snmp4j.agent.*;
0029: import org.snmp4j.agent.mo.*;
0030: import org.snmp4j.agent.mo.snmp.*;
0031: import org.snmp4j.agent.request.*;
0032: import org.snmp4j.log.LogFactory;
0033: import org.snmp4j.log.LogAdapter;
0034: import org.snmp4j.log.LogLevel;
0035:
0036: //--AgentGen BEGIN=_IMPORT
0037: import java.util.Iterator;
0038: import java.util.HashMap;
0039: import java.util.Map;
0040: import java.util.WeakHashMap;
0041: import org.snmp4j.agent.io.MOInput;
0042: import java.io.IOException;
0043:
0044: //--AgentGen END
0045:
0046: public class Snmp4jLogMib
0047: //--AgentGen BEGIN=_EXTENDS
0048: //--AgentGen END
0049: implements MOGroup
0050: //--AgentGen BEGIN=_IMPLEMENTS
0051: , MOServerLookupListener, MOTableRowListener, RowStatusListener
0052: //--AgentGen END
0053: {
0054:
0055: private static final LogAdapter LOGGER = LogFactory
0056: .getLogger(Snmp4jLogMib.class);
0057:
0058: //--AgentGen BEGIN=_STATIC
0059: private static final MOTableRowFilter NOT_ACTIVE_ROW_FILTER = new MOTableRowFilter() {
0060: public boolean passesFilter(MOTableRow row) {
0061: if (row instanceof Snmp4jLogLoggerRow) {
0062: Snmp4jLogLoggerRow r = (Snmp4jLogLoggerRow) row;
0063: if (r.getSnmp4jLogLoggerRowStatus().getValue() == RowStatus.active) {
0064: return true;
0065: }
0066: }
0067: return false;
0068: }
0069:
0070: };
0071: //--AgentGen END
0072:
0073: // Factory
0074: private static MOFactory moFactory = DefaultMOFactory.getInstance();
0075:
0076: // Constants
0077: private static final OID oidSnmp4jLogSysDescr = new OID(new int[] {
0078: 1, 3, 6, 1, 4, 1, 4976, 10, 1, 1, 1, 1, 1, 1, 0 });
0079: private static final OID oidSnmp4jLogFactory = new OID(new int[] {
0080: 1, 3, 6, 1, 4, 1, 4976, 10, 1, 1, 1, 1, 1, 2, 0 });
0081: private static final OID oidSnmp4jLogRootLevel = new OID(new int[] {
0082: 1, 3, 6, 1, 4, 1, 4976, 10, 1, 1, 1, 1, 2, 1, 0 });
0083:
0084: // Scalars
0085: private MOScalar snmp4jLogSysDescr;
0086: private MOScalar snmp4jLogFactory;
0087: private MOScalar snmp4jLogRootLevel;
0088:
0089: // Tables
0090: private static final OID oidSnmp4jLogLoggerEntry = new OID(
0091: new int[] { 1, 3, 6, 1, 4, 1, 4976, 10, 1, 1, 1, 1, 2, 2, 1 });
0092:
0093: // Column sub-identifer defintions for snmp4jLogLoggerEntry:
0094: private static final int colSnmp4jLogLoggerIndex = 2;
0095: private static final int colSnmp4jLogLoggerLevel = 3;
0096: private static final int colSnmp4jLogLoggerEffectiveLevel = 4;
0097: private static final int colSnmp4jLogLoggerStorageType = 5;
0098: private static final int colSnmp4jLogLoggerRowStatus = 6;
0099:
0100: // Column index defintions for snmp4jLogLoggerEntry:
0101: private static final int idxSnmp4jLogLoggerIndex = 0;
0102: private static final int idxSnmp4jLogLoggerLevel = 1;
0103: private static final int idxSnmp4jLogLoggerEffectiveLevel = 2;
0104: private static final int idxSnmp4jLogLoggerStorageType = 3;
0105: private static final int idxSnmp4jLogLoggerRowStatus = 4;
0106: private static MOTableSubIndex[] snmp4jLogLoggerEntryIndexes = new MOTableSubIndex[] { moFactory
0107: .createSubIndex(SMIConstants.SYNTAX_OCTET_STRING, 0, 127) };
0108:
0109: private static MOTableIndex snmp4jLogLoggerEntryIndex = moFactory
0110: .createIndex(snmp4jLogLoggerEntryIndexes, true,
0111: new MOTableIndexValidator() {
0112: public boolean isValidIndex(OID index) {
0113: boolean isValidIndex = true;
0114: //--AgentGen BEGIN=snmp4jLogLoggerEntry::isValidIndex
0115: //--AgentGen END
0116: return isValidIndex;
0117: }
0118: });
0119:
0120: private MOTable snmp4jLogLoggerEntry;
0121: private MOMutableTableModel snmp4jLogLoggerEntryModel;
0122: private static final OID oidSnmp4jLogLoggerToHandlerEntry = new OID(
0123: new int[] { 1, 3, 6, 1, 4, 1, 4976, 10, 1, 1, 1, 1, 2, 3, 1 });
0124:
0125: // Column sub-identifer defintions for snmp4jLogLoggerToHandlerEntry:
0126: private static final int colSnmp4jLogLoggerToHandlerThreshold = 1;
0127: private static final int colSnmp4jLogLoggerToHandlerStorageType = 2;
0128: private static final int colSnmp4jLogLoggerToHandlerRowStatus = 3;
0129:
0130: // Column index defintions for snmp4jLogLoggerToHandlerEntry:
0131: private static final int idxSnmp4jLogLoggerToHandlerThreshold = 0;
0132: private static final int idxSnmp4jLogLoggerToHandlerStorageType = 1;
0133: private static final int idxSnmp4jLogLoggerToHandlerRowStatus = 2;
0134: private static MOTableSubIndex[] snmp4jLogLoggerToHandlerEntryIndexes = new MOTableSubIndex[] {
0135: moFactory.createSubIndex(SMIConstants.SYNTAX_INTEGER, 1, 1),
0136: moFactory.createSubIndex(SMIConstants.SYNTAX_OCTET_STRING,
0137: 0, 255) };
0138:
0139: private static MOTableIndex snmp4jLogLoggerToHandlerEntryIndex = moFactory
0140: .createIndex(snmp4jLogLoggerToHandlerEntryIndexes, false);
0141:
0142: private MOTable snmp4jLogLoggerToHandlerEntry;
0143: private MOMutableTableModel snmp4jLogLoggerToHandlerEntryModel;
0144: private static final OID oidSnmp4jLogHandlerEntry = new OID(
0145: new int[] { 1, 3, 6, 1, 4, 1, 4976, 10, 1, 1, 1, 1, 2, 5,
0146: 2, 1 });
0147:
0148: // Column sub-identifer defintions for snmp4jLogHandlerEntry:
0149: private static final int colSnmp4jLogHandlerType = 2;
0150: private static final int colSnmp4jLogHandlerStorageType = 3;
0151: private static final int colSnmp4jLogHandlerRowStatus = 4;
0152:
0153: // Column index defintions for snmp4jLogHandlerEntry:
0154: private static final int idxSnmp4jLogHandlerType = 0;
0155: private static final int idxSnmp4jLogHandlerStorageType = 1;
0156: private static final int idxSnmp4jLogHandlerRowStatus = 2;
0157: private static MOTableSubIndex[] snmp4jLogHandlerEntryIndexes = new MOTableSubIndex[] { moFactory
0158: .createSubIndex(SMIConstants.SYNTAX_OCTET_STRING, 0, 255) };
0159:
0160: private static MOTableIndex snmp4jLogHandlerEntryIndex = moFactory
0161: .createIndex(snmp4jLogHandlerEntryIndexes, false);
0162:
0163: private MOTable snmp4jLogHandlerEntry;
0164: private MOMutableTableModel snmp4jLogHandlerEntryModel;
0165: private static final OID oidSnmp4jLogFileHandlerEntry = new OID(
0166: new int[] { 1, 3, 6, 1, 4, 1, 4976, 10, 1, 1, 1, 1, 2, 5,
0167: 3, 1, 1 });
0168:
0169: // Column sub-identifer defintions for snmp4jLogFileHandlerEntry:
0170: private static final int colSnmp4jLogFileHandlerPath = 1;
0171: private static final int colSnmp4jLogFileHandlerAppend = 2;
0172: private static final int colSnmp4jLogFileHandlerBufferedIO = 3;
0173: private static final int colSnmp4jLogFileHandlerBufferSize = 4;
0174:
0175: // Column index defintions for snmp4jLogFileHandlerEntry:
0176: private static final int idxSnmp4jLogFileHandlerPath = 0;
0177: private static final int idxSnmp4jLogFileHandlerAppend = 1;
0178: private static final int idxSnmp4jLogFileHandlerBufferedIO = 2;
0179: private static final int idxSnmp4jLogFileHandlerBufferSize = 3;
0180: private static MOTableSubIndex[] snmp4jLogFileHandlerEntryIndexes = new MOTableSubIndex[] { moFactory
0181: .createSubIndex(SMIConstants.SYNTAX_OCTET_STRING, 0, 255) };
0182:
0183: private static MOTableIndex snmp4jLogFileHandlerEntryIndex = moFactory
0184: .createIndex(snmp4jLogFileHandlerEntryIndexes, false);
0185:
0186: private MOTable snmp4jLogFileHandlerEntry;
0187: private MOMutableTableModel snmp4jLogFileHandlerEntryModel;
0188: private static final OID oidSnmp4jLogConsoleHandlerEntry = new OID(
0189: new int[] { 1, 3, 6, 1, 4, 1, 4976, 10, 1, 1, 1, 1, 2, 5,
0190: 3, 2, 1 });
0191:
0192: // Column sub-identifer defintions for snmp4jLogConsoleHandlerEntry:
0193: private static final int colSnmp4jLogConsoleHandlerTarget = 1;
0194:
0195: // Column index defintions for snmp4jLogConsoleHandlerEntry:
0196: private static final int idxSnmp4jLogConsoleHandlerTarget = 0;
0197: private static MOTableSubIndex[] snmp4jLogConsoleHandlerEntryIndexes = new MOTableSubIndex[] { moFactory
0198: .createSubIndex(SMIConstants.SYNTAX_OCTET_STRING, 0, 127) };
0199:
0200: private static MOTableIndex snmp4jLogConsoleHandlerEntryIndex = moFactory
0201: .createIndex(snmp4jLogConsoleHandlerEntryIndexes, false);
0202:
0203: private MOTable snmp4jLogConsoleHandlerEntry;
0204: private MOMutableTableModel snmp4jLogConsoleHandlerEntryModel;
0205:
0206: //--AgentGen BEGIN=_MEMBERS
0207: private Map loggers = new HashMap();
0208: private Map loggerNames2Index = new WeakHashMap();
0209: private int nextLoggerIndex = 1;
0210: private Object lastLoggerUpdateSource;
0211:
0212: //--AgentGen END
0213:
0214: public Snmp4jLogMib() {
0215: snmp4jLogSysDescr = moFactory.createScalar(
0216: oidSnmp4jLogSysDescr, MOAccessImpl.ACCESS_READ_ONLY,
0217: new OctetString());
0218: snmp4jLogFactory = moFactory.createScalar(oidSnmp4jLogFactory,
0219: MOAccessImpl.ACCESS_READ_ONLY, new OctetString());
0220: snmp4jLogRootLevel = new Snmp4jLogRootLevel(
0221: oidSnmp4jLogRootLevel, MOAccessImpl.ACCESS_READ_WRITE);
0222: snmp4jLogRootLevel
0223: .addMOValueValidationListener(new Snmp4jLogLevelValidator());
0224: createSnmp4jLogLoggerEntry();
0225: createSnmp4jLogLoggerToHandlerEntry();
0226: createSnmp4jLogHandlerEntry();
0227: createSnmp4jLogFileHandlerEntry();
0228: createSnmp4jLogConsoleHandlerEntry();
0229: //--AgentGen BEGIN=_DEFAULTCONSTRUCTOR
0230: //--AgentGen END
0231: }
0232:
0233: public MOTable getSnmp4jLogLoggerEntry() {
0234: return snmp4jLogLoggerEntry;
0235: }
0236:
0237: private void createSnmp4jLogLoggerEntry() {
0238: MOColumn[] snmp4jLogLoggerEntryColumns = new MOColumn[5];
0239: snmp4jLogLoggerEntryColumns[idxSnmp4jLogLoggerIndex] = new MOColumn(
0240: colSnmp4jLogLoggerIndex, SMIConstants.SYNTAX_INTEGER32,
0241: MOAccessImpl.ACCESS_READ_ONLY);
0242: snmp4jLogLoggerEntryColumns[idxSnmp4jLogLoggerLevel] = new MOMutableColumn(
0243: colSnmp4jLogLoggerLevel, SMIConstants.SYNTAX_INTEGER,
0244: MOAccessImpl.ACCESS_READ_CREATE, new Integer32(1), true);
0245: ((MOMutableColumn) snmp4jLogLoggerEntryColumns[idxSnmp4jLogLoggerLevel])
0246: .addMOValueValidationListener(new Snmp4jLogLevelValidator());
0247: snmp4jLogLoggerEntryColumns[idxSnmp4jLogLoggerEffectiveLevel] = new MOColumn(
0248: colSnmp4jLogLoggerEffectiveLevel,
0249: SMIConstants.SYNTAX_INTEGER,
0250: MOAccessImpl.ACCESS_READ_ONLY);
0251: snmp4jLogLoggerEntryColumns[idxSnmp4jLogLoggerStorageType] = new StorageType(
0252: colSnmp4jLogLoggerStorageType,
0253: MOAccessImpl.ACCESS_READ_CREATE, new Integer32(2), true);
0254: snmp4jLogLoggerEntryColumns[idxSnmp4jLogLoggerRowStatus] = new RowStatus(
0255: colSnmp4jLogLoggerRowStatus);
0256:
0257: snmp4jLogLoggerEntryModel = new DefaultMOMutableTableModel();
0258: snmp4jLogLoggerEntryModel
0259: .setRowFactory(new Snmp4jLogLoggerEntryRowFactory());
0260: snmp4jLogLoggerEntry = moFactory.createTable(
0261: oidSnmp4jLogLoggerEntry, snmp4jLogLoggerEntryIndex,
0262: snmp4jLogLoggerEntryColumns, snmp4jLogLoggerEntryModel);
0263: ((RowStatus) snmp4jLogLoggerEntryColumns[idxSnmp4jLogLoggerRowStatus])
0264: .addRowStatusListener(this );
0265: snmp4jLogLoggerEntry.addMOTableRowListener(this );
0266: // Not needed any more (since 1.1):
0267: // updateLoggerTable();
0268: }
0269:
0270: public MOTable getSnmp4jLogLoggerToHandlerEntry() {
0271: return snmp4jLogLoggerToHandlerEntry;
0272: }
0273:
0274: private void createSnmp4jLogLoggerToHandlerEntry() {
0275: MOColumn[] snmp4jLogLoggerToHandlerEntryColumns = new MOColumn[3];
0276: snmp4jLogLoggerToHandlerEntryColumns[idxSnmp4jLogLoggerToHandlerThreshold] = new MOMutableColumn(
0277: colSnmp4jLogLoggerToHandlerThreshold,
0278: SMIConstants.SYNTAX_INTEGER,
0279: MOAccessImpl.ACCESS_READ_CREATE, new Integer32(2), true);
0280: ((MOMutableColumn) snmp4jLogLoggerToHandlerEntryColumns[idxSnmp4jLogLoggerToHandlerThreshold])
0281: .addMOValueValidationListener(new Snmp4jLogLevelValidator());
0282: snmp4jLogLoggerToHandlerEntryColumns[idxSnmp4jLogLoggerToHandlerStorageType] = new StorageType(
0283: colSnmp4jLogLoggerToHandlerStorageType,
0284: MOAccessImpl.ACCESS_READ_CREATE, new Integer32(2), true);
0285: snmp4jLogLoggerToHandlerEntryColumns[idxSnmp4jLogLoggerToHandlerRowStatus] = new RowStatus(
0286: colSnmp4jLogLoggerToHandlerRowStatus);
0287:
0288: snmp4jLogLoggerToHandlerEntryModel = new DefaultMOMutableTableModel();
0289: snmp4jLogLoggerToHandlerEntryModel
0290: .setRowFactory(new Snmp4jLogLoggerToHandlerEntryRowFactory());
0291: snmp4jLogLoggerToHandlerEntry = moFactory.createTable(
0292: oidSnmp4jLogLoggerToHandlerEntry,
0293: snmp4jLogLoggerToHandlerEntryIndex,
0294: snmp4jLogLoggerToHandlerEntryColumns,
0295: snmp4jLogLoggerToHandlerEntryModel);
0296: }
0297:
0298: public MOTable getSnmp4jLogHandlerEntry() {
0299: return snmp4jLogHandlerEntry;
0300: }
0301:
0302: private void createSnmp4jLogHandlerEntry() {
0303: MOColumn[] snmp4jLogHandlerEntryColumns = new MOColumn[3];
0304: snmp4jLogHandlerEntryColumns[idxSnmp4jLogHandlerType] = new MOMutableColumn(
0305: colSnmp4jLogHandlerType,
0306: SMIConstants.SYNTAX_OBJECT_IDENTIFIER,
0307: MOAccessImpl.ACCESS_READ_CREATE, new OID(
0308: "1.3.6.1.4.1.4976.10.1.1.1.1.2.5.1.2.1"), true);
0309: ((MOMutableColumn) snmp4jLogHandlerEntryColumns[idxSnmp4jLogHandlerType])
0310: .addMOValueValidationListener(new Snmp4jLogHandlerTypeValidator());
0311: snmp4jLogHandlerEntryColumns[idxSnmp4jLogHandlerStorageType] = new StorageType(
0312: colSnmp4jLogHandlerStorageType,
0313: MOAccessImpl.ACCESS_READ_CREATE, null, true);
0314: snmp4jLogHandlerEntryColumns[idxSnmp4jLogHandlerRowStatus] = new RowStatus(
0315: colSnmp4jLogHandlerRowStatus);
0316:
0317: snmp4jLogHandlerEntryModel = new DefaultMOMutableTableModel();
0318: snmp4jLogHandlerEntryModel
0319: .setRowFactory(new Snmp4jLogHandlerEntryRowFactory());
0320: snmp4jLogHandlerEntry = moFactory.createTable(
0321: oidSnmp4jLogHandlerEntry, snmp4jLogHandlerEntryIndex,
0322: snmp4jLogHandlerEntryColumns,
0323: snmp4jLogHandlerEntryModel);
0324: }
0325:
0326: public MOTable getSnmp4jLogFileHandlerEntry() {
0327: return snmp4jLogFileHandlerEntry;
0328: }
0329:
0330: private void createSnmp4jLogFileHandlerEntry() {
0331: MOColumn[] snmp4jLogFileHandlerEntryColumns = new MOColumn[4];
0332: snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerPath] = new MOMutableColumn(
0333: colSnmp4jLogFileHandlerPath,
0334: SMIConstants.SYNTAX_OCTET_STRING,
0335: MOAccessImpl.ACCESS_READ_CREATE, new OctetString(
0336: new byte[] { (byte) 115, (byte) 110,
0337: (byte) 109, (byte) 112, (byte) 52,
0338: (byte) 106, (byte) 46, (byte) 108,
0339: (byte) 111, (byte) 103 }), true);
0340: ((MOMutableColumn) snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerPath])
0341: .addMOValueValidationListener(new Snmp4jLogFileHandlerPathValidator());
0342: snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerAppend] = new MOMutableColumn(
0343: colSnmp4jLogFileHandlerAppend,
0344: SMIConstants.SYNTAX_INTEGER,
0345: MOAccessImpl.ACCESS_READ_CREATE, new Integer32(1), true);
0346: ((MOMutableColumn) snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerAppend])
0347: .addMOValueValidationListener(new Snmp4jLogFileHandlerAppendValidator());
0348: snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerBufferedIO] = new MOMutableColumn(
0349: colSnmp4jLogFileHandlerBufferedIO,
0350: SMIConstants.SYNTAX_INTEGER,
0351: MOAccessImpl.ACCESS_READ_CREATE, new Integer32(1), true);
0352: ((MOMutableColumn) snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerBufferedIO])
0353: .addMOValueValidationListener(new Snmp4jLogFileHandlerBufferedIOValidator());
0354: snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerBufferSize] = new MOMutableColumn(
0355: colSnmp4jLogFileHandlerBufferSize,
0356: SMIConstants.SYNTAX_GAUGE32,
0357: MOAccessImpl.ACCESS_READ_CREATE, new UnsignedInteger32(
0358: 16535), true);
0359: ((MOMutableColumn) snmp4jLogFileHandlerEntryColumns[idxSnmp4jLogFileHandlerBufferSize])
0360: .addMOValueValidationListener(new Snmp4jLogFileHandlerBufferSizeValidator());
0361:
0362: snmp4jLogFileHandlerEntryModel = new DefaultMOMutableTableModel();
0363: snmp4jLogFileHandlerEntryModel
0364: .setRowFactory(new Snmp4jLogFileHandlerEntryRowFactory());
0365: snmp4jLogFileHandlerEntry = moFactory.createTable(
0366: oidSnmp4jLogFileHandlerEntry,
0367: snmp4jLogFileHandlerEntryIndex,
0368: snmp4jLogFileHandlerEntryColumns,
0369: snmp4jLogFileHandlerEntryModel);
0370: }
0371:
0372: public MOTable getSnmp4jLogConsoleHandlerEntry() {
0373: return snmp4jLogConsoleHandlerEntry;
0374: }
0375:
0376: private void createSnmp4jLogConsoleHandlerEntry() {
0377: MOColumn[] snmp4jLogConsoleHandlerEntryColumns = new MOColumn[1];
0378: snmp4jLogConsoleHandlerEntryColumns[idxSnmp4jLogConsoleHandlerTarget] = new Enumerated(
0379: colSnmp4jLogConsoleHandlerTarget,
0380: MOAccessImpl.ACCESS_READ_CREATE, new Integer32(1),
0381: true, new int[] {
0382: Snmp4jLogConsoleHandlerTargetEnum.systemOut,
0383: Snmp4jLogConsoleHandlerTargetEnum.systemErr });
0384: ((MOMutableColumn) snmp4jLogConsoleHandlerEntryColumns[idxSnmp4jLogConsoleHandlerTarget])
0385: .addMOValueValidationListener(new Snmp4jLogConsoleHandlerTargetValidator());
0386:
0387: snmp4jLogConsoleHandlerEntryModel = new DefaultMOMutableTableModel();
0388: snmp4jLogConsoleHandlerEntryModel
0389: .setRowFactory(new Snmp4jLogConsoleHandlerEntryRowFactory());
0390: snmp4jLogConsoleHandlerEntry = moFactory.createTable(
0391: oidSnmp4jLogConsoleHandlerEntry,
0392: snmp4jLogConsoleHandlerEntryIndex,
0393: snmp4jLogConsoleHandlerEntryColumns,
0394: snmp4jLogConsoleHandlerEntryModel);
0395: }
0396:
0397: public void registerMOs(MOServer server, OctetString context)
0398: throws DuplicateRegistrationException {
0399: // Scalar Objects
0400: server.register(this .snmp4jLogSysDescr, context);
0401: server.register(this .snmp4jLogFactory, context);
0402: server.register(this .snmp4jLogRootLevel, context);
0403: server.register(this .snmp4jLogLoggerEntry, context);
0404: /**@todo implement other tables
0405: server.register(this.snmp4jLogLoggerToHandlerEntry, context);
0406: server.register(this.snmp4jLogHandlerEntry, context);
0407: server.register(this.snmp4jLogFileHandlerEntry, context);
0408: server.register(this.snmp4jLogConsoleHandlerEntry, context);
0409: */
0410: //--AgentGen BEGIN=_registerMOs
0411: server.addLookupListener(this , this .snmp4jLogSysDescr);
0412: server.addLookupListener(this , this .snmp4jLogLoggerEntry);
0413: //--AgentGen END
0414: }
0415:
0416: public void unregisterMOs(MOServer server, OctetString context) {
0417: // Scalar Objects
0418: server.unregister(this .snmp4jLogSysDescr, context);
0419: server.unregister(this .snmp4jLogFactory, context);
0420: server.unregister(this .snmp4jLogRootLevel, context);
0421: server.unregister(this .snmp4jLogLoggerEntry, context);
0422: server.unregister(this .snmp4jLogLoggerToHandlerEntry, context);
0423: server.unregister(this .snmp4jLogHandlerEntry, context);
0424: server.unregister(this .snmp4jLogFileHandlerEntry, context);
0425: server.unregister(this .snmp4jLogConsoleHandlerEntry, context);
0426: //--AgentGen BEGIN=_unregisterMOs
0427: server.removeLookupListener(this , this .snmp4jLogSysDescr);
0428: server.removeLookupListener(this , this .snmp4jLogLoggerEntry);
0429: //--AgentGen END
0430: }
0431:
0432: // Notifications
0433:
0434: // Scalars
0435: class Snmp4jLogRootLevel extends MOScalar {
0436: Snmp4jLogRootLevel(OID oid, MOAccess access) {
0437: super (oid, access, new Integer32());
0438: }
0439:
0440: public void commit(SubRequest request) {
0441: //--AgentGen BEGIN=snmp4jLogRootLevel::commit
0442: Variable vb = request.getVariableBinding().getVariable();
0443: int v = ((Integer32) vb).getValue();
0444: LogAdapter logAdapter = LogFactory.getLogFactory()
0445: .getRootLogger();
0446: logAdapter.setLogLevel(new LogLevel(v));
0447: //--AgentGen END
0448: super .commit(request);
0449: }
0450:
0451: public void load(MOInput input) throws IOException {
0452: super .load(input);
0453: int v = ((Integer32) getValue()).getValue();
0454: LogAdapter logAdapter = LogFactory.getLogFactory()
0455: .getRootLogger();
0456: if (v != LogLevel.LEVEL_NONE) {
0457: logAdapter.setLogLevel(new LogLevel(v));
0458: }
0459: }
0460:
0461: }
0462:
0463: // Value Validators
0464: /**
0465: * The <code>Snmp4jLogRootLevelValidator</code> implements the value
0466: * validation for <code>Snmp4jLogRootLevel</code>.
0467: */
0468: static class Snmp4jLogLevelValidator implements
0469: MOValueValidationListener {
0470:
0471: public void validate(MOValueValidationEvent validationEvent) {
0472: Variable newValue = validationEvent.getNewValue();
0473: //--AgentGen BEGIN=snmp4jLogRootLevel::validate
0474: int v = ((Integer32) newValue).getValue();
0475: if ((v < 1) || (v > 8)) {
0476: validationEvent
0477: .setValidationStatus(SnmpConstants.SNMP_ERROR_WRONG_VALUE);
0478: }
0479: //--AgentGen END
0480: }
0481: }
0482:
0483: /**
0484: * The <code>Snmp4jLogHandlerTypeValidator</code> implements the value
0485: * validation for <code>Snmp4jLogHandlerType</code>.
0486: */
0487: static class Snmp4jLogHandlerTypeValidator implements
0488: MOValueValidationListener {
0489:
0490: public void validate(MOValueValidationEvent validationEvent) {
0491: Variable newValue = validationEvent.getNewValue();
0492: //--AgentGen BEGIN=snmp4jLogHandlerType::validate
0493: //--AgentGen END
0494: }
0495: }
0496:
0497: /**
0498: * The <code>Snmp4jLogFileHandlerPathValidator</code> implements the value
0499: * validation for <code>Snmp4jLogFileHandlerPath</code>.
0500: */
0501: static class Snmp4jLogFileHandlerPathValidator implements
0502: MOValueValidationListener {
0503:
0504: public void validate(MOValueValidationEvent validationEvent) {
0505: Variable newValue = validationEvent.getNewValue();
0506: OctetString os = (OctetString) newValue;
0507: if (!(((os.length() >= 1) && (os.length() <= 512)))) {
0508: validationEvent
0509: .setValidationStatus(SnmpConstants.SNMP_ERROR_WRONG_LENGTH);
0510: return;
0511: }
0512: //--AgentGen BEGIN=snmp4jLogFileHandlerPath::validate
0513: //--AgentGen END
0514: }
0515: }
0516:
0517: /**
0518: * The <code>Snmp4jLogFileHandlerAppendValidator</code> implements the value
0519: * validation for <code>Snmp4jLogFileHandlerAppend</code>.
0520: */
0521: static class Snmp4jLogFileHandlerAppendValidator implements
0522: MOValueValidationListener {
0523:
0524: public void validate(MOValueValidationEvent validationEvent) {
0525: Variable newValue = validationEvent.getNewValue();
0526: //--AgentGen BEGIN=snmp4jLogFileHandlerAppend::validate
0527: //--AgentGen END
0528: }
0529: }
0530:
0531: /**
0532: * The <code>Snmp4jLogFileHandlerBufferedIOValidator</code> implements the value
0533: * validation for <code>Snmp4jLogFileHandlerBufferedIO</code>.
0534: */
0535: static class Snmp4jLogFileHandlerBufferedIOValidator implements
0536: MOValueValidationListener {
0537:
0538: public void validate(MOValueValidationEvent validationEvent) {
0539: Variable newValue = validationEvent.getNewValue();
0540: //--AgentGen BEGIN=snmp4jLogFileHandlerBufferedIO::validate
0541: //--AgentGen END
0542: }
0543: }
0544:
0545: /**
0546: * The <code>Snmp4jLogFileHandlerBufferSizeValidator</code> implements the value
0547: * validation for <code>Snmp4jLogFileHandlerBufferSize</code>.
0548: */
0549: static class Snmp4jLogFileHandlerBufferSizeValidator implements
0550: MOValueValidationListener {
0551:
0552: public void validate(MOValueValidationEvent validationEvent) {
0553: Variable newValue = validationEvent.getNewValue();
0554: //--AgentGen BEGIN=snmp4jLogFileHandlerBufferSize::validate
0555: //--AgentGen END
0556: }
0557: }
0558:
0559: /**
0560: * The <code>Snmp4jLogConsoleHandlerTargetValidator</code> implements the value
0561: * validation for <code>Snmp4jLogConsoleHandlerTarget</code>.
0562: */
0563: static class Snmp4jLogConsoleHandlerTargetValidator implements
0564: MOValueValidationListener {
0565:
0566: public void validate(MOValueValidationEvent validationEvent) {
0567: Variable newValue = validationEvent.getNewValue();
0568: //--AgentGen BEGIN=snmp4jLogConsoleHandlerTarget::validate
0569: //--AgentGen END
0570: }
0571: }
0572:
0573: public static final class Snmp4jLogLoggerToHandlerThresholdEnum {
0574: /* -- no level has been specified */
0575: public static final int notSpecified = 0;
0576: public static final int off = 1;
0577: public static final int all = 2;
0578: public static final int trace = 3;
0579: public static final int debug = 4;
0580: public static final int info = 5;
0581: public static final int warn = 6;
0582: public static final int error = 7;
0583: public static final int fatal = 8;
0584: }
0585:
0586: public static final class Snmp4jLogFileHandlerAppendEnum {
0587: public static final int _true = 1;
0588: public static final int _false = 2;
0589: }
0590:
0591: public static final class Snmp4jLogFileHandlerBufferedIOEnum {
0592: public static final int _true = 1;
0593: public static final int _false = 2;
0594: }
0595:
0596: public static final class Snmp4jLogConsoleHandlerTargetEnum {
0597: public static final int systemOut = 1;
0598: public static final int systemErr = 2;
0599: }
0600:
0601: // Rows and Factories
0602: class Snmp4jLogLoggerEntryRowFactory extends
0603: DefaultMOMutableRow2PCFactory {
0604: public Snmp4jLogLoggerEntryRowFactory() {
0605: }
0606:
0607: public MOTableRow createRow(OID index, Variable[] values)
0608: throws UnsupportedOperationException {
0609: // Snmp4jLogLoggerEntryRow row = new Snmp4jLogLoggerEntryRow(index, values);
0610: //--AgentGen BEGIN=snmp4jLogLoggerEntry::createRow
0611: int i = nextLoggerIndex++;
0612: Snmp4jLogLoggerEntryRow row = new Snmp4jLogLoggerRow(index,
0613: values, i, null);
0614: row.setSnmp4jLogLoggerIndex(new Integer32(i));
0615: loggerNames2Index.put(new OctetString(index.toByteArray())
0616: .toString(), new Integer(i));
0617: //--AgentGen END
0618: return row;
0619: }
0620:
0621: public void freeRow(MOTableRow row) {
0622: //--AgentGen BEGIN=snmp4jLogLoggerEntry::freeRow
0623: //--AgentGen END
0624: }
0625: }
0626:
0627: class Snmp4jLogLoggerEntryRow extends DefaultMOMutableRow2PC {
0628: public Snmp4jLogLoggerEntryRow(OID index, Variable[] values) {
0629: super (index, values);
0630: }
0631:
0632: public Integer32 getSnmp4jLogLoggerIndex() {
0633: return (Integer32) getValue(idxSnmp4jLogLoggerIndex);
0634: }
0635:
0636: public void setSnmp4jLogLoggerIndex(Integer32 newValue) {
0637: setValue(idxSnmp4jLogLoggerIndex, newValue);
0638: }
0639:
0640: public Integer32 getSnmp4jLogLoggerLevel() {
0641: return (Integer32) getValue(idxSnmp4jLogLoggerLevel);
0642: }
0643:
0644: public void setSnmp4jLogLoggerLevel(Integer32 newValue) {
0645: setValue(idxSnmp4jLogLoggerLevel, newValue);
0646: }
0647:
0648: public Integer32 getSnmp4jLogLoggerEffectiveLevel() {
0649: return (Integer32) getValue(idxSnmp4jLogLoggerEffectiveLevel);
0650: }
0651:
0652: public void setSnmp4jLogLoggerEffectiveLevel(Integer32 newValue) {
0653: setValue(idxSnmp4jLogLoggerEffectiveLevel, newValue);
0654: }
0655:
0656: public Integer32 getSnmp4jLogLoggerStorageType() {
0657: return (Integer32) getValue(idxSnmp4jLogLoggerStorageType);
0658: }
0659:
0660: public void setSnmp4jLogLoggerStorageType(Integer32 newValue) {
0661: setValue(idxSnmp4jLogLoggerStorageType, newValue);
0662: }
0663:
0664: public Integer32 getSnmp4jLogLoggerRowStatus() {
0665: return (Integer32) getValue(idxSnmp4jLogLoggerRowStatus);
0666: }
0667:
0668: public void setSnmp4jLogLoggerRowStatus(Integer32 newValue) {
0669: setValue(idxSnmp4jLogLoggerRowStatus, newValue);
0670: }
0671:
0672: //--AgentGen BEGIN=snmp4jLogLoggerEntry::RowFactory
0673: //--AgentGen END
0674: }
0675:
0676: class Snmp4jLogLoggerToHandlerEntryRowFactory extends
0677: DefaultMOMutableRow2PCFactory {
0678: public MOTableRow createRow(OID index, Variable[] values)
0679: throws UnsupportedOperationException {
0680: Snmp4jLogLoggerToHandlerEntryRow row = new Snmp4jLogLoggerToHandlerEntryRow(
0681: index, values);
0682: //--AgentGen BEGIN=snmp4jLogLoggerToHandlerEntry::createRow
0683: //--AgentGen END
0684: return row;
0685: }
0686:
0687: public void freeRow(MOTableRow row) {
0688: //--AgentGen BEGIN=snmp4jLogLoggerToHandlerEntry::freeRow
0689: //--AgentGen END
0690: }
0691: }
0692:
0693: class Snmp4jLogLoggerToHandlerEntryRow extends
0694: DefaultMOMutableRow2PC {
0695: public Snmp4jLogLoggerToHandlerEntryRow(OID index,
0696: Variable[] values) {
0697: super (index, values);
0698: }
0699:
0700: public Integer32 getSnmp4jLogLoggerToHandlerThreshold() {
0701: return (Integer32) getValue(idxSnmp4jLogLoggerToHandlerThreshold);
0702: }
0703:
0704: public void setSnmp4jLogLoggerToHandlerThreshold(
0705: Integer32 newValue) {
0706: setValue(idxSnmp4jLogLoggerToHandlerThreshold, newValue);
0707: }
0708:
0709: public Integer32 getSnmp4jLogLoggerToHandlerStorageType() {
0710: return (Integer32) getValue(idxSnmp4jLogLoggerToHandlerStorageType);
0711: }
0712:
0713: public void setSnmp4jLogLoggerToHandlerStorageType(
0714: Integer32 newValue) {
0715: setValue(idxSnmp4jLogLoggerToHandlerStorageType, newValue);
0716: }
0717:
0718: public Integer32 getSnmp4jLogLoggerToHandlerRowStatus() {
0719: return (Integer32) getValue(idxSnmp4jLogLoggerToHandlerRowStatus);
0720: }
0721:
0722: public void setSnmp4jLogLoggerToHandlerRowStatus(
0723: Integer32 newValue) {
0724: setValue(idxSnmp4jLogLoggerToHandlerRowStatus, newValue);
0725: }
0726:
0727: //--AgentGen BEGIN=snmp4jLogLoggerToHandlerEntry::RowFactory
0728: //--AgentGen END
0729: }
0730:
0731: class Snmp4jLogHandlerEntryRowFactory extends
0732: DefaultMOMutableRow2PCFactory {
0733: public MOTableRow createRow(OID index, Variable[] values)
0734: throws UnsupportedOperationException {
0735: Snmp4jLogHandlerEntryRow row = new Snmp4jLogHandlerEntryRow(
0736: index, values);
0737: //--AgentGen BEGIN=snmp4jLogHandlerEntry::createRow
0738: //--AgentGen END
0739: return row;
0740: }
0741:
0742: public void freeRow(MOTableRow row) {
0743: //--AgentGen BEGIN=snmp4jLogHandlerEntry::freeRow
0744: //--AgentGen END
0745: }
0746: }
0747:
0748: class Snmp4jLogHandlerEntryRow extends DefaultMOMutableRow2PC {
0749: public Snmp4jLogHandlerEntryRow(OID index, Variable[] values) {
0750: super (index, values);
0751: }
0752:
0753: public OID getSnmp4jLogHandlerType() {
0754: return (OID) getValue(idxSnmp4jLogHandlerType);
0755: }
0756:
0757: public void setSnmp4jLogHandlerType(OID newValue) {
0758: setValue(idxSnmp4jLogHandlerType, newValue);
0759: }
0760:
0761: public Integer32 getSnmp4jLogHandlerStorageType() {
0762: return (Integer32) getValue(idxSnmp4jLogHandlerStorageType);
0763: }
0764:
0765: public void setSnmp4jLogHandlerStorageType(Integer32 newValue) {
0766: setValue(idxSnmp4jLogHandlerStorageType, newValue);
0767: }
0768:
0769: public Integer32 getSnmp4jLogHandlerRowStatus() {
0770: return (Integer32) getValue(idxSnmp4jLogHandlerRowStatus);
0771: }
0772:
0773: public void setSnmp4jLogHandlerRowStatus(Integer32 newValue) {
0774: setValue(idxSnmp4jLogHandlerRowStatus, newValue);
0775: }
0776:
0777: //--AgentGen BEGIN=snmp4jLogHandlerEntry::RowFactory
0778: //--AgentGen END
0779: }
0780:
0781: class Snmp4jLogFileHandlerEntryRowFactory extends
0782: DefaultMOMutableRow2PCFactory {
0783: public MOTableRow createRow(OID index, Variable[] values)
0784: throws UnsupportedOperationException {
0785: Snmp4jLogFileHandlerEntryRow row = new Snmp4jLogFileHandlerEntryRow(
0786: index, values);
0787: //--AgentGen BEGIN=snmp4jLogFileHandlerEntry::createRow
0788: //--AgentGen END
0789: return row;
0790: }
0791:
0792: public void freeRow(MOTableRow row) {
0793: //--AgentGen BEGIN=snmp4jLogFileHandlerEntry::freeRow
0794: //--AgentGen END
0795: }
0796: }
0797:
0798: class Snmp4jLogFileHandlerEntryRow extends DefaultMOMutableRow2PC {
0799: public Snmp4jLogFileHandlerEntryRow(OID index, Variable[] values) {
0800: super (index, values);
0801: }
0802:
0803: public OctetString getSnmp4jLogFileHandlerPath() {
0804: return (OctetString) getValue(idxSnmp4jLogFileHandlerPath);
0805: }
0806:
0807: public void setSnmp4jLogFileHandlerPath(OctetString newValue) {
0808: setValue(idxSnmp4jLogFileHandlerPath, newValue);
0809: }
0810:
0811: public Integer32 getSnmp4jLogFileHandlerAppend() {
0812: return (Integer32) getValue(idxSnmp4jLogFileHandlerAppend);
0813: }
0814:
0815: public void setSnmp4jLogFileHandlerAppend(Integer32 newValue) {
0816: setValue(idxSnmp4jLogFileHandlerAppend, newValue);
0817: }
0818:
0819: public Integer32 getSnmp4jLogFileHandlerBufferedIO() {
0820: return (Integer32) getValue(idxSnmp4jLogFileHandlerBufferedIO);
0821: }
0822:
0823: public void setSnmp4jLogFileHandlerBufferedIO(Integer32 newValue) {
0824: setValue(idxSnmp4jLogFileHandlerBufferedIO, newValue);
0825: }
0826:
0827: public UnsignedInteger32 getSnmp4jLogFileHandlerBufferSize() {
0828: return (UnsignedInteger32) getValue(idxSnmp4jLogFileHandlerBufferSize);
0829: }
0830:
0831: public void setSnmp4jLogFileHandlerBufferSize(
0832: UnsignedInteger32 newValue) {
0833: setValue(idxSnmp4jLogFileHandlerBufferSize, newValue);
0834: }
0835:
0836: //--AgentGen BEGIN=snmp4jLogFileHandlerEntry::RowFactory
0837: //--AgentGen END
0838: }
0839:
0840: class Snmp4jLogConsoleHandlerEntryRowFactory extends
0841: DefaultMOMutableRow2PCFactory {
0842: public Snmp4jLogConsoleHandlerEntryRowFactory() {
0843: }
0844:
0845: public MOTableRow createRow(OID index, Variable[] values)
0846: throws UnsupportedOperationException {
0847: Snmp4jLogConsoleHandlerEntryRow row = new Snmp4jLogConsoleHandlerEntryRow(
0848: index, values);
0849: //--AgentGen BEGIN=snmp4jLogConsoleHandlerEntry::createRow
0850:
0851: //--AgentGen END
0852: return row;
0853: }
0854:
0855: public void freeRow(MOTableRow row) {
0856: //--AgentGen BEGIN=snmp4jLogConsoleHandlerEntry::freeRow
0857: //--AgentGen END
0858: }
0859: }
0860:
0861: class Snmp4jLogConsoleHandlerEntryRow extends
0862: DefaultMOMutableRow2PC {
0863: public Snmp4jLogConsoleHandlerEntryRow(OID index,
0864: Variable[] values) {
0865: super (index, values);
0866: }
0867:
0868: public Integer32 getSnmp4jLogConsoleHandlerTarget() {
0869: return (Integer32) getValue(idxSnmp4jLogConsoleHandlerTarget);
0870: }
0871:
0872: public void setSnmp4jLogConsoleHandlerTarget(Integer32 newValue) {
0873: setValue(idxSnmp4jLogConsoleHandlerTarget, newValue);
0874: }
0875:
0876: //--AgentGen BEGIN=snmp4jLogConsoleHandlerEntry::RowFactory
0877: //--AgentGen END
0878: }
0879:
0880: //--AgentGen BEGIN=_METHODS
0881:
0882: private OctetString getLogSysDescr() {
0883: LogFactory logFactory = LogFactory.getLogFactory();
0884: if (logFactory == null) {
0885: return new OctetString();
0886: }
0887: return new OctetString(logFactory.toString());
0888: }
0889:
0890: private OctetString getLogFactory() {
0891: LogFactory logFactory = LogFactory.getLogFactory();
0892: if (logFactory == null) {
0893: return new OctetString();
0894: }
0895: return new OctetString(logFactory.getClass().getName());
0896: }
0897:
0898: public void lookupEvent(MOServerLookupEvent event) {
0899: if (event.getLookupResult() == this .snmp4jLogSysDescr) {
0900: this .snmp4jLogSysDescr.setValue(getLogSysDescr());
0901: }
0902: if (event.getLookupResult() == this .snmp4jLogFactory) {
0903: this .snmp4jLogFactory.setValue(getLogFactory());
0904: }
0905: /* This table is updated by the queryEvent method below
0906: else if (event.getLookupResult() == this.snmp4jLogLoggerEntry) {
0907: updateLoggerTable();
0908: }
0909: */
0910: }
0911:
0912: public void queryEvent(MOServerLookupEvent event) {
0913: if ((event.getLookupResult() == this .snmp4jLogLoggerEntry)
0914: && (!DefaultMOQuery.isSameSource(event.getQuery(),
0915: lastLoggerUpdateSource))) {
0916: lastLoggerUpdateSource = event.getSource();
0917: updateLoggerTable();
0918: }
0919: }
0920:
0921: private static OID getLoggerIndex(LogAdapter logger) {
0922: return new OctetString(logger.getName()).toSubIndex(true);
0923: }
0924:
0925: private Snmp4jLogLoggerRow createLoggerRow(int n,
0926: LogAdapter logger, int storageType) {
0927: OID index = getLoggerIndex(logger);
0928: Variable[] row = new Variable[5];
0929: int i = 0;
0930: row[i++] = new Integer32(n);
0931: row[i++] = new Integer32(logger.getLogLevel().getLevel());
0932: row[i++] = new Integer32(logger.getEffectiveLogLevel()
0933: .getLevel());
0934: row[i++] = new Integer32(storageType);
0935: row[i++] = new Integer32(RowStatus.active);
0936: return new Snmp4jLogLoggerRow(index, row, n, logger);
0937: }
0938:
0939: private int getStorageType(LogAdapter logger) {
0940: Snmp4jLogLoggerRow row = (Snmp4jLogLoggerRow) snmp4jLogLoggerEntryModel
0941: .getRow(getLoggerIndex(logger));
0942: if (row != null) {
0943: return row.getSnmp4jLogLoggerStorageType().getValue();
0944: }
0945: return StorageType.volatile_;
0946: }
0947:
0948: public void updateLoggerTable() {
0949: snmp4jLogLoggerEntryModel.clear(NOT_ACTIVE_ROW_FILTER);
0950: if (LogFactory.getLogFactory() == null) {
0951: return;
0952: }
0953: Iterator loggers = LogFactory.getLogFactory().loggers();
0954: this .loggers = new HashMap();
0955: LogAdapter rootLogger = LogFactory.getLogFactory()
0956: .getRootLogger();
0957: snmp4jLogLoggerEntryModel.addRow(createLoggerRow(1, rootLogger,
0958: getStorageType(rootLogger)));
0959: while (loggers.hasNext()) {
0960: LogAdapter l = (LogAdapter) loggers.next();
0961: int i = 1;
0962: Integer index = (Integer) loggerNames2Index
0963: .get(l.getName());
0964: if (index == null) {
0965: i = nextLoggerIndex++;
0966: loggerNames2Index.put(l.getName(), new Integer(i));
0967: } else {
0968: i = index.intValue();
0969: }
0970: this .loggers.put(new Integer(i + 1), l);
0971: snmp4jLogLoggerEntryModel.addRow(createLoggerRow(i + 1, l,
0972: getStorageType(l)));
0973: }
0974: }
0975:
0976: public void rowStatusChanged(RowStatusEvent event) {
0977: if (event.getTable().equals(snmp4jLogLoggerEntry)) {
0978: if ((event.getNewStatus() == RowStatus.active)
0979: || (event.getNewStatus() == RowStatus.createAndGo)) {
0980: Snmp4jLogLoggerRow r = (Snmp4jLogLoggerRow) event
0981: .getRow();
0982: OctetString loggerName = new OctetString(r.getIndex()
0983: .toByteArray());
0984: LogAdapter logAdapter = LogFactory.getLogger(loggerName
0985: .toString());
0986: r.setLogAdapter(logAdapter);
0987: logAdapter.setLogLevel(new LogLevel(r
0988: .getSnmp4jLogLoggerLevel().getValue()));
0989: }
0990: }
0991: }
0992:
0993: public void rowChanged(MOTableRowEvent event) {
0994: if (event.getTable().equals(snmp4jLogLoggerEntry)) {
0995: switch (event.getType()) {
0996: case MOTableRowEvent.UPDATED: {
0997: Snmp4jLogLoggerRow r = (Snmp4jLogLoggerRow) event
0998: .getRow();
0999: if (r.getLogAdapter() != null) {
1000: r.getLogAdapter().setLogLevel(
1001: new LogLevel(r.getSnmp4jLogLoggerLevel()
1002: .getValue()));
1003: }
1004: break;
1005: }
1006: case MOTableRowEvent.ADD: {
1007: Snmp4jLogLoggerRow r = (Snmp4jLogLoggerRow) event
1008: .getRow();
1009: OctetString loggerName = new OctetString(r.getIndex()
1010: .toByteArray());
1011: LogAdapter logAdapter = LogFactory.getLogger(loggerName
1012: .toString());
1013: r.setLogAdapter(logAdapter);
1014: int level = r.getSnmp4jLogLoggerLevel().getValue();
1015: logAdapter.setLogLevel(new LogLevel(level));
1016: break;
1017: }
1018: }
1019: }
1020: }
1021:
1022: //--AgentGen END
1023:
1024: //--AgentGen BEGIN=_CLASSES
1025:
1026: public class Snmp4jLogLoggerRow extends Snmp4jLogLoggerEntryRow {
1027:
1028: private LogAdapter logger;
1029: private int n;
1030:
1031: protected Snmp4jLogLoggerRow(OID index, Variable[] values,
1032: int n, LogAdapter logger) {
1033: super (index, values);
1034: this .n = n;
1035: this .logger = logger;
1036: }
1037:
1038: public void setLogAdapter(LogAdapter logAdapter) {
1039: this .logger = logAdapter;
1040: }
1041:
1042: public LogAdapter getLogAdapter() {
1043: return logger;
1044: }
1045:
1046: }
1047:
1048: //--AgentGen END
1049:
1050: //--AgentGen BEGIN=_END
1051: //--AgentGen END
1052: }
|