Package javax.transaction

Examples of javax.transaction.Synchronization


      }
      else if (mode == ConnectionMode.WITH_TRANSACTION_MANAGER)
      {
         try
         {
            transactionManager.getTransaction().registerSynchronization(new Synchronization()
            {

               public void beforeCompletion()
               {
               }
View Full Code Here


   * avoiding object loading during a flush. Not needed during transactions.
   */
  public void onFlush(FlushEvent event) {
    if ( used ) {
      Session session = event.getSession();
      Synchronization synchronization = flushSynch.get( session );
      if ( synchronization != null ) {
        //first cleanup
        flushSynch.remove( session );
        log.debug( "flush event causing index update out of transaction" );
        synchronization.beforeCompletion();
        synchronization.afterCompletion( Status.STATUS_COMMITTED );
      }
    }
  }
View Full Code Here

    }
    else {
      status = Status.STATUS_PREPARING;

      for ( int i = 0; i < synchronizations.size(); i++ ) {
        Synchronization s = ( Synchronization ) synchronizations.get( i );
        s.beforeCompletion();
      }

      status = Status.STATUS_COMMITTING;

      if ( connection != null ) {
        try {
          connection.commit();
          connection.close();
        }
        catch ( SQLException sqle ) {
          status = Status.STATUS_UNKNOWN;
          throw new SystemException();
        }
      }

      status = Status.STATUS_COMMITTED;

      for ( int i = 0; i < synchronizations.size(); i++ ) {
        Synchronization s = ( Synchronization ) synchronizations.get( i );
        s.afterCompletion( status );
      }

      //status = Status.STATUS_NO_TRANSACTION;
      jtaTransactionManager.endCurrent( this );
    }
View Full Code Here

      }
    }

    if (synchronizations != null) {
           for ( int i = 0; i < synchronizations.size(); i++ ) {
             Synchronization s = ( Synchronization ) synchronizations.get( i );
             s.afterCompletion( status );
           }
    }

    //status = Status.STATUS_NO_TRANSACTION;
    jtaTransactionManager.endCurrent( this );
View Full Code Here

          }
          //flush before completion and
          //register clear on rollback
          log.trace( "Adding flush() and close() synchronization" );
          joinableCMTTransaction.registerSynchronization(
              new Synchronization() {
                public void beforeCompletion() {
                  boolean flush = false;
                  TransactionFactory.Context ctx = null;
                  try {
                    ctx = (TransactionFactory.Context) session;
View Full Code Here

    if ( !open ) throw new IllegalStateException( "EntityManager is closed" );
    if ( !discardOnClose && isTransactionInProgress() ) {
      //delay the closing till the end of the enlisted transaction
      getSession().getTransaction().registerSynchronization(
          new Synchronization() {
            public void beforeCompletion() {
              //nothing to do
            }

            public void afterCompletion(int i) {
View Full Code Here

        return resources.remove(key);
    }

    public void registerSynchronization(final TransactionSynchronization synchronization) {
        if (isTransactionActive()) {
            synchronizationRegistry.registerInterposedSynchronization(new Synchronization() {
                public void beforeCompletion() {
                    synchronization.beforeCompletion();
                }

                public void afterCompletion(int s) {
View Full Code Here

            //noinspection unchecked
            Set<EntityBean> registeredEntities = (LinkedHashSet<EntityBean>) synchronizationRegistry.getResource(ENTITIES_TO_STORE);
            if (registeredEntities == null) {
                registeredEntities = new LinkedHashSet<EntityBean>();
                synchronizationRegistry.putResource(ENTITIES_TO_STORE, registeredEntities);
                synchronizationRegistry.registerInterposedSynchronization(new Synchronization() {
                    public void beforeCompletion() {
                        //noinspection unchecked
                        Set<EntityBean> registeredEntities = (LinkedHashSet<EntityBean>) synchronizationRegistry.getResource(ENTITIES_TO_STORE);
                        if (registeredEntities == null) {
                            return;
View Full Code Here

    if ( disabled ) {
      return;
    }

    Session session = event.getSession();
    Synchronization synchronization = flushSynch.get( session );
    if ( synchronization != null ) {
      //first cleanup
      flushSynch.remove( session );
      log.debug( "flush event causing index update out of transaction" );
      synchronization.beforeCompletion();
      synchronization.afterCompletion( Status.STATUS_COMMITTED );
    }
  }
View Full Code Here

    }

    private void beforeCompletion(List syncs) {
        int i = 0;
        while (true) {
            Synchronization synch;
            synchronized (this) {
                if (i == syncs.size()) {
                    return;
                } else {
                    synch = (Synchronization) syncs.get(i++);
                }
            }
            try {
                synch.beforeCompletion();
            } catch (Exception e) {
                log.warn("Unexpected exception from beforeCompletion; transaction will roll back", e);
                synchronized (this) {
                    markRollbackCause(e);
                    status = Status.STATUS_MARKED_ROLLBACK;
View Full Code Here

TOP

Related Classes of javax.transaction.Synchronization

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.