ro.isdc.wro.model.resource.support
Class AbstractConfigurableStrategySupport<S,P>

java.lang.Object
  extended by ro.isdc.wro.model.resource.support.AbstractConfigurableStrategySupport<S,P>
Type Parameters:
S - strategy type
P - provider type
Direct Known Subclasses:
AbstractConfigurableMultipleStrategy, AbstractConfigurableSingleStrategy

public abstract class AbstractConfigurableStrategySupport<S,P>
extends Object

Abstracts the configurable creation of the strategies based on ProviderFinder. Uses two generic parameters:

Since:
1.4.7
Author:
Alex Objelean

Constructor Summary
AbstractConfigurableStrategySupport()
           
 
Method Summary
protected  void copyAll(Map<String,S> source, Map<String,S> target)
          Utility method which copies all entries from source into target.
 Set<String> getAvailableAliases()
           
 Collection<S> getAvailableStrategies()
           
protected  String getConfiguredValue()
           
protected  Class<P> getProviderClass()
           
protected  ProviderFinder<P> getProviderFinder()
           
protected abstract  Map<String,S> getStrategies(P provider)
           
protected  S getStrategyForAlias(String alias)
          Override this method if a fallback search is required.
protected abstract  String getStrategyKey()
           
protected  Properties newProperties()
           
protected  void overrideDefaultStrategyMap(Map<String,S> map)
          Invoked after the the map of strategies is built from providers.
 void setProperties(Properties props)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConfigurableStrategySupport

public AbstractConfigurableStrategySupport()
Method Detail

getStrategyForAlias

protected S getStrategyForAlias(String alias)
Override this method if a fallback search is required.

Parameters:
alias - of the strategy to use.
Returns:
the strategy S if one is found or null if no corresponding strategy found.

getConfiguredValue

protected final String getConfiguredValue()
Returns:
the value configured in the properties file using the strategy key.

getAvailableAliases

public final Set<String> getAvailableAliases()
Returns:
a set of available aliases.

getAvailableStrategies

public final Collection<S> getAvailableStrategies()
Returns:
a set of available strategies.

overrideDefaultStrategyMap

protected void overrideDefaultStrategyMap(Map<String,S> map)
Invoked after the the map of strategies is built from providers. Allows client to override its keys or add new entries.

Parameters:
map - the built map.

copyAll

protected final void copyAll(Map<String,S> source,
                             Map<String,S> target)
Utility method which copies all entries from source into target. Entries with the same keys from target will be overridden with entries from source. This operation is similar to Map.putAll(Map), but it doesn't require changing generics to construction like
 
 

Parameters:
source - the map from where the entries will be copied into target.
target - the map where to put entries from source.

newProperties

protected Properties newProperties()
Returns:
Properties used to lookup namingStrategy alias.

setProperties

public final void setProperties(Properties props)
Parameters:
props - Properties containing configured alias.

getProviderFinder

protected ProviderFinder<P> getProviderFinder()
Returns:
the ProviderFinder used to find all strategies.

getProviderClass

protected Class<P> getProviderClass()
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.

getStrategies

protected abstract Map<String,S> getStrategies(P provider)
Parameters:
provider - the instance responsible for strategy lookup.
Returns:
the map of provided strategies.

getStrategyKey

protected abstract String getStrategyKey()
Returns:
the key of the strategy property.


Copyright © 2008-2013. All Rights Reserved.