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
 
 public class MetaNamingService extends DummyNamingService A naming service of multiple naming services. Supports .b32.i2p and {b64} lookups. Supports caching.
- 
- 
Field SummaryFields Modifier and Type Field Description protected List<NamingService>_services- 
Fields inherited from class net.i2p.client.naming.DummyNamingServiceBASE32_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 SummaryConstructors Constructor Description MetaNamingService(I2PAppContext context)Adds the services from the i2p.nameservicelist property, in order, as chained services.MetaNamingService(I2PAppContext context, List<NamingService> services)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddNamingService(NamingService ns, boolean head)Only for chaining-capable NamingServices.voidexport(Writer out, Properties options)All services aggregated.Map<String,String>getBase64Entries(Properties options)All services aggregatedMap<String,Destination>getEntries(Properties options)All services aggregatedSet<String>getNames(Properties options)All services aggregatedList<NamingService>getNamingServices()This implementation returns null.Destinationlookup(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.booleanput(String hostname, Destination d, Properties options)Stores in the last servicebooleanputIfAbsent(String hostname, Destination d, Properties options)Stores in the last servicevoidregisterListener(NamingServiceListener nsl)booleanremove(String hostname, Properties options)Removes from all servicesbooleanremoveNamingService(NamingService ns)Only for chaining-capable NamingServices.StringreverseLookup(Destination dest, Properties options)Same as reverseLookup(dest) but with options This implementation returns null.voidshutdown()Parent will call when removed.intsize(Properties options)All services aggregatedvoidunregisterListener(NamingServiceListener nsl)- 
Methods inherited from class net.i2p.client.naming.DummyNamingServiceclearCache, getCache, putCache, removeCache
 - 
Methods inherited from class net.i2p.client.naming.NamingServiceaddDestination, 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 Detail- 
_servicesprotected final List<NamingService> _services 
 
- 
 - 
Constructor Detail- 
MetaNamingServicepublic MetaNamingService(I2PAppContext context) Adds the services from the i2p.nameservicelist property, in order, as chained services.
 - 
MetaNamingServicepublic MetaNamingService(I2PAppContext context, List<NamingService> services) - 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 Detail- 
addNamingServicepublic boolean addNamingService(NamingService ns, boolean head) Description copied from class:NamingServiceOnly for chaining-capable NamingServices. This implementation returns false. Subclasses implementing chaining should override.- Overrides:
- addNamingServicein class- NamingService
- head- or tail
- Returns:
- success
 
 - 
getNamingServicespublic List<NamingService> getNamingServices() Description copied from class:NamingServiceThis implementation returns null. Subclasses implementing chaining should override.- Overrides:
- getNamingServicesin class- NamingService
- Returns:
- chained naming services or null
 
 - 
removeNamingServicepublic boolean removeNamingService(NamingService ns) Description copied from class:NamingServiceOnly for chaining-capable NamingServices. This implementation returns false. Subclasses implementing chaining should override.- Overrides:
- removeNamingServicein class- NamingService
- Returns:
- success
 
 - 
registerListenerpublic void registerListener(NamingServiceListener nsl) - Overrides:
- registerListenerin class- NamingService
 
 - 
unregisterListenerpublic void unregisterListener(NamingServiceListener nsl) - Overrides:
- unregisterListenerin class- NamingService
 
 - 
lookuppublic Destination lookup(String hostname, Properties lookupOptions, Properties storedOptions) Description copied from class:NamingServiceSame 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:
- lookupin class- DummyNamingService
- Parameters:
- hostname- mixed case as it could be a key
- lookupOptions- input parameter, NamingService-specific, can be null
- storedOptions- output parameter, NamingService-specific, any stored properties will be added if non-null
- Returns:
- dest or null
 
 - 
reverseLookuppublic String reverseLookup(Destination dest, Properties options) Description copied from class:NamingServiceSame as reverseLookup(dest) but with options This implementation returns null. Subclasses implementing reverse lookups should override.- Overrides:
- reverseLookupin class- NamingService
- Parameters:
- dest- non-null
- options- NamingService-specific, can be null
- Returns:
- hostname or null
 
 - 
putpublic boolean put(String hostname, Destination d, Properties options) Stores in the last service- Overrides:
- putin class- NamingService
- options- NamingService-specific, can be null
- Returns:
- success
 
 - 
putIfAbsentpublic boolean putIfAbsent(String hostname, Destination d, Properties options) Stores in the last service- Overrides:
- putIfAbsentin class- NamingService
- options- NamingService-specific, can be null
- Returns:
- success
 
 - 
removepublic boolean remove(String hostname, Properties options) Removes from all services- Overrides:
- removein class- NamingService
- options- NamingService-specific, can be null
- Returns:
- true if removed successfully, false on error or if it did not exist
 
 - 
getEntriespublic Map<String,Destination> getEntries(Properties options) All services aggregated- Overrides:
- getEntriesin class- NamingService
- 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
 
 - 
getBase64Entriespublic Map<String,String> getBase64Entries(Properties options) All services aggregated- Overrides:
- getBase64Entriesin class- NamingService
- 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
 
 - 
getNamespublic Set<String> getNames(Properties options) All services aggregated- Overrides:
- getNamesin class- NamingService
- 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
 
 - 
exportpublic void export(Writer out, Properties options) throws IOException All services aggregated. Duplicates not removed (for efficiency)- Overrides:
- exportin class- NamingService
- options- NamingService-specific, can be null
- Throws:
- IOException
- Since:
- 0.9.20
 
 - 
sizepublic int size(Properties options) All services aggregated- Overrides:
- sizein class- NamingService
- Parameters:
- options- NamingService-specific, can be null
- Returns:
- number of entries (matching the options if non-null) or -1 if unknown
 
 - 
shutdownpublic void shutdown() Description copied from class:NamingServiceParent will call when removed. If this is the root naming service, the core will stop it. Should not be called by others.- Overrides:
- shutdownin class- NamingService
 
 
- 
 
-