expose the way to specify context env properties
remove unused lazy load code (we actively load components in the RouterContext)
This commit is contained in:
@ -17,6 +17,7 @@ import net.i2p.router.peermanager.ReliabilityCalculator;
|
|||||||
import net.i2p.router.peermanager.SpeedCalculator;
|
import net.i2p.router.peermanager.SpeedCalculator;
|
||||||
import net.i2p.router.peermanager.IntegrationCalculator;
|
import net.i2p.router.peermanager.IntegrationCalculator;
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build off the core I2P context to provide a root for a router instance to
|
* Build off the core I2P context to provide a root for a router instance to
|
||||||
@ -51,8 +52,9 @@ public class RouterContext extends I2PAppContext {
|
|||||||
private Calculator _speedCalc;
|
private Calculator _speedCalc;
|
||||||
private Calculator _reliabilityCalc;
|
private Calculator _reliabilityCalc;
|
||||||
|
|
||||||
public RouterContext(Router router) {
|
public RouterContext(Router router) { this(router, null); }
|
||||||
super();
|
public RouterContext(Router router, Properties envProps) {
|
||||||
|
super(envProps);
|
||||||
_router = router;
|
_router = router;
|
||||||
initAll();
|
initAll();
|
||||||
}
|
}
|
||||||
@ -183,283 +185,3 @@ public class RouterContext extends I2PAppContext {
|
|||||||
/** how do we rank the reliability of profiles? */
|
/** how do we rank the reliability of profiles? */
|
||||||
public Calculator reliabilityCalculator() { return _reliabilityCalc; }
|
public Calculator reliabilityCalculator() { return _reliabilityCalc; }
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public class RouterContext extends I2PAppContext {
|
|
||||||
private Router _router;
|
|
||||||
private ClientManagerFacade _clientManagerFacade;
|
|
||||||
private ClientMessagePool _clientMessagePool;
|
|
||||||
private JobQueue _jobQueue;
|
|
||||||
private InNetMessagePool _inNetMessagePool;
|
|
||||||
private OutNetMessagePool _outNetMessagePool;
|
|
||||||
private MessageHistory _messageHistory;
|
|
||||||
private OutboundMessageRegistry _messageRegistry;
|
|
||||||
private NetworkDatabaseFacade _netDb;
|
|
||||||
private KeyManager _keyManager;
|
|
||||||
private CommSystemFacade _commSystem;
|
|
||||||
private ProfileOrganizer _profileOrganizer;
|
|
||||||
private PeerManagerFacade _peerManagerFacade;
|
|
||||||
private ProfileManager _profileManager;
|
|
||||||
private BandwidthLimiter _bandwidthLimiter;
|
|
||||||
private TunnelManagerFacade _tunnelManager;
|
|
||||||
private StatisticsManager _statPublisher;
|
|
||||||
private Shitlist _shitlist;
|
|
||||||
private MessageValidator _messageValidator;
|
|
||||||
private volatile boolean _clientManagerFacadeInitialized;
|
|
||||||
private volatile boolean _clientMessagePoolInitialized;
|
|
||||||
private volatile boolean _jobQueueInitialized;
|
|
||||||
private volatile boolean _inNetMessagePoolInitialized;
|
|
||||||
private volatile boolean _outNetMessagePoolInitialized;
|
|
||||||
private volatile boolean _messageHistoryInitialized;
|
|
||||||
private volatile boolean _messageRegistryInitialized;
|
|
||||||
private volatile boolean _netDbInitialized;
|
|
||||||
private volatile boolean _peerSelectorInitialized;
|
|
||||||
private volatile boolean _keyManagerInitialized;
|
|
||||||
private volatile boolean _commSystemInitialized;
|
|
||||||
private volatile boolean _profileOrganizerInitialized;
|
|
||||||
private volatile boolean _profileManagerInitialized;
|
|
||||||
private volatile boolean _peerManagerFacadeInitialized;
|
|
||||||
private volatile boolean _bandwidthLimiterInitialized;
|
|
||||||
private volatile boolean _tunnelManagerInitialized;
|
|
||||||
private volatile boolean _statPublisherInitialized;
|
|
||||||
private volatile boolean _shitlistInitialized;
|
|
||||||
private volatile boolean _messageValidatorInitialized;
|
|
||||||
|
|
||||||
private Calculator _isFailingCalc = new IsFailingCalculator(this);
|
|
||||||
private Calculator _integrationCalc = new IntegrationCalculator(this);
|
|
||||||
private Calculator _speedCalc = new SpeedCalculator(this);
|
|
||||||
private Calculator _reliabilityCalc = new ReliabilityCalculator(this);
|
|
||||||
|
|
||||||
public Calculator isFailingCalculator() { return _isFailingCalc; }
|
|
||||||
public Calculator integrationCalculator() { return _integrationCalc; }
|
|
||||||
public Calculator speedCalculator() { return _speedCalc; }
|
|
||||||
public Calculator reliabilityCalculator() { return _reliabilityCalc; }
|
|
||||||
|
|
||||||
|
|
||||||
public RouterContext(Router router) {
|
|
||||||
super();
|
|
||||||
_router = router;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Router router() { return _router; }
|
|
||||||
public Hash routerHash() { return _router.getRouterInfo().getIdentity().getHash(); }
|
|
||||||
|
|
||||||
public ClientManagerFacade clientManager() {
|
|
||||||
if (!_clientManagerFacadeInitialized) initializeClientManagerFacade();
|
|
||||||
return _clientManagerFacade;
|
|
||||||
}
|
|
||||||
private void initializeClientManagerFacade() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_clientManagerFacade == null) {
|
|
||||||
_clientManagerFacade = new ClientManagerFacadeImpl(this);
|
|
||||||
}
|
|
||||||
_clientManagerFacadeInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientMessagePool clientMessagePool() {
|
|
||||||
if (!_clientMessagePoolInitialized) initializeClientMessagePool();
|
|
||||||
return _clientMessagePool;
|
|
||||||
}
|
|
||||||
private void initializeClientMessagePool() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_clientMessagePool == null) {
|
|
||||||
_clientMessagePool = new ClientMessagePool(this);
|
|
||||||
}
|
|
||||||
_clientMessagePoolInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public InNetMessagePool inNetMessagePool() {
|
|
||||||
if (!_inNetMessagePoolInitialized) initializeInNetMessagePool();
|
|
||||||
return _inNetMessagePool;
|
|
||||||
}
|
|
||||||
private void initializeInNetMessagePool() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_inNetMessagePool == null) {
|
|
||||||
_inNetMessagePool = new InNetMessagePool(this);
|
|
||||||
}
|
|
||||||
_inNetMessagePoolInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public OutNetMessagePool outNetMessagePool() {
|
|
||||||
if (!_outNetMessagePoolInitialized) initializeOutNetMessagePool();
|
|
||||||
return _outNetMessagePool;
|
|
||||||
}
|
|
||||||
private void initializeOutNetMessagePool() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_outNetMessagePool == null) {
|
|
||||||
_outNetMessagePool = new OutNetMessagePool(this);
|
|
||||||
}
|
|
||||||
_outNetMessagePoolInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageHistory messageHistory() {
|
|
||||||
if (!_messageHistoryInitialized) initializeMessageHistory();
|
|
||||||
return _messageHistory;
|
|
||||||
}
|
|
||||||
private void initializeMessageHistory() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_messageHistory == null) {
|
|
||||||
_messageHistory = new MessageHistory(this);
|
|
||||||
}
|
|
||||||
_messageHistoryInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public OutboundMessageRegistry messageRegistry() {
|
|
||||||
if (!_messageRegistryInitialized) initializeMessageRegistry();
|
|
||||||
return _messageRegistry;
|
|
||||||
}
|
|
||||||
private void initializeMessageRegistry() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_messageRegistry == null)
|
|
||||||
_messageRegistry = new OutboundMessageRegistry(this);
|
|
||||||
_messageRegistryInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public NetworkDatabaseFacade netDb() {
|
|
||||||
if (!_netDbInitialized) initializeNetDb();
|
|
||||||
return _netDb;
|
|
||||||
}
|
|
||||||
private void initializeNetDb() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_netDb == null)
|
|
||||||
_netDb = new KademliaNetworkDatabaseFacade(this);
|
|
||||||
_netDbInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public JobQueue jobQueue() {
|
|
||||||
if (!_jobQueueInitialized) initializeJobQueue();
|
|
||||||
return _jobQueue;
|
|
||||||
}
|
|
||||||
private void initializeJobQueue() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_jobQueue == null) {
|
|
||||||
_jobQueue= new JobQueue(this);
|
|
||||||
}
|
|
||||||
_jobQueueInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public KeyManager keyManager() {
|
|
||||||
if (!_keyManagerInitialized) initializeKeyManager();
|
|
||||||
return _keyManager;
|
|
||||||
}
|
|
||||||
private void initializeKeyManager() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_keyManager == null)
|
|
||||||
_keyManager = new KeyManager(this);
|
|
||||||
_keyManagerInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommSystemFacade commSystem() {
|
|
||||||
if (!_commSystemInitialized) initializeCommSystem();
|
|
||||||
return _commSystem;
|
|
||||||
}
|
|
||||||
private void initializeCommSystem() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_commSystem == null)
|
|
||||||
_commSystem = new CommSystemFacadeImpl(this);
|
|
||||||
_commSystemInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileOrganizer profileOrganizer() {
|
|
||||||
if (!_profileOrganizerInitialized) initializeProfileOrganizer();
|
|
||||||
return _profileOrganizer;
|
|
||||||
}
|
|
||||||
private void initializeProfileOrganizer() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_profileOrganizer == null)
|
|
||||||
_profileOrganizer = new ProfileOrganizer(this);
|
|
||||||
_profileOrganizerInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public PeerManagerFacade peerManager() {
|
|
||||||
if (!_peerManagerFacadeInitialized) initializePeerManager();
|
|
||||||
return _peerManagerFacade;
|
|
||||||
}
|
|
||||||
private void initializePeerManager() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_peerManagerFacade == null)
|
|
||||||
_peerManagerFacade = new PeerManagerFacadeImpl(this);
|
|
||||||
_peerManagerFacadeInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public BandwidthLimiter bandwidthLimiter() {
|
|
||||||
if (!_bandwidthLimiterInitialized) initializeBandwidthLimiter();
|
|
||||||
return _bandwidthLimiter;
|
|
||||||
}
|
|
||||||
private void initializeBandwidthLimiter() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_bandwidthLimiter == null)
|
|
||||||
_bandwidthLimiter = new TrivialBandwidthLimiter(this);
|
|
||||||
_bandwidthLimiterInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TunnelManagerFacade tunnelManager() {
|
|
||||||
if (!_tunnelManagerInitialized) initializeTunnelManager();
|
|
||||||
return _tunnelManager;
|
|
||||||
}
|
|
||||||
private void initializeTunnelManager() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_tunnelManager == null)
|
|
||||||
_tunnelManager = new PoolingTunnelManagerFacade(this);
|
|
||||||
_tunnelManagerInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public ProfileManager profileManager() {
|
|
||||||
if (!_profileManagerInitialized) initializeProfileManager();
|
|
||||||
return _profileManager;
|
|
||||||
}
|
|
||||||
private void initializeProfileManager() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_profileManager == null)
|
|
||||||
_profileManager = new ProfileManagerImpl(this);
|
|
||||||
_profileManagerInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public StatisticsManager statPublisher() {
|
|
||||||
if (!_statPublisherInitialized) initializeStatPublisher();
|
|
||||||
return _statPublisher;
|
|
||||||
}
|
|
||||||
private void initializeStatPublisher() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_statPublisher == null)
|
|
||||||
_statPublisher = new StatisticsManager(this);
|
|
||||||
_statPublisherInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Shitlist shitlist() {
|
|
||||||
if (!_shitlistInitialized) initializeShitlist();
|
|
||||||
return _shitlist;
|
|
||||||
}
|
|
||||||
private void initializeShitlist() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_shitlist == null)
|
|
||||||
_shitlist = new Shitlist(this);
|
|
||||||
_shitlistInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageValidator messageValidator() {
|
|
||||||
if (!_messageValidatorInitialized) initializeMessageValidator();
|
|
||||||
return _messageValidator;
|
|
||||||
}
|
|
||||||
private void initializeMessageValidator() {
|
|
||||||
synchronized (this) {
|
|
||||||
if (_messageValidator == null)
|
|
||||||
_messageValidator = new MessageValidator(this);
|
|
||||||
_messageValidatorInitialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
Reference in New Issue
Block a user