Package org.hibernate.engine.transaction.jta.platform.spi

Examples of org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform


  private boolean isDriver;
  private boolean isInitiator;

  public JTATransactionManagerTransaction(TransactionCoordinator coordinator) {
    super( coordinator );
    final JtaPlatform jtaPlatform = coordinator
          .getTransactionContext()
          .getTransactionEnvironment()
          .getJtaPlatform();
    this.transactionManager = jtaPlatform.retrieveTransactionManager();
  }
View Full Code Here


  @Override
  public boolean isJoinableJtaTransaction(TransactionCoordinator transactionCoordinator,
      TransactionImplementor transaction) {
    try {
      final JtaPlatform jtaPlatform = transactionCoordinator
          .getTransactionContext()
          .getTransactionEnvironment()
          .getJtaPlatform();
      if ( jtaPlatform == null ) {
        throw new TransactionException( "Unable to check transaction status" );
      }
      if ( jtaPlatform.retrieveTransactionManager() != null ) {
        return JtaStatusHelper.isActive( jtaPlatform.retrieveTransactionManager().getStatus() );
      }
      else {
        final UserTransaction ut = jtaPlatform.retrieveUserTransaction();
        return ut != null && JtaStatusHelper.isActive( ut );
      }
    }
    catch ( SystemException se ) {
      throw new TransactionException( "Unable to check transaction status", se );
View Full Code Here

        if ( ut != null ) {
          return JtaStatusHelper.isActive( ut );
        }
      }

      final JtaPlatform jtaPlatform = transactionCoordinator
          .getTransactionContext()
          .getTransactionEnvironment()
          .getJtaPlatform();
      if ( jtaPlatform == null ) {
        throw new TransactionException( "Unable to check transaction status" );
      }
      if ( jtaPlatform.retrieveTransactionManager() != null ) {
        return JtaStatusHelper.isActive( jtaPlatform.retrieveTransactionManager().getStatus() );
      }
      else {
        final UserTransaction ut = jtaPlatform.retrieveUserTransaction();
        return ut != null && JtaStatusHelper.isActive( ut );
      }
    }
    catch ( SystemException se ) {
      throw new TransactionException( "Unable to check transaction status", se );
View Full Code Here

  @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;
View Full Code Here

    // 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

    JtaPlatform jtaPlatform = getTransactionEnvironment().getJtaPlatform();
    if ( jtaPlatform == null ) {
      // if no jta platform was registered we wont be able to register a jta synchronization
      return;
    }

    // Can we resister a synchronization
    if ( !jtaPlatform.canRegisterSynchronization() ) {
      LOG.trace( "registered JTA platform says we cannot currently resister synchronization; skipping" );
      return;
    }

    // Should we resister a synchronization
    if ( !transactionFactory().isJoinableJtaTransaction( this, currentHibernateTransaction ) ) {
      LOG.trace( "TransactionFactory reported no JTA transaction to join; skipping Synchronization registration" );
      return;
    }

    jtaPlatform.registerSynchronization( new RegisteredSynchronization( getSynchronizationCallbackCoordinator() ) );
    getSynchronizationCallbackCoordinator().synchronizationRegistered();
    synchronizationRegistered = true;
    LOG.debug( "successfully registered Synchronization" );
  }
View Full Code Here

  public JtaPlatform resolveJtaPlatform(Map configurationValues, ServiceRegistryImplementor registry) {
    final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );

    // Initially look for a JtaPlatformProvider
    for ( JtaPlatformProvider provider : classLoaderService.loadJavaServices( JtaPlatformProvider.class ) ) {
      final JtaPlatform providedPlatform = provider.getProvidedJtaPlatform();
      if ( providedPlatform!= null ) {
        return providedPlatform;
      }
    }
