I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 3a61d260 authored by jrandom's avatar jrandom Committed by zzz
Browse files

cleanup wrt multiple app contexts

parent 5bc433d1
No related branches found
No related tags found
No related merge requests found
...@@ -51,13 +51,6 @@ import net.i2p.util.RandomSource; ...@@ -51,13 +51,6 @@ import net.i2p.util.RandomSource;
public class I2PAppContext { public class I2PAppContext {
/** the context that components without explicit root are bound */ /** the context that components without explicit root are bound */
protected static I2PAppContext _globalAppContext; protected static I2PAppContext _globalAppContext;
/**
* Determine if the app context been initialized. If this is false
* and something asks for the globalAppContext, a new one is created,
* otherwise the existing one is used.
*
*/
protected static volatile boolean _globalAppContextInitialized;
private Properties _overrideProps; private Properties _overrideProps;
...@@ -96,12 +89,10 @@ public class I2PAppContext { ...@@ -96,12 +89,10 @@ public class I2PAppContext {
* *
*/ */
public static I2PAppContext getGlobalContext() { public static I2PAppContext getGlobalContext() {
if (!_globalAppContextInitialized) { synchronized (I2PAppContext.class) {
synchronized (I2PAppContext.class) { if (_globalAppContext == null) {
System.err.println("*** Building seperate global context!"); System.err.println("*** Building a seperate global context!");
if (_globalAppContext == null) _globalAppContext = new I2PAppContext(false, null);
_globalAppContext = new I2PAppContext(false, null);
_globalAppContextInitialized = true;
} }
} }
return _globalAppContext; return _globalAppContext;
...@@ -125,15 +116,10 @@ public class I2PAppContext { ...@@ -125,15 +116,10 @@ public class I2PAppContext {
* @param doInit should this context be used as the global one (if necessary)? * @param doInit should this context be used as the global one (if necessary)?
*/ */
private I2PAppContext(boolean doInit, Properties envProps) { private I2PAppContext(boolean doInit, Properties envProps) {
//System.out.println("App context created: " + this);
if (doInit) { if (doInit) {
if (!_globalAppContextInitialized) { synchronized (I2PAppContext.class) {
synchronized (I2PAppContext.class) { if (_globalAppContext == null)
if (_globalAppContext == null) { _globalAppContext = this;
_globalAppContext = this;
_globalAppContextInitialized = true;
}
}
} }
} }
_overrideProps = envProps; _overrideProps = envProps;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment