public class StrategySelectorImpl extends Object implements StrategySelector
| Constructor and Description |
|---|
StrategySelectorImpl(ClassLoaderService classLoaderService)
Constructs a StrategySelectorImpl using the given class loader service.
|
| Modifier and Type | Method and Description |
|---|---|
<T> void |
registerStrategyImplementor(Class<T> strategy,
String name,
Class<? extends T> implementation)
Registers a named implementor of a particular strategy contract.
|
<T> T |
resolveDefaultableStrategy(Class<T> strategy,
Object strategyReference,
T defaultValue)
Resolve strategy instances.
|
<T> T |
resolveStrategy(Class<T> strategy,
Object strategyReference)
Resolve strategy instances.
|
<T> Class<? extends T> |
selectStrategyImplementor(Class<T> strategy,
String name)
Locate the named strategy implementation.
|
<T> void |
unRegisterStrategyImplementor(Class<T> strategy,
Class<? extends T> implementation)
Un-registers a named implementor of a particular strategy contract.
|
public StrategySelectorImpl(ClassLoaderService classLoaderService)
classLoaderService - The class loader service usable by this StrategySelectorImpl instance.public <T> void registerStrategyImplementor(Class<T> strategy, String name, Class<? extends T> implementation)
StrategySelectorregisterStrategyImplementor in interface StrategySelectorT - The type of the strategy. Used to make sure that the strategy and implementation are type
compatible.strategy - The strategy contract.name - The registration nameimplementation - The implementation Classpublic <T> void unRegisterStrategyImplementor(Class<T> strategy, Class<? extends T> implementation)
StrategySelectorunRegisterStrategyImplementor in interface StrategySelectorT - The type of the strategy. Used to make sure that the strategy and implementation are type
compatible.strategy - The strategy contract.implementation - The implementation Classpublic <T> Class<? extends T> selectStrategyImplementor(Class<T> strategy, String name)
StrategySelectorselectStrategyImplementor in interface StrategySelectorT - The type of the strategy. Used to make sure that the strategy and implementation are type
compatible.strategy - The type of strategy to be resolved.name - The name of the strategy to locate; might be either a registered name or the implementation FQN.public <T> T resolveStrategy(Class<T> strategy, Object strategyReference)
StrategySelectorStrategySelector.resolveDefaultableStrategy(java.lang.Class<T>, java.lang.Object, T).
Only difference is that here, the implied default value is null.resolveStrategy in interface StrategySelectorT - The type of the strategy. Used to make sure that the strategy and implementation are type
compatible.strategy - The type (interface) of the strategy to be resolved.strategyReference - The reference to the strategy for which we need to resolve an instance.public <T> T resolveDefaultableStrategy(Class<T> strategy, Object strategyReference, T defaultValue)
StrategySelectornull - in which case defaultValue is returned.
Class - an instance is created by calling
Class.newInstance() (aka, the class's no-arg ctor).
Class reference
is resolved, and then an instance is created by calling Class.newInstance()
resolveDefaultableStrategy in interface StrategySelectorT - The type of the strategy. Used to make sure that the strategy and implementation are type
compatible.strategy - The type (interface) of the strategy to be resolved.strategyReference - The reference to the strategy for which we need to resolve an instance.defaultValue - THe default value to use if strategyReference is nullCopyright © 2001-2015 Red Hat, Inc. All Rights Reserved.