类org.hibernate.boot.spi.SessionFactoryOptions源码实例Demo

下面列出了怎么用org.hibernate.boot.spi.SessionFactoryOptions的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: TypeSafeActivator.java
private static ValidatorFactory resolveProvidedFactory(SessionFactoryOptions options) {
	final Object validatorFactoryReference = options.getValidatorFactoryReference();

	if ( validatorFactoryReference == null ) {
		return null;
	}

	try {
		return ValidatorFactory.class.cast( validatorFactoryReference );
	}
	catch ( ClassCastException e ) {
		throw new IntegrationException(
				String.format(
						Locale.ENGLISH,
						"ValidatorFactory reference (provided via %s) was not castable to %s : %s",
						SessionFactoryOptions.class.getName(),
						ValidatorFactory.class.getName(),
						validatorFactoryReference.getClass().getName()
				)
		);
	}
}
 
源代码2 项目: lams   文件: JtaTransactionCoordinatorImpl.java
/**
 * Construct a JtaTransactionCoordinatorImpl instance.  package-protected to ensure access goes through
 * builder.
 *
 * @param owner The transactionCoordinatorOwner
 * @param autoJoinTransactions Should JTA transactions be auto-joined?  Or should we wait for explicit join calls?
 */
JtaTransactionCoordinatorImpl(
		TransactionCoordinatorBuilder transactionCoordinatorBuilder,
		TransactionCoordinatorOwner owner,
		boolean autoJoinTransactions) {
	this.transactionCoordinatorBuilder = transactionCoordinatorBuilder;
	this.transactionCoordinatorOwner = owner;
	this.autoJoinTransactions = autoJoinTransactions;

	this.observers = new ArrayList<>();

	final JdbcSessionContext jdbcSessionContext = owner.getJdbcSessionOwner().getJdbcSessionContext();

	this.jtaPlatform = jdbcSessionContext.getServiceRegistry().getService( JtaPlatform.class );

	final SessionFactoryOptions sessionFactoryOptions = jdbcSessionContext.getSessionFactory().getSessionFactoryOptions();
	this.preferUserTransactions = sessionFactoryOptions.isPreferUserTransaction();
	this.performJtaThreadTracking = sessionFactoryOptions.isJtaTrackByThread();

	synchronizationRegistered = false;

	pulse();
}
 
源代码3 项目: lams   文件: SessionFactoryServiceRegistryImpl.java
@SuppressWarnings( {"unchecked"})
public SessionFactoryServiceRegistryImpl(
		ServiceRegistryImplementor parent,
		List<SessionFactoryServiceInitiator> initiators,
		List<ProvidedService> providedServices,
		SessionFactoryImplementor sessionFactory,
		BootstrapContext bootstrapContext,
		SessionFactoryOptions sessionFactoryOptions) {
	super( parent );

	this.sessionFactory = sessionFactory;
	this.sessionFactoryOptions = sessionFactoryOptions;
	this.bootstrapContext = bootstrapContext;

	// for now, just use the standard initiator list
	for ( SessionFactoryServiceInitiator initiator : initiators ) {
		// create the bindings up front to help identify to which registry services belong
		createServiceBinding( initiator );
	}

	for ( ProvidedService providedService : providedServices ) {
		createServiceBinding( providedService );
	}

	bootstrapContext = null;
}
 
源代码4 项目: lams   文件: AbstractRegionFactory.java
@Override
public final void start(SessionFactoryOptions settings, Map configValues) throws CacheException {
	if ( started.compareAndSet( false, true ) ) {
		synchronized (this) {
			this.options = settings;
			try {
				prepareForUse( settings, configValues );
				startingException = null;
			}
			catch ( Exception e ) {
				options = null;
				started.set( false );
				startingException = e;
			}
		}
	}
	else {
		SecondLevelCacheLogger.INSTANCE.attemptToStartAlreadyStartedCacheProvider();
	}
}
 
