DummyNamingService
, SingleFileNamingService
public abstract class NamingService
extends java.lang.Object
修飾子とタイプ | フィールド | 説明 |
---|---|---|
protected I2PAppContext |
_context |
|
protected java.util.Set<NamingServiceListener> |
_listeners |
|
protected Log |
_log |
|
protected java.util.Set<NamingServiceUpdater> |
_updaters |
|
static java.lang.String |
PROP_IMPL |
what classname should be used as the naming service impl?
|
修飾子 | コンストラクタ | 説明 |
---|---|---|
protected |
NamingService(I2PAppContext context) |
The naming service should only be constructed and accessed through the
application context.
|
修飾子とタイプ | メソッド | 説明 |
---|---|---|
boolean |
addDestination(java.lang.String hostname,
Destination d) |
Add a Destination to an existing hostname's entry in the addressbook.
|
boolean |
addDestination(java.lang.String hostname,
Destination d,
java.util.Properties options) |
Add a Destination to an existing hostname's entry in the addressbook.
|
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.
|
void |
export(java.io.Writer out) |
Export in a hosts.txt format.
|
void |
export(java.io.Writer out,
java.util.Properties options) |
Export in a hosts.txt format.
|
java.util.Map<java.lang.String,java.lang.String> |
getBase64Entries(java.util.Properties options) |
This may be more or less efficient than getEntries(),
depending on the implementation.
|
java.util.Properties |
getConfiguration() |
Warning - unimplemented in any subclass.
|
java.util.Map<java.lang.String,Destination> |
getEntries() |
Warning - This obviously brings the whole database into memory,
so use is discouraged.
|
java.util.Map<java.lang.String,Destination> |
getEntries(java.util.Properties options) |
Warning - This will bring the whole database into memory
if options is null, empty, or unsupported, use with caution.
|
java.lang.String |
getName() |
|
java.util.Set<java.lang.String> |
getNames() |
|
java.util.Set<java.lang.String> |
getNames(java.util.Properties options) |
|
java.util.List<NamingService> |
getNamingServices() |
This implementation returns null.
|
NamingService |
getParent() |
This implementation returns null.
|
Destination |
lookup(java.lang.String hostname) |
Look up a host name.
|
abstract Destination |
lookup(java.lang.String hostname,
java.util.Properties lookupOptions,
java.util.Properties storedOptions) |
Same as lookup(hostname) but with in and out options
Note that whether this (and lookup(hostname)) resolve Base 32 addresses
in the form {52 chars}.b32.i2p is NamingService-specific.
|
Destination |
lookup(Hash hash,
int timeout) |
Same as lookupBase32() but with the SHA256 Hash precalculated
This implementation returns null.
|
java.util.List<Destination> |
lookupAll(java.lang.String hostname) |
For NamingServices that support multiple Destinations for a single host name,
return all of them.
|
java.util.List<Destination> |
lookupAll(java.lang.String hostname,
java.util.Properties lookupOptions,
java.util.List<java.util.Properties> storedOptions) |
For NamingServices that support multiple Destinations and Properties for a single host name,
return all of them.
|
Destination |
lookupBase32(java.lang.String hostname,
int timeout) |
Lookup a Base 32 address.
|
protected Destination |
lookupBase64(java.lang.String hostname) |
If the host name is a valid Base64 encoded destination, return the
decoded Destination.
|
boolean |
put(java.lang.String hostname,
Destination d) |
Add a hostname and Destination to the addressbook.
|
boolean |
put(java.lang.String hostname,
Destination d,
java.util.Properties options) |
Add a hostname and Destination to the addressbook.
|
boolean |
putAll(java.util.Map<java.lang.String,Destination> entries,
java.util.Properties options) |
Put all the entries, each with the given options.
|
boolean |
putIfAbsent(java.lang.String hostname,
Destination d) |
Add a hostname and Destination to the addressbook.
|
boolean |
putIfAbsent(java.lang.String hostname,
Destination d,
java.util.Properties options) |
Add a hostname and Destination to the addressbook.
|
void |
registerListener(NamingServiceListener nsl) |
|
void |
registerUpdater(NamingServiceUpdater nsu) |
|
boolean |
remove(java.lang.String hostname) |
Delete the entry.
|
boolean |
remove(java.lang.String hostname,
java.util.Properties options) |
Delete the entry.
|
boolean |
remove(java.lang.String hostname,
Destination d) |
Remove a hostname's entry only if it contains the Destination d.
|
boolean |
remove(java.lang.String hostname,
Destination d,
java.util.Properties options) |
Remove a hostname's entry only if it contains the Destination d.
|
boolean |
removeNamingService(NamingService ns) |
Only for chaining-capable NamingServices.
|
void |
requestUpdate(java.util.Properties options) |
Ask any registered updaters to update now
|
java.lang.String |
reverseLookup(Destination dest) |
Reverse lookup a destination
This implementation returns reverseLookup(dest, null).
|
java.lang.String |
reverseLookup(Destination d,
java.util.Properties options) |
Same as reverseLookup(dest) but with options
This implementation returns null.
|
java.lang.String |
reverseLookup(Hash h) |
Reverse lookup a hash.
|
java.util.List<java.lang.String> |
reverseLookupAll(Destination dest) |
Reverse lookup a destination
This implementation returns reverseLookupAll(dest, null).
|
java.util.List<java.lang.String> |
reverseLookupAll(Destination d,
java.util.Properties options) |
Same as reverseLookupAll(dest) but with options
This implementation returns the result from reverseLookup, or null.
|
java.util.List<java.lang.String> |
reverseLookupAll(Hash h) |
Reverse lookup a hash.
|
boolean |
setConfiguration(java.util.Properties p) |
Warning - unimplemented in any subclass.
|
void |
shutdown() |
Parent will call when removed.
|
int |
size() |
|
int |
size(java.util.Properties options) |
This implementation returns -1.
|
void |
start() |
Parent will call when added.
|
java.lang.String |
toString() |
|
void |
unregisterListener(NamingServiceListener nsl) |
|
void |
unregisterUpdater(NamingServiceUpdater nsu) |
|
boolean |
update(java.lang.String hostname,
Destination d,
java.util.Properties options) |
Fails if entry did not previously exist.
|
protected final Log _log
protected final I2PAppContext _context
protected final java.util.Set<NamingServiceListener> _listeners
protected final java.util.Set<NamingServiceUpdater> _updaters
public static final java.lang.String PROP_IMPL
protected NamingService(I2PAppContext context)
public Destination lookup(java.lang.String hostname)
null
if name is unknown.public java.lang.String reverseLookup(Destination dest)
dest
- non-nullnull
if none is known. It is safe for subclasses to always return
null
if no reverse lookup is possible.public java.lang.String reverseLookup(Hash h)
h
- non-nullnull
if none is known. It is safe for subclasses to always return
null
if no reverse lookup is possible.protected Destination lookupBase64(java.lang.String hostname)
hostname
- 516+ character Base 64public java.lang.String toString()
toString
クラス内 java.lang.Object
public java.lang.String getName()
public java.util.Properties getConfiguration()
public boolean setConfiguration(java.util.Properties p)
public java.util.List<NamingService> getNamingServices()
public NamingService getParent()
public boolean addNamingService(NamingService ns)
public boolean addNamingService(NamingService ns, boolean head)
head
- or tailpublic boolean removeNamingService(NamingService ns)
public int size()
public int size(java.util.Properties options)
options
- NamingService-specific, can be nullpublic java.util.Map<java.lang.String,Destination> getEntries()
public java.util.Map<java.lang.String,Destination> getEntries(java.util.Properties options)
options
- NamingService-specific, can be nullpublic java.util.Map<java.lang.String,java.lang.String> getBase64Entries(java.util.Properties options)
options
- NamingService-specific, can be nullpublic void export(java.io.Writer out) throws java.io.IOException
java.io.IOException
public void export(java.io.Writer out, java.util.Properties options) throws java.io.IOException
options
- NamingService-specific, can be nulljava.io.IOException
public java.util.Set<java.lang.String> getNames()
public java.util.Set<java.lang.String> getNames(java.util.Properties options)
options
- NamingService-specific, can be nullpublic boolean put(java.lang.String hostname, Destination d)
public boolean put(java.lang.String hostname, Destination d, java.util.Properties options)
options
- NamingService-specific, can be nullpublic boolean putIfAbsent(java.lang.String hostname, Destination d)
public boolean putIfAbsent(java.lang.String hostname, Destination d, java.util.Properties options)
options
- NamingService-specific, can be nullpublic boolean putAll(java.util.Map<java.lang.String,Destination> entries, java.util.Properties options)
options
- NamingService-specific, can be nullpublic boolean update(java.lang.String hostname, Destination d, java.util.Properties options)
d
- may be null if only options are changingoptions
- NamingService-specific, can be nullpublic boolean remove(java.lang.String hostname)
public boolean remove(java.lang.String hostname, java.util.Properties options)
options
- NamingService-specific, can be nullpublic void requestUpdate(java.util.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(java.lang.String hostname, java.util.Properties lookupOptions, java.util.Properties storedOptions)
lookupOptions
- input parameter, NamingService-specific, can be nullstoredOptions
- output parameter, NamingService-specific, any stored properties will be added if non-nullpublic java.lang.String reverseLookup(Destination d, java.util.Properties options)
d
- non-nulloptions
- NamingService-specific, can be nullpublic Destination lookupBase32(java.lang.String hostname, int timeout)
hostname
- must be {52 chars}.b32.i2ptimeout
- in seconds; <= 0 means use router defaultpublic Destination lookup(Hash hash, int timeout)
timeout
- in seconds; <= 0 means use router defaultpublic void start()
public void shutdown()
public java.util.List<Destination> lookupAll(java.lang.String hostname)
public java.util.List<Destination> lookupAll(java.lang.String hostname, java.util.Properties lookupOptions, java.util.List<java.util.Properties> storedOptions)
lookupOptions
- input parameter, NamingService-specific, may be nullstoredOptions
- output parameter, NamingService-specific, any stored properties will be added if non-nullpublic boolean addDestination(java.lang.String hostname, Destination d)
public boolean addDestination(java.lang.String hostname, Destination d, java.util.Properties options)
options
- NamingService-specific, may be nullpublic boolean remove(java.lang.String hostname, Destination d)
public boolean remove(java.lang.String hostname, Destination d, java.util.Properties options)
options
- NamingService-specific, may be nullpublic java.util.List<java.lang.String> reverseLookupAll(Hash h)
h
- non-nullnull
if none is known. It is safe for subclasses to always return
null
if no reverse lookup is possible.public java.util.List<java.lang.String> reverseLookupAll(Destination dest)
dest
- non-nullnull
if none is known. It is safe for subclasses to always return
null
if no reverse lookup is possible.public java.util.List<java.lang.String> reverseLookupAll(Destination d, java.util.Properties options)
d
- non-nulloptions
- NamingService-specific, can be nullnull
public static final NamingService createInstance(I2PAppContext context)