Top Description Fields Constructors Methods
org.hibernate.boot.registry.selector.internal

public Class StrategySelectorImpl

extends Object
implements StrategySelector
Class Inheritance
All Implemented Interfaces
org.hibernate.boot.registry.selector.spi.StrategySelector, org.hibernate.service.Service, java.io.Serializable
Imports
java.util.Collection, .Collections, .HashSet, .Iterator, .Map, java.util.concurrent.Callable, .ConcurrentHashMap, org.hibernate.HibernateException, org.hibernate.boot.registry.classloading.spi.ClassLoaderService, .ClassLoadingException, org.hibernate.boot.registry.selector.spi.StrategyCreator, .StrategySelectionException, .StrategySelector, org.jboss.logging.Logger

Standard implementation of the StrategySelector contract.
Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
private final ClassLoaderService
private final Map<Class<T>, LazyServiceResolver<T>>
private static final Logger
private final Map<Class<T>, Map<String, Class<T>>>
private static final StrategyCreator<T>

Constructor Summary

AccessConstructor and Description
public
StrategySelectorImpl(ClassLoaderService
The class loader service usable by this StrategySelectorImpl instance.
classLoaderService
)

Constructs a StrategySelectorImpl using the given class loader service.

Method Summary

Modifier and TypeMethod and Description
public Collection<E>
getRegisteredStrategyImplementors(Class<T> strategy)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.getRegisteredStrategyImplementors.

Retrieve all of the registered implementors of the given strategy.
public <T> void
registerStrategyImplementor(Class<T>
The strategy contract.
strategy
,
String
The registration name
name
,
Class<? extends T>
The implementation Class
implementation
)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.registerStrategyImplementor.

Registers a named implementor of a particular strategy contract.
public <T> void
public <T> T
resolveDefaultableStrategy(Class<T>
The type (interface) of the strategy to be resolved.
strategy
,
Object
The reference to the strategy for which we need to resolve an instance.
strategyReference
,
final T
THe default value to use if strategyReference is null
defaultValue
)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.resolveDefaultableStrategy.

Resolve strategy instances.
public <T> T
resolveDefaultableStrategy(Class<T>
The type (interface) of the strategy to be resolved.
strategy
,
Object
The reference to the strategy for which we need to resolve an instance.
strategyReference
,
Callable<T>
A strategy for resolving the default value strategyReference resolves to null.
defaultResolver
)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.resolveDefaultableStrategy, org.hibernate.boot.registry.selector.spi.StrategySelector.resolveDefaultableStrategy.

Resolve strategy instances.
public <T> T
resolveStrategy(Class<T> strategy, Object strategyReference)

public <T> T
resolveStrategy(Class<T> strategy, Object strategyReference, T defaultValue, StrategyCreator<T> creator)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.resolveStrategy.

public <T> T
public <T> Class<? extends T>
selectStrategyImplementor(Class<T>
The type of strategy to be resolved.
strategy
,
String
The name of the strategy to locate; might be either a registered name or the implementation FQN.
name
)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.selectStrategyImplementor.

Locate the named strategy implementation.
public <T> void
unRegisterStrategyImplementor(Class<T>
The strategy contract.
strategy
,
Class<? extends T>
The implementation Class
implementation
)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.unRegisterStrategyImplementor.

Un-registers a named implementor of a particular strategy contract.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoaderServiceback to summary
private final ClassLoaderService classLoaderService
lazyStrategyImplementorByStrategyMapback to summary
private final Map<Class<T>, LazyServiceResolver<T>> lazyStrategyImplementorByStrategyMap
logback to summary
private static final Logger log
namedStrategyImplementorByStrategyMapback to summary
private final Map<Class<T>, Map<String, Class<T>>> namedStrategyImplementorByStrategyMap
STANDARD_STRATEGY_CREATORback to summary
private static final StrategyCreator<T> STANDARD_STRATEGY_CREATOR

Constructor Detail

StrategySelectorImplback to summary
public StrategySelectorImpl(ClassLoaderService classLoaderService)

Constructs a StrategySelectorImpl using the given class loader service.

Parameters
classLoaderService:ClassLoaderService

The class loader service usable by this StrategySelectorImpl instance.

Method Detail

getRegisteredStrategyImplementorsback to summary
public Collection<E> getRegisteredStrategyImplementors(Class<T> strategy)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.getRegisteredStrategyImplementors.

Doc from org.hibernate.boot.registry.selector.spi.StrategySelector.getRegisteredStrategyImplementors.

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