源代码5 项目: lams   文件: PersistentTableBulkIdStrategy.java
@Override
protected void initialize(MetadataBuildingOptions buildingOptions, SessionFactoryOptions sessionFactoryOptions) {
	final StandardServiceRegistry serviceRegistry = buildingOptions.getServiceRegistry();
	final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class );
	final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );

	final String catalogName = configService.getSetting(
			CATALOG,
			StandardConverters.STRING,
			configService.getSetting( AvailableSettings.DEFAULT_CATALOG, StandardConverters.STRING )
	);
	final String schemaName = configService.getSetting(
			SCHEMA,
			StandardConverters.STRING,
			configService.getSetting( AvailableSettings.DEFAULT_SCHEMA, StandardConverters.STRING )
	);

	this.catalog = jdbcEnvironment.getIdentifierHelper().toIdentifier( catalogName );
	this.schema = jdbcEnvironment.getIdentifierHelper().toIdentifier( schemaName );

	this.dropIdTables = configService.getSetting(
			DROP_ID_TABLES,
			StandardConverters.BOOLEAN,
			false
	);
}
 
private CacheManager useExplicitCacheManager(SessionFactoryOptions settings, Object setting) {
    if (setting instanceof CacheManager) {
        return (CacheManager) setting;
    }

    final Class<? extends CacheManager> cacheManagerClass;
    if (setting instanceof Class) {
        cacheManagerClass = (Class<? extends CacheManager>) setting;
    } else {
        cacheManagerClass = settings.getServiceRegistry().getService(ClassLoaderService.class).classForName(setting.toString());
    }

    try {
        return cacheManagerClass.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
        throw new CacheException("Could not use explicit CacheManager : " + setting);
    }
}
 
源代码7 项目: mPaaS   文件: RedissonCacheRegionFactory.java
/**
 * 准备阶段
 */
@Override
protected void prepareForUse(SessionFactoryOptions settings, Map properties) throws CacheException {
    this.context = ApplicationContextHolder.getApplicationContext();
    this.defaultConfig = context.getBean(Config.class);
    super.prepareForUse(settings, properties);
}
 
源代码8 项目: mPass   文件: RedissonCacheRegionFactory.java
/**
 * 准备阶段
 */
@Override
protected void prepareForUse(SessionFactoryOptions settings, Map properties) throws CacheException {
    this.context = ApplicationContextHolder.getApplicationContext();
    this.defaultConfig = context.getBean(Config.class);
    super.prepareForUse(settings, properties);
}
 
源代码9 项目: redisson   文件: RedissonRegionFactory.java
@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()));
}
 
源代码10 项目: J2Cache   文件: J2CacheRegionFactory.java
@Override
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
    this.settings = settings;
    if (this.channel == null) {
        this.channel = J2Cache.getChannel();
    }
}
 
源代码11 项目: redisson   文件: RedissonRegionFactory.java
@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()));

}
 
public TransactionalJ2CacheEntityRegionAccessStrategy(
        J2CacheEntityRegion region,
        CacheRegion cache,
        SessionFactoryOptions settings) {
    super(region, settings);
    this.cache = cache;
}
 
@Override
public EntityManagerFactory build() {
    final SessionFactoryOptionsBuilder optionsBuilder = metadata.buildSessionFactoryOptionsBuilder();
    populate(optionsBuilder, standardServiceRegistry, multiTenancyStrategy);
    SessionFactoryOptions options = optionsBuilder.buildOptions();
    return new ReactiveSessionFactoryImpl(metadata.getOriginalMetadata(), options);
}
 
源代码14 项目: lams   文件: Settings.java
public Settings(SessionFactoryOptions sessionFactoryOptions, Metadata metadata) {
	this(
			sessionFactoryOptions,
			extractName( metadata.getDatabase().getDefaultNamespace().getName().getCatalog() ),
			extractName( metadata.getDatabase().getDefaultNamespace().getName().getSchema() )
	);
}
 
