|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.client.naming.NamingService
public abstract class NamingService
Naming services create a subclass of this class.
Field Summary | |
---|---|
protected I2PAppContext |
_context
|
protected Set<NamingServiceListener> |
_listeners
|
protected Log |
_log
|
protected Set<NamingServiceUpdater> |
_updaters
|
static String |
PROP_IMPL
what classname should be used as the naming service impl? |
Constructor Summary | |
---|---|
protected |
NamingService(I2PAppContext context)
The naming service should only be constructed and accessed through the application context. |
Method Summary | |
---|---|
boolean |
addNamingService(NamingService ns)
Only for chaining-capable NamingServices. |
boolean |
addNamingService(NamingService ns,
boolean head)
Only for chaining-capable NamingServices |
static NamingService |
createInstance(I2PAppContext context)
WARNING - for use by I2PAppContext only - others must use I2PAppContext.namingService() Get a naming service instance. |
Map<String,String> |
getBase64Entries(Properties options)
This may be more or less efficient than getEntries(), depending on the implementation. |
Properties |
getConfiguration()
Warning - unimplemented in any subclass. |
Map<String,Destination> |
getEntries()
Warning - This obviously brings the whole database into memory, so use is discouraged. |
Map<String,Destination> |
getEntries(Properties options)
Warning - This will bring the whole database into memory if options is null, empty, or unsupported, use with caution. |
String |
getName()
|
Set<String> |
getNames()
|
Set<String> |
getNames(Properties options)
|
List<NamingService> |
getNamingServices()
|
NamingService |
getParent()
|
Destination |
lookup(Hash hash,
int timeout)
Same as lookupB32 but with the SHA256 Hash precalculated |
Destination |
lookup(String hostname)
Look up a host name. |
abstract Destination |
lookup(String hostname,
Properties lookupOptions,
Properties storedOptions)
Same as lookup(hostname) but with in and out options Note that whether this (and lookup(hostname)) resolve B32 addresses is NamingService-specific. |
Destination |
lookupBase32(String hostname,
int timeout)
Lookup a Base 32 address. |
protected Destination |
lookupBase64(String hostname)
Check if host name is valid Base64 encoded dest and return this dest in that case. |
boolean |
put(String hostname,
Destination d)
|
boolean |
put(String hostname,
Destination d,
Properties options)
|
boolean |
putAll(Map<String,Destination> entries,
Properties options)
|
boolean |
putIfAbsent(String hostname,
Destination d)
Fails if entry previously exists |
boolean |
putIfAbsent(String hostname,
Destination d,
Properties options)
Fails if entry previously exists |
void |
registerListener(NamingServiceListener nsl)
|
void |
registerUpdater(NamingServiceUpdater nsu)
|
boolean |
remove(String hostname)
|
boolean |
remove(String hostname,
Properties options)
|
boolean |
removeNamingService(NamingService ns)
Only for chaining-capable NamingServices |
void |
requestUpdate(Properties options)
Ask any registered updaters to update now |
String |
reverseLookup(Destination dest)
Reverse lookup a destination |
String |
reverseLookup(Destination d,
Properties options)
Same as reverseLookup(dest) but with options |
String |
reverseLookup(Hash h)
Reverse lookup a hash |
boolean |
setConfiguration(Properties p)
Warning - unimplemented in any subclass. |
void |
shutdown()
Parent will call when removed. |
int |
size()
|
int |
size(Properties options)
|
void |
start()
Parent will call when added. |
String |
toString()
|
void |
unregisterListener(NamingServiceListener nsl)
|
void |
unregisterUpdater(NamingServiceUpdater nsu)
|
boolean |
update(String hostname,
Destination d,
Properties options)
Fails if entry did not previously exist. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Log _log
protected final I2PAppContext _context
protected final Set<NamingServiceListener> _listeners
protected final Set<NamingServiceUpdater> _updaters
public static final String PROP_IMPL
Constructor Detail |
---|
protected NamingService(I2PAppContext context)
Method Detail |
---|
public Destination lookup(String hostname)
null
if name is unknown.public String reverseLookup(Destination dest)
dest
- non-null
null
if none is known. It is safe for subclasses to always return
null
if no reverse lookup is possible.public String reverseLookup(Hash h)
h
- non-null
null
if none is known. It is safe for subclasses to always return
null
if no reverse lookup is possible.protected Destination lookupBase64(String hostname)
hostname
- 516+ character Base 64
public String toString()
toString
in class Object
public String getName()
public Properties getConfiguration()
public boolean setConfiguration(Properties p)
public List<NamingService> getNamingServices()
public NamingService getParent()
public boolean addNamingService(NamingService ns)
public boolean addNamingService(NamingService ns, boolean head)
head
- or tail
public boolean removeNamingService(NamingService ns)
public int size()
public int size(Properties options)
options
- NamingService-specific, can be null
public Map<String,Destination> getEntries()
public Map<String,Destination> getEntries(Properties options)
options
- NamingService-specific, can be null
public Map<String,String> getBase64Entries(Properties options)
options
- NamingService-specific, can be null
public Set<String> getNames()
public Set<String> getNames(Properties options)
options
- NamingService-specific, can be null
public boolean put(String hostname, Destination d)
public boolean put(String hostname, Destination d, Properties options)
options
- NamingService-specific, can be null
public boolean putIfAbsent(String hostname, Destination d)
public boolean putIfAbsent(String hostname, Destination d, Properties options)
options
- NamingService-specific, can be null
public boolean putAll(Map<String,Destination> entries, Properties options)
options
- NamingService-specific, can be null
public boolean update(String hostname, Destination d, Properties options)
d
- may be null if only options are changingoptions
- NamingService-specific, can be null
public boolean remove(String hostname)
public boolean remove(String hostname, Properties options)
options
- NamingService-specific, can be null
public void requestUpdate(Properties options)
options
- NamingService- or updater-specific, may be nullpublic void registerListener(NamingServiceListener nsl)
public void unregisterListener(NamingServiceListener nsl)
public void registerUpdater(NamingServiceUpdater nsu)
public void unregisterUpdater(NamingServiceUpdater nsu)
public abstract Destination lookup(String hostname, Properties lookupOptions, Properties storedOptions)
lookupOptions
- input parameter, NamingService-specific, can be nullstoredOptions
- output parameter, NamingService-specific, any stored properties will be added if non-null
public String reverseLookup(Destination d, Properties options)
d
- non-nulloptions
- NamingService-specific, can be null
public Destination lookupBase32(String hostname, int timeout)
hostname
- must be {52 chars}.b32.i2ptimeout
- in seconds; <= 0 means use router default
public Destination lookup(Hash hash, int timeout)
timeout
- in seconds; <= 0 means use router default
public void start()
public void shutdown()
public static final NamingService createInstance(I2PAppContext context)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |