Class AttemptsManagerDefault
java.lang.Object
org.spincast.plugins.attemptslimiter.AttemptsManagerDefault
- All Implemented Interfaces:
AttemptsManager
-
Field Summary
-
Constructor Summary
ConstructorDescriptionAttemptsManagerDefault
(SpincastAttemptsLimiterPluginRepository SpincastAttemptsLimiterPluginRepository, AttemptFactory attemptFactory, SpincastAttemptsLimiterPluginConfig spincastAttemptsLimiterPluginConfig) -
Method Summary
Modifier and TypeMethodDescriptionattempt
(String actionName, AttemptCriteria... criterias) Gets the currentAttempt
, given the action to protect and criterias.attempt
(String actionName, AttemptsAutoIncrementType attemptsAutoIncrementType, AttemptCriteria... criterias) Gets the currentAttempt
, given the action to protect and criterias.protected AttemptFactory
protected AttemptRule
getAttemptRule
(String actionName) Gets all the registeredAttemptRule
rules, by action names.protected SpincastAttemptsLimiterPluginConfig
protected SpincastAttemptsLimiterPluginRepository
void
registerAttempRule
(String actionName, int nbrMaxAttemptsPerDuration, Duration duration) Creates and registers aAttemptRule
rule from the required informations.void
registerAttempRule
(AttemptRule attemptRule) Registers aAttemptRule
rule.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
AttemptsManagerDefault
@Inject public AttemptsManagerDefault(SpincastAttemptsLimiterPluginRepository SpincastAttemptsLimiterPluginRepository, AttemptFactory attemptFactory, SpincastAttemptsLimiterPluginConfig spincastAttemptsLimiterPluginConfig)
-
-
Method Details
-
getSpincastAttemptsLimiterPluginRepository
-
getAttemptRulesByActionName
Description copied from interface:AttemptsManager
Gets all the registeredAttemptRule
rules, by action names.- Specified by:
getAttemptRulesByActionName
in interfaceAttemptsManager
-
getAttemptRule
-
getAttemptFactory
-
getSpincastAttemptsLimiterPluginConfig
-
attempt
Description copied from interface:AttemptsManager
Gets the currentAttempt
, given the action to protect and criterias. With this object you can:-
Know if the action should be allowed or blocked,
by calling
Attempt.isMaxReached()
. -
Manually increment the number of attempts using
Attempt.incrementAttemptsCount()
, if you didn't let the {AttemptsManager.attempt(String, AttemptCriteria...)
} method do it automatically (seeSpincastAttemptsLimiterPluginConfig.getDefaultAttemptAutoIncrementType()
).
- Specified by:
attempt
in interfaceAttemptsManager
-
Know if the action should be allowed or blocked,
by calling
-
attempt
public Attempt attempt(String actionName, AttemptsAutoIncrementType attemptsAutoIncrementType, AttemptCriteria... criterias) Description copied from interface:AttemptsManager
Gets the currentAttempt
, given the action to protect and criterias. With this object you can:-
Know if the action should be allowed or blocked,
by calling
Attempt.isMaxReached()
. -
Manually increment the number of attempts using
Attempt.incrementAttemptsCount()
, if you didn't let the {{@link #attempt(String, AttemptAutoIncrementType, AttemptCriteria...))}} method do it automatically.
- Specified by:
attempt
in interfaceAttemptsManager
attemptsAutoIncrementType
- Specifies if the method should increment the number of attempts by itself. If you don't let it do it, you need to increment the number of attempts by yourself, by callingAttempt.incrementAttemptsCount()
on the returned object.
-
Know if the action should be allowed or blocked,
by calling
-
registerAttempRule
Description copied from interface:AttemptsManager
Registers aAttemptRule
rule.- Specified by:
registerAttempRule
in interfaceAttemptsManager
-
registerAttempRule
Description copied from interface:AttemptsManager
Creates and registers aAttemptRule
rule from the required informations.- Specified by:
registerAttempRule
in interfaceAttemptsManager
-