ro.isdc.wro.cache.ConfigurableCacheStrategy Maven / Gradle / Ivy
package ro.isdc.wro.cache;
import java.util.Map;
import ro.isdc.wro.cache.impl.LruMemoryCacheStrategy;
import ro.isdc.wro.cache.spi.CacheStrategyProvider;
import ro.isdc.wro.model.resource.support.AbstractConfigurableSingleStrategy;
/**
* Uses the {@link CacheStrategy} implementation associated with an alias read from properties file.
*
* @author Alex Objelean
* @created 22 Sep 2012
* @since 1.5.0
*/
public class ConfigurableCacheStrategy
extends AbstractConfigurableSingleStrategy, CacheStrategyProvider>
implements CacheStrategy {
/**
* Property name to specify alias.
*/
public static final String KEY = "cacheStrategy";
/**
* {@inheritDoc}
*/
public void clear() {
getConfiguredStrategy().clear();
}
/**
* {@inheritDoc}
*/
public void destroy() {
getConfiguredStrategy().destroy();
}
/**
* {@inheritDoc}
*/
public CacheValue get(final CacheKey key) {
return getConfiguredStrategy().get(key);
}
/**
* {@inheritDoc}
*/
public void put(final CacheKey key, final CacheValue value) {
getConfiguredStrategy().put(key, value);
}
/**
* {@inheritDoc}
*/
@Override
protected String getStrategyKey() {
return KEY;
}
/**
* {@inheritDoc}
*/
@Override
protected CacheStrategy getDefaultStrategy() {
return new LruMemoryCacheStrategy();
}
/**
* {@inheritDoc}
*/
@Override
protected Map> getStrategies(final CacheStrategyProvider provider) {
return provider.provideCacheStrategies();
}
/**
* {@inheritDoc}
*/
@Override
protected Class getProviderClass() {
return CacheStrategyProvider.class;
}
}