org.jclouds.rest.suppliers
Class MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T>

java.lang.Object
  extended by org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T>
All Implemented Interfaces:
com.google.common.base.Supplier<T>

public class MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T>
extends Object
implements com.google.common.base.Supplier<T>

This will retry the supplier if it encounters a timeout exception, but not if it encounters an AuthorizationException.

A shared exception reference is used so that anyone who encounters an authorizationexception will be short-circuited. This prevents accounts from being locked out.

details

http://code.google.com/p/google-guice/issues/detail?id=483 guice doesn't remember when singleton providers throw exceptions. in this case, if the supplier fails with an authorization exception, it is called again for each provider method that depends on it. To short-circuit this, we remember the last exception trusting that guice is single-threaded.

Author:
Adrian Cole

Constructor Summary
MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier(AtomicReference<AuthorizationException> authException, long seconds, com.google.common.base.Supplier<T> delegate)
           
 
Method Summary
static
<T> MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T>
create(AtomicReference<AuthorizationException> authException, long seconds, com.google.common.base.Supplier<T> delegate)
           
 T get()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier

public MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier(AtomicReference<AuthorizationException> authException,
                                                                    long seconds,
                                                                    com.google.common.base.Supplier<T> delegate)
Method Detail

create

public static <T> MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<T> create(AtomicReference<AuthorizationException> authException,
                                                                                         long seconds,
                                                                                         com.google.common.base.Supplier<T> delegate)

get

public T get()
Specified by:
get in interface com.google.common.base.Supplier<T>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2012 jclouds. All Rights Reserved.