diff --git a/apps/addressbook/java/src/net/i2p/addressbook/DaemonThread.java b/apps/addressbook/java/src/net/i2p/addressbook/DaemonThread.java
index b2ff2c511..44592f8ef 100644
--- a/apps/addressbook/java/src/net/i2p/addressbook/DaemonThread.java
+++ b/apps/addressbook/java/src/net/i2p/addressbook/DaemonThread.java
@@ -21,13 +21,18 @@
package net.i2p.addressbook;
+import java.util.Properties;
+
+import net.i2p.I2PAppContext;
+import net.i2p.client.naming.NamingServiceUpdater;
+
/**
* A thread that waits five minutes, then runs the addressbook daemon.
*
* @author Ragnarok
*
*/
-class DaemonThread extends Thread {
+class DaemonThread extends Thread implements NamingServiceUpdater {
private String[] args;
@@ -49,11 +54,21 @@ class DaemonThread extends Thread {
// Thread.sleep(5 * 60 * 1000);
//} catch (InterruptedException exp) {
//}
+ I2PAppContext.getGlobalContext().namingService().registerUpdater(this);
Daemon.main(this.args);
+ I2PAppContext.getGlobalContext().namingService().unregisterUpdater(this);
}
public void halt() {
Daemon.stop();
interrupt();
}
+
+ /**
+ * The NamingServiceUpdater interface
+ * @since 0.8.6
+ */
+ public void update(Properties options) {
+ interrupt();
+ }
}
diff --git a/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java b/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java
index 176561aca..88a6552be 100644
--- a/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java
+++ b/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java
@@ -33,6 +33,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;
+import net.i2p.I2PAppContext;
import net.i2p.util.SecureFileOutputStream;
public class SubscriptionsBean
@@ -130,15 +131,19 @@ public class SubscriptionsBean
if (action.equals(_("Save"))) {
save();
String nonce = System.getProperty("addressbook.nonce");
+ /*******
if (nonce != null) {
// Yes this is a hack.
// No it doesn't work on a text-mode browser.
// Fetching from the addressbook servlet
// with the correct parameters will kick off a
// config reload and fetch.
- message = _("Subscriptions saved, updating addressbook from subscription sources now.") +
- "
";
+ *******/
+ if (content != null && content.length() > 2) {
+ message = _("Subscriptions saved, updating addressbook from subscription sources now.");
+ // + "
";
+ I2PAppContext.getGlobalContext().namingService().requestUpdate(null);
} else {
message = _("Subscriptions saved.");
}
diff --git a/core/java/src/net/i2p/client/naming/NamingService.java b/core/java/src/net/i2p/client/naming/NamingService.java
index 7292ba9af..a86da11f6 100644
--- a/core/java/src/net/i2p/client/naming/NamingService.java
+++ b/core/java/src/net/i2p/client/naming/NamingService.java
@@ -31,6 +31,7 @@ public abstract class NamingService {
private final static Log _log = new Log(NamingService.class);
protected final I2PAppContext _context;
protected final Set _listeners;
+ protected final Set _updaters;
/** what classname should be used as the naming service impl? */
public static final String PROP_IMPL = "i2p.naming.impl";
@@ -45,6 +46,7 @@ public abstract class NamingService {
protected NamingService(I2PAppContext context) {
_context = context;
_listeners = new CopyOnWriteArraySet();
+ _updaters = new CopyOnWriteArraySet();
}
/**
@@ -315,12 +317,15 @@ public abstract class NamingService {
}
/**
- * Ask the NamingService to update its database
- * Should this be a separate interface? This is what addressbook needs
- * @param options NamingService-specific, can be null
+ * Ask any registered updaters to update now
+ * @param options NamingService- or updater-specific, may be null
* @since 0.8.5
*/
- public void requestUpdate(Properties options) {}
+ public void requestUpdate(Properties options) {
+ for (NamingServiceUpdater nsu : _updaters) {
+ nsu.update(options);
+ }
+ }
/**
* @since 0.8.5
@@ -336,6 +341,20 @@ public abstract class NamingService {
_listeners.remove(nsl);
}
+ /**
+ * @since 0.8.6
+ */
+ public void registerUpdater(NamingServiceUpdater nsu) {
+ _updaters.add(nsu);
+ }
+
+ /**
+ * @since 0.8.6
+ */
+ public void unregisterUpdater(NamingServiceUpdater nsu) {
+ _updaters.remove(nsu);
+ }
+
/**
* Same as lookup(hostname) but with in and out options
* Note that whether this (and lookup(hostname)) resolve B32 addresses is
diff --git a/core/java/src/net/i2p/client/naming/NamingServiceListener.java b/core/java/src/net/i2p/client/naming/NamingServiceListener.java
index 2966d48dd..92bb88f82 100644
--- a/core/java/src/net/i2p/client/naming/NamingServiceListener.java
+++ b/core/java/src/net/i2p/client/naming/NamingServiceListener.java
@@ -4,6 +4,9 @@ import java.util.Properties;
import net.i2p.data.Destination;
+/**
+ * @since 0.8.6
+ */
public interface NamingServiceListener {
/** also called when a NamingService is added or removed */
diff --git a/core/java/src/net/i2p/client/naming/NamingServiceUpdater.java b/core/java/src/net/i2p/client/naming/NamingServiceUpdater.java
new file mode 100644
index 000000000..c1bc66327
--- /dev/null
+++ b/core/java/src/net/i2p/client/naming/NamingServiceUpdater.java
@@ -0,0 +1,16 @@
+package net.i2p.client.naming;
+
+import java.util.Properties;
+
+/**
+ * @since 0.8.6
+ */
+public interface NamingServiceUpdater {
+
+ /**
+ * Should not block.
+ * @param options Updater-specific, may be null
+ */
+ public void update(Properties options);
+}
+