Class AttemptsManagerDefault
java.lang.Object
org.spincast.plugins.attemptslimiter.AttemptsManagerDefault
- All Implemented Interfaces:
AttemptsManager
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAttemptsManagerDefault(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 AttemptFactoryprotected AttemptRulegetAttemptRule(String actionName) Gets all the registeredAttemptRulerules, by action names.protected SpincastAttemptsLimiterPluginConfigprotected SpincastAttemptsLimiterPluginRepositoryvoidregisterAttempRule(String actionName, int nbrMaxAttemptsPerDuration, Duration duration) Creates and registers aAttemptRulerule from the required informations.voidregisterAttempRule(AttemptRule attemptRule) Registers aAttemptRulerule.
-
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:AttemptsManagerGets all the registeredAttemptRulerules, by action names.- Specified by:
getAttemptRulesByActionNamein interfaceAttemptsManager
-
getAttemptRule
-
getAttemptFactory
-
getSpincastAttemptsLimiterPluginConfig
-
attempt
Description copied from interface:AttemptsManagerGets 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:
attemptin 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:AttemptsManagerGets 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:
attemptin interfaceAttemptsManagerattemptsAutoIncrementType- 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:AttemptsManagerRegisters aAttemptRulerule.- Specified by:
registerAttempRulein interfaceAttemptsManager
-
registerAttempRule
Description copied from interface:AttemptsManagerCreates and registers aAttemptRulerule from the required informations.- Specified by:
registerAttempRulein interfaceAttemptsManager
-