|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.I2PAppContext
public class I2PAppContext
Provide a base scope for accessing singletons that I2P exposes. Rather than using the traditional singleton, where any component can access the component in question directly, all of those I2P related singletons are exposed through a particular I2PAppContext. This helps not only with understanding their use and the components I2P exposes, but it also allows multiple isolated environments to operate concurrently within the same JVM - particularly useful for stubbing out implementations of the rooted components and simulating the software's interaction between multiple instances.
As a simplification, there is also a global context - if some component needs access to one of the singletons but doesn't have its own context from which to root itself, it binds to the I2PAppContext's globalAppContext(), which is the first context that was created within the JVM, or a new one if no context existed already. This functionality is often used within the I2P core for logging - e.g.private static final Log _log = new Log(someClass.class);It is for this reason that applications that care about working with multiple contexts should build their own context as soon as possible (within the main(..)) so that any referenced components will latch on to that context instead of instantiating a new one. However, there are situations in which both can be relevent.
Field Summary | |
---|---|
protected Clock |
_clock
|
protected boolean |
_clockInitialized
|
protected static I2PAppContext |
_globalAppContext
the context that components without explicit root are bound |
protected KeyRing |
_keyRing
|
protected boolean |
_keyRingInitialized
|
Constructor Summary | |
---|---|
I2PAppContext()
Lets root a brand new context |
|
I2PAppContext(java.util.Properties envProps)
Lets root a brand new context |
Method Summary | |
---|---|
void |
addShutdownTask(java.lang.Runnable task)
|
AESEngine |
aes()
Ok, I'll admit it. |
Clock |
clock()
The context's synchronized clock, which is kept context specific only to enable simulators to play with clock skew among different instances. |
void |
deleteTempDir()
don't rely on deleteOnExit() |
DSAEngine |
dsa()
Our DSA engine (see HMAC and SHA above) |
ElGamalAESEngine |
elGamalAESEngine()
Access the ElGamal/AES+SessionTag engine for this context. |
ElGamalEngine |
elGamalEngine()
This is the ElGamal engine used within this context. |
java.io.File |
getAppDir()
|
java.io.File |
getBaseDir()
|
boolean |
getBooleanProperty(java.lang.String propName)
Default false |
boolean |
getBooleanPropertyDefaultTrue(java.lang.String propName)
|
java.io.File |
getConfigDir()
|
static I2PAppContext |
getGlobalContext()
Pull the default context, creating a new one if necessary, else using the first one created. |
java.io.File |
getLogDir()
|
java.io.File |
getPIDDir()
|
java.lang.String |
getProperty(java.lang.String propName)
Access the configuration attributes of this context, using properties provided during the context construction, or falling back on System.getProperty if no properties were provided during construction (or the specified prop wasn't included). |
boolean |
getProperty(java.lang.String propName,
boolean defaultVal)
Return a boolean with a boolean default |
int |
getProperty(java.lang.String propName,
int defaultVal)
Return an int with an int default |
java.lang.String |
getProperty(java.lang.String propName,
java.lang.String defaultValue)
Access the configuration attributes of this context, using properties provided during the context construction, or falling back on System.getProperty if no properties were provided during construction (or the specified prop wasn't included). |
java.util.Set |
getPropertyNames()
Access the configuration attributes of this context, listing the properties provided during the context construction, as well as the ones included in System.getProperties. |
java.io.File |
getRouterDir()
|
java.util.Set<java.lang.Runnable> |
getShutdownTasks()
|
java.io.File |
getTempDir()
|
HMACGenerator |
hmac()
There is absolutely no good reason to make this context specific, other than for consistency, and perhaps later we'll want to include some stats. |
HMAC256Generator |
hmac256()
|
protected void |
initializeClock()
|
protected void |
initializeKeyRing()
|
boolean |
isRouterContext()
Use this instead of context instanceof RouterContext |
KeyGenerator |
keyGenerator()
Component to generate ElGamal, DSA, and Session keys. |
KeyRing |
keyRing()
Basic hash map |
LogManager |
logManager()
Query the log manager for this context, which may in turn have its own set of configuration settings (loaded from the context's properties). |
NamingService |
namingService()
Pull up the naming service used in this context. |
PetNameDB |
petnameDb()
Deprecated. unused |
RandomSource |
random()
[insert snarky comment here] |
RoutingKeyGenerator |
routingKeyGenerator()
Determine how much do we want to mess with the keys to turn them into something we can route. |
SessionKeyManager |
sessionKeyManager()
The session key manager which coordinates the sessionKey / sessionTag data. |
SHA256Generator |
sha()
Our SHA256 instance (see the hmac discussion for why its context specific) |
StatManager |
statManager()
The statistics component with which we can track various events over time. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static I2PAppContext _globalAppContext
protected Clock _clock
protected KeyRing _keyRing
protected volatile boolean _clockInitialized
protected volatile boolean _keyRingInitialized
Constructor Detail |
---|
public I2PAppContext()
public I2PAppContext(java.util.Properties envProps)
Method Detail |
---|
public static I2PAppContext getGlobalContext()
public java.io.File getBaseDir()
public java.io.File getConfigDir()
public java.io.File getRouterDir()
public java.io.File getPIDDir()
public java.io.File getLogDir()
public java.io.File getAppDir()
public java.io.File getTempDir()
public void deleteTempDir()
public java.lang.String getProperty(java.lang.String propName)
public java.lang.String getProperty(java.lang.String propName, java.lang.String defaultValue)
public int getProperty(java.lang.String propName, int defaultVal)
public boolean getProperty(java.lang.String propName, boolean defaultVal)
public boolean getBooleanProperty(java.lang.String propName)
public boolean getBooleanPropertyDefaultTrue(java.lang.String propName)
public java.util.Set getPropertyNames()
public StatManager statManager()
public SessionKeyManager sessionKeyManager()
public NamingService namingService()
public PetNameDB petnameDb()
public ElGamalEngine elGamalEngine()
public ElGamalAESEngine elGamalAESEngine()
public AESEngine aes()
public LogManager logManager()
public HMACGenerator hmac()
public HMAC256Generator hmac256()
public SHA256Generator sha()
public DSAEngine dsa()
public KeyGenerator keyGenerator()
public Clock clock()
protected void initializeClock()
public RoutingKeyGenerator routingKeyGenerator()
public KeyRing keyRing()
protected void initializeKeyRing()
public RandomSource random()
public void addShutdownTask(java.lang.Runnable task)
public java.util.Set<java.lang.Runnable> getShutdownTasks()
public boolean isRouterContext()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |