Package net.i2p.client.naming
Class MetaNamingService
java.lang.Object
net.i2p.client.naming.NamingService
net.i2p.client.naming.DummyNamingService
net.i2p.client.naming.MetaNamingService
- Direct Known Subclasses:
HostsTxtNamingService
A naming service of multiple naming services.
Supports .b32.i2p and {b64} lookups.
Supports caching.
-
Field Summary
Fields inherited from class net.i2p.client.naming.DummyNamingService
BASE32_HASH_LENGTH, CACHE_MAX_SIZE, DEST_SIZE, PROP_B32
Fields inherited from class net.i2p.client.naming.NamingService
_context, _listeners, _log, _updaters, PROP_IMPL
-
Constructor Summary
ConstructorDescriptionMetaNamingService
(I2PAppContext context) Adds the services from the i2p.nameservicelist property, in order, as chained services.MetaNamingService
(I2PAppContext context, List<NamingService> services) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addNamingService
(NamingService ns, boolean head) Only for chaining-capable NamingServices.void
export
(Writer out, Properties options) All services aggregated.getBase64Entries
(Properties options) All services aggregatedgetEntries
(Properties options) All services aggregatedgetNames
(Properties options) All services aggregatedThis implementation returns null.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 Base 32 addresses in the form {52 chars}.b32.i2p is NamingService-specific.boolean
put
(String hostname, Destination d, Properties options) Stores in the last serviceboolean
putIfAbsent
(String hostname, Destination d, Properties options) Stores in the last servicevoid
boolean
remove
(String hostname, Properties options) Removes from all servicesboolean
Only for chaining-capable NamingServices.reverseLookup
(Destination dest, Properties options) Same as reverseLookup(dest) but with options This implementation returns null.void
shutdown()
Parent will call when removed.int
size
(Properties options) All services aggregatedvoid
Methods inherited from class net.i2p.client.naming.DummyNamingService
clearCache, getCache, putCache, removeCache
Methods inherited from class net.i2p.client.naming.NamingService
addDestination, addDestination, addNamingService, createInstance, export, getConfiguration, getEntries, getName, getNames, getParent, lookup, lookup, lookupAll, lookupAll, lookupBase32, lookupBase64, put, putAll, putIfAbsent, registerUpdater, remove, remove, remove, requestUpdate, reverseLookup, reverseLookup, reverseLookupAll, reverseLookupAll, reverseLookupAll, setConfiguration, size, start, toString, unregisterUpdater, update
-
Field Details
-
_services
-
-
Constructor Details
-
MetaNamingService
Adds the services from the i2p.nameservicelist property, in order, as chained services. -
MetaNamingService
- Parameters:
services
- if non-null, services to be added. If null, this will only handle b32 and b64, until addNamingService() is called later.- Since:
- 0.8.7
-
-
Method Details
-
addNamingService
Description copied from class:NamingService
Only for chaining-capable NamingServices. This implementation returns false. Subclasses implementing chaining should override.- Overrides:
addNamingService
in classNamingService
- Parameters:
head
- or tail- Returns:
- success
-
getNamingServices
Description copied from class:NamingService
This implementation returns null. Subclasses implementing chaining should override.- Overrides:
getNamingServices
in classNamingService
- Returns:
- chained naming services or null
-
removeNamingService
Description copied from class:NamingService
Only for chaining-capable NamingServices. This implementation returns false. Subclasses implementing chaining should override.- Overrides:
removeNamingService
in classNamingService
- Returns:
- success
-
registerListener
- Overrides:
registerListener
in classNamingService
-
unregisterListener
- Overrides:
unregisterListener
in classNamingService
-
lookup
Description copied from class:NamingService
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.- Overrides:
lookup
in classDummyNamingService
- Parameters:
hostname
- mixed case as it could be a keylookupOptions
- input parameter, NamingService-specific, can be nullstoredOptions
- output parameter, NamingService-specific, any stored properties will be added if non-null- Returns:
- dest or null
-
reverseLookup
Description copied from class:NamingService
Same as reverseLookup(dest) but with options This implementation returns null. Subclasses implementing reverse lookups should override.- Overrides:
reverseLookup
in classNamingService
- Parameters:
dest
- non-nulloptions
- NamingService-specific, can be null- Returns:
- hostname or null
-
put
Stores in the last service- Overrides:
put
in classNamingService
- Parameters:
options
- NamingService-specific, can be null- Returns:
- success
-
putIfAbsent
Stores in the last service- Overrides:
putIfAbsent
in classNamingService
- Parameters:
options
- NamingService-specific, can be null- Returns:
- success
-
remove
Removes from all services- Overrides:
remove
in classNamingService
- Parameters:
options
- NamingService-specific, can be null- Returns:
- true if removed successfully, false on error or if it did not exist
-
getEntries
All services aggregated- Overrides:
getEntries
in classNamingService
- Parameters:
options
- NamingService-specific, can be null- Returns:
- all mappings (matching the options if non-null) or empty Map if none; Returned Map is not necessarily sorted, implementation dependent
-
getBase64Entries
All services aggregated- Overrides:
getBase64Entries
in classNamingService
- Parameters:
options
- NamingService-specific, can be null- Returns:
- all mappings (matching the options if non-null) or empty Map if none; Returned Map is not necessarily sorted, implementation dependent
- Since:
- 0.9.20
-
getNames
All services aggregated- Overrides:
getNames
in classNamingService
- Parameters:
options
- NamingService-specific, can be null- Returns:
- all known hostnames (matching the options if non-null) or empty Set if none; Returned Set is not necessarily sorted, implementation dependent
-
export
All services aggregated. Duplicates not removed (for efficiency)- Overrides:
export
in classNamingService
- Parameters:
options
- NamingService-specific, can be null- Throws:
IOException
- Since:
- 0.9.20
-
size
All services aggregated- Overrides:
size
in classNamingService
- Parameters:
options
- NamingService-specific, can be null- Returns:
- number of entries (matching the options if non-null) or -1 if unknown
-
shutdown
public void shutdown()Description copied from class:NamingService
Parent will call when removed. If this is the root naming service, the core will stop it. Should not be called by others.- Overrides:
shutdown
in classNamingService
-