class SelfPopulatingCache extends BlockingCache {

    @Override
    public Element get(final Object key) throws LockTimeoutException {

        Element element = super.get(key);

        if (element == null) {
            try {
                // Value not cached - fetch it
                Object value = factory.createEntry(key);
                element = makeAndCheckElement(key, value);
            } catch (final Throwable throwable) {
                // Could not fetch - Ditch the entry from the cache and rethrow
                // release the lock you acquired
                element = new Element(key, null);
                throw new CacheException("Could not fetch object for cache entry with key \"" + key + "\".", throwable);
            } finally {
                put(element);
            }
        }
        return element;
    }

    public  SelfPopulatingCache(final Ehcache cache, final CacheEntryFactory factory);

}