/** * Constructor. A Local Configuration Datastore is passed to the engine. It will be used to store * and retrieve data (engine Id, engine boots). * * <p>WARNING : The SnmpEngineId is computed as follow: * * <ul> * <li>If an lcd file is provided containing the property "localEngineID", this property value * is used.. * <li>If not, if the passed engineID is not null, this engine ID is used. * <li>If not, a time based engineID is computed. * </ul> * * This constructor should be called by an <CODE>SnmpEngineFactory</CODE>. Don't call it directly. * * @param fact The factory used to instantiate this engine. * @param lcd The local configuration datastore. * @param engineid The engine ID to use. If null is provided, an SnmpEngineId is computed using * the current time. * @throws UnknownHostException Exception thrown, if the host name located in the property * "localEngineID" is invalid. */ public SnmpEngineImpl(SnmpEngineFactory fact, SnmpLcd lcd, SnmpEngineId engineid) throws UnknownHostException { init(lcd, fact); initEngineID(); if (this.engineid == null) { if (engineid != null) this.engineid = engineid; else this.engineid = SnmpEngineId.createEngineId(); } lcd.storeEngineId(this.engineid); if (isTraceOn()) { trace("SnmpEngine", "LOCAL ENGINE ID: " + this.engineid); } }
/** * Constructor. A Local Configuration Datastore is passed to the engine. It will be used to store * and retrieve data (engine ID, engine boots). * * <p>WARNING : The SnmpEngineId is computed as follow: * * <ul> * <li>If an lcd file is provided containing the property "localEngineID", this property value * is used.. * <li>If not, a time based engineID is computed. * </ul> * * When no configuration nor java property is set for the engine ID value, a unique time based * engine ID will be generated. This constructor should be called by an <CODE>SnmpEngineFactory * </CODE>. Don't call it directly. * * @param fact The factory used to instantiate this engine. * @param lcd The local configuration datastore. */ public SnmpEngineImpl(SnmpEngineFactory fact, SnmpLcd lcd) throws UnknownHostException { init(lcd, fact); initEngineID(); if (engineid == null) engineid = SnmpEngineId.createEngineId(); lcd.storeEngineId(engineid); if (isTraceOn()) { trace( "SnmpEngine", "LOCAL ENGINE ID: " + engineid + " / " + "LOCAL ENGINE NB BOOTS: " + boot + " / " + "LOCAL ENGINE START TIME: " + getEngineTime()); } }
// Initialize the engineID. private void initEngineID() throws UnknownHostException { String id = lcd.getEngineId(); if (id != null) { engineid = SnmpEngineId.createEngineId(id); } }