methodGroupName = methodSignature.toString();
break;
}
// get the limiter strategy chain from the spring context
AbstractLimiterStrategy limiterStrategyChain = (AbstractLimiterStrategy) applicationContext.getBean(annotation.limiterBean());
// generate a uuid to be used later on if rollback is required
UUID methodInvocationUUID = UUIDGenerator.generateUUID();
// run through the limiter strategy chain and get the conclusion
LimiterStrategyConclusion conclusion = limiterStrategyChain.hasLimitBeenExceededChain(methodGroupName, methodInvocationUUID,
joinPoint.getArgs());
// if limit is not exceeded call the method and do a post invocation clean up where needed
if (!conclusion.getHasLimitBeenExceeded()) {
logger.trace("About to run method " + methodSignature.toString());
try {
Object obj = joinPoint.proceed(joinPoint.getArgs());
logger.trace("Finished running " + methodSignature.toString());
return obj;
} catch (Throwable t) {
logger.debug("Method " + methodSignature.toString() + " did not exit gracefully. " + t);
throw t;
} finally {
limiterStrategyChain.postInvocationCleanupChain(methodGroupName, methodInvocationUUID, joinPoint.getArgs());
}
}
// throw an exception containing the conclusion
throw new RateLimiterException("Method call blocked.", conclusion);