org.hibernate.boot.registry.selector.spi.StrategySelector Java Examples

The following examples show how to use org.hibernate.boot.registry.selector.spi.StrategySelector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FastBootMetadataBuilder.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private void registerIdentifierGenerators(StandardServiceRegistry ssr) {
    final StrategySelector strategySelector = ssr.getService(StrategySelector.class);

    // apply id generators
    final Object idGeneratorStrategyProviderSetting = buildTimeSettings
            .get(AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER);
    if (idGeneratorStrategyProviderSetting != null) {
        final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = strategySelector
                .resolveStrategy(IdentifierGeneratorStrategyProvider.class, idGeneratorStrategyProviderSetting);
        final MutableIdentifierGeneratorFactory identifierGeneratorFactory = ssr
                .getService(MutableIdentifierGeneratorFactory.class);
        if (identifierGeneratorFactory == null) {
            throw persistenceException("Application requested custom identifier generator strategies, "
                    + "but the MutableIdentifierGeneratorFactory could not be found");
        }
        for (Map.Entry<String, Class<?>> entry : idGeneratorStrategyProvider.getStrategies().entrySet()) {
            identifierGeneratorFactory.register(entry.getKey(), entry.getValue());
        }
    }
}
 
Example #2
Source File: QuarkusStrategySelectorBuilder.java    From quarkus with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: JdbcEnvironmentImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private String determineCurrentSchemaName(
		DatabaseMetaData databaseMetaData,
		ServiceRegistry serviceRegistry,
		Dialect dialect) throws SQLException {
	final SchemaNameResolver schemaNameResolver;

	final Object setting = serviceRegistry.getService( ConfigurationService.class ).getSettings().get( SCHEMA_NAME_RESOLVER );
	if ( setting == null ) {
		schemaNameResolver = dialect.getSchemaNameResolver();
	}
	else {
		schemaNameResolver = serviceRegistry.getService( StrategySelector.class ).resolveDefaultableStrategy(
				SchemaNameResolver.class,
				setting,
				dialect.getSchemaNameResolver()
		);
	}

	try {
		return schemaNameResolver.resolveSchemaName( databaseMetaData.getConnection(), dialect );
	}
	catch (Exception e) {
		log.debug( "Unable to resolve connection default schema", e );
		return null;
	}
}
 
Example #4
Source File: DefaultMergeEventListener.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private EntityCopyObserver createEntityCopyObserver(SessionFactoryImplementor sessionFactory) {
	final ServiceRegistry serviceRegistry = sessionFactory.getServiceRegistry();
	if ( entityCopyObserverStrategy == null ) {
		final ConfigurationService configurationService
				= serviceRegistry.getService( ConfigurationService.class );
		entityCopyObserverStrategy = configurationService.getSetting(
				AvailableSettings.MERGE_ENTITY_COPY_OBSERVER,
				new ConfigurationService.Converter<String>() {
					@Override
					public String convert(Object value) {
						return value.toString();
					}
				},
				EntityCopyNotAllowedObserver.SHORT_NAME
		);
		LOG.debugf( "EntityCopyObserver strategy: %s", entityCopyObserverStrategy );
	}
	final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
	return strategySelector.resolveStrategy( EntityCopyObserver.class, entityCopyObserverStrategy );
}
 
Example #5
Source File: QueryTranslatorFactoryInitiator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public QueryTranslatorFactory initiateService(
		Map configurationValues,
		ServiceRegistryImplementor registry) {
	final StrategySelector strategySelector = registry.getService( StrategySelector.class );
	final QueryTranslatorFactory factory = strategySelector.resolveDefaultableStrategy(
			QueryTranslatorFactory.class,
			configurationValues.get( QUERY_TRANSLATOR ),
			ASTQueryTranslatorFactory.INSTANCE
	);

	log.debugf( "QueryTranslatorFactory : %s", factory );
	if ( factory instanceof ASTQueryTranslatorFactory ) {
		log.usingAstQueryTranslatorFactory();
	}

	return factory;
}
 