Returns:Collection<E>

The implementors. Should never return null

Annotations
@Override
@SuppressWarnings:unchecked
registerStrategyImplementorback to summary
public <T> void registerStrategyImplementor(Class<T> strategy, String name, Class<? extends T> implementation)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.registerStrategyImplementor.

Doc from org.hibernate.boot.registry.selector.spi.StrategySelector.registerStrategyImplementor.

Registers a named implementor of a particular strategy contract.

Parameters
<T>
The type of the strategy. Used to make sure that the strategy and implementation are type compatible.
strategy:Class<T>

The strategy contract.

name:String

The registration name

implementation:Class<? extends T>

The implementation Class

Annotations
@Override
registerStrategyLazilyback to summary
public <T> void registerStrategyLazily(Class<T> strategy, LazyServiceResolver<T> resolver)
resolveDefaultableStrategyback to summary
public <T> T resolveDefaultableStrategy(Class<T> strategy, Object strategyReference, final T defaultValue)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.resolveDefaultableStrategy.

Doc from org.hibernate.boot.registry.selector.spi.StrategySelector.resolveDefaultableStrategy.

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 calling Class#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 calling Class#newInstance()
Parameters
<T>
The type of the strategy. Used to make sure that the strategy and implementation are type compatible.
strategy:Class<T>

The type (interface) of the strategy to be resolved.

strategyReference:Object

The reference to the strategy for which we need to resolve an instance.

defaultValue:T

THe default value to use if strategyReference is null

Returns:T

The strategy instance

Annotations
@Override
resolveDefaultableStrategyback to summary
public <T> T resolveDefaultableStrategy(Class<T> strategy, Object strategyReference, Callable<T> defaultResolver)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.resolveDefaultableStrategy, org.hibernate.boot.registry.selector.spi.StrategySelector.resolveDefaultableStrategy.

Doc from org.hibernate.boot.registry.selector.spi.StrategySelector.resolveDefaultableStrategy.

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 calling Class#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 calling Class#newInstance()
Parameters
<T>
The type of the strategy. Used to make sure that the strategy and implementation are type compatible.
strategy:Class<T>

The type (interface) of the strategy to be resolved.

strategyReference:Object

The reference to the strategy for which we need to resolve an instance.

defaultResolver:Callable<T>

A strategy for resolving the default value strategyReference resolves to null.

Returns:T

The strategy instance

Annotations
@Override
@SuppressWarnings:unchecked
resolveStrategyback to summary
public <T> T resolveStrategy(Class<T> strategy, Object strategyReference)
Annotations
@Override
resolveStrategyback to summary
public <T> T resolveStrategy(Class<T> strategy, Object strategyReference, T defaultValue, StrategyCreator<T> creator)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.resolveStrategy.

Annotations
@Override
resolveStrategyback to summary
public <T> T resolveStrategy(Class<T> strategy, Object strategyReference, Callable<T> defaultResolver, StrategyCreator<T> creator)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.resolveStrategy, org.hibernate.boot.registry.selector.spi.StrategySelector.resolveStrategy.

Annotations
@SuppressWarnings:unchecked
@Override
selectStrategyImplementorback to summary
public <T> Class<? extends T> selectStrategyImplementor(Class<T> strategy, String name)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.selectStrategyImplementor.

Doc from org.hibernate.boot.registry.selector.spi.StrategySelector.selectStrategyImplementor.

Locate the named strategy implementation.

Parameters
<T>
The type of the strategy. Used to make sure that the strategy and implementation are type compatible.
strategy:Class<T>

The type of strategy to be resolved.

name:String

The name of the strategy to locate; might be either a registered name or the implementation FQN.

Returns:Class<? extends T>

The named strategy implementation class.

Annotations
@Override
@SuppressWarnings:unchecked
unRegisterStrategyImplementorback to summary
public <T> void unRegisterStrategyImplementor(Class<T> strategy, Class<? extends T> implementation)

Implements org.hibernate.boot.registry.selector.spi.StrategySelector.unRegisterStrategyImplementor.

Doc from org.hibernate.boot.registry.selector.spi.StrategySelector.unRegisterStrategyImplementor.

Un-registers a named implementor of a particular strategy contract. Un-registers all named registrations for the given strategy contract naming the given class.

Parameters
<T>
The type of the strategy. Used to make sure that the strategy and implementation are type compatible.
strategy:Class<T>

The strategy contract.

implementation:Class<? extends T>

The implementation Class

Annotations
@Override