* Naming service, addressbook, susidns:

- Replace img hack for susidns requesting addressbook update
      with registration and request through the NamingService
This commit is contained in:
zzz
2011-03-15 23:16:44 +00:00
parent 12c5b9c21c
commit 0352ca3ef6
5 changed files with 66 additions and 8 deletions

View File

@ -31,6 +31,7 @@ public abstract class NamingService {
private final static Log _log = new Log(NamingService.class);
protected final I2PAppContext _context;
protected final Set<NamingServiceListener> _listeners;
protected final Set<NamingServiceUpdater> _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

View File

@ -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 */

View File

@ -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);
}