Example #6
Source File: SessionFactoryOptionsBuilder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private static Interceptor determineInterceptor(Map configurationSettings, StrategySelector strategySelector) {
	Object setting = configurationSettings.get( INTERCEPTOR );
	if ( setting == null ) {
		// try the legacy (deprecated) JPA name
		setting = configurationSettings.get( org.hibernate.jpa.AvailableSettings.INTERCEPTOR );
		if ( setting != null ) {
			DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
					org.hibernate.jpa.AvailableSettings.INTERCEPTOR,
					INTERCEPTOR
			);
		}
	}

	return strategySelector.resolveStrategy(
			Interceptor.class,
			setting
	);
}
 
Example #7
Source File: BootstrapServiceRegistryImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 strategySelector The StrategySelector to use
 * @param integratorService The IntegratorService to use
 *
 * @see org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
 */
public BootstrapServiceRegistryImpl(
		boolean autoCloseRegistry,
		ClassLoaderService classLoaderService,
		StrategySelector strategySelector,
		IntegratorService integratorService) {
	this.autoCloseRegistry = autoCloseRegistry;

	this.classLoaderServiceBinding = new ServiceBinding<ClassLoaderService>(
			this,
			ClassLoaderService.class,
			classLoaderService
	);

	this.strategySelectorBinding = new ServiceBinding<StrategySelector>(
			this,
			StrategySelector.class,
			strategySelector
	);

	this.integratorServiceBinding = new ServiceBinding<IntegratorService>(
			this,
			IntegratorService.class,
			integratorService
	);
}
 
Example #8
Source File: BootstrapServiceRegistryImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 )
	);
}
 
Example #9
Source File: EntityManagerFactoryBuilderImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void configure(StandardServiceRegistry ssr, MergedSettings mergedSettings) {
	final StrategySelector strategySelector = ssr.getService( StrategySelector.class );

	// apply id generators
	final Object idGeneratorStrategyProviderSetting = configurationValues.remove( AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER );
	if ( idGeneratorStrategyProviderSetting != null ) {
		final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider =
				strategySelector.resolveStrategy( IdentifierGeneratorStrategyProvider.class, idGeneratorStrategyProviderSetting );
		final MutableIdentifierGeneratorFactory identifierGeneratorFactory = ssr.getService( MutableIdentifierGeneratorFactory.class );
		if ( identifierGeneratorFactory == null ) {
			throw persistenceException(
					"Application requested custom identifier generator strategies, " +
							"but the MutableIdentifierGeneratorFactory could not be found"
			);
		}
		for ( Map.Entry<String,Class<?>> entry : idGeneratorStrategyProvider.getStrategies().entrySet() ) {
			identifierGeneratorFactory.register( entry.getKey(), entry.getValue() );
		}
	}
}
 
Example #10
Source File: JtaPlatformInitiator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
@SuppressWarnings( {"unchecked"})
public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
	final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM );
	JtaPlatform platform = registry.getService( StrategySelector.class ).resolveStrategy( JtaPlatform.class, setting );

	if ( platform == null ) {
		LOG.debugf( "No JtaPlatform was specified, checking resolver" );
		platform = registry.getService( JtaPlatformResolver.class ).resolveJtaPlatform( configurationValues, registry );
	}

	if ( platform == null ) {
		LOG.debugf( "No JtaPlatform was specified, checking resolver" );
		platform = getFallbackProvider( configurationValues, registry );
	}

	return platform;
}
 
Example #11
Source File: ConnectionProviderInitiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private ConnectionProvider instantiateAgroalProvider(StrategySelector strategySelector) {
	try {
		return strategySelector.selectStrategyImplementor( ConnectionProvider.class, AGROAL_STRATEGY ).newInstance();
	}
	catch ( Exception e ) {
		LOG.agroalProviderClassNotFound();
		return null;
	}
}
 
Example #12
Source File: ConnectionProviderInitiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private ConnectionProvider instantiateViburProvider(StrategySelector strategySelector) {
	try {
		return strategySelector.selectStrategyImplementor( ConnectionProvider.class, VIBUR_STRATEGY ).newInstance();
	}
	catch ( Exception e ) {
		LOG.viburProviderClassNotFound();
		return null;
	}
}
 
