Class PingingServletContextListener
- java.lang.Object
-
- pl.morgwai.base.servlet.guice.scopes.GuiceServletContextListener
-
- pl.morgwai.base.servlet.guice.utils.PingingServletContextListener
-
- All Implemented Interfaces:
EventListener
,ServletContextListener
public abstract class PingingServletContextListener extends GuiceServletContextListener
Subclass ofGuiceServletContextListener
that automatically registers and deregistersEndpoints
added withGuiceServletContextListener.addEndpoint(Class, String)
to the associatedWebsocketPingerService
.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_FAILURE_LIMIT
protected WebsocketPingerService
pingerService
The app-wide pinger service to whichGuiceServletContextListener.addEndpoint(Class, String)
method registersEndpoints
.-
Fields inherited from class pl.morgwai.base.servlet.guice.scopes.GuiceServletContextListener
appDeployment, containerCallScope, deploymentName, endpointConfigurator, endpointContainer, httpSessionScope, injector, servletModule, websocketConnectionScope
-
-
Constructor Summary
Constructors Constructor Description PingingServletContextListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected GuiceServerEndpointConfigurator
createEndpointConfigurator()
OverridesGuiceServletContextListener.endpointConfigurator
to be aPingingEndpointConfigurator
.protected WebsocketPingerService
createPingerService()
Createsthe app-wide pinger service
.protected int
getPingFailureLimit()
Allows to overridepingerService
'sfailureLimit
param.protected long
getPingIntervalMillis()
Allows to overridepingerService
'sinterval
param.protected boolean
isPingerInKeepAliveOnlyMode()
Allows to overridepingerService
's mode.protected boolean
shouldSynchronizePingSending()
Allows to overridepingerService
'ssynchronizeSending
flag.-
Methods inherited from class pl.morgwai.base.servlet.guice.scopes.GuiceServletContextListener
addConfigurationHook, addEndpoint, addEndpoint, addEnsureSessionFilter, addFilter, addFilter, addFilter, addServlet, addShutdownHook, configureInjections, configureServletsFiltersEndpoints, contextDestroyed, contextInitialized, createInjector, getExecutorsTerminationTimeout, handleUnterminatedExecutors
-
-
-
-
Field Detail
-
pingerService
protected WebsocketPingerService pingerService
The app-wide pinger service to whichGuiceServletContextListener.addEndpoint(Class, String)
method registersEndpoints
. Initialized with the result ofcreatePingerService()
.The app-wide pinger service is also stored as a
deployment attribute
underfully-qualified name
ofWebsocketPingerService
class.
-
DEFAULT_FAILURE_LIMIT
public static final int DEFAULT_FAILURE_LIMIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
isPingerInKeepAliveOnlyMode
protected boolean isPingerInKeepAliveOnlyMode()
Allows to overridepingerService
's mode. By defaultfalse
.This method is called by
createPingerService()
, it may useGuiceServletContextListener.appDeployment
andGuiceServletContextListener.injector
.
-
getPingIntervalMillis
protected long getPingIntervalMillis()
Allows to overridepingerService
'sinterval
param. By defaultWebsocketPingerService.DEFAULT_INTERVAL_SECONDS
converted to millis.This method is called by
createPingerService()
, it may useGuiceServletContextListener.appDeployment
andGuiceServletContextListener.injector
.
-
getPingFailureLimit
protected int getPingFailureLimit()
Allows to overridepingerService
'sfailureLimit
param. By default 4.This method is called by
createPingerService()
, it may useGuiceServletContextListener.appDeployment
andGuiceServletContextListener.injector
.
-
shouldSynchronizePingSending
protected boolean shouldSynchronizePingSending()
Allows to overridepingerService
'ssynchronizeSending
flag. By defaultfalse
.This method is called by
createPingerService()
, it may useGuiceServletContextListener.appDeployment
andGuiceServletContextListener.injector
.
-
createPingerService
protected WebsocketPingerService createPingerService()
Createsthe app-wide pinger service
. By default it callsisPingerInKeepAliveOnlyMode()
,getPingIntervalMillis()
andgetPingFailureLimit()
andshouldSynchronizePingSending()
to configure the service.This method is called once in a
createEndpointConfigurator()
and may be overridden if other customizations are required. It may useGuiceServletContextListener.appDeployment
andGuiceServletContextListener.injector
.
-
createEndpointConfigurator
protected GuiceServerEndpointConfigurator createEndpointConfigurator()
OverridesGuiceServletContextListener.endpointConfigurator
to be aPingingEndpointConfigurator
. Alsocreates the app-wide pinger service
and stores it as adeployment attribute
underfully-qualified name
ofWebsocketPingerService
class.- Overrides:
createEndpointConfigurator
in classGuiceServletContextListener
-
-