class RetryTemplateAspect implements BeanFactoryAware {

    @Around("@annotation(retryTemplateAnnotation)")
    public Object retry(final ProceedingJoinPoint pjp,
                        final RetryTemplate retryTemplateAnnotation) throws Throwable {
        final String name = retryTemplateAnnotation.name();
        final String recoveryCallbackName = retryTemplateAnnotation.recoveryCallbackName();

        org.springframework.retry.support.RetryTemplate retryTemplate =
            beanFactory.getBean(name, org.springframework.retry.support.RetryTemplate.class);

        RecoveryCallback<Object> recoveryCallback = null;
        if (! Strings.isNullOrEmpty(recoveryCallbackName)) {
            recoveryCallback =
                    beanFactory.getBean(recoveryCallbackName, org.springframework.retry.RecoveryCallback.class);
        }


        if (logger.isDebugEnabled()) {
            logger.debug("Have @RetryTemplate method with retryTemplate name {} and callback name {}, " +
                    "wrapping call on method {} of target object {}",
                    new Object[]{
                            name,
                            recoveryCallbackName,
                            pjp.getSignature().getName(),
                            pjp.getTarget()});
        }

        return retryTemplate.execute(
                new RetryCallback<Object, Exception>() {
                    public Object doWithRetry(RetryContext context) throws Exception {
                        try {
                            return pjp.proceed();
                        }
                        catch (Error e) {
                            throw e;
                        }
                        catch (Exception e) {
                            throw e;
                        }
                        catch (Throwable e) {
                            throw new RuntimeException(e);
                        }
                    }
                },
                recoveryCallback);
    }

    public  RetryTemplateAspect();

}