org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform Java Examples
The following examples show how to use
org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform.
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: QuarkusStrategySelectorBuilder.java From quarkus with Apache License 2.0 | 6 votes |
/** * 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 #2
Source File: JtaTransactionCoordinatorImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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(); }
Example #3
Source File: JtaTransactionCoordinatorImpl.java From lams with GNU General Public License v2.0 | 6 votes |
public JtaTransactionCoordinatorImpl( TransactionCoordinatorBuilder transactionCoordinatorBuilder, TransactionCoordinatorOwner owner, boolean autoJoinTransactions, JtaPlatform jtaPlatform, boolean preferUserTransactions, boolean performJtaThreadTracking, TransactionObserver... observers) { this.transactionCoordinatorBuilder = transactionCoordinatorBuilder; this.transactionCoordinatorOwner = owner; this.autoJoinTransactions = autoJoinTransactions; this.jtaPlatform = jtaPlatform; this.preferUserTransactions = preferUserTransactions; this.performJtaThreadTracking = performJtaThreadTracking; this.observers = new ArrayList<>(); if ( observers != null ) { Collections.addAll( this.observers, observers ); } synchronizationRegistered = false; pulse(); }
Example #4
Source File: JtaPlatformInitiator.java From lams with GNU General Public License v2.0 | 6 votes |
@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 #5
Source File: NoJtaPlatformInitiator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) { return NoJtaPlatform.INSTANCE; }
Example #6
Source File: SpringSessionContext.java From java-technology-stack with MIT License | 5 votes |
/** * Create a new SpringSessionContext for the given Hibernate SessionFactory. * @param sessionFactory the SessionFactory to provide current Sessions for */ public SpringSessionContext(SessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; try { JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class); this.transactionManager = jtaPlatform.retrieveTransactionManager(); if (this.transactionManager != null) { this.jtaSessionContext = new SpringJtaSessionContext(sessionFactory); } } catch (Exception ex) { LogFactory.getLog(SpringSessionContext.class).warn( "Could not introspect Hibernate JtaPlatform for SpringJtaSessionContext", ex); } }
Example #7
Source File: SpringSessionContext.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new SpringSessionContext for the given Hibernate SessionFactory. * @param sessionFactory the SessionFactory to provide current Sessions for */ public SpringSessionContext(SessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; try { JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class); this.transactionManager = jtaPlatform.retrieveTransactionManager(); if (this.transactionManager != null) { this.jtaSessionContext = new SpringJtaSessionContext(sessionFactory); } } catch (Exception ex) { LogFactory.getLog(SpringSessionContext.class).warn( "Could not introspect Hibernate JtaPlatform for SpringJtaSessionContext", ex); } }
Example #8
Source File: SpringSessionContext.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new SpringSessionContext for the given Hibernate SessionFactory. * @param sessionFactory the SessionFactory to provide current Sessions for */ public SpringSessionContext(SessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; try { JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class); this.transactionManager = jtaPlatform.retrieveTransactionManager(); if (this.transactionManager != null) { this.jtaSessionContext = new SpringJtaSessionContext(sessionFactory); } } catch (Exception ex) { LogFactory.getLog(SpringSessionContext.class).warn( "Could not introspect Hibernate JtaPlatform for SpringJtaSessionContext", ex); } }
Example #9
Source File: TransactionAwareSessionContext.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Registers transaction synchronization with session in order to clean up and close the session when transaction * finishes. * * @param session * Session to register into transaction synchronization. Cannot be null. * @return Returns <code>true</code> if the session was register into any available synchronization strategy, * <code>false</code> otherwise. */ private boolean registerSynchronization(final Session session) { // Tries Spring's transaction manager synchronization. if (TransactionSynchronizationManager.isSynchronizationActive()) { // If it's allowed, registers synchronization to cleanup session. TransactionSynchronizationManager.registerSynchronization(createTransactionSynchronization(session)); return true; } else { // Tries JTA transaction manager synchronization. JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class); // If it's allowed, registers synchronization to cleanup session. if (jtaPlatform.canRegisterSynchronization()) { List<TransactionSynchronization> synchronizations; synchronizations = Arrays.asList(createTransactionSynchronization(session)); Synchronization jtaSync; jtaSync = new JtaAfterCompletionSynchronization(synchronizations); jtaPlatform.registerSynchronization(jtaSync); return true; } } return false; }
Example #10
Source File: SpringSessionContext.java From spring-analysis-note with MIT License | 5 votes |
/** * Create a new SpringSessionContext for the given Hibernate SessionFactory. * @param sessionFactory the SessionFactory to provide current Sessions for */ public SpringSessionContext(SessionFactoryImplementor sessionFactory) { this.sessionFactory = sessionFactory; try { JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class); this.transactionManager = jtaPlatform.retrieveTransactionManager(); if (this.transactionManager != null) { this.jtaSessionContext = new SpringJtaSessionContext(sessionFactory); } } catch (Exception ex) { LogFactory.getLog(SpringSessionContext.class).warn( "Could not introspect Hibernate JtaPlatform for SpringJtaSessionContext", ex); } }
Example #11
Source File: SessionFactoryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
private boolean canAccessTransactionManager() { try { return serviceRegistry.getService( JtaPlatform.class ).retrieveTransactionManager() != null; } catch (Exception e) { return false; } }
Example #12
Source File: JtaPlatformInitiator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public Class<JtaPlatform> getServiceInitiated() { return JtaPlatform.class; }
Example #13
Source File: GrailsSessionContext.java From gorm-hibernate5 with Apache License 2.0 | 4 votes |
public void initJta() { JtaPlatform jtaPlatform = sessionFactory.getServiceRegistry().getService(JtaPlatform.class); TransactionManager transactionManager = jtaPlatform.retrieveTransactionManager(); jtaSessionContext = transactionManager == null ? null : new SpringJtaSessionContext(sessionFactory); }
Example #14
Source File: IgniteDatastoreProvider.java From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void injectServices(ServiceRegistryImplementor serviceRegistryImplementor) { this.classLoaderService = serviceRegistryImplementor.getService( ClassLoaderService.class ); this.jtaPlatform = serviceRegistryImplementor.getService( JtaPlatform.class ); this.jdbcServices = serviceRegistryImplementor.getService( JdbcServices.class ); }
Example #15
Source File: IgniteTransactionManagerFactory.java From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 | 4 votes |
public IgniteTransactionManagerFactory(JtaPlatform platform) { this.platform = platform; }
Example #16
Source File: StrategySelectorBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
private void addJtaPlatforms(StrategySelectorImpl strategySelector, Class<? extends JtaPlatform> impl, String... names) { for ( String name : names ) { strategySelector.registerStrategyImplementor( JtaPlatform.class, name, impl ); } }
Example #17
Source File: StatelessSessionImpl.java From lams with GNU General Public License v2.0 | 4 votes |
private JtaPlatform getJtaPlatform() { return getFactory().getServiceRegistry().getService( JtaPlatform.class ); }
Example #18
Source File: JtaPlatformInitiator.java From lams with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings({"WeakerAccess", "unused"}) protected JtaPlatform getFallbackProvider(Map configurationValues, ServiceRegistryImplementor registry) { return null; }
Example #19
Source File: Settings.java From lams with GNU General Public License v2.0 | 4 votes |
public JtaPlatform getJtaPlatform() { return sessionFactoryOptions.getServiceRegistry().getService( JtaPlatform.class ); }
Example #20
Source File: QuarkusJtaPlatformInitiator.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Class<JtaPlatform> getServiceInitiated() { return JtaPlatform.class; }
Example #21
Source File: QuarkusJtaPlatformInitiator.java From quarkus with Apache License 2.0 | 4 votes |
public JtaPlatform buildJtaPlatformInstance() { return jtaIsPresent ? getJtaInstance() : getNoJtaInstance(); }
Example #22
Source File: QuarkusJtaPlatformInitiator.java From quarkus with Apache License 2.0 | 4 votes |
@Override public JtaPlatform initiateService(Map map, ServiceRegistryImplementor serviceRegistryImplementor) { return buildJtaPlatformInstance(); }
Example #23
Source File: NoJtaPlatformInitiator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override public Class<JtaPlatform> getServiceInitiated() { return JtaPlatform.class; }
Example #24
Source File: HibernateL2CacheTransactionalSelfTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@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 #25
Source File: HibernateL2CacheTransactionalSelfTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@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; }