* Get the PetNameDB for the PetNameNamingService from the router context.

This commit is contained in:
ragnarok
2005-09-18 22:36:10 +00:00
committed by zzz
parent edf04f07c9
commit d40bb459ea
2 changed files with 18 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import net.i2p.client.naming.NamingService; import net.i2p.client.naming.NamingService;
import net.i2p.client.naming.PetNameDB;
import net.i2p.crypto.AESEngine; import net.i2p.crypto.AESEngine;
import net.i2p.crypto.CryptixAESEngine; import net.i2p.crypto.CryptixAESEngine;
import net.i2p.crypto.DSAEngine; import net.i2p.crypto.DSAEngine;
@ -60,6 +61,7 @@ public class I2PAppContext {
private StatManager _statManager; private StatManager _statManager;
private SessionKeyManager _sessionKeyManager; private SessionKeyManager _sessionKeyManager;
private NamingService _namingService; private NamingService _namingService;
private PetNameDB _petnameDb;
private ElGamalEngine _elGamalEngine; private ElGamalEngine _elGamalEngine;
private ElGamalAESEngine _elGamalAESEngine; private ElGamalAESEngine _elGamalAESEngine;
private AESEngine _AESEngine; private AESEngine _AESEngine;
@ -74,6 +76,7 @@ public class I2PAppContext {
private volatile boolean _statManagerInitialized; private volatile boolean _statManagerInitialized;
private volatile boolean _sessionKeyManagerInitialized; private volatile boolean _sessionKeyManagerInitialized;
private volatile boolean _namingServiceInitialized; private volatile boolean _namingServiceInitialized;
private volatile boolean _petnameDbInitialized;
private volatile boolean _elGamalEngineInitialized; private volatile boolean _elGamalEngineInitialized;
private volatile boolean _elGamalAESEngineInitialized; private volatile boolean _elGamalAESEngineInitialized;
private volatile boolean _AESEngineInitialized; private volatile boolean _AESEngineInitialized;
@ -128,6 +131,7 @@ public class I2PAppContext {
_statManager = null; _statManager = null;
_sessionKeyManager = null; _sessionKeyManager = null;
_namingService = null; _namingService = null;
_petnameDb = null;
_elGamalEngine = null; _elGamalEngine = null;
_elGamalAESEngine = null; _elGamalAESEngine = null;
_logManager = null; _logManager = null;
@ -237,6 +241,19 @@ public class I2PAppContext {
} }
} }
public PetNameDB petnameDb() {
if (!_petnameDbInitialized) initializePetnameDb();
return _petnameDb;
}
private void initializePetnameDb() {
synchronized (this) {
if (_petnameDb == null) {
_petnameDb = new PetNameDB();
}
_petnameDbInitialized = true;
}
}
/** /**
* This is the ElGamal engine used within this context. While it doesn't * This is the ElGamal engine used within this context. While it doesn't
* really have anything substantial that is context specific (the algorithm * really have anything substantial that is context specific (the algorithm

View File

@ -17,7 +17,7 @@ public class PetNameNamingService extends NamingService {
public PetNameNamingService(I2PAppContext context) { public PetNameNamingService(I2PAppContext context) {
super(context); super(context);
_petnameDb = new PetNameDB(); _petnameDb = _context.petnameDb();
String file = _context.getProperty(PROP_PETNAME_FILE, DEFAULT_PETNAME_FILE); String file = _context.getProperty(PROP_PETNAME_FILE, DEFAULT_PETNAME_FILE);
//If the petnamedb file doesn't exist, create it, using the //If the petnamedb file doesn't exist, create it, using the