源代码15 项目: lams   文件: NativeQueryInterpreterInitiator.java
@Override
public NativeQueryInterpreter initiateService(
		SessionFactoryImplementor sessionFactory,
		SessionFactoryOptions sessionFactoryOptions,
		ServiceRegistryImplementor registry) {
	return new NativeQueryInterpreterStandardImpl( sessionFactory );
}
 
源代码16 项目: lams   文件: CacheInitiator.java
@Override
public CacheImplementor initiateService(
		SessionFactoryImplementor sessionFactory,
		SessionFactoryOptions sessionFactoryOptions,
		ServiceRegistryImplementor registry) {
	final RegionFactory regionFactory = registry.getService( RegionFactory.class );
	return ( ! NoCachingRegionFactory.class.isInstance( regionFactory ) )
			? new EnabledCaching( sessionFactory )
			: new DisabledCaching( sessionFactory );
}
 
public SessionFactoryServiceRegistry buildSessionFactoryServiceRegistry(
		SessionFactoryImplementor sessionFactory,
		BootstrapContext bootstrapContext,
		SessionFactoryOptions options) {
	return new SessionFactoryServiceRegistryImpl(
			parent,
			initiators,
			providedServices,
			sessionFactory,
			bootstrapContext,
			options
	);
}
 
@Override
public SessionFactoryServiceRegistry buildServiceRegistry(
		SessionFactoryImplementor sessionFactory,
		BootstrapContext bootstrapContext,
		SessionFactoryOptions options) {
	final ClassLoaderService cls = options.getServiceRegistry().getService( ClassLoaderService.class );
	final SessionFactoryServiceRegistryBuilderImpl builder = new SessionFactoryServiceRegistryBuilderImpl( theBasicServiceRegistry );

	for ( SessionFactoryServiceContributor contributor : cls.loadJavaServices( SessionFactoryServiceContributor.class ) ) {
		contributor.contribute( builder );
	}

	return builder.buildSessionFactoryServiceRegistry( sessionFactory, bootstrapContext, options );
}
 
源代码19 项目: lams   文件: StatisticsInitiator.java
@Override
public StatisticsImplementor initiateService(
		SessionFactoryImplementor sessionFactory,
		SessionFactoryOptions sessionFactoryOptions,
		ServiceRegistryImplementor registry) {
	final Object configValue = registry
			.getService( ConfigurationService.class )
			.getSettings()
			.get( STATS_BUILDER );
	return initiateServiceInternal( sessionFactory, configValue, registry );
}
 
源代码20 项目: lams   文件: SessionFactoryImpl.java
public static Interceptor configuredInterceptor(Interceptor interceptor, SessionFactoryOptions options) {
	// NOTE : DO NOT return EmptyInterceptor.INSTANCE from here as a "default for the Session"
	// 		we "filter" that one out here.  The return from here should represent the
	//		explicitly configured Interceptor (if one).  Return null from here instead; Session
	//		will handle it

	if ( interceptor != null && interceptor != EmptyInterceptor.INSTANCE ) {
		return interceptor;
	}

	// prefer the SF-scoped interceptor, prefer that to any Session-scoped interceptor prototype
	if ( options.getInterceptor() != null && options.getInterceptor() != EmptyInterceptor.INSTANCE ) {
		return options.getInterceptor();
	}

	// then check the Session-scoped interceptor prototype
	if ( options.getStatelessInterceptorImplementor() != null && options.getStatelessInterceptorImplementorSupplier() != null ) {
		throw new HibernateException(
				"A session scoped interceptor class or supplier are allowed, but not both!" );
	}
	else if ( options.getStatelessInterceptorImplementor() != null ) {
		try {
			/**
			 * We could remove the getStatelessInterceptorImplementor method and use just the getStatelessInterceptorImplementorSupplier
			 * since it can cover both cases when the user has given a Supplier<? extends Interceptor> or just the
			 * Class<? extends Interceptor>, in which case, we simply instantiate the Interceptor when calling the Supplier.
			 */
			return options.getStatelessInterceptorImplementor().newInstance();
		}
		catch (InstantiationException | IllegalAccessException e) {
			throw new HibernateException( "Could not supply session-scoped SessionFactory Interceptor", e );
		}
	}
	else if ( options.getStatelessInterceptorImplementorSupplier() != null ) {
		return options.getStatelessInterceptorImplementorSupplier().get();
	}

	return null;
}
 
