Class StrategySelectorImpl
java.lang.Object
org.hibernate.boot.registry.selector.internal.StrategySelectorImpl
- All Implemented Interfaces:
Serializable
,StrategySelector
,Service
Standard implementation of the
StrategySelector
contract.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStrategySelectorImpl
(ClassLoaderService classLoaderService) Constructs a StrategySelectorImpl using the given class loader service. -
Method Summary
Modifier and TypeMethodDescriptiongetRegisteredStrategyImplementors
(Class strategy) Retrieve all of the registered implementors of the given strategy.<T> void
registerStrategyImplementor
(Class<T> strategy, String name, Class<? extends T> implementation) Registers a named implementor of a particular strategy contract.<T> void
registerStrategyLazily
(Class<T> strategy, LazyServiceResolver<T> resolver) <T> T
resolveDefaultableStrategy
(Class<T> strategy, Object strategyReference, Callable<T> defaultResolver) Resolve strategy instances.<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> T
resolveStrategy
(Class<T> strategy, Object strategyReference, Callable<T> defaultResolver, StrategyCreator<T> creator) <T> T
resolveStrategy
(Class<T> strategy, Object strategyReference, T defaultValue, StrategyCreator<T> creator) <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.
-
Constructor Details
-
StrategySelectorImpl
Constructs a StrategySelectorImpl using the given class loader service.- Parameters:
classLoaderService
- The class loader service usable by this StrategySelectorImpl instance.
-
-
Method Details
-
registerStrategyLazily
-
registerStrategyImplementor
public <T> void registerStrategyImplementor(Class<T> strategy, String name, Class<? extends T> implementation) Description copied from interface:StrategySelector
Registers a named implementor of a particular strategy contract.- Specified by:
registerStrategyImplementor
in interfaceStrategySelector
- Type Parameters:
T
- The type of the strategy. Used to make sure that the strategy and implementation are type compatible.- Parameters:
strategy
- The strategy contract.name
- The registration nameimplementation
- The implementation Class
-
unRegisterStrategyImplementor
Description copied from interface:StrategySelector
Un-registers a named implementor of a particular strategy contract. Un-registers all named registrations for the given strategy contract naming the given class.- Specified by:
unRegisterStrategyImplementor
in interfaceStrategySelector
- Type Parameters:
T
- The type of the strategy. Used to make sure that the strategy and implementation are type compatible.- Parameters:
strategy
- The strategy contract.implementation
- The implementation Class
-
selectStrategyImplementor
Description copied from interface:StrategySelector
Locate the named strategy implementation.- Specified by:
selectStrategyImplementor
in interfaceStrategySelector
- Type Parameters:
T
- The type of the strategy. Used to make sure that the strategy and implementation are type compatible.- Parameters:
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.- Returns:
- The named strategy implementation class.
-
resolveStrategy
Description copied from interface:StrategySelector
Resolve strategy instances. See discussion onStrategySelector.resolveDefaultableStrategy(java.lang.Class<T>, java.lang.Object, T)
. Only difference is that here, the implied default value isnull
.- Specified by:
resolveStrategy
in interfaceStrategySelector
- Type Parameters:
T
- The type of the strategy. Used to make sure that the strategy and implementation are type compatible.- Parameters:
strategy
- The type (interface) of the strategy to be resolved.strategyReference
- The reference to the strategy for which we need to resolve an instance.- Returns:
- The strategy instance
-
resolveDefaultableStrategy
public <T> T resolveDefaultableStrategy(Class<T> strategy, Object strategyReference, T defaultValue) Description copied from interface:StrategySelector
Resolve strategy instances. The incoming reference might be:-
null
- in which case defaultValue is returned. - An actual instance of the strategy type - it is returned, as is
-
A reference to the implementation
Class
- an instance is created by callingClass.newInstance()
(aka, the class's no-arg ctor). -
The name of the implementation class - First the implementation's
Class
reference is resolved, and then an instance is created by callingClass.newInstance()
- Specified by:
resolveDefaultableStrategy
in interfaceStrategySelector
- Type Parameters:
T
- The type of the strategy. Used to make sure that the strategy and implementation are type compatible.- Parameters:
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 null- Returns:
- The strategy instance
-
-
resolveDefaultableStrategy
public <T> T resolveDefaultableStrategy(Class<T> strategy, Object strategyReference, Callable<T> defaultResolver) Description copied from interface:StrategySelector
Resolve strategy instances. The incoming reference might be:-
null
- in which case defaultValue is returned. - An actual instance of the strategy type - it is returned, as is
-
A reference to the implementation
Class
- an instance is created by callingClass.newInstance()
(aka, the class's no-arg ctor). -
The name of the implementation class - First the implementation's
Class
reference is resolved, and then an instance is created by callingClass.newInstance()
- Specified by:
resolveDefaultableStrategy
in interfaceStrategySelector
- Type Parameters:
T
- The type of the strategy. Used to make sure that the strategy and implementation are type compatible.- Parameters:
strategy
- The type (interface) of the strategy to be resolved.strategyReference
- The reference to the strategy for which we need to resolve an instance.defaultResolver
- A strategy for resolving the default value strategyReference resolves to null.- Returns:
- The strategy instance
-
-
resolveStrategy
public <T> T resolveStrategy(Class<T> strategy, Object strategyReference, T defaultValue, StrategyCreator<T> creator) - Specified by:
resolveStrategy
in interfaceStrategySelector
-
getRegisteredStrategyImplementors
Description copied from interface:StrategySelector
Retrieve all of the registered implementors of the given strategy. Useful to allow defaulting the choice to the single registered implementor when only one is registered- Specified by:
getRegisteredStrategyImplementors
in interfaceStrategySelector
- Returns:
- The implementors. Should never return
null
-
resolveStrategy
public <T> T resolveStrategy(Class<T> strategy, Object strategyReference, Callable<T> defaultResolver, StrategyCreator<T> creator) - Specified by:
resolveStrategy
in interfaceStrategySelector
-