Package com.ccbill.clessidra.strategy

Examples of com.ccbill.clessidra.strategy.AbstractLimiterStrategy


      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);
View Full Code Here

TOP

Related Classes of com.ccbill.clessidra.strategy.AbstractLimiterStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.