下面列出了怎么用org.hibernate.boot.registry.selector.internal.StrategySelectorImpl的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Builds the selector.
*
* @param classLoaderService The class loading service used to (attempt to) resolve any un-registered
* strategy implementations.
*
* @return The selector.
*/
public static StrategySelector buildSelector(ClassLoaderService classLoaderService) {
final StrategySelectorImpl strategySelector = new StrategySelectorImpl(classLoaderService);
// build the baseline...
strategySelector.registerStrategyLazily(Dialect.class, new DefaultDialectSelector());
strategySelector.registerStrategyLazily(JtaPlatform.class, new DefaultJtaPlatformSelector());
addTransactionCoordinatorBuilders(strategySelector);
addMultiTableBulkIdStrategies(strategySelector);
addImplicitNamingStrategies(strategySelector);
addCacheKeysFactories(strategySelector);
// Required to support well known extensions e.g. Envers
// TODO: should we introduce a new integrator SPI to limit these to extensions supported by Quarkus?
for (StrategyRegistrationProvider provider : classLoaderService.loadJavaServices(StrategyRegistrationProvider.class)) {
for (StrategyRegistration discoveredStrategyRegistration : provider.getStrategyRegistrations()) {
applyFromStrategyRegistration(strategySelector, discoveredStrategyRegistration);
}
}
return strategySelector;
}
/**
* Constructs a BootstrapServiceRegistryImpl.
*
* Do not use directly generally speaking. Use {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder}
* instead.
*
* @param autoCloseRegistry See discussion on
* {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder#disableAutoClose}
* @param classLoaderService The ClassLoaderService to use
* @param providedIntegrators The group of explicitly provided integrators
*
* @see org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
*/
public BootstrapServiceRegistryImpl(
boolean autoCloseRegistry,
ClassLoaderService classLoaderService,
LinkedHashSet<Integrator> providedIntegrators) {
this.autoCloseRegistry = autoCloseRegistry;
this.classLoaderServiceBinding = new ServiceBinding<ClassLoaderService>(
this,
ClassLoaderService.class,
classLoaderService
);
final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
this.strategySelectorBinding = new ServiceBinding<StrategySelector>(
this,
StrategySelector.class,
strategySelector
);
this.integratorServiceBinding = new ServiceBinding<IntegratorService>(
this,
IntegratorService.class,
new IntegratorServiceImpl( providedIntegrators, classLoaderService )
);
}
private BootstrapServiceRegistry buildEmptyBootstrapServiceRegistry() {
// N.B. support for custom IntegratorProvider injected via Properties (as
// instance) removed
// N.B. support for custom StrategySelector is not implemented yet
final StrategySelectorImpl strategySelector = new StrategySelectorImpl(FlatClassLoaderService.INSTANCE);
return new BootstrapServiceRegistryImpl(true,
FlatClassLoaderService.INSTANCE,
strategySelector, // new MirroringStrategySelector(),
new MirroringIntegratorService(integrators));
}
@SuppressWarnings("unchecked")
private static <T> void applyFromStrategyRegistration(
StrategySelectorImpl strategySelector,
StrategyRegistration<T> strategyRegistration) {
for (String name : strategyRegistration.getSelectorNames()) {
strategySelector.registerStrategyImplementor(
strategyRegistration.getStrategyRole(),
name,
strategyRegistration.getStrategyImplementation());
}
}
private static void addTransactionCoordinatorBuilders(StrategySelectorImpl strategySelector) {
strategySelector.registerStrategyImplementor(
TransactionCoordinatorBuilder.class,
JdbcResourceLocalTransactionCoordinatorBuilderImpl.SHORT_NAME,
JdbcResourceLocalTransactionCoordinatorBuilderImpl.class);
strategySelector.registerStrategyImplementor(
TransactionCoordinatorBuilder.class,
JtaTransactionCoordinatorBuilderImpl.SHORT_NAME,
JtaTransactionCoordinatorBuilderImpl.class);
}
private static void addMultiTableBulkIdStrategies(StrategySelectorImpl strategySelector) {
strategySelector.registerStrategyImplementor(
MultiTableBulkIdStrategy.class,
PersistentTableBulkIdStrategy.SHORT_NAME,
PersistentTableBulkIdStrategy.class);
strategySelector.registerStrategyImplementor(
MultiTableBulkIdStrategy.class,
GlobalTemporaryTableBulkIdStrategy.SHORT_NAME,
GlobalTemporaryTableBulkIdStrategy.class);
strategySelector.registerStrategyImplementor(
MultiTableBulkIdStrategy.class,
LocalTemporaryTableBulkIdStrategy.SHORT_NAME,
LocalTemporaryTableBulkIdStrategy.class);
}
private static void addImplicitNamingStrategies(StrategySelectorImpl strategySelector) {
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"default",
ImplicitNamingStrategyJpaCompliantImpl.class);
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"jpa",
ImplicitNamingStrategyJpaCompliantImpl.class);
strategySelector.registerStrategyImplementor(
ImplicitNamingStrategy.class,
"component-path",
ImplicitNamingStrategyComponentPathImpl.class);
}
private static void addCacheKeysFactories(StrategySelectorImpl strategySelector) {
strategySelector.registerStrategyImplementor(
CacheKeysFactory.class,
DefaultCacheKeysFactory.SHORT_NAME,
DefaultCacheKeysFactory.class);
strategySelector.registerStrategyImplementor(
CacheKeysFactory.class,
SimpleCacheKeysFactory.SHORT_NAME,
SimpleCacheKeysFactory.class);
}
private BootstrapServiceRegistry buildEmptyBootstrapServiceRegistry() {
// N.B. support for custom IntegratorProvider injected via Properties (as
// instance) removed
// N.B. support for custom StrategySelector is not implemented yet
final StrategySelectorImpl strategySelector = new StrategySelectorImpl(FlatClassLoaderService.INSTANCE);
return new BootstrapServiceRegistryImpl(true,
FlatClassLoaderService.INSTANCE,
strategySelector, // new MirroringStrategySelector(),
new MirroringIntegratorService(integrators));
}