View Full Code Here

    super( factory );
  }

  @Override
  public Session currentSession() throws HibernateException {
    final JtaPlatform jtaPlatform = factory().getServiceRegistry().getService( JtaPlatform.class );
    final TransactionManager transactionManager = jtaPlatform.retrieveTransactionManager();
    if ( transactionManager == null ) {
      throw new HibernateException( "No TransactionManagerLookup specified" );
    }

    Transaction txn;
    try {
      txn = transactionManager.getTransaction();
      if ( txn == null ) {
        throw new HibernateException( "Unable to locate current JTA transaction" );
      }
      if ( !JtaStatusHelper.isActive( txn.getStatus() ) ) {
        // We could register the session against the transaction even though it is
        // not started, but we'd have no guarantee of ever getting the map
        // entries cleaned up (aside from spawning threads).
        throw new HibernateException( "Current transaction is not in progress" );
      }
    }
    catch ( HibernateException e ) {
      throw e;
    }
    catch ( Throwable t ) {
      throw new HibernateException( "Problem locating/validating JTA transaction", t );
    }

    final Object txnIdentifier = jtaPlatform.getTransactionIdentifier( txn );

    Session currentSession = currentSessionMap.get( txnIdentifier );

    if ( currentSession == null ) {
      currentSession = buildOrObtainSession();
View Full Code Here

    // 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

    JtaPlatform jtaPlatform = getTransactionEnvironment().getJtaPlatform();
    if ( jtaPlatform == null ) {
      // if no jta platform was registered we wont be able to register a jta synchronization
      return;
    }

    // Can we resister a synchronization
    if ( !jtaPlatform.canRegisterSynchronization() ) {
      LOG.trace( "registered JTA platform says we cannot currently resister synchronization; skipping" );
      return;
    }

    // Should we resister a synchronization
    if ( ! transactionFactory().isJoinableJtaTransaction( this, currentHibernateTransaction ) ) {
      LOG.trace( "TransactionFactory reported no JTA transaction to join; skipping Synchronization registration" );
      return;
    }

    jtaPlatform.registerSynchronization( new RegisteredSynchronization( getSynchronizationCallbackCoordinator() ) );
    synchronizationRegistered = true;
    LOG.debug( "successfully registered Synchronization" );
  }
View Full Code Here

    // 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

    JtaPlatform jtaPlatform = getTransactionEnvironment().getJtaPlatform();
    if ( jtaPlatform == null ) {
      // if no jta platform was registered we wont be able to register a jta synchronization
      return;
    }

    // Can we resister a synchronization
    if ( !jtaPlatform.canRegisterSynchronization() ) {
      LOG.trace( "registered JTA platform says we cannot currently resister synchronization; skipping" );
      return;
    }

    // Should we resister a synchronization
    if ( ! transactionFactory().isJoinableJtaTransaction( this, currentHibernateTransaction ) ) {
      LOG.trace( "TransactionFactory reported no JTA transaction to join; skipping Synchronization registration" );
      return;
    }

    jtaPlatform.registerSynchronization( new RegisteredSynchronization( getSynchronizationCallbackCoordinator() ) );
    synchronizationRegistered = true;
    LOG.debug( "successfully registered Synchronization" );
  }
View Full Code Here

    super( factory );
  }

  @Override
  public Session currentSession() throws HibernateException {
    final JtaPlatform jtaPlatform = factory().getServiceRegistry().getService( JtaPlatform.class );
    final TransactionManager transactionManager = jtaPlatform.retrieveTransactionManager();
    if ( transactionManager == null ) {
      throw new HibernateException( "No TransactionManagerLookup specified" );
    }

    Transaction txn;
    try {
      txn = transactionManager.getTransaction();
      if ( txn == null ) {
        throw new HibernateException( "Unable to locate current JTA transaction" );
      }
      if ( !JtaStatusHelper.isActive( txn.getStatus() ) ) {
        // We could register the session against the transaction even though it is
        // not started, but we'd have no guarantee of ever getting the map
        // entries cleaned up (aside from spawning threads).
        throw new HibernateException( "Current transaction is not in progress" );
      }
    }
    catch ( HibernateException e ) {
      throw e;
    }
    catch ( Throwable t ) {
      throw new HibernateException( "Problem locating/validating JTA transaction", t );
    }

    final Object txnIdentifier = jtaPlatform.getTransactionIdentifier( txn );

    Session currentSession = currentSessionMap.get( txnIdentifier );

    if ( currentSession == null ) {
      currentSession = buildOrObtainSession();
View Full Code Here

TOP

Related Classes of org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.