Class PingingServletContextListener
- java.lang.Object
-
- pl.morgwai.base.servlet.guice.scopes.GuiceServletContextListener
-
- pl.morgwai.base.servlet.guice.utils.PingingServletContextListener
-
- All Implemented Interfaces:
ServletContextListener
,EventListener
public abstract class PingingServletContextListener extends GuiceServletContextListener
AGuiceServletContextListener
that automatically registers and deregisters endpoints to aWebsocketPingerService
. Endpoints need to be created withaddEndpoint(Class, String)
or annotated to usePingingEndpointConfigurator
.
-
-
Field Summary
Fields Modifier and Type Field Description protected WebsocketPingerService
pingerService
-
Fields inherited from class pl.morgwai.base.servlet.guice.scopes.GuiceServletContextListener
containerCallContextTracker, containerCallScope, endpointConfigurator, endpointContainer, httpSessionScope, injector, log, servletContainer, servletModule, websocketConnectionScope
-
-
Constructor Summary
Constructors Constructor Description PingingServletContextListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contextDestroyed(ServletContextEvent destruction)
Stops the associatedWebsocketPingerService
.protected GuiceServerEndpointConfigurator
createEndpointConfigurator()
Overrides default configurator used byGuiceServletContextListener.addEndpoint(Class, String)
to be aPingingEndpointConfigurator
.protected Injector
createInjector(LinkedList<Module> modules)
Called byGuiceServletContextListener.contextInitialized(ServletContextEvent)
to createthe app-wide Injector
.protected WebsocketPingerService
createPingerService()
Creates aWebsocketPingerService
.protected int
getPingFailureLimit()
Allows subclasses to override ping failure limit.protected int
getPingIntervalSeconds()
Allows subclasses to override ping interval.protected int
getPingSize()
Allows subclasses to override ping data size.protected boolean
isPingerInKeepAliveOnlyMode()
Allows subclasses to override pinger mode.protected boolean
shouldSynchronizePingSending()
Allows subclasses to overridesynchronizeSending
flag.-
Methods inherited from class pl.morgwai.base.servlet.guice.scopes.GuiceServletContextListener
addEndpoint, addEndpoint, addFilter, addFilter, addFilter, addServlet, configureInjections, configureServletsFiltersEndpoints, contextInitialized, getExecutorsTerminationTimeoutSeconds, handleUnterminatedExecutors, installEnsureSessionFilter
-
-
-
-
Field Detail
-
pingerService
protected final WebsocketPingerService pingerService
-
-
Method Detail
-
isPingerInKeepAliveOnlyMode
protected boolean isPingerInKeepAliveOnlyMode()
Allows subclasses to override pinger mode. By defaultfalse
.
-
getPingIntervalSeconds
protected int getPingIntervalSeconds()
Allows subclasses to override ping interval. By defaultWebsocketPingerService.DEFAULT_INTERVAL
.
-
getPingFailureLimit
protected int getPingFailureLimit()
Allows subclasses to override ping failure limit. By defaultWebsocketPingerService.DEFAULT_FAILURE_LIMIT
.
-
getPingSize
protected int getPingSize()
Allows subclasses to override ping data size. By defaultWebsocketPingerService.DEFAULT_PING_SIZE
.
-
shouldSynchronizePingSending
protected boolean shouldSynchronizePingSending()
Allows subclasses to overridesynchronizeSending
flag. By defaultfalse
.
-
createPingerService
protected WebsocketPingerService createPingerService()
Creates aWebsocketPingerService
. Used in constructor to initializepingerService
. By default usesisPingerInKeepAliveOnlyMode()
,getPingIntervalSeconds()
,getPingFailureLimit()
andgetPingSize()
to configure the returned service. May be overridden if non-standard customizations are required.
-
createInjector
protected Injector createInjector(LinkedList<Module> modules)
Description copied from class:GuiceServletContextListener
Called byGuiceServletContextListener.contextInitialized(ServletContextEvent)
to createthe app-wide Injector
. By default basically callsGuice.createInjector(modules)
. May be overridden if any additional customizations are needed.- Overrides:
createInjector
in classGuiceServletContextListener
-
createEndpointConfigurator
protected GuiceServerEndpointConfigurator createEndpointConfigurator()
Overrides default configurator used byGuiceServletContextListener.addEndpoint(Class, String)
to be aPingingEndpointConfigurator
.- Overrides:
createEndpointConfigurator
in classGuiceServletContextListener
-
contextDestroyed
public void contextDestroyed(ServletContextEvent destruction)
Stops the associatedWebsocketPingerService
.- Specified by:
contextDestroyed
in interfaceServletContextListener
- Overrides:
contextDestroyed
in classGuiceServletContextListener
-
-