Class QuartzSessionValidationScheduler
- java.lang.Object
-
- org.apache.shiro.session.mgt.quartz.QuartzSessionValidationScheduler
-
- All Implemented Interfaces:
SessionValidationScheduler
public class QuartzSessionValidationScheduler extends Object implements SessionValidationScheduler
An implementation of theSessionValidationScheduler
that uses Quartz to schedule a job to callValidatingSessionManager.validateSessions()
on a regular basis.- Since:
- 0.1
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_SESSION_VALIDATION_INTERVAL
The default interval at which sessions will be validated (1 hour); This can be overridden by callingsetSessionValidationInterval(long)
-
Constructor Summary
Constructors Constructor Description QuartzSessionValidationScheduler()
Default constructor.QuartzSessionValidationScheduler(ValidatingSessionManager sessionManager)
Constructor that specifies the session manager that should be used for validating sessions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disableSessionValidation()
Disables the session validation job.void
enableSessionValidation()
Starts session validation by creating a Quartz simple trigger, linking it to theQuartzSessionValidationJob
, and scheduling it with the Quartz scheduler.protected Scheduler
getScheduler()
boolean
isEnabled()
Returnstrue
if this Scheduler is enabled and ready to begin validation at the appropriate time,false
otherwise.void
setScheduler(Scheduler scheduler)
void
setSessionManager(ValidatingSessionManager sessionManager)
void
setSessionValidationInterval(long sessionValidationInterval)
Specifies how frequently (in milliseconds) this Scheduler will call theValidatingSessionManager#validateSessions()
method.
-
-
-
Field Detail
-
DEFAULT_SESSION_VALIDATION_INTERVAL
public static final long DEFAULT_SESSION_VALIDATION_INTERVAL
The default interval at which sessions will be validated (1 hour); This can be overridden by callingsetSessionValidationInterval(long)
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
QuartzSessionValidationScheduler
public QuartzSessionValidationScheduler()
Default constructor.
-
QuartzSessionValidationScheduler
public QuartzSessionValidationScheduler(ValidatingSessionManager sessionManager)
Constructor that specifies the session manager that should be used for validating sessions.- Parameters:
sessionManager
- the SessionManager that should be used to validate sessions.
-
-
Method Detail
-
getScheduler
protected Scheduler getScheduler() throws SchedulerException
- Throws:
SchedulerException
-
setScheduler
public void setScheduler(Scheduler scheduler)
-
setSessionManager
public void setSessionManager(ValidatingSessionManager sessionManager)
-
isEnabled
public boolean isEnabled()
Description copied from interface:SessionValidationScheduler
Returnstrue
if this Scheduler is enabled and ready to begin validation at the appropriate time,false
otherwise. It does not indicate if the validation is actually executing at that instant - only that it is prepared to do so at the appropriate time.- Specified by:
isEnabled
in interfaceSessionValidationScheduler
- Returns:
true
if this Scheduler is enabled and ready to begin validation at the appropriate time,false
otherwise.
-
setSessionValidationInterval
public void setSessionValidationInterval(long sessionValidationInterval)
Specifies how frequently (in milliseconds) this Scheduler will call theValidatingSessionManager#validateSessions()
method.Unless this method is called, the default value is
DEFAULT_SESSION_VALIDATION_INTERVAL
.- Parameters:
sessionValidationInterval
-
-
enableSessionValidation
public void enableSessionValidation()
Starts session validation by creating a Quartz simple trigger, linking it to theQuartzSessionValidationJob
, and scheduling it with the Quartz scheduler.- Specified by:
enableSessionValidation
in interfaceSessionValidationScheduler
-
disableSessionValidation
public void disableSessionValidation()
Description copied from interface:SessionValidationScheduler
Disables the session validation job.- Specified by:
disableSessionValidation
in interfaceSessionValidationScheduler
-
-