本文整理汇总了Java中org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform类的典型用法代码示例。如果您正苦于以下问题:Java JtaPlatform类的具体用法?Java JtaPlatform怎么用?Java JtaPlatform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JtaPlatform类属于org.hibernate.engine.transaction.jta.platform.spi包,在下文中一共展示了JtaPlatform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJtaTransactionManager
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
protected TransactionManager getJtaTransactionManager(Session session) {
SessionFactoryImplementor sessionFactoryImpl = null;
if (sessionFactory instanceof SessionFactoryImplementor) {
sessionFactoryImpl = ((SessionFactoryImplementor) sessionFactory);
}
else if (session != null) {
SessionFactory internalFactory = session.getSessionFactory();
if (internalFactory instanceof SessionFactoryImplementor) {
sessionFactoryImpl = (SessionFactoryImplementor) internalFactory;
}
}
if (sessionFactoryImpl == null) {
return null;
}
ServiceBinding<JtaPlatform> sb = sessionFactory.getServiceRegistry().locateServiceBinding(JtaPlatform.class);
if (sb == null) {
return null;
}
return sb.getService().retrieveTransactionManager();
}
示例2: initiateService
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
@Override
@SuppressWarnings( {"unchecked"})
public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM );
final JtaPlatform platform = registry.getService( StrategySelector.class ).resolveStrategy( JtaPlatform.class, setting );
if ( platform == null ) {
LOG.debugf( "No JtaPlatform was specified, checking resolver" );
return registry.getService( JtaPlatformResolver.class ).resolveJtaPlatform( configurationValues, registry );
}
return platform;
}
示例3: TransactionEnvironmentImpl
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
public TransactionEnvironmentImpl(SessionFactoryImpl sessionFactory) {
this.sessionFactory = sessionFactory;
this.statisticsImplementor = sessionFactory.getStatisticsImplementor();
this.serviceRegistry = sessionFactory.getServiceRegistry();
this.jdbcServices = serviceRegistry.getService( JdbcServices.class );
this.jtaPlatform = serviceRegistry.getService( JtaPlatform.class );
this.transactionFactory = serviceRegistry.getService( TransactionFactory.class );
}
示例4: canAccessTransactionManager
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
private boolean canAccessTransactionManager() {
try {
return serviceRegistry.getService( JtaPlatform.class ).retrieveTransactionManager() != null;
}
catch (Exception e) {
return false;
}
}
示例5: registerSynchronization
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
/**
* 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;
}
示例6: SpringSessionContext
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
/**
* 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);
}
}
示例7: getJtaPlatform
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
public JtaPlatform getJtaPlatform() {
return jtaPlatform;
}
示例8: setJtaPlatform
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
void setJtaPlatform(JtaPlatform jtaPlatform) {
this.jtaPlatform = jtaPlatform;
}
示例9: getServiceInitiated
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
@Override
public Class<JtaPlatform> getServiceInitiated() {
return JtaPlatform.class;
}
示例10: attemptToRegisterJtaSync
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
private void attemptToRegisterJtaSync() {
if ( synchronizationRegistered ) {
return;
}
final JtaPlatform jtaPlatform = getTransactionEnvironment().getJtaPlatform();
if ( jtaPlatform == null ) {
// if no jta platform was registered we wont be able to register a jta synchronization
return;
}
// Has the local transaction (Hibernate facade) taken on the responsibility of driving the transaction inflow?
if ( currentHibernateTransaction.isInitiator() ) {
return;
}
final JoinStatus joinStatus = currentHibernateTransaction.getJoinStatus();
if ( joinStatus != JoinStatus.JOINED ) {
// the transaction is not (yet) joined, see if we should join...
if ( !transactionContext.shouldAutoJoinTransaction() ) {
// we are supposed to not auto join transactions; if the transaction is not marked for join
// we cannot go any further in attempting to join (register sync).
if ( joinStatus != JoinStatus.MARKED_FOR_JOINED ) {
if (isDebugging) {
LOG.debug( "Skipping JTA sync registration due to auto join checking" );
}
return;
}
}
}
// IMPL NOTE : At this point the local callback is the "maybe" one. The only time that needs to change is if
// we are able to successfully register the transaction synchronization in which case the local callback would become
// non driving. To that end, the following checks are simply opt outs where we are unable to register the
// synchronization
// Can we resister a synchronization
if ( !jtaPlatform.canRegisterSynchronization() ) {
if (isTracing) {
LOG.trace( "registered JTA platform says we cannot currently register synchronization; skipping" );
}
return;
}
// Should we resister a synchronization
if ( !transactionFactory().isJoinableJtaTransaction( this, currentHibernateTransaction ) ) {
if (isTracing) {
LOG.trace( "TransactionFactory reported no JTA transaction to join; skipping Synchronization registration" );
}
return;
}
jtaPlatform.registerSynchronization( new RegisteredSynchronization( getSynchronizationCallbackCoordinator() ) );
getSynchronizationCallbackCoordinator().synchronizationRegistered();
synchronizationRegistered = true;
if (isDebugging) {
LOG.debug( "successfully registered Synchronization" );
}
}
示例11: getJtaPlatform
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
@Override
public JtaPlatform getJtaPlatform() {
return jtaPlatform;
}
示例12: addJtaPlatforms
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
private void addJtaPlatforms(StrategySelectorImpl strategySelector, Class<? extends JtaPlatform> impl, String... names) {
for ( String name : names ) {
strategySelector.registerStrategyImplementor( JtaPlatform.class, name, impl );
}
}
示例13: IgniteTransactionManagerFactory
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
public IgniteTransactionManagerFactory(JtaPlatform platform) {
this.platform = platform;
}
示例14: injectServices
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistryImplementor) {
this.jtaPlatform = serviceRegistryImplementor.getService( JtaPlatform.class );
this.jdbcServices = serviceRegistryImplementor.getService( JdbcServices.class );
}
示例15: extractJBossTransactionManager
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; //导入依赖的package包/类
private static TransactionManager extractJBossTransactionManager(EntityManagerFactory factory) {
SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) ( (HibernateEntityManagerFactory) factory ).getSessionFactory();
return sessionFactory.getServiceRegistry().getService( JtaPlatform.class ).retrieveTransactionManager();
}