org.jclouds.cache
Class RetryingCacheLoaderDecorator<K,V>

java.lang.Object
  extended by org.jclouds.cache.RetryingCacheLoaderDecorator<K,V>
Type Parameters:
K - the base key type for all cache loaders created by this decorator
V - the base value type for all cache loaders created by this decorator
Direct Known Subclasses:
RetryingCacheLoaderDecorator.BackoffExponentiallyAndRetryOnThrowableCacheLoaderDecorator

@Beta
public class RetryingCacheLoaderDecorator<K,V>
extends Object

A decorator of CacheLoader instances having any combination of the following features:

These features are all optional; cache loaders can be created using all or none of them. By default, the input cache loader is returned unaffected.

Usage example:

Since:
1.5
Author:
Adrian Cole

Nested Class Summary
static class RetryingCacheLoaderDecorator.BackoffExponentiallyAndRetryOnThrowableCacheLoaderDecorator<K,V>
           
static class RetryingCacheLoaderDecorator.OnThrowableBuilder<K,V>
           
 
Constructor Summary
protected RetryingCacheLoaderDecorator()
           
 
Method Summary
<K1 extends K,V1 extends V>
com.google.common.cache.CacheLoader<K1,V1>
decorate(com.google.common.cache.CacheLoader<K1,V1> loader)
          Decorates a cacheloader, or returns the same value, if no retrying features were requested.
static RetryingCacheLoaderDecorator<Object,Object> newDecorator()
          Constructs a new RetryingCacheLoaderDecorator instance with default settings, and no retrying any kind.
 RetryingCacheLoaderDecorator.OnThrowableBuilder<K,V> on(Class<? extends Throwable> retryableThrowable)
          Determines the action to carry out on a particular throwable.
protected  com.google.common.base.Objects.ToStringHelper string()
          append any state that should be considered in toString() here.
 String toString()
          Returns a string representation for this RetryingCacheLoaderDecorator instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RetryingCacheLoaderDecorator

protected RetryingCacheLoaderDecorator()
Method Detail

newDecorator

public static RetryingCacheLoaderDecorator<Object,Object> newDecorator()
Constructs a new RetryingCacheLoaderDecorator instance with default settings, and no retrying any kind.


on

public RetryingCacheLoaderDecorator.OnThrowableBuilder<K,V> on(Class<? extends Throwable> retryableThrowable)
Determines the action to carry out on a particular throwable.


decorate

public <K1 extends K,V1 extends V> com.google.common.cache.CacheLoader<K1,V1> decorate(com.google.common.cache.CacheLoader<K1,V1> loader)
Decorates a cacheloader, or returns the same value, if no retrying features were requested.

This method does not alter the state of this RetryingCacheLoaderDecorator instance, so it can be invoked again to create multiple independent cache loaders.

Parameters:
loader - the cache loader used to obtain new values
Returns:
a cache loader having the requested features

toString

public String toString()
Returns a string representation for this RetryingCacheLoaderDecorator instance. The exact form of the returned string is not specified.

Overrides:
toString in class Object

string

protected com.google.common.base.Objects.ToStringHelper string()
append any state that should be considered in toString() here.



Copyright © 2009-2013 jclouds. All Rights Reserved.