Class IP2LocationModule
java.lang.Object
com.iizix.server.geo.ip2location.IP2LocationModule
- All Implemented Interfaces:
IServerModule<Object>
The IP geolocation server module: the IIZI bootstrap of the
co.mindus.ip2location library. Added by ServerShell.onWorkerStarted right after the Push Notification module, which reaches initialize(IServer) through ServerShell.addModule.What the switches do.
ServerSettings.IP2LOCATION_ENABLED(default off):initialize(IServer)configures theIP2LocationManagerasynchronously from the settings - the database directory, the LITE database tier, IPv4 or IPv4+IPv6, memory mapping, the recovery configuration, the download token - so the server starts without waiting for a download.onServerReady(IServer)then registers the region location providers with IP2Location first, which makes it the default provider ofRegionLocationService; lookups stay on the server. Without the switch nothing of this happens, exactly as before this module existed: no provider is registered in production.ServerSettings.GEO_WEB_PROVIDERS(default off): the web providers GeoPlugin, IPStack and IPWhoIs are registered too (after IP2Location when that is enabled); a lookup through one of them sends the client's IP address to that web service.ServerSettings.GEO_SESSION_LOG(default off):SessionGeoLoggerwrites the geolocation of every client session at connect, reconnect and disconnect, using whichever provider is the default. It is read at every event, not here.
The module exposes no WebSocket end point. dispose() shuts the manager down; the providers are disposed of by ServerShell.dispose through RegionLocationService.shutdown(), which only that class may call.
Cluster index. IIZI has no per-instance identity for clustered servers (nothing in com.iizix.server.loadbalancer numbers the members), so the index is always 0 and the database directory is the configured path as is.
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe cluster index of this server instance: IIZI has none, so 0 (unclustered).Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionvoiddispose()Disposes of this server module: shuts the IP2Location manager down when it was started.Gets the description.Gets the name of the module.initialize(IServer server) Initializes the module: whenServerSettings.IP2LOCATION_ENABLEDis on, configures theIP2LocationManagerasynchronously from the settings.voidonServerReady(IServer server) Called when the server is ready: registers the region location providers when the local service or the web providers are enabled.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IServerModule
processServerArg
Field Details
CLUSTER_INDEX
public static final int CLUSTER_INDEXThe cluster index of this server instance: IIZI has none, so 0 (unclustered).- See Also:
Constructor Details
IP2LocationModule
public IP2LocationModule()
Method Details
getModuleName
Gets the name of the module.- Specified by:
getModuleNamein interfaceIServerModule<Object>- Returns:
- "IP Geolocation".
getModuleDescripion
Gets the description.- Specified by:
getModuleDescripionin interfaceIServerModule<Object>- Returns:
- A descriptive text of the module.
initialize
Initializes the module: whenServerSettings.IP2LOCATION_ENABLEDis on, configures theIP2LocationManagerasynchronously from the settings.- Specified by:
initializein interfaceIServerModule<Object>- Parameters:
server- The server instance.- Returns:
- The end point constructor (handles nothing).
onServerReady
Called when the server is ready: registers the region location providers when the local service or the web providers are enabled. Without either, nothing is registered, which is the state production has always been in.- Specified by:
onServerReadyin interfaceIServerModule<Object>- Parameters:
server- The server instance.
dispose
public void dispose()Disposes of this server module: shuts the IP2Location manager down when it was started.- Specified by:
disposein interfaceIServerModule<Object>