forked from I2P_Developers/i2p.i2p
Addressbook: Remove static reference, hide implementation
Requires Android fix (ticket #1972)
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="addressbook" default="war" basedir=".">
|
||||
<project name="addressbook" default="all" basedir=".">
|
||||
|
||||
<property name="src" value="java/src"/>
|
||||
<property name="build" value="build"/>
|
||||
|
@ -43,13 +43,13 @@ import net.i2p.util.SystemVersion;
|
||||
|
||||
/**
|
||||
* Main class of addressbook. Performs updates, and runs the main loop.
|
||||
* As of 0.9.30, package private, run with DaemonThread.
|
||||
*
|
||||
* @author Ragnarok
|
||||
*
|
||||
*/
|
||||
public class Daemon {
|
||||
class Daemon {
|
||||
public static final String VERSION = "2.0.4";
|
||||
private static final Daemon _instance = new Daemon();
|
||||
private volatile boolean _running;
|
||||
private static final boolean DEBUG = false;
|
||||
private static final String DEFAULT_SUB = "http://i2p-projekt.i2p/hosts.txt";
|
||||
@ -787,14 +787,15 @@ public class Daemon {
|
||||
* others are ignored.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Daemon daemon = new Daemon();
|
||||
if (args != null && args.length > 0 && args[0].equals("test"))
|
||||
_instance.test(args);
|
||||
daemon.test(args);
|
||||
else
|
||||
_instance.run(args);
|
||||
daemon.run(args);
|
||||
}
|
||||
|
||||
/** @since 0.9.26 */
|
||||
private static void test(String[] args) {
|
||||
public static void test(String[] args) {
|
||||
Properties ctxProps = new Properties();
|
||||
String PROP_FORCE = "i2p.naming.blockfile.writeInAppContext";
|
||||
ctxProps.setProperty(PROP_FORCE, "true");
|
||||
@ -875,14 +876,14 @@ public class Daemon {
|
||||
* Call this to get the addressbook to reread its config and
|
||||
* refetch its subscriptions.
|
||||
*/
|
||||
public static void wakeup() {
|
||||
synchronized (_instance) {
|
||||
_instance.notifyAll();
|
||||
public void wakeup() {
|
||||
synchronized (this) {
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public static void stop() {
|
||||
_instance._running = false;
|
||||
public void stop() {
|
||||
_running = false;
|
||||
wakeup();
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import net.i2p.util.I2PAppThread;
|
||||
public class DaemonThread extends I2PAppThread implements NamingServiceUpdater {
|
||||
|
||||
private final String[] args;
|
||||
private final Daemon daemon;
|
||||
|
||||
/**
|
||||
* Construct a DaemonThread with the command line arguments args.
|
||||
@ -44,6 +45,7 @@ public class DaemonThread extends I2PAppThread implements NamingServiceUpdater {
|
||||
*/
|
||||
public DaemonThread(String[] args) {
|
||||
this.args = args;
|
||||
daemon = new Daemon();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -56,18 +58,28 @@ public class DaemonThread extends I2PAppThread implements NamingServiceUpdater {
|
||||
//} catch (InterruptedException exp) {
|
||||
//}
|
||||
I2PAppContext.getGlobalContext().namingService().registerUpdater(this);
|
||||
Daemon.main(this.args);
|
||||
I2PAppContext.getGlobalContext().namingService().unregisterUpdater(this);
|
||||
try {
|
||||
if (args != null && args.length > 0 && args[0].equals("test"))
|
||||
daemon.test(args);
|
||||
else
|
||||
daemon.run(args);
|
||||
} finally {
|
||||
I2PAppContext.getGlobalContext().namingService().unregisterUpdater(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void halt() {
|
||||
Daemon.stop();
|
||||
daemon.stop();
|
||||
interrupt();
|
||||
}
|
||||
|
||||
/**
|
||||
* The NamingServiceUpdater interface
|
||||
* @param options ignored
|
||||
* The NamingServiceUpdater interface.
|
||||
* While this may be called directly, the recommended way
|
||||
* is to call I2PAppContext.namingService().requestUpdate(Properties)
|
||||
* which will call this.
|
||||
*
|
||||
* @param options ignored, may be null
|
||||
* @since 0.8.7
|
||||
*/
|
||||
public void update(Properties options) {
|
||||
|
Reference in New Issue
Block a user