源代码21 项目: lams   文件: RegionNameQualifier.java
public String qualify(String regionName, SessionFactoryOptions options) {
	final String prefix = options.getCacheRegionPrefix();
	if ( prefix == null ) {
		return regionName;
	}

	return qualify( prefix, regionName );
}
 
源代码22 项目: lams   文件: CacheUtils.java
public static boolean isUnqualified(String regionName, SessionFactoryOptions options) {
	final String prefix = options.getCacheRegionPrefix();
	if ( prefix == null ) {
		return true;
	}
	else {
		return !regionName.startsWith( prefix );
	}
}
 
源代码23 项目: lams   文件: EventListenerRegistryImpl.java
/**
 * @deprecated Use {@link EventListenerRegistryImpl#EventListenerRegistryImpl(BootstrapContext, SessionFactoryImplementor)} instead
 */
@Deprecated
EventListenerRegistryImpl(
		SessionFactoryImplementor sessionFactory,
		SessionFactoryOptions sessionFactoryOptions,
		ServiceRegistryImplementor registry) {
	this.sessionFactory = sessionFactory;

	this.callbackRegistry = new CallbackRegistryImpl();

	this.registeredEventListeners = buildListenerGroups();
}
 
源代码24 项目: lams   文件: EventListenerServiceInitiator.java
@Override
public EventListenerRegistry initiateService(
		SessionFactoryImplementor sessionFactory,
		SessionFactoryOptions sessionFactoryOptions,
		ServiceRegistryImplementor registry) {
	return new EventListenerRegistryImpl( sessionFactory, sessionFactoryOptions, registry );
}
 
源代码25 项目: lams   文件: SessionFactoryOptionsBuilder.java
public SessionFactoryOptions buildOptions() {
	if ( MutableJpaCompliance.class.isInstance( this.jpaCompliance ) ) {
		this.jpaCompliance = mutableJpaCompliance().immutableCopy();
	}

	return this;
}
 
源代码26 项目: lams   文件: CteValuesListBulkIdStrategy.java
@Override
public void prepare(
		JdbcServices jdbcServices,
		JdbcConnectionAccess jdbcConnectionAccess,
		MetadataImplementor metadataImplementor,
		SessionFactoryOptions sessionFactoryOptions) {
	// nothing to do
}
 
源代码27 项目: lams   文件: GlobalTemporaryTableBulkIdStrategy.java
@Override
protected void initialize(MetadataBuildingOptions buildingOptions, SessionFactoryOptions sessionFactoryOptions) {
	final StandardServiceRegistry serviceRegistry = buildingOptions.getServiceRegistry();
	final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
	this.dropIdTables = configService.getSetting(
			DROP_ID_TABLES,
			StandardConverters.BOOLEAN,
			false
	);
}
 
源代码28 项目: lams   文件: InlineIdsInClauseBulkIdStrategy.java
@Override
public void prepare(
		JdbcServices jdbcServices,
		JdbcConnectionAccess jdbcConnectionAccess,
		MetadataImplementor metadataImplementor,
		SessionFactoryOptions sessionFactoryOptions) {
	// nothing to do
}
 
@Override
public void prepare(
		JdbcServices jdbcServices,
		JdbcConnectionAccess jdbcConnectionAccess,
		MetadataImplementor metadataImplementor,
		SessionFactoryOptions sessionFactoryOptions) {
	// nothing to do
}
 
源代码30 项目: lams   文件: InlineIdsOrClauseBulkIdStrategy.java
@Override
public void prepare(
		JdbcServices jdbcServices,
		JdbcConnectionAccess jdbcConnectionAccess,
		MetadataImplementor metadataImplementor,
		SessionFactoryOptions sessionFactoryOptions) {
	// nothing to do
}
 
 类所在包
 类方法
 同包方法