ro.isdc.wro.cache
Class ConfigurableCacheStrategy

java.lang.Object
  extended by ro.isdc.wro.model.resource.support.AbstractConfigurableStrategySupport<S,P>
      extended by ro.isdc.wro.model.resource.support.AbstractConfigurableSingleStrategy<CacheStrategy<CacheKey,CacheValue>,CacheStrategyProvider>
          extended by ro.isdc.wro.cache.ConfigurableCacheStrategy
All Implemented Interfaces:
CacheStrategy<CacheKey,CacheValue>

public class ConfigurableCacheStrategy
extends AbstractConfigurableSingleStrategy<CacheStrategy<CacheKey,CacheValue>,CacheStrategyProvider>
implements CacheStrategy<CacheKey,CacheValue>

Uses the CacheStrategy implementation associated with an alias read from properties file.

Since:
1.5.0
Author:
Alex Objelean

Field Summary
static String KEY
          Property name to specify alias.
 
Constructor Summary
ConfigurableCacheStrategy()
           
 
Method Summary
 void clear()
          Clear all cache contents.
 void destroy()
          Perform the clean up.
 CacheValue get(CacheKey key)
          Restore a value from the cache.
protected  CacheStrategy<CacheKey,CacheValue> getDefaultStrategy()
          
protected  Class<CacheStrategyProvider> getProviderClass()
          
protected  Map<String,CacheStrategy<CacheKey,CacheValue>> getStrategies(CacheStrategyProvider provider)
          
protected  String getStrategyKey()
          
 void put(CacheKey key, CacheValue value)
          Put a value in the cache using a key.
 
Methods inherited from class ro.isdc.wro.model.resource.support.AbstractConfigurableSingleStrategy
getConfiguredStrategy
 
Methods inherited from class ro.isdc.wro.model.resource.support.AbstractConfigurableStrategySupport
copyAll, getAvailableAliases, getAvailableStrategies, getConfiguredValue, getProviderFinder, getStrategyForAlias, newProperties, overrideDefaultStrategyMap, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY

public static final String KEY
Property name to specify alias.

See Also:
Constant Field Values
Constructor Detail

ConfigurableCacheStrategy

public ConfigurableCacheStrategy()
Method Detail

clear

public void clear()
Clear all cache contents.

Specified by:
clear in interface CacheStrategy<CacheKey,CacheValue>

destroy

public void destroy()
Perform the clean up.

Specified by:
destroy in interface CacheStrategy<CacheKey,CacheValue>

get

public CacheValue get(CacheKey key)
Restore a value from the cache.

Specified by:
get in interface CacheStrategy<CacheKey,CacheValue>
Parameters:
key - Object
Returns:
value Object.

put

public void put(CacheKey key,
                CacheValue value)
Put a value in the cache using a key.

Specified by:
put in interface CacheStrategy<CacheKey,CacheValue>
Parameters:
key - Object.
value - Object.

getStrategyKey

protected String getStrategyKey()

Specified by:
getStrategyKey in class AbstractConfigurableStrategySupport<CacheStrategy<CacheKey,CacheValue>,CacheStrategyProvider>
Returns:
the key of the strategy property.

getDefaultStrategy

protected CacheStrategy<CacheKey,CacheValue> getDefaultStrategy()

Specified by:
getDefaultStrategy in class AbstractConfigurableSingleStrategy<CacheStrategy<CacheKey,CacheValue>,CacheStrategyProvider>
Returns:
the default strategy implementation to use when no key is configured is provided.

getStrategies

protected Map<String,CacheStrategy<CacheKey,CacheValue>> getStrategies(CacheStrategyProvider provider)

Specified by:
getStrategies in class AbstractConfigurableStrategySupport<CacheStrategy<CacheKey,CacheValue>,CacheStrategyProvider>
Parameters:
provider - the instance responsible for strategy lookup.
Returns:
the map of provided strategies.

getProviderClass

protected Class<CacheStrategyProvider> getProviderClass()

Overrides:
getProviderClass in class AbstractConfigurableStrategySupport<CacheStrategy<CacheKey,CacheValue>,CacheStrategyProvider>
Returns:
the class of the provider of type P. Uses ParameterizedType to compute the class. Override it to support anonymous classes which do not play well with ParameterizedType's.


Copyright © 2008-2013. All Rights Reserved.