Class IP2LocationRegionService
java.lang.Object
com.iizix.geo.RegionLocationService
com.iizix.server.geo.ip2location.IP2LocationRegionService
The IP2Location region location provider: answers
RegionLocationService requests from the local IP2Location LITE database through IP2LocationManager. No client IP address leaves the server, which is what sets it apart from the web providers GeoPlugin, IPStack and IPWhoIs of com.iizix.server.region; it is registered first by ServerShell.registerRegionLocationServiceProviders when the service is enabled and is therefore the default provider.The provider is available while the manager is configured (the service may still be initializing: a lookup then answers with an error location saying so, and the base class caches only valid answers over erroneous ones).
The mapping from the library's GeoLocation to RegionLocation is toRegionLocation(GeoLocation): country code and name, region, city, ZIP code and time zone as the database tier provides them, the coordinates when the tier has them (the library reports 0.0/0.0 when it has none, which is not a location), and no accuracy radius, because IP2Location publishes none.
- Author:
- Christopher Mindus
Field Summary
FieldsFields inherited from class RegionLocationService
ENCODING, ENCODING_NAMEConstructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprotected booleanReturns if the provider can be used: the manager has a configured service.static booleanReturns if the manager has a configured service, i.e.protected RegionLocationRequests region location information from the local database.static RegionLocationMaps a lookup result of the library to a region location.Methods inherited from class RegionLocationService
configure, createRegionLocation, createRegionLocation, createRegionLocation, getDefaultName, getInstance, getName, getNames, initialize, isDisposed, onDisposed, parse, setGlobalCacheSize, shutdown
Field Details
NAME
Constructor Details
IP2LocationRegionService
public IP2LocationRegionService()Constructs the provider. The default timeout is the minimum the base class allows (5 seconds); a local lookup takes microseconds, the timeout only bounds a caller that waits synchronously while the database is being loaded.
Method Details
isManagerConfigured
public static boolean isManagerConfigured()Returns if the manager has a configured service, i.e. if a provider instance would be available;ServerShell.registerRegionLocationServiceProvidersasks this before constructing one.- Returns:
- true when configured, false otherwise.
isAvailable
protected boolean isAvailable()Returns if the provider can be used: the manager has a configured service.- Overrides:
isAvailablein classRegionLocationService- Returns:
- true when configured, false otherwise.
request
Requests region location information from the local database.- Specified by:
requestin classRegionLocationService- Parameters:
ipAddress- The IP address (IPv4 or IPv6) to look up.- Returns:
- The region location, always non-null: an error location when the lookup did not succeed, with the library's status code as the error text.
toRegionLocation
Maps a lookup result of the library to a region location.- Parameters:
loc- The lookup result.- Returns:
- The region location; an error location carrying "IP2Location: " and the status code when the lookup was not OK.