Example #13
Source File: SessionFactoryOptionsBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "deprecation"})
private static Supplier<? extends Interceptor> determineStatelessInterceptor(
		Map configurationSettings,
		StrategySelector strategySelector) {
	Object setting = configurationSettings.get( SESSION_SCOPED_INTERCEPTOR );
	if ( setting == null ) {
		// try the legacy (deprecated) JPA name
		setting = configurationSettings.get( org.hibernate.jpa.AvailableSettings.SESSION_INTERCEPTOR );
		if ( setting != null ) {
			DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
					org.hibernate.jpa.AvailableSettings.SESSION_INTERCEPTOR,
					SESSION_SCOPED_INTERCEPTOR
			);
		}
	}

	if ( setting == null ) {
		return null;
	}
	else if ( setting instanceof Supplier ) {
		return (Supplier<? extends Interceptor>) setting;
	}
	else if ( setting instanceof Class ) {
		Class<? extends Interceptor> clazz = (Class<? extends Interceptor>) setting;
		return interceptorSupplier( clazz );
	}
	else {
		return interceptorSupplier(
				strategySelector.selectStrategyImplementor(
						Interceptor.class,
						setting.toString()
				)
		);
	}
}
 
Example #14
Source File: BootstrapContextImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public BootstrapContextImpl(
		StandardServiceRegistry serviceRegistry,
		MetadataBuildingOptions metadataBuildingOptions) {
	this.serviceRegistry = serviceRegistry;
	this.classmateContext = new ClassmateContext();
	this.metadataBuildingOptions = metadataBuildingOptions;

	final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
	this.classLoaderAccess = new ClassLoaderAccessImpl( classLoaderService );
	this.hcannReflectionManager = generateHcannReflectionManager();

	final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
	final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );

	this.jpaCompliance = new MutableJpaComplianceImpl( configService.getSettings(), false );
	this.scanOptions = new StandardScanOptions(
			(String) configService.getSettings().get( AvailableSettings.SCANNER_DISCOVERY ),
			false
	);

	// ScanEnvironment must be set explicitly
	this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER );
	if ( this.scannerSetting == null ) {
		this.scannerSetting = configService.getSettings().get( AvailableSettings.SCANNER_DEPRECATED );
		if ( this.scannerSetting != null ) {
			DEPRECATION_LOGGER.logDeprecatedScannerSetting();
		}
	}
	this.archiveDescriptorFactory = strategySelector.resolveStrategy(
			ArchiveDescriptorFactory.class,
			configService.getSettings().get( AvailableSettings.SCANNER_ARCHIVE_INTERPRETER )
	);
	this.typeConfiguration = new TypeConfiguration();
}
 
Example #15
Source File: StrategySelectorBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds the selector.
 *
 * @param classLoaderService The class loading service used to (attempt to) resolve any un-registered
 * strategy implementations.
 *
 * @return The selector.
 */
public StrategySelector buildSelector(ClassLoaderService classLoaderService) {
	final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );

	// build the baseline...
	addDialects( strategySelector );
	addJtaPlatforms( strategySelector );
	addTransactionCoordinatorBuilders( strategySelector );
	addMultiTableBulkIdStrategies( strategySelector );
	addEntityCopyObserverStrategies( strategySelector );
	addImplicitNamingStrategies( strategySelector );
	addCacheKeysFactories( strategySelector );

	// apply auto-discovered registrations
	for ( StrategyRegistrationProvider provider : classLoaderService.loadJavaServices( StrategyRegistrationProvider.class ) ) {
		for ( StrategyRegistration discoveredStrategyRegistration : provider.getStrategyRegistrations() ) {
			applyFromStrategyRegistration( strategySelector, discoveredStrategyRegistration );
		}
	}

	// apply customizations
	for ( StrategyRegistration explicitStrategyRegistration : explicitStrategyRegistrations ) {
		applyFromStrategyRegistration( strategySelector, explicitStrategyRegistration );
	}

	return strategySelector;
}
 
