Class FileUploadModule
java.lang.Object
com.iizix.server.upload.FileUploadModule
- All Implemented Interfaces:
IServerModule<Object>
The server module of the upload service: owns the staging store, the server-global registry, the chunk servlet and the sweeps, and routes the registry's events to the application session that owns each reservation.
Lifecycle, in the PushNotificationModule shape: initialize(IServer) builds the store and the registry; onServerReady(IServer) runs the cold-start sweep (every directory is a previous boot's: app sessions never outlive the process), registers the servlet when $upload.allow is on (mount-time gate; the reservation-time gate is the service's and requires this mount too, isRouteAvailable()), registers a server dispose listener that cancels every live reservation, and starts the periodic sweep; dispose() unregisters the servlet and stops the sweep.
- Author:
- Christopher Mindus
Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptioncreateService(IUploadSessionContext context) Creates the service of an application session and routes its events.voiddispose()Disposes of this server module.voiddisposeService(AppGyroFileUploaderService service) Disposes of a session's service: every transfer of the session is cancelled and removed.static FileUploadModuleGets the live module.Gets the description.--- IServerModule ---Gets the registry.getStore()Gets the store.initialize(IServer server) Initializes the module end point constructor.booleanChecks if the chunk servlet is registered.voidonServerReady(IServer server) Called when the server is ready.Finds the service owning a reservation.intsweep(long now) One in-process sweep: idle reservations by the clock (belt and braces beside the timers), then orphaned directories - anything on disk whose application session has no service here.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IServerModule
processServerArg
Constructor Details
FileUploadModule
public FileUploadModule()Constructor for the server: everything is built ininitialize(IServer).
Method Details
getInstance
Gets the live module.- Returns:
- The module, or null if the server has not initialized it or has disposed of it.
getModuleName
--- IServerModule ---- Specified by:
getModuleNamein interfaceIServerModule<Object>- Returns:
- A name such as "Load Balancer" or "License Manager".
getModuleDescripion
Description copied from interface:IServerModuleGets the description.- Specified by:
getModuleDescripionin interfaceIServerModule<Object>- Returns:
- A descriptive text of the module such a "Load Balancer for servers in the co.iizi.* domain" or "Backup License Manager for com.domain.LicMan".
initialize
Description copied from interface:IServerModuleInitializes the module end point constructor.- Specified by:
initializein interfaceIServerModule<Object>- Parameters:
server- The server instance.- Returns:
- The end point constructor.
- Throws:
Exception- For failures: the module will not be used...
onServerReady
Description copied from interface:IServerModuleCalled when the server is ready. A server module that wishes to listen to when the server is going to be disposed can do so usingIServer.addDisposeListener(com.iizix.server.IServerDisposeListener)at this stage.- Specified by:
onServerReadyin interfaceIServerModule<Object>- Parameters:
server- The server instance.
dispose
public void dispose()Description copied from interface:IServerModuleDisposes of this server module. After dispose is called andIServerModule.dispose()has been called, the end point constructor is automatically removed and disposed of.- Specified by:
disposein interfaceIServerModule<Object>
sweep
public int sweep(long now) One in-process sweep: idle reservations by the clock (belt and braces beside the timers), then orphaned directories - anything on disk whose application session has no service here.- Parameters:
now- The current time.- Returns:
- The number of directories swept from disk.
createService
Creates the service of an application session and routes its events.- Parameters:
context- The session context.- Returns:
- The service.
disposeService
Disposes of a session's service: every transfer of the session is cancelled and removed.- Parameters:
service- The service.
serviceOf
Finds the service owning a reservation.- Parameters:
r- The reservation.- Returns:
- The service, or null if the session has none (disposed).
getRegistry
getStore
isServletRegistered
public boolean isServletRegistered()Checks if the chunk servlet is registered.- Returns:
- true if registered.