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