Example #16
Source File: BootstrapServiceRegistryImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings( {"unchecked"})
public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole) {
	if ( ClassLoaderService.class.equals( serviceRole ) ) {
		return (ServiceBinding<R>) classLoaderServiceBinding;
	}
	else if ( StrategySelector.class.equals( serviceRole) ) {
		return (ServiceBinding<R>) strategySelectorBinding;
	}
	else if ( IntegratorService.class.equals( serviceRole ) ) {
		return (ServiceBinding<R>) integratorServiceBinding;
	}

	return null;
}
 
Example #17
Source File: RedissonRegionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
    this.redisson = createRedissonClient(properties);
    this.settings = new Settings(settings);
    
    StrategySelector selector = settings.getServiceRegistry().getService(StrategySelector.class);
    cacheKeysFactory = selector.resolveDefaultableStrategy(CacheKeysFactory.class, 
                            properties.get(Environment.CACHE_KEYS_FACTORY), new RedissonCacheKeysFactory(redisson.getConfig().getCodec()));
}
 
Example #18
Source File: RedissonRegionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
protected void prepareForUse(SessionFactoryOptions settings, @SuppressWarnings("rawtypes") Map properties) throws CacheException {
    this.redisson = createRedissonClient(properties);
    
    StrategySelector selector = settings.getServiceRegistry().getService(StrategySelector.class);
    cacheKeysFactory = selector.resolveDefaultableStrategy(CacheKeysFactory.class, 
            properties.get(Environment.CACHE_KEYS_FACTORY), new RedissonCacheKeysFactory(redisson.getConfig().getCodec()));
}
 
Example #19
Source File: RedissonRegionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
    this.redisson = createRedissonClient(properties);
    this.settings = new Settings(settings);

    StrategySelector selector = settings.getServiceRegistry().getService(StrategySelector.class);
    cacheKeysFactory = selector.resolveDefaultableStrategy(CacheKeysFactory.class,
                            properties.get(Environment.CACHE_KEYS_FACTORY), new RedissonCacheKeysFactory(redisson.getConfig().getCodec()));

}
 
Example #20
Source File: ConnectionProviderInitiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private ConnectionProvider instantiateHikariProvider(StrategySelector strategySelector) {
	try {
		return strategySelector.selectStrategyImplementor( ConnectionProvider.class, HIKARI_STRATEGY ).newInstance();
	}
	catch ( Exception e ) {
		LOG.hikariProviderClassNotFound();
		return null;
	}
}
 
Example #21
Source File: FastBootMetadataBuilder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private BootstrapServiceRegistry buildBootstrapServiceRegistry(ClassLoaderService providedClassLoaderService) {

        // N.B. support for custom IntegratorProvider injected via Properties (as
        // instance) removed

        final QuarkusIntegratorServiceImpl integratorService = new QuarkusIntegratorServiceImpl(providedClassLoaderService);
        final QuarkusStrategySelectorBuilder strategySelectorBuilder = new QuarkusStrategySelectorBuilder();
        final StrategySelector strategySelector = strategySelectorBuilder.buildSelector(providedClassLoaderService);
        return new BootstrapServiceRegistryImpl(true, providedClassLoaderService, strategySelector, integratorService);
    }
 
Example #22
Source File: PropertyAccessStrategyResolverStandardImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected StrategySelector strategySelectorService() {
	if ( strategySelectorService == null ) {
		if ( serviceRegistry == null ) {
			throw new HibernateException( "ServiceRegistry not yet injected; PropertyAccessStrategyResolver not ready for use." );
		}
		strategySelectorService = serviceRegistry.getService( StrategySelector.class );
	}
	return strategySelectorService;
}
 
Example #23
Source File: TransactionCoordinatorBuilderInitiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TransactionCoordinatorBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
	return registry.getService( StrategySelector.class ).resolveDefaultableStrategy(
			TransactionCoordinatorBuilder.class,
			determineStrategySelection( configurationValues ),
			JdbcResourceLocalTransactionCoordinatorBuilderImpl.INSTANCE
	);
}
 
