org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl Java Examples

The following examples show how to use org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl. 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 static void applyTransactionProperties(PersistenceUnitDescriptor persistenceUnit,
        Map<String, Object> configurationValues) {
    PersistenceUnitTransactionType transactionType = PersistenceUnitTransactionTypeHelper
            .interpretTransactionType(configurationValues.get(JPA_TRANSACTION_TYPE));
    if (transactionType == null) {
        transactionType = persistenceUnit.getTransactionType();
    }
    if (transactionType == null) {
        // is it more appropriate to have this be based on bootstrap entry point (EE vs SE)?
        transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
    }
    boolean hasTransactionStrategy = configurationValues.containsKey(TRANSACTION_COORDINATOR_STRATEGY);
    if (hasTransactionStrategy) {
        LOG.overridingTransactionStrategyDangerous(TRANSACTION_COORDINATOR_STRATEGY);
    } else {
        if (transactionType == PersistenceUnitTransactionType.JTA) {
            configurationValues.put(TRANSACTION_COORDINATOR_STRATEGY,
                    JtaTransactionCoordinatorBuilderImpl.class);
        } else if (transactionType == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
            configurationValues.put(TRANSACTION_COORDINATOR_STRATEGY,
                    JdbcResourceLocalTransactionCoordinatorBuilderImpl.class);
        }
    }
}
 
Example #2
Source File: EntityManagerFactoryBuilderImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void applyTransactionProperties(StandardServiceRegistryBuilder ssrBuilder) {
	PersistenceUnitTransactionType txnType = PersistenceUnitTransactionTypeHelper.interpretTransactionType(
			configurationValues.get( JPA_TRANSACTION_TYPE )
	);
	if ( txnType == null ) {
		txnType = persistenceUnit.getTransactionType();
	}
	if ( txnType == null ) {
		// is it more appropriate to have this be based on bootstrap entry point (EE vs SE)?
		txnType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
	}
	boolean hasTxStrategy = configurationValues.containsKey( TRANSACTION_COORDINATOR_STRATEGY );
	if ( hasTxStrategy ) {
		LOG.overridingTransactionStrategyDangerous( TRANSACTION_COORDINATOR_STRATEGY );
	}
	else {
		if ( txnType == PersistenceUnitTransactionType.JTA ) {
			ssrBuilder.applySetting( TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class );
		}
		else if ( txnType == PersistenceUnitTransactionType.RESOURCE_LOCAL ) {
			ssrBuilder.applySetting( TRANSACTION_COORDINATOR_STRATEGY, JdbcResourceLocalTransactionCoordinatorBuilderImpl.class );
		}
	}
}
 
Example #3
Source File: QuarkusStrategySelectorBuilder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static void addTransactionCoordinatorBuilders(StrategySelectorImpl strategySelector) {
    strategySelector.registerStrategyImplementor(
            TransactionCoordinatorBuilder.class,
            JdbcResourceLocalTransactionCoordinatorBuilderImpl.SHORT_NAME,
            JdbcResourceLocalTransactionCoordinatorBuilderImpl.class);
    strategySelector.registerStrategyImplementor(
            TransactionCoordinatorBuilder.class,
            JtaTransactionCoordinatorBuilderImpl.SHORT_NAME,
            JtaTransactionCoordinatorBuilderImpl.class);
}
 
Example #4
Source File: StrategySelectorBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void addTransactionCoordinatorBuilders(StrategySelectorImpl strategySelector) {
	strategySelector.registerStrategyImplementor(
			TransactionCoordinatorBuilder.class,
			JdbcResourceLocalTransactionCoordinatorBuilderImpl.SHORT_NAME,
			JdbcResourceLocalTransactionCoordinatorBuilderImpl.class
	);
	strategySelector.registerStrategyImplementor(
			TransactionCoordinatorBuilder.class,
			JtaTransactionCoordinatorBuilderImpl.SHORT_NAME,
			JtaTransactionCoordinatorBuilderImpl.class
	);

	// add the legacy TransactionFactory impl names...
	strategySelector.registerStrategyImplementor(
			TransactionCoordinatorBuilder.class,
			"org.hibernate.transaction.JDBCTransactionFactory",
			JdbcResourceLocalTransactionCoordinatorBuilderImpl.class
	);
	strategySelector.registerStrategyImplementor(
			TransactionCoordinatorBuilder.class,
			"org.hibernate.transaction.JTATransactionFactory",
			JtaTransactionCoordinatorBuilderImpl.class
	);
	strategySelector.registerStrategyImplementor(
			TransactionCoordinatorBuilder.class,
			"org.hibernate.transaction.CMTTransactionFactory",
			JtaTransactionCoordinatorBuilderImpl.class
	);
}
 
Example #5
Source File: HibernateL2CacheTransactionalSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Nullable @Override protected StandardServiceRegistryBuilder registryBuilder() {
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();

    DatasourceConnectionProviderImpl connProvider = new DatasourceConnectionProviderImpl();

    BasicManagedDataSource dataSrc = new BasicManagedDataSource(); // JTA-aware data source.

    dataSrc.setTransactionManager(jotm.getTransactionManager());

    dataSrc.setDefaultAutoCommit(false);

    JdbcDataSource h2DataSrc = new JdbcDataSource();

    h2DataSrc.setURL(CONNECTION_URL);

    dataSrc.setXaDataSourceInstance(h2DataSrc);

    connProvider.setDataSource(dataSrc);

    connProvider.configure(Collections.emptyMap());

    builder.addService(ConnectionProvider.class, connProvider);

    builder.addService(JtaPlatform.class, new TestJtaPlatform());

    builder.applySetting(Environment.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName());

    return builder;
}
 
Example #6
Source File: HibernateL2CacheTransactionalSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Nullable @Override protected StandardServiceRegistryBuilder registryBuilder() {
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();

    DatasourceConnectionProviderImpl connProvider = new DatasourceConnectionProviderImpl();

    BasicManagedDataSource dataSrc = new BasicManagedDataSource(); // JTA-aware data source.

    dataSrc.setTransactionManager(jotm.getTransactionManager());

    dataSrc.setDefaultAutoCommit(false);

    JdbcDataSource h2DataSrc = new JdbcDataSource();

    h2DataSrc.setURL(CONNECTION_URL);

    dataSrc.setXaDataSourceInstance(h2DataSrc);

    connProvider.setDataSource(dataSrc);

    connProvider.configure(Collections.emptyMap());

    builder.addService(ConnectionProvider.class, connProvider);

    builder.addService(JtaPlatform.class, new TestJtaPlatform());

    builder.applySetting(Environment.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName());

    return builder;
}