Example #24
Source File: ManagedBeanRegistryInitiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private BeanContainer interpretExplicitBeanContainer(
		Object explicitSetting,
		ClassLoaderService classLoaderService, ServiceRegistryImplementor serviceRegistry) {
	if ( explicitSetting == null ) {
		return null;
	}

	if ( explicitSetting instanceof BeanContainer ) {
		return (BeanContainer) explicitSetting;
	}

	// otherwise we ultimately need to resolve this to a class
	final Class containerClass;
	if ( explicitSetting instanceof Class ) {
		containerClass = (Class) explicitSetting;
	}
	else {
		final String name = explicitSetting.toString();
		// try the StrategySelector service
		final Class selected = serviceRegistry.getService( StrategySelector.class )
				.selectStrategyImplementor( BeanContainer.class, name );
		if ( selected != null ) {
			containerClass = selected;
		}
		else {
			containerClass = classLoaderService.classForName( name );
		}
	}

	try {
		return (BeanContainer) containerClass.newInstance();
	}
	catch (Exception e) {
		throw new InstantiationException( "Unable to instantiate specified BeanContainer : " + containerClass.getName(), containerClass, e );
	}
}
 
Example #25
Source File: SchemaValidatorTask.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void configure(MetadataBuilder metadataBuilder, StandardServiceRegistry serviceRegistry) {
	final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
	if ( implicitNamingStrategy != null ) {
		metadataBuilder.applyImplicitNamingStrategy(
				strategySelector.resolveStrategy( ImplicitNamingStrategy.class, implicitNamingStrategy )
		);
	}
	if ( physicalNamingStrategy != null ) {
		metadataBuilder.applyPhysicalNamingStrategy(
				strategySelector.resolveStrategy( PhysicalNamingStrategy.class, physicalNamingStrategy )
		);
	}
}
 
Example #26
Source File: HibernateSchemaManagementTool.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private SchemaFilterProvider getSchemaFilterProvider(Map options) {
	final Object configuredOption = (options == null)
			? null
			: options.get( AvailableSettings.HBM2DDL_FILTER_PROVIDER );
	return serviceRegistry.getService( StrategySelector.class ).resolveDefaultableStrategy(
			SchemaFilterProvider.class,
			configuredOption,
			DefaultSchemaFilterProvider.INSTANCE
	);
}
 
Example #27
Source File: SchemaManagementToolInitiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SchemaManagementTool initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
	final Object setting = configurationValues.get( AvailableSettings.SCHEMA_MANAGEMENT_TOOL );
	SchemaManagementTool tool = registry.getService( StrategySelector.class ).resolveStrategy( SchemaManagementTool.class, setting );
	if ( tool == null ) {
		tool = new HibernateSchemaManagementTool();
	}

	return tool;
}
 
Example #28
Source File: JtaPlatformResolverInitiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public JtaPlatformResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
	final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM_RESOLVER );
	final JtaPlatformResolver resolver = registry.getService( StrategySelector.class )
			.resolveStrategy( JtaPlatformResolver.class, setting );
	if ( resolver == null ) {
		log.debugf( "No JtaPlatformResolver was specified, using default [%s]", StandardJtaPlatformResolver.class.getName() );
		return StandardJtaPlatformResolver.INSTANCE;
	}
	return resolver;
}
 
Example #29
Source File: ConnectionProviderInitiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private Class<? extends ConnectionProvider> getSingleRegisteredProvider(StrategySelector strategySelector) {
	final Collection<Class<? extends ConnectionProvider>> implementors = strategySelector.getRegisteredStrategyImplementors( ConnectionProvider.class );
	if ( implementors != null && implementors.size() == 1 ) {
		return implementors.iterator().next();
	}

	return null;
}
 
Example #30
Source File: ConnectionProviderInitiator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private ConnectionProvider instantiateC3p0Provider(StrategySelector strategySelector) {
	try {
		return strategySelector.selectStrategyImplementor( ConnectionProvider.class, C3P0_STRATEGY ).newInstance();
	}
	catch ( Exception e ) {
		LOG.c3p0ProviderClassNotFound( C3P0_STRATEGY );
		return